Esempio n. 1
0
        void GetCodeBehind(out IType codeBehindClass, out ProjectDom projectDatabase)
        {
            codeBehindClass = null;
            projectDatabase = null;

            if (HasDoc && !string.IsNullOrEmpty(aspDoc.Info.InheritedClass))
            {
                projectDatabase = ProjectDomService.GetProjectDom(project);
                if (projectDatabase != null)
                {
                    codeBehindClass = projectDatabase.GetType(aspDoc.Info.InheritedClass, false, false);
                }
            }
        }
Esempio n. 2
0
        public override ParsedDocument Parse(ProjectDom dom, string fileName, string content)
        {
            ParsedDocument doc = new ParsedDocument(fileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            Project p = (null == dom || null == dom.Project)?
                        IdeApp.Workspace.GetProjectContainingFile(fileName):
                        dom.Project;
            ProjectInformation pi = ProjectInformationManager.Instance.Get(p);
            CompilationUnit    cu;

            doc.CompilationUnit = cu = new CompilationUnit(fileName);
            IType   tmp;
            IMember member;

            string[] contentLines = content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            DomType  globals      = new DomType(cu, ClassType.Unknown, GettextCatalog.GetString("(Global Scope)"), new DomLocation(1, 1), string.Empty, new DomRegion(1, int.MaxValue), new List <IMember> ());

            lock (pi) {
                // Add containers to type list
                foreach (LanguageItem li in pi.Containers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        tmp = LanguageItemToIMember(pi, li, contentLines) as IType;
                        if (null != tmp)
                        {
                            cu.Add(tmp);
                        }
                    }
                }

                // Add global category for unscoped symbols
                foreach (LanguageItem li in pi.InstanceMembers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        member = LanguageItemToIMember(pi, li, contentLines);
                        if (null != member)
                        {
                            globals.Add(member);
                        }
                    }
                }
            }

            cu.Add(globals);

            return(doc);
        }
