예제 #1
0
        private static SyntaxElement[] ParseFileContent(CompilationUnitSyntax root, SemanticCache semanticCache)
        {
            var walker = new FileSyntaxWalker(semanticCache);

            walker.Visit(root);

            return(walker.ResultsAccumulator.GetResults());
        }
예제 #2
0
        private static ParsedSourceFilesCollection ParseProjectSourceFiles(Project targetProject)
        {
            var results = new ParsedSourceFilesCollection();

            foreach (var document in targetProject.Documents)
            {
                var tree = document.GetSyntaxTreeAsync().Result;
                if (tree.HasCompilationUnitRoot)
                {
                    var root  = tree.GetCompilationUnitRoot();
                    var model = document.GetSemanticModelAsync().Result;
                    var semanticInterpreter = new SemanticCache(targetProject, model);

                    var elements           = ParseFileContent(root, semanticInterpreter);
                    var relativePathToFile = targetProject.GetRelativePathToFile(document.FilePath);

                    results[relativePathToFile] = new SourceFileParsingInfo(relativePathToFile, elements);
                }
            }

            return(results);
        }
예제 #3
0
 public FileSyntaxWalker(SemanticCache semanticCache)
     : base(SyntaxWalkerDepth.StructuredTrivia)
 {
     _semanticCache = semanticCache;
 }