Example #1
0
			public CSharpChunkParser (SpanParser spanParser, Mono.TextEditor.Document doc, ColorSheme style, SyntaxMode mode, LineSegment line) : base (spanParser, doc, style, mode, line)
			{
				document = IdeApp.Workbench.GetDocument (doc.FileName);
				
				foreach (var tag in ProjectDomService.SpecialCommentTags) {
					tags.Add (tag.Tag);
				}
				
				ICSharpCode.OldNRefactory.Ast.CompilationUnit unit = null;
				if (document != null && document.ParsedDocument != null && MonoDevelop.Core.PropertyService.Get ("EnableSemanticHighlighting", false)) {
					resolver = document.GetResolver ();
					if (!document.ParsedDocument.TryGetTag (out unit)) {
						try {
							using (ICSharpCode.OldNRefactory.IParser parser = ICSharpCode.OldNRefactory.ParserFactory.CreateParser (ICSharpCode.OldNRefactory.SupportedLanguage.CSharp, document.Editor.Document.OpenTextReader ())) {
								parser.Parse ();
								unit = parser.CompilationUnit;
								document.ParsedDocument.SetTag (unit);
							}
						} catch (Exception) {
							resolver = null;
							return;
						}
					}
					resolver.SetupParsedCompilationUnit (unit);
				}
			}