Esempio n. 3
0
        public override IEnumerable <object> CreateResolveResult(ProjectDom dom, IMember callingMember)
        {
            List <object> result = new List <object> ();

            if (ResolvedExpression != null && ResolvedExpression.ExpressionContext != null && ResolvedExpression.ExpressionContext.IsObjectCreation)
            {
                AddType(dom, result, dom.GetType(ResolvedType), callingMember, true);
            }
            else
            {
                AddType(dom, result, ResolvedType, callingMember, StaticResolve);
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Formats a text document directly with insert/remove operations.
        /// </summary>
        /// <param name="textEditorData">
        /// A <see cref="System.Object"/> that must be from type Mono.TextEditorData.
        /// </param>
        /// <param name="dom">
        /// A <see cref="ProjectDom"/>
        /// </param>
        /// <param name="unit">
        /// A <see cref="ICompilationUnit"/>
        /// </param>
        /// <param name="caretLocation">
        /// A <see cref="DomLocation"/> that should be the end location to which the parsing should occur.
        /// </param>
        public void OnTheFlyFormat(PolicyContainer policyParent, TextEditorData data,
                                   IType callingType, IMember callingMember, ProjectDom dom, ICompilationUnit unit,
                                   DomLocation endLocation)
        {
            var adv = formatter as IAdvancedCodeFormatter;

            if (adv == null || !adv.SupportsOnTheFlyFormatting)
            {
                throw new InvalidOperationException("On the fly formatting not supported");
            }

            adv.OnTheFlyFormat(policyParent ?? PolicyService.DefaultPolicies, mimeTypeChain,
                               data, callingType, callingMember, dom, unit, endLocation);
        }
Esempio n. 5
0
 public static bool IncludeProtected(ProjectDom dom, IType type, IType callingType)
 {
     if (type == null || callingType == null)
     {
         return(false);
     }
     foreach (IType t in dom.GetInheritanceTree(type))
     {
         if (t.FullName == callingType.FullName)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 6
0
        protected override void Run()
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null || doc.FileName == FilePath.Null || doc.CompilationUnit == null)
            {
                return;
            }
            ITextEditorExtension ext = doc.EditorExtension;

            while (ext != null && !(ext is CompletionTextEditorExtension))
            {
                ext = ext.Next;
            }
            if (ext == null)
            {
                return;
            }

            ProjectDom        dom   = doc.Dom;
            ImportSymbolCache cache = new ImportSymbolCache();

            List <ImportSymbolCompletionData> typeList = new List <ImportSymbolCompletionData> ();

            foreach (IType type in dom.Types)
            {
                typeList.Add(new ImportSymbolCompletionData(doc, cache, dom, type));
            }
            foreach (var refDom in dom.References)
            {
                foreach (IType type in refDom.Types)
                {
                    typeList.Add(new ImportSymbolCompletionData(doc, cache, dom, type));
                }
            }

            typeList.Sort(delegate(ImportSymbolCompletionData left, ImportSymbolCompletionData right) {
                return(left.Type.Name.CompareTo(right.Type.Name));
            });


            CompletionDataList completionList = new CompletionDataList();

            completionList.IsSorted = true;
            typeList.ForEach(cd => completionList.Add(cd));

            ((CompletionTextEditorExtension)ext).ShowCompletion(completionList);
        }
Esempio n. 7
0
 public override void AddProjectContent(ITreeBuilder builder)
 {
     if (project != null)
     {
         ProjectDom dom = ProjectDomService.GetProjectDom(Project);
         AddProjectContent(builder, dom.GetNamespaceContents(FullName, false, false));
     }
     else
     {
         foreach (Project p in IdeApp.Workspace.GetAllProjects())
         {
             ProjectDom dom = ProjectDomService.GetProjectDom(p);
             AddProjectContent(builder, dom.GetNamespaceContents(FullName, false, false));
         }
     }
 }
        public string OutputNode(ProjectDom dom, AstNode node, string indent)
        {
            StringWriter           w            = new StringWriter();
            var                    policyParent = dom != null && dom.Project != null ? dom.Project.Policies : null;
            IEnumerable <string>   types        = DesktopService.GetMimeTypeInheritanceChain(CSharpFormatter.MimeType);
            CSharpFormattingPolicy codePolicy   = policyParent != null?policyParent.Get <CSharpFormattingPolicy> (types) : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <CSharpFormattingPolicy> (types);

            var formatter = new TextWriterOutputFormatter(w);
            int col       = GetColumn(indent, 0, 4);

            formatter.Indentation = System.Math.Max(0, col / 4);
            OutputVisitor visitor = new OutputVisitor(formatter, codePolicy.CreateOptions());

            node.AcceptVisitor(visitor, null);
            return(w.ToString());
        }
Esempio n. 9
0
        public static string GenerateIdentifierUniqueInClass(ProjectDom parserContext, IType cls, string trialIdentifier)
        {
            string trialValue = trialIdentifier;

            for (int suffix = 1; suffix <= int.MaxValue; suffix++)
            {
                if (!IdentifierExistsInClass(parserContext, cls, trialValue))
                {
                    return(trialValue);
                }

                trialValue = trialIdentifier + suffix.ToString();
            }

            throw new Exception("Tried identifiers up to " + trialValue + " and all already existed");
        }
Esempio n. 10
0
        IEnumerable <MemberReference> FindReferences(ProjectDom dom, FilePath fileName, INode member)
        {
            var editor = TextFileProvider.Instance.GetTextEditorData(fileName);
            var doc    = ProjectDomService.GetParsedDocument(dom, fileName);

            if (doc == null || doc.CompilationUnit == null)
            {
                return(null);
            }
            var resolver = new NRefactoryResolver(dom, doc.CompilationUnit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName);

            FindMemberAstVisitor visitor = new FindMemberAstVisitor(editor.Document, resolver, member);

            visitor.IncludeXmlDocumentation = IncludeDocumentation;
            visitor.RunVisitor();
            return(visitor.FoundReferences);
        }
Esempio n. 11
0
        public IType FindClass(string className, bool getUserClass)
        {
            GtkDesignInfo info       = GtkDesignInfo.FromProject(project);
            FilePath      gui_folder = info.SteticFolder;
            ProjectDom    ctx        = GetParserContext();

            if (ctx == null)
            {
                return(null);
            }
            IEnumerable <IType> classes = ctx.Types;

            if (classes == null)
            {
                return(null);
            }
            foreach (IType cls in classes)
            {
                if (cls.FullName == className)
                {
                    if (getUserClass)
                    {
                        // Return this class only if it is declared outside the gtk-gui
                        // folder. Generated partial classes will be ignored.
                        foreach (IType part in cls.Parts)
                        {
                            if (part.CompilationUnit.FileName.FullPath.IsChildPathOf(gui_folder))
                            {
                                continue;
                            }
                            if (part.CompilationUnit != null && !part.CompilationUnit.FileName.IsNullOrEmpty && !part.CompilationUnit.FileName.FileName.Contains(info.BuildFileExtension))
                            {
                                return(part);
                            }
                        }
                        continue;
                    }
                    if (getUserClass && cls.CompilationUnit != null && !string.IsNullOrEmpty(cls.CompilationUnit.FileName) && cls.CompilationUnit.FileName.IsChildPathOf(gui_folder))
                    {
                        continue;
                    }
                    return(cls);
                }
            }
            return(null);
        }
Esempio n. 12
0
        static bool IsTypeCompatible(ProjectDom ctx, string existingType, string checkType)
        {
            if (existingType == checkType)
            {
                return(true);
            }
            IType cls = EnsureClassExists(ctx, checkType, DomRegion.Empty);

            foreach (IReturnType baseType in cls.BaseTypes)
            {
                if (IsTypeCompatible(ctx, existingType, baseType.FullName))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 13
0
        public static IReturnType GetComponentType(ProjectDom dom, IReturnType returnType)
        {
            if (dom == null || returnType == null)
            {
                return(null);
            }
            if (returnType.FullName == DomReturnType.String.FullName && returnType.ArrayDimensions == 0)
            {
                return(DomReturnType.Char);
            }
            if (returnType.ArrayDimensions > 0)
            {
                return(new DomReturnType(returnType.FullName));
            }

            IType resolvedType = dom.GetType(returnType);

            if (resolvedType != null)
            {
                foreach (IType curType in dom.GetInheritanceTree(resolvedType))
                {
                    foreach (IReturnType baseType in curType.BaseTypes)
                    {
                        if (baseType.FullName == "System.Collections.Generic.IEnumerable" && baseType.GenericArguments.Count == 1)
                        {
                            return(baseType.GenericArguments [0]);
                        }
                    }

                    foreach (IProperty property in curType.Properties)
                    {
                        if (property.IsIndexer && !property.IsExplicitDeclaration)
                        {
                            return(property.ReturnType);
                        }
                    }
                }
            }

            if (returnType.GenericArguments.Count > 0)
            {
                return(returnType.GenericArguments [0]);
            }

            return(null);
        }
        void RunFormatter()
        {
            if (PropertyService.Get("OnTheFlyFormatting", false) && textEditorData != null && !(textEditorData.CurrentMode is TextLinkEditMode))
            {
                //		textEditorData.Document.TextReplaced -= TextCut;
                ProjectDom dom = ProjectDomService.GetProjectDom(Document.Project);
                if (dom == null)
                {
                    dom = ProjectDomService.GetFileDom(Document.FileName);
                }

                DomLocation location = new DomLocation(textEditorData.Caret.Location.Line + (lastCharInserted == '\n' ? -1 : 0), textEditorData.Caret.Location.Column);
                //				CSharpFormatter.Format (textEditorData, dom, Document.CompilationUnit, location);
                OnTheFlyFormatter.Format(Document, dom, location, lastCharInserted == '\n');

                //		textEditorData.Document.TextReplaced += TextCut;
            }
        }
        public void FindReferences()
        {
            IMember member = widget.ActiveMember;

            if (member == null)
            {
                return;
            }
            ProjectDom dom = ProjectDomService.GetProjectDom(IdeApp.ProjectOperations.CurrentSelectedProject);

            if (dom == null)
            {
                return;
            }
            Refactorer refactorer = new Refactorer(dom, null, null, member, null);

            refactorer.FindReferences();
        }
Esempio n. 16
0
        void GetType(IAttributedXObject attributedOb, Action <IType, ProjectDom> action)
        {
            ProjectDom database = GetDb();

            if (database == null)
            {
                return;
            }
            foreach (string namespc in namespaces)
            {
                IType controlType = database.GetType(namespc + "." + attributedOb.Name.Name);
                if (controlType != null)
                {
                    action(controlType, database);
                    break;
                }
            }
        }
        List <IType> GetTypes()
        {
            List <IType> list = new List <IType> ();

            getTypesTimer.BeginTiming();
            try {
                foreach (Document doc in IdeApp.Workbench.Documents)
                {
                    // We only want to check it here if it's not part
                    // of the open combine.  Otherwise, it will get
                    // checked down below.
                    if (doc.Project == null && doc.IsFile)
                    {
                        ICompilationUnit info = doc.CompilationUnit;
                        if (info != null)
                        {
                            foreach (IType c in info.Types)
                            {
                                list.Add(c);
                            }
                        }
                    }
                }

                ReadOnlyCollection <Project> projects = IdeApp.Workspace.GetAllProjects();

                foreach (Project p in projects)
                {
                    ProjectDom dom = ProjectDomService.GetProjectDom(p);
                    if (dom == null)
                    {
                        continue;
                    }
                    foreach (IType c in dom.Types)
                    {
                        AddType(c, list);
                    }
                }
            } finally {
                getTypesTimer.EndTiming();
            }
            return(list);
        }
Esempio n. 18
0
        protected override SourceCodeLocation GetSourceCodeLocation(string fullClassName, string methodName)
        {
            ProjectDom ctx = ProjectDomService.GetProjectDom(project);
            IType      cls = ctx.GetType(fullClassName);

            if (cls == null)
            {
                return(null);
            }

            foreach (IMethod met in cls.Methods)
            {
                if (met.Name == methodName)
                {
                    return(new SourceCodeLocation(cls.CompilationUnit.FileName, met.Location.Line, met.Location.Column));
                }
            }
            return(new SourceCodeLocation(cls.CompilationUnit.FileName, cls.Location.Line, cls.Location.Column));
        }
Esempio n. 19
0
        public bool BindToClass()
        {
            if (SourceCodeFile != FilePath.Null)
            {
                return(true);
            }

            // Find the classes that could be bound to this design
            ProjectDom ctx  = fproject.GetParserContext();
            ArrayList  list = new ArrayList();

            foreach (IType cls in ctx.Types)
            {
                if (IsValidClass(ctx, cls))
                {
                    list.Add(cls.FullName);
                }
            }

            // Ask what to do

            try {
                using (BindDesignDialog dialog = new BindDesignDialog(Name, list, Project.Project.BaseDirectory)) {
                    if (!dialog.Run())
                    {
                        return(false);
                    }

                    if (dialog.CreateNew)
                    {
                        CreateClass(dialog.ClassName, dialog.Namespace, dialog.Folder);
                    }

                    string fullName = dialog.Namespace.Length > 0 ? dialog.Namespace + "." + dialog.ClassName : dialog.ClassName;
                    rootWidget.Name = fullName;
                    fproject.Save(true);
                }
                return(true);
            } catch (Exception ex) {
                MessageService.ShowException(ex);
                return(false);
            }
        }
Esempio n. 20
0
//		static ProjectDom GetMLDom (MoonlightProject project)
//		{
//			return ProjectDomService.GetAssemblyDom (
//				MonoDevelop.Core.Runtime.SystemAssemblyService.GetAssemblyNameForVersion (
//					"System.Windows", GetProjectTargetFramework (project)));
//		}

        public static IEnumerable <IType> ListControlClasses(ProjectDom database, string namespac)
        {
            if (database == null)
            {
                yield break;
            }

            DomReturnType swd = new DomReturnType("System.Windows.DependencyObject");

            //return classes if they derive from system.web.ui.control
            foreach (IMember mem in database.GetNamespaceContents(namespac, true, true))
            {
                IType cls = mem as IType;
                if (cls != null && !cls.IsAbstract && cls.IsPublic && cls.IsBaseType(swd))
                {
                    yield return(cls);
                }
            }
        }
        public static void AcceptChanges(IProgressMonitor monitor, ProjectDom dom, List <Change> changes, MonoDevelop.Projects.Text.ITextFileProvider fileProvider)
        {
            RefactorerContext rctx    = new RefactorerContext(dom, fileProvider, null);
            RenameHandler     handler = new RenameHandler(changes);

            FileService.FileRenamed += handler.FileRename;
            for (int i = 0; i < changes.Count; i++)
            {
                changes[i].PerformChange(monitor, rctx);
                TextReplaceChange replaceChange = changes[i] as TextReplaceChange;
                if (replaceChange == null)
                {
                    continue;
                }
                for (int j = i + 1; j < changes.Count; j++)
                {
                    TextReplaceChange change = changes[j] as TextReplaceChange;
                    if (change == null)
                    {
                        continue;
                    }
                    if (replaceChange.Offset >= 0 && change.Offset >= 0 && replaceChange.FileName == change.FileName)
                    {
                        if (replaceChange.Offset < change.Offset)
                        {
                            change.Offset -= replaceChange.RemovedChars;
                            if (!string.IsNullOrEmpty(replaceChange.InsertedText))
                            {
                                change.Offset += replaceChange.InsertedText.Length;
                            }
                        }
                        else if (replaceChange.Offset < change.Offset + change.RemovedChars)
                        {
                            change.RemovedChars -= replaceChange.RemovedChars;
                            change.Offset        = replaceChange.Offset + replaceChange.InsertedText.Length;
                        }
                    }
                }
            }
            FileService.FileRenamed -= handler.FileRename;
            TextReplaceChange.FinishRefactoringOperation();
        }
Esempio n. 22
0
                public ConditinalExpressionEvaluator(Mono.TextEditor.Document doc)
                {
                    var project = IdeApp.ProjectOperations.CurrentSelectedProject;

                    if (project != null)
                    {
                        DotNetProjectConfiguration configuration = project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration) as DotNetProjectConfiguration;
                        if (configuration != null)
                        {
                            CSharpCompilerParameters cparams = configuration.CompilationParameters as CSharpCompilerParameters;
                            if (cparams != null)
                            {
                                string[] syms = cparams.DefineSymbols.Split(';', ',', ' ', '\t');
                                foreach (string s in syms)
                                {
                                    string ss = s.Trim();
                                    if (ss.Length > 0 && !symbols.Contains(ss))
                                    {
                                        symbols.Add(ss);
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("NO CONFIGURATION");
                        }
                    }

                    ProjectDom     dom            = ProjectDomService.GetProjectDom(project);
                    ParsedDocument parsedDocument = ProjectDomService.GetParsedDocument(dom, doc.FileName);

/*					if (parsedDocument == null)
 *                                              parsedDocument = ProjectDomService.ParseFile (dom, doc.FileName ?? "a.cs", delegate { return doc.Text; });*/
                    if (parsedDocument != null)
                    {
                        foreach (PreProcessorDefine define in parsedDocument.Defines)
                        {
                            symbols.Add(define.Define);
                        }
                    }
                }
        public override IEnumerable <MemberReference> FindReferences(ProjectDom dom, FilePath fileName, IEnumerable <INode> searchedMembers)
        {
            var editor = TextFileProvider.Instance.GetTextEditorData(fileName);
            AspNetAppProject project = dom.Project as AspNetAppProject;

            if (project == null)
            {
                yield break;
            }

            var unit = AspNetParserService.GetCompileUnit(project, fileName, true);

            if (unit == null)
            {
                yield break;
            }
            var refman = new DocumentReferenceManager(project);

            var parsedAspDocument = (AspNetParsedDocument) new AspNetParser().Parse(dom, fileName, editor.Text);

            refman.Doc = parsedAspDocument;

            var usings       = refman.GetUsings();
            var documentInfo = new DocumentInfo(dom, unit, usings, refman.GetDoms());

            var builder = new AspLanguageBuilder();


            var buildDocument = new Mono.TextEditor.Document();
            var offsetInfos   = new List <LocalDocumentInfo.OffsetInfo> ();

            buildDocument.Text = builder.BuildDocumentString(documentInfo, editor, offsetInfos, true);
            var parsedDocument = AspLanguageBuilder.Parse(dom, fileName, buildDocument.Text);

            foreach (var member in searchedMembers)
            {
                foreach (var reference in SearchMember(member, dom, fileName, editor, buildDocument, offsetInfos, parsedDocument))
                {
                    yield return(reference);
                }
            }
        }
Esempio n. 24
0
        NSObjectTypeInfo ConvertType(ProjectDom dom, IType type)
        {
            string objcName = null;
            bool   isModel  = false;

            foreach (var att in type.Attributes)
            {
                if (att.AttributeType.FullName == registerAttType.FullName)
                {
                    //type registered with an explicit type name are up to the user to proide a valid name
                    if (att.PositionalArguments.Count == 1)
                    {
                        objcName = (string)((System.CodeDom.CodePrimitiveExpression)att.PositionalArguments[0]).Value;
                    }
                    //non-nested types in the root namespace have names accessible from obj-c
                    else if (string.IsNullOrEmpty(type.Namespace) && type.Name.IndexOf('.') < 0)
                    {
                        objcName = type.Name;
                    }
                }
                if (att.AttributeType.FullName == modelAttType.FullName)
                {
                    isModel = true;
                }
            }
            if (string.IsNullOrEmpty(objcName))
            {
                return(null);
            }

            var info = new NSObjectTypeInfo(objcName, type.FullName, null, type.BaseType.FullName, isModel);

            info.IsUserType = type.SourceProject != null;

            if (info.IsUserType)
            {
                UpdateType(dom, info, type);
                info.DefinedIn = type.Parts.Select(p => (string)p.CompilationUnit.FileName).ToArray();
            }

            return(info);
        }
Esempio n. 25
0
        internal bool IsValidClass(ProjectDom ctx, IType cls)
        {
            if (cls.BaseTypes != null)
            {
                foreach (IReturnType bt in cls.BaseTypes)
                {
                    if (bt.FullName == rootWidget.Component.Type.ClassName)
                    {
                        return(true);
                    }

                    IType baseCls = ctx.GetType(bt);
                    if (baseCls != null && IsValidClass(ctx, baseCls))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 26
0
        public override void Setup()
        {
            base.Setup();
            string solFile = Util.GetSampleProject("completion-db-test", "CompletionDbTest.sln");

            solution = (Solution)Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);
            ProjectDomService.Load(solution);

            Project prj;

            prj  = solution.FindProjectByName("Library2");
            lib2 = ProjectDomService.GetProjectDom(prj);
            lib2.ForceUpdate(true);
            prj  = solution.FindProjectByName("Library1");
            lib1 = ProjectDomService.GetProjectDom(prj);
            lib1.ForceUpdate(true);
            prj         = solution.FindProjectByName("CompletionDbTest");
            mainProject = ProjectDomService.GetProjectDom(prj);
            mainProject.ForceUpdate(true);
        }
Esempio n. 27
0
        IEnumerable <NSObjectTypeInfo> GetRegisteredObjects(ProjectDom dom)
        {
            var nso = dom.GetType(nsobjectType);

            if (nso == null)
            {
                throw new Exception("Could not get NSObject from type database");
            }

            yield return(new NSObjectTypeInfo("NSObject", nsobjectType.FullName, null, null, false));

            foreach (var type in dom.GetSubclasses(nso, true))
            {
                var info = ConvertType(dom, type);
                if (info != null)
                {
                    yield return(info);
                }
            }
        }
Esempio n. 28
0
        void RunFormatter()
        {
            if (PropertyService.Get("OnTheFlyFormatting", false) && textEditorData != null)
            {
                textEditorData.Paste -= TextEditorDataPaste;
                //		textEditorData.Document.TextReplaced -= TextCut;
                ProjectDom dom = ProjectDomService.GetProjectDom(Document.Project);
                if (dom == null)
                {
                    dom = ProjectDomService.GetFileDom(Document.FileName);
                }

                DomLocation location = new DomLocation(textEditorData.Caret.Location.Line, textEditorData.Caret.Location.Column);
                CSharpFormatter.Format(textEditorData, dom, Document.CompilationUnit, location);
//				OnTheFlyFormatter.Format (textEditorData, dom, location);

                //		textEditorData.Document.TextReplaced += TextCut;
                textEditorData.Paste += TextEditorDataPaste;
            }
        }
Esempio n. 29
0
        bool IsSubclass(ProjectDom ctx, IType baseClass, IType subclass)
        {
            foreach (IReturnType clsName in subclass.BaseTypes)
            {
                if (clsName.FullName == baseClass.FullName)
                {
                    return(true);
                }
            }

            foreach (IReturnType clsName in subclass.BaseTypes)
            {
                IType cls = ctx.GetType(clsName);
                if (cls != null && IsSubclass(ctx, baseClass, cls))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 30
0
        internal static bool IsValidClass(ProjectDom ctx, IType cls)
        {
            if (cls.BaseTypes != null)
            {
                foreach (IReturnType bt in cls.BaseTypes)
                {
                    if (bt.FullName == "Gtk.ActionGroup")
                    {
                        return(true);
                    }

                    IType baseCls = ctx.GetType(bt);
                    if (baseCls != null && IsValidClass(ctx, baseCls))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }