static public ClassMapper analysecode(string sourceText, string file) { StringBuilder b = new StringBuilder(); ClassMapper mapper = new ClassMapper(); mapper.filename = file; string filename = file; //string sourceText = File.ReadAllText(filename); var parser = new CSharpParser(); SyntaxTree syntaxTree = parser.Parse(sourceText, file); var pc = new CSharpProjectContent(); pc = (CSharpProjectContent)pc.AddOrUpdateFiles(syntaxTree.ToTypeSystem()); ICompilation compilation = pc.CreateCompilation(); var resolver = new CSharpAstResolver(compilation, syntaxTree, syntaxTree.ToTypeSystem()); var classVisitor = new ClassVisitor(resolver); classVisitor.filename = filename; classVisitor.b = b; classVisitor.wm = new CacheManager(); classVisitor.mapper = mapper; classVisitor.syntax = syntaxTree; syntaxTree.AcceptVisitor(classVisitor); mapper.syntax = syntaxTree; return(mapper); }
public void AnalyzeCSharpFile(string path) { mapper = new ClassMapper(); if (mappers == null) { mappers = new ArrayList(); } mappers.Add(mapper); mapper.filename = path; string filename = path; string sourceText = File.ReadAllText(filename); CSharpParser parser = new CSharpParser(); SyntaxTree syntaxTree = parser.Parse(sourceText, Path.GetFileNameWithoutExtension(filename)); var pc = new CSharpProjectContent(); pc = (CSharpProjectContent)pc.AddOrUpdateFiles(syntaxTree.ToTypeSystem()); ICompilation compilation = pc.CreateCompilation(); var resolver = new CSharpAstResolver(compilation, syntaxTree, syntaxTree.ToTypeSystem()); var classVisitor = new ClassVisitor(resolver); classVisitor.filename = path; classVisitor.b = b; classVisitor.wm = wm; classVisitor.mapper = mapper; classVisitor.syntax = syntaxTree; syntaxTree.AcceptVisitor(classVisitor); syntax = syntaxTree; }