public static void BuildChildNodes(ITreeBuilder builder, Project project)
        {
            if (project is DotNetProject)
            {
                builder.AddChild(((DotNetProject)project).References);
            }
            bool       publicOnly = builder.Options ["PublicApiOnly"];
            ProjectDom dom        = ProjectDomService.GetProjectDom(project);

            //IParserContext ctx = IdeApp.Workspace.ParserDatabase.GetProjectParserContext (project);
            foreach (IMember ob in dom.GetNamespaceContents("", false, false))
            {
                if (ob is Namespace)
                {
                    if (builder.Options ["NestedNamespaces"])
                    {
                        builder.AddChild(new ProjectNamespaceData(project, ((Namespace)ob).Name));
                    }
                    else
                    {
                        FillNamespaces(builder, project, ((Namespace)ob).Name);
                    }
                }
                else if (!publicOnly || ((IType)ob).IsPublic)
                {
                    builder.AddChild(new ClassData(project, ob as IType));
                }
            }
        }
        public static AddinData GetAddinData(DotNetProject project)
        {
            AddinData data = project.ExtendedProperties ["MonoDevelop.AddinAuthoring"] as AddinData;

            if (data != null)
            {
                return(data);
            }

            if (data == null)
            {
                foreach (ProjectFile pfile in project.Files)
                {
                    if (pfile.Name.EndsWith(".addin.xml") || pfile.Name.EndsWith(".addin"))
                    {
                        return(new AddinData(project));
                    }
                }
                ProjectDom dom = ProjectDomService.GetProjectDom(project);
                if (dom != null && dom.Attributes.Any(
                        a => a.AttributeType.FullName == "Mono.Addins.AddinAttribute" || a.AttributeType.FullName == "Mono.Addins.AddinRootAttribute"
                        ))
                {
                    return(new AddinData(project));
                }
            }
            return(null);
        }
 void SearchThread()
 {
     if (!IdeApp.Workspace.IsOpen)
     {
         return;
     }
     foreach (Project project in IdeApp.Workspace.GetAllProjects())
     {
         ProjectDom dom = ProjectDomService.GetProjectDom(project);
         if (dom == null)
         {
             continue;
         }
         foreach (IType type in dom.Types)
         {
             if (ShouldAdd(type))
             {
                 lock (searchResults) {
                     searchResults.Add(type);
                     GLib.Idle.Add(AddItemGui);
                 }
             }
         }
     }
 }
Exemple #4
0
        public static GtkComponentType GetComponentType(this ProjectFile pf)
        {
            GtkDesignInfo  info = GtkDesignInfo.FromProject(pf.Project);
            ParsedDocument doc  = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(pf.Project), pf.Name);

            //ParsedDocument doc = ProjectDomService.ParseFile (ProjectDomService.GetProjectDom (pf.Project), pf.FilePath.ToString ());
            if (doc != null && doc.CompilationUnit != null)
            {
                foreach (IType t in doc.CompilationUnit.Types)
                {
                    string className = t.FullName;
                    if (className != null)
                    {
                        GuiBuilderWindow win = info.GuiBuilderProject.GetWindowForClass(className);
                        if (win != null)
                        {
                            return(win.RootWidget.IsWindow ? GtkComponentType.Dialog : GtkComponentType.Widget);
                        }

                        Stetic.ActionGroupInfo action = info.GuiBuilderProject.GetActionGroup(className);
                        if (action != null)
                        {
                            return(GtkComponentType.ActionGroup);
                        }
                    }
                }
            }
            if (pf.Name.Contains("IconFactory.gtkx"))
            {
                return(GtkComponentType.IconFactory);
            }

            return(GtkComponentType.None);
        }
        public static void FillNamespaces(ITreeBuilder builder, Project project, string ns)
        {
            ProjectDom     dom     = ProjectDomService.GetProjectDom(project);
            List <IMember> members = dom.GetNamespaceContents(ns, false, false);

            //IParserContext ctx = IdeApp.Workspace.ParserDatabase.GetProjectParserContext (project);
            if (members.Count > 0)
            {
                if (builder.Options ["ShowProjects"])
                {
                    builder.AddChild(new ProjectNamespaceData(project, ns));
                }
                else
                {
                    if (!builder.HasChild(ns, typeof(NamespaceData)))
                    {
                        builder.AddChild(new ProjectNamespaceData(null, ns));
                    }
                }
            }
            foreach (IMember ob in members)
            {
                if (ob is Namespace)
                {
                    FillNamespaces(builder, project, ns + "." + ((Namespace)ob).Name);
                }
            }
        }
