Exemple #1
0
        private IEnumerable GetProjectSymbols()
        {
            SolutionElement scope = CodeRush.Source.ActiveSolution;

            if (scope == null)
            {
                return(null);
            }
            List <IElement> list = new List <IElement>();

            foreach (ProjectElement project in scope.AllProjects)
            {
                foreach (AssemblyReference reference in project.AssemblyReferences)
                {
                    if (reference == null)
                    {
                        continue;
                    }
                    IElementCollection rootElements = reference.AssemblyModel.RootElements;
                    list.AddRange(rootElements);
                }
                foreach (IElement element in project.ProjectSymbols.Values)
                {
                    list.Add(element);
                }
            }
            return(list);
        }
        public override SolutionElement LoadFrom(string path, string configuration, string plargorm)
        {
            SolutionElement solution = new SolutionElement(path);

            LoadProjects(solution, path, configuration, plargorm);
            return(solution);
        }
Exemple #3
0
        private void PlugIn1_SolutionOpened()
        {
            SolutionElement activeSolution = CodeRush.Source.ActiveSolution;

            if (activeSolution == null)
            {
                return;
            }

            List <string> unresolvedAssemblies = new List <string>();

            foreach (ProjectElement project in activeSolution.ProjectElements)
            {
                foreach (AssemblyReference reference in project.AssemblyReferences)
                {
                    if (reference.Name.StartsWith("DevExpress"))
                    {
                        if (!File.Exists(reference.FilePath))
                        {
                            unresolvedAssemblies.Add(reference.Name);
                        }
                    }
                }
            }

            if (unresolvedAssemblies.Count > 0)
            {
                UnresolvedReferences form = new UnresolvedReferences(unresolvedAssemblies);
                form.ShowDialog(CodeRush.IDE);
            }
        }
        protected void LoadProjects(SolutionElement solution, string path, string configuration, string platform)
        {
            string lSolutionDir = Path.GetDirectoryName(path);

            using (StreamReader lReader = new StreamReader(path))
                LoadProjects(lReader, solution, lSolutionDir, configuration, platform);
        }
        protected void LoadProjects(StreamReader reader, SolutionElement solution, string solutionDir, string configuration, string platform)
        {
            ProjectInfo lInfo     = null;
            Hashtable   lProjects = new Hashtable();
            string      lLine     = reader.ReadLine();

            while (lLine != null)
            {
                if (lLine.StartsWith(STR_Project))
                {
                    lInfo = GetProjectInfo(solutionDir, lLine);
                    if (lInfo.Name != "Solution Items")
                    {
                        lProjects.Add(lInfo.Guid, lInfo);
                    }
                }

                string trimmedLine = lLine.Trim();
                if (trimmedLine.StartsWith("ProjectReferences"))
                {
                    AddProjectRefernces(lInfo, trimmedLine);
                }

                lLine = reader.ReadLine();
            }
            LoadProjects(solution, solutionDir, lProjects, configuration, platform);
        }
Exemple #6
0
 public SolutionElement GetParsedSolution()
 {
     if (_SolutionElement == null)
     {
         _SolutionElement = OpenSolution(Path);
     }
     return(_SolutionElement);
 }
Exemple #7
0
 // public methods...
 public void CloseSolution()
 {
     if (_SolutionElement != null)
     {
         _SolutionElement.CloseSolution();
         _SolutionElement = null;
     }
 }
 void SyncProjectSymbols(SolutionElement solution)
 {
     if (solution == null)
         return;
     NodeList projects = solution.ProjectElements;
     int count = projects.Count;
     if (count == 0)
         return;
     for (int i = 0; i < count; i++)
     {
         ProjectElement project = (ProjectElement)projects[i];
         project.SyncProjectSymbolsAfterWait();
     }
 }
        private SourceFile findFileInSolution(ProjectElement currentProject)
        {
            SolutionElement solution = currentProject.Solution as SolutionElement;

            foreach (var project in solution.AllProjects)
            {
                IEnumerable <SourceFile> files = (project as ProjectElement).GetFilesByName(hqlNamedQueryFileName);
                if (files.Count() > 0)
                {
                    return(files.First());
                }
            }

            return(null);
        }
        protected void LoadProjects(SolutionElement solution, string solutionDir, Hashtable projects, string confguration, string platform)
        {
            IDictionaryEnumerator lEnum = projects.GetEnumerator();

            while (lEnum.MoveNext())
            {
                string                lGuid         = (string)lEnum.Key;
                ProjectInfo           lInfo         = (ProjectInfo)lEnum.Value;
                FileProjectLoaderBase projectLoader = CreateProjectLoader(lInfo);
                ProjectElement        lProject      = projectLoader.Load(lInfo, projects, confguration, platform);
                if (lProject != null)
                {
                    solution.AddProject(lProject);
                }
            }
        }
Exemple #11
0
        void SyncProjectSymbols(SolutionElement solution)
        {
            if (solution == null)
            {
                return;
            }
            NodeList projects = solution.ProjectElements;
            int      count    = projects.Count;

            if (count == 0)
            {
                return;
            }
            for (int i = 0; i < count; i++)
            {
                ProjectElement project = (ProjectElement)projects[i];
                project.SyncProjectSymbolsAfterWait();
            }
        }
