public override ParsedDocument Parse (ProjectDom dom, string fileName, string content) { using (ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser (ICSharpCode.NRefactory.SupportedLanguage.CSharp, new StringReader (content))) { ParsedDocument result = new ParsedDocument (fileName); result.CompilationUnit = new MonoDevelop.Projects.Dom.CompilationUnit (fileName); parser.Errors.Error += delegate(int line, int col, string message) { result.Add (new Error (ErrorType.Error, line, col, message)); }; parser.Lexer.SpecialCommentTags = LexerTags; parser.Lexer.EvaluateConditionalCompilation = true; if (dom != null && dom.Project != null) { DotNetProjectConfiguration conf = dom.Project.DefaultConfiguration as DotNetProjectConfiguration; CSharpCompilerParameters par = conf != null ? conf.CompilationParameters as CSharpCompilerParameters : null; if (par != null) parser.Lexer.SetConditionalCompilationSymbols (par.DefineSymbols); } parser.Parse (); SpecialTracker tracker = new SpecialTracker (result); foreach (ICSharpCode.NRefactory.ISpecial special in parser.Lexer.SpecialTracker.CurrentSpecials) { special.AcceptVisitor (tracker, null); } foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in parser.Lexer.TagComments) { result.Add (new Tag (tagComment.Tag, tagComment.CommentText, new DomRegion (tagComment.StartPosition.Y, tagComment.StartPosition.X, tagComment.EndPosition.Y, tagComment.EndPosition.X))); } ConversionVisitior visitor = new ConversionVisitior (result, parser.Lexer.SpecialTracker.CurrentSpecials); visitor.VisitCompilationUnit (parser.CompilationUnit, null); result.CompilationUnit.Tag = parser.CompilationUnit; LastUnit = parser.CompilationUnit; return result; } }
public override ParsedDocument Parse (ProjectDom dom, string fileName, string content) { using (ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser (ICSharpCode.NRefactory.SupportedLanguage.CSharp, new StringReader (content))) { ParsedDocument result = new ParsedDocument (fileName); result.CompilationUnit = new MonoDevelop.Projects.Dom.CompilationUnit (fileName); parser.ParseMethodBodies = false; parser.Errors.Error += delegate(int line, int col, string message) { result.Add (new Error (ErrorType.Error, line, col, message)); }; parser.Lexer.SpecialCommentTags = ProjectDomService.SpecialCommentTags.GetNames (); parser.Lexer.EvaluateConditionalCompilation = true; if (dom != null && dom.Project != null && MonoDevelop.Ide.IdeApp.Workspace != null) { DotNetProjectConfiguration configuration = dom.Project.GetConfiguration (MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as DotNetProjectConfiguration; CSharpCompilerParameters par = configuration != null ? configuration.CompilationParameters as CSharpCompilerParameters : null; if (par != null) parser.Lexer.SetConditionalCompilationSymbols (par.DefineSymbols); } parser.Parse (); SpecialTracker tracker = new SpecialTracker (result); foreach (ICSharpCode.NRefactory.ISpecial special in parser.Lexer.SpecialTracker.CurrentSpecials) { special.AcceptVisitor (tracker, null); } foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in parser.Lexer.TagComments) { result.Add (new Tag (tagComment.Tag, tagComment.CommentText, new DomRegion (tagComment.StartPosition.Y, tagComment.StartPosition.X, tagComment.EndPosition.Y, tagComment.EndPosition.X))); } ConversionVisitior visitor = new ConversionVisitior (dom, result, parser.Lexer.SpecialTracker.CurrentSpecials); visitor.VisitCompilationUnit (parser.CompilationUnit, null); result.CompilationUnit.Tag = parser.CompilationUnit; LastUnit = parser.CompilationUnit; return result; } }