Exemple #6
0
        public NSObjectInfoTracker(DotNetProject project, string wrapperRootNamespace)
        {
            this.project = project;

            string foundation = wrapperRootNamespace + ".Foundation";

            connectAttType  = new DomReturnType(foundation, "ConnectAttribute");
            exportAttType   = new DomReturnType(foundation, "ExportAttribute");
            registerAttType = new DomReturnType(foundation, "RegisterAttribute");
            modelAttType    = new DomReturnType(foundation, "ModelAttribute");
            nsobjectType    = new DomReturnType(foundation, "NSObject");

            //FIXME: might there be a race here?
            var dom = ProjectDomService.GetProjectDom(project);

            if (dom == null)
            {
                subscribedDomLoaded              = true;
                ProjectDomService.DomRegistered += DomLoaded;
            }
            else
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                    DomLoaded(dom);
                });
            }
        }
 void FillClasses()
 {
     try {
         ProjectDom ctx = ProjectDomService.GetProjectDom(project);
         if (ctx == null)
         {
             // Project not found in parser database
             return;
         }
         foreach (IType c in ctx.Types)
         {
             if (c.Methods != null)
             {
                 foreach (IMethod m in c.Methods)
                 {
                     if (m.IsStatic && m.Name == "Main")
                     {
                         classListStore.AppendValues(c.FullName);
                     }
                 }
             }
         }
         classListFilled = true;
     } catch (InvalidOperationException) {
         // Project not found in parser database
     }
 }
Exemple #8
0
        void OnFileAdded(object sender, ProjectFileEventArgs args)
        {
            ParsedDocument doc = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(args.Project), args.ProjectFile.Name);

            if (doc == null || doc.CompilationUnit == null)
            {
                return;
            }

            string dir = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "stetic"), "deleted-designs");

            if (!Directory.Exists(dir) || Directory.GetFiles(dir).Length == 0)
            {
                return;
            }

            foreach (IType t in doc.CompilationUnit.Types)
            {
                string path = Path.Combine(dir, t.FullName + ".xml");
                if (!System.IO.File.Exists(path))
                {
                    continue;
                }
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(path);
                AddNewComponent(xmldoc.DocumentElement);
                System.IO.File.Delete(path);
            }
        }
Exemple #9
0
        public string GetComponentFile(string componentName)
        {
            IType type = GuiBuilderProject.FindClass(componentName);

            if (type != null)
            {
                foreach (IType part in type.Parts)
                {
                    string componentFile = part.CompilationUnit.FileName.FullPath;
                    if (componentFile.Contains(BuildFileExtension))
                    {
                        componentFile = componentFile.Replace(BuildFileExtension, string.Empty);
                    }

                    return(componentFile);
                }
            }

            //If ProjectDom does not exist, assume that project is being created
            //and return component file path that is located in the project root folder
            ProjectDom ctx = ProjectDomService.GetProjectDom(project);

            if (ctx == null)
            {
                string componentFile = Path.Combine(project.BaseDirectory, componentName + langExtension);
                if (File.Exists(componentFile))
                {
                    return(componentFile);
                }
            }

            return(null);
        }
Exemple #10
0
        public object LoadAssembly(string file)
        {
            DotNetProject project = null;

            foreach (DotNetProject p in solution.GetAllSolutionItems <DotNetProject> ())
            {
                foreach (var conf in p.Configurations)
                {
                    if (p.GetOutputFileName(conf.Selector) == file)
                    {
                        project = p;
                        break;
                    }
                }
            }
            if (project != null)
            {
                return(ProjectDomService.GetProjectDom(project));
            }
            else
            {
                if (!loadedDoms.Contains(file))
                {
                    loadedDoms.Add(file);
                    ProjectDomService.LoadAssembly(Runtime.SystemAssemblyService.DefaultRuntime, file);
                }
                return(ProjectDomService.GetAssemblyDom(Runtime.SystemAssemblyService.DefaultRuntime, file));
            }
        }