Exemple #12
0
        private void XMLRefSearch_SearchReferences(Object Sender, DevExpress.CodeRush.Core.SearchEventArgs ea)
        {
            // Store Value of initial XmlAttribute
            TextDocument activeDoc  = CodeRush.Documents.ActiveTextDocument;
            string       StartValue = ((XmlAttribute)activeDoc.GetNodeAt(CodeRush.Caret.Line, CodeRush.Caret.Offset)).Value;

            // Iterate LanguageElements in solution
            SolutionElement activeSolution = CodeRush.Source.ActiveSolution;

            foreach (ProjectElement project in activeSolution.AllProjects)
            {
                foreach (SourceFile sourceFile in project.AllFiles)
                {
                    SourceFile        activeFile = CodeRush.Source.ActiveSourceFile;
                    ElementEnumerable Enumerator = new ElementEnumerable(sourceFile, new XMLAttributeFilter(StartValue, _Attributes), true);
                    foreach (XmlAttribute CurrentAttribute in Enumerator)
                    {
                        ea.AddRange(new FileSourceRange(CurrentAttribute.FileNode, CurrentAttribute.ValueRange));
                    }
                }
            }
        }
Exemple #13
0
        // private methods...
        SolutionElement OpenSolution(string path)
        {
            SolutionLoaderBase loader   = GetSolutionLoader(path);
            SolutionElement    solution = null;

            if (string.IsNullOrEmpty(_Configuration) || string.IsNullOrEmpty(_Platform))
            {
                solution = loader.LoadFrom(path);
            }
            else
            {
                solution = loader.LoadFrom(path, _Configuration, _Platform);
            }
            if (!_SkipMetadataLoading)
            {
                AssemblyReferenceManager.Instance.LoadAllAssemblies();
            }
            SolutionParseController controller = new SolutionParseController();

            controller.ParseSolution(solution);
            SyncProjectSymbols(solution);
            return(solution);
        }
 protected void LoadProjects(SolutionElement solution, string path, string configuration, string platform)
 {
     string lSolutionDir = Path.GetDirectoryName(path);
     using (StreamReader lReader = new StreamReader(path))
         LoadProjects(lReader, solution, lSolutionDir, configuration, platform);
 }
 protected void LoadProjects(SolutionElement solution, string path)
 {
     LoadProjects(solution, path, string.Empty, string.Empty);
 }
        protected void LoadProjects(StreamReader reader, SolutionElement solution, string solutionDir, string configuration, string platform)
        {
            ProjectInfo lInfo = null;
            Hashtable lProjects = new Hashtable();
            string lLine = reader.ReadLine();
            while (lLine != null)
            {
                if (lLine.StartsWith(STR_Project))
                {
                    lInfo = GetProjectInfo(solutionDir, lLine);
                    if (lInfo.Name != "Solution Items")
                        lProjects.Add(lInfo.Guid, lInfo);
                }

                string trimmedLine = lLine.Trim();
                if (trimmedLine.StartsWith("ProjectReferences"))
                    AddProjectRefernces(lInfo, trimmedLine);

                lLine = reader.ReadLine();
            }
            LoadProjects(solution, solutionDir, lProjects, configuration, platform);
        }
 protected void LoadProjects(StreamReader reader, SolutionElement solution, string solutionDir)
 {
     LoadProjects(reader, solution, solutionDir, string.Empty, string.Empty);
 }
 protected void LoadProjects(SolutionElement solution, string solutionDir, Hashtable projects, string confguration, string platform)
 {
     IDictionaryEnumerator lEnum = projects.GetEnumerator();
     while (lEnum.MoveNext())
     {
         string lGuid = (string)lEnum.Key;
         ProjectInfo lInfo = (ProjectInfo)lEnum.Value;
         FileProjectLoaderBase projectLoader = CreateProjectLoader(lInfo);
         ProjectElement lProject = projectLoader.Load(lInfo, projects, confguration, platform);
         if (lProject != null)
             solution.AddProject(lProject);
     }
 }
 protected void LoadProjects(SolutionElement solution, string solutionDir, Hashtable projects)
 {
     LoadProjects(solution, solutionDir, projects, string.Empty, string.Empty);
 }
 protected void LoadProjects(SolutionElement solution, string solutionDir, Hashtable projects)
 {
     LoadProjects(solution, solutionDir, projects, string.Empty, string.Empty);
 }
 protected void LoadProjects(StreamReader reader, SolutionElement solution, string solutionDir)
 {
     LoadProjects(reader, solution, solutionDir, string.Empty, string.Empty);
 }
 public override SolutionElement LoadFrom(string path, string configuration, string plargorm)
 {
     SolutionElement solution = new SolutionElement(path);
     LoadProjects(solution, path, configuration, plargorm);
     return solution;
 }
 public SolutionElement GetParsedSolution()
 {
     if (_SolutionElement == null)
         _SolutionElement = OpenSolution(Path);
     return _SolutionElement;
 }
 protected void LoadProjects(SolutionElement solution, string path)
 {
     LoadProjects(solution, path, string.Empty, string.Empty);
 }
 // public methods...
 public void CloseSolution()
 {
     if (_SolutionElement != null)
     {
         _SolutionElement.CloseSolution();
         _SolutionElement = null;
     }
 }