Beispiel #1
0
        public static ISet <string> Gather(SyntaxTree syntaxTree, IEnumerable <string> predefinedSymbols)
        {
            var obj = new DefinedSymbolsGatherer(predefinedSymbols);

            syntaxTree.AcceptVisitor(obj);
            return(obj._definedSymbols);
        }
        public PreparedCompilation CreateCompilation(IEnumerable <ISourceFile> sourceFiles, IEnumerable <IAssemblyReference> references, IList <string> defineConstants)
        {
            IProjectContent project = new CSharpProjectContent();

            var files = sourceFiles.Select(f => {
                using (var rdr = f.Open()) {
                    var syntaxTree     = CreateParser(defineConstants).Parse(rdr, f.Filename);
                    var expandResult   = new QueryExpressionExpander().ExpandQueryExpressions(syntaxTree);
                    syntaxTree         = (expandResult != null ? (SyntaxTree)expandResult.AstNode : syntaxTree);
                    var definedSymbols = DefinedSymbolsGatherer.Gather(syntaxTree, defineConstants);
                    return(new PreparedCompilation.ParsedSourceFile(syntaxTree, new CSharpUnresolvedFile(f.Filename, new UsingScope()), definedSymbols));
                }
            }).ToList();

            foreach (var f in files)
            {
                var tcv = new TypeSystemConvertVisitor(f.ParsedFile);
                f.SyntaxTree.AcceptVisitor(tcv);
                project = project.AddOrUpdateFiles(f.ParsedFile);
            }
            project = project.AddAssemblyReferences(references);

            return(new PreparedCompilation(project.CreateCompilation(), files));
        }
 public static ISet<string> Gather(CompilationUnit cu, IEnumerable<string> predefinedSymbols)
 {
     var obj = new DefinedSymbolsGatherer(predefinedSymbols);
     cu.AcceptVisitor(obj);
     return obj._definedSymbols;
 }
 public static ISet<string> Gather(SyntaxTree syntaxTree, IEnumerable<string> predefinedSymbols)
 {
     var obj = new DefinedSymbolsGatherer(predefinedSymbols);
     syntaxTree.AcceptVisitor(obj);
     return obj._definedSymbols;
 }