Exemple #11
0
        void OnFileRemoved(object sender, ProjectFileEventArgs args)
        {
            ArrayList toDelete = new ArrayList();

            ParsedDocument doc = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(args.Project), args.ProjectFile.Name);

            if (doc == null || doc.CompilationUnit == null)
            {
                return;
            }

            foreach (IType t in doc.CompilationUnit.Types)
            {
                GuiBuilderWindow win = GetWindowForClass(t.FullName);
                if (win != null)
                {
                    toDelete.Add(win);
                }
            }

            foreach (GuiBuilderWindow win in toDelete)
            {
                Remove(win);
            }
        }
Exemple #12
0
        void AddAspAttributeCompletionData(CompletionDataList list, S.XName name, Dictionary <string, string> existingAtts)
        {
            Debug.Assert(name.IsValid);
            Debug.Assert(name.HasPrefix);

            var database = ProjectDomService.GetProjectDom(project);

            if (database == null)
            {
                LoggingService.LogWarning("Could not obtain project DOM in AddAspAttributeCompletionData");
                return;
            }

            IType controlClass = refman.GetControlType(name.Prefix, name.Name);

            if (controlClass == null)
            {
                controlClass = database.GetType("System.Web.UI.WebControls.WebControl");
                if (controlClass == null)
                {
                    LoggingService.LogWarning("Could not obtain IType for System.Web.UI.WebControls.WebControl");
                    return;
                }
            }

            AddControlMembers(list, database, controlClass, existingAtts);
        }
Exemple #13
0
        public static IMember AddMemberToClass(Project project, IType cls, IType specificPartToAffect, CodeTypeMember member, bool throwIfExists)
        {
            bool isChildClass = false;

            foreach (IType c in cls.Parts)
            {
                if (c == specificPartToAffect)
                {
                    isChildClass = true;
                }
            }
            if (!isChildClass)
            {
                throw new ArgumentException("Class specificPartToAffect is not a part of class cls");
            }

            ProjectDom dom            = ProjectDomService.GetProjectDom(project);
            IMember    existingMember = GetCompatibleMemberInClass(dom, cls, member);

            if (existingMember == null)
            {
                return(CodeGenerationService.AddCodeDomMember(specificPartToAffect, member));
            }

            if (throwIfExists)
            {
                throw new MemberExistsException(cls.Name, member, MemberType.Method, existingMember.BodyRegion, cls.CompilationUnit.FileName);
            }

            return(existingMember);
        }
Exemple #14
0
        public static void AddTypes(ProjectProperties projectprop, MetricsContext ctx)
        {
            ProjectDom dom = ProjectDomService.GetProjectDom(projectprop.Project);

            foreach (IType ob in dom.Types)
            {
                projectprop.AddInstance(ob);
            }
        }
Exemple #15
0
                public ConditinalExpressionEvaluator(Mono.TextEditor.Document doc)
                {
                    var project = GetProject(doc);

                    if (project == null)
                    {
                        var ideDocument = IdeApp.Workbench.GetDocument(doc.FileName);
                        if (ideDocument != null)
                        {
                            project = ideDocument.Project;
                        }
                    }

                    if (project == null)
                    {
                        project = IdeApp.Workspace.GetProjectContainingFile(doc.FileName);
                    }

                    if (project != null)
                    {
                        var configuration = project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration) as DotNetProjectConfiguration;
                        if (configuration != null)
                        {
                            var 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");
                        }
                    }

                    var dom            = ProjectDomService.GetProjectDom(project);
                    var 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);
                        }
                    }
                }
        ProjectDom GetParserContext(LocalVariable var)
        {
            Project p = GetProjectForFile(var.FileName);

            if (p != null)
            {
                return(ProjectDomService.GetProjectDom(p));
            }
            return(ProjectDom.Empty);
        }
        public IType CreateClass(Project project, string language, string directory, string namspace, CodeTypeDeclaration type)
        {
            ProjectDom        ctx  = ProjectDomService.GetProjectDom(project);
            RefactorerContext gctx = new RefactorerContext(ctx, fileProvider, null);
            IRefactorer       gen  = LanguageBindingService.GetRefactorerForLanguage(language);
            IType             c    = gen.CreateClass(gctx, directory, namspace, type);

            gctx.Save();
            return(c);
        }
Exemple #18
0
//		Mono.TextEditor.Document document;
//		MonoDevelop.Ide.Gui.Document doc;
//		IParser parser;
//		IResolver resolver;
//		IExpressionFinder expressionFinder;

/*		void Init (Mono.TextEditor.Document document)
 *              {
 *
 * //			parser = ProjectDomService.GetParser (document.FileName, document.MimeType);
 * //			expressionFinder = ProjectDomService.GetExpressionFinder (document.FileName);
 *              }*/


        ProjectDom GetParserContext(Mono.TextEditor.Document document)
        {
            var project = IdeApp.ProjectOperations.CurrentSelectedProject;

            if (project != null)
            {
                return(ProjectDomService.GetProjectDom(project));
            }
            return(ProjectDom.Empty);
        }
Exemple #19
0
        public ProjectDom GetParserContext()
        {
            ProjectDom dom = ProjectDomService.GetProjectDom(Project);

            if (dom != null && needsUpdate)
            {
                needsUpdate = false;
                dom.ForceUpdate();
            }
            return(dom);
        }
 ProjectDom GetParserContext(IType cls)
 {
     if (cls != null && cls.CompilationUnit != null)
     {
         Project p = GetProjectForFile(cls.CompilationUnit.FileName);
         if (p != null)
         {
             return(ProjectDomService.GetProjectDom(p));
         }
     }
     return(ProjectDom.Empty);
 }
Exemple #21
0
        public void Update()
        {
            objcTypes.Clear();
            cliTypes.Clear();

            var dom = ProjectDomService.GetProjectDom(project);

            if (dom != null)
            {
                DomLoaded(dom);
            }
        }
Exemple #22
0
        public static NSObjectProjectInfo GetProjectInfo(DotNetProject project)
        {
            var dom = ProjectDomService.GetProjectDom(project);

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

            dom.ForceUpdate(true);

            return(GetProjectInfo(dom));
        }
Exemple #23
0
        protected virtual void MasterChanged(object sender, EventArgs e)
        {
            if (IsPartialView || !HasMaster)
            {
                return;
            }

            if (masterEntry.Text == oldMaster)
            {
                return;
            }
            oldMaster = masterEntry.Text;

            primaryPlaceholderStore.Clear();
            ContentPlaceHolders.Clear();

            string realPath = project.VirtualToLocalPath(oldMaster, null);

            if (!File.Exists(realPath))
            {
                return;
            }

            var pd = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(project), realPath)
                     as AspNetParsedDocument;

            if (pd != null)
            {
                try {
                    var visitor = new ContentPlaceHolderVisitor();
                    pd.RootNode.AcceptVisit(visitor);
                    ContentPlaceHolders.AddRange(visitor.PlaceHolders);

                    for (int i = 0; i < ContentPlaceHolders.Count; i++)
                    {
                        string placeholder = ContentPlaceHolders[i];
                        primaryPlaceholderStore.AppendValues(placeholder);

                        if (placeholder.Contains("main") || placeholder.Contains("Main") ||
                            placeholder.Contains("content") || placeholder.Contains("Main"))
                        {
                            primaryPlaceholderCombo.Active = i;
                        }
                    }
                } catch (Exception ex) {
                    LoggingService.LogError("Unhandled exception getting master regions for '" + realPath + "'", ex);
                }
            }

            Validate();
        }
Exemple #24
0
        public IType GetCodebehindType(string fileName)
        {
            string typeName = GetCodebehindTypeName(fileName);

            if (typeName != null)
            {
                var dom = ProjectDomService.GetProjectDom(this);
                if (dom != null)
                {
                    return(dom.GetType(typeName, true));
                }
            }
            return(null);
        }
Exemple #25
0
 public WebTypeContext(AspNetAppProject project)
 {
     if (project == null)
     {
         throw new ArgumentException("project");
     }
     Project      = project;
     SystemWebDom = GetSystemWebDom(project);
     ProjectDom   = ProjectDomService.GetProjectDom(project);
     if (ProjectDom == null)
     {
         throw new InvalidOperationException("Could not load parse database for project");
     }
 }
Exemple #26
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);
                }
            }
        }
Exemple #27
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));
         }
     }
 }
Exemple #28
0
        protected ProjectDom GetParserContext()
        {
            CheckInitialized();

            IViewContent view    = document.Window.ViewContent;
            string       file    = view.IsUntitled ? view.UntitledName : view.ContentName;
            Project      project = view.Project;

            if (project != null)
            {
                return(ProjectDomService.GetProjectDom(project));
            }
            else
            {
                return(ProjectDomService.GetFileDom(file));
            }
        }
        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();
        }