public void VsTextViewCreated(IVsTextView textViewAdapter) { ITextView textView = AdapterService.GetWpfTextView(textViewAdapter); if (textView == null) { return; } ThreadHelper.ThrowIfNotOnUIThread(); Parser.Project parsedproject = null; var buffer = textView.TextBuffer; IVsTextBuffer bufferAdapter; buffer.Properties.TryGetProperty(typeof(IVsTextBuffer), out bufferAdapter); var persist = (IPersistFileFormat)bufferAdapter; if (persist != null) { string filename = null; uint formatindex = 0; if (persist.GetCurFile(out filename, out formatindex) == VSConstants.S_OK) { var doctable = new RunningDocumentTable(ServiceProvider); var hierarchy = doctable.GetHierarchyItem(filename); if (hierarchy != null) { parsedproject = Parser.ProjectMapper.GetInstance().Map(hierarchy); } } } if (!buffer.Properties.ContainsProperty(typeof(Parser.Project))) { buffer.Properties.AddProperty(typeof(Parser.Project), parsedproject); } Func <EpochCompletionCommandHandler> createCommandHandler = delegate() { return(new EpochCompletionCommandHandler(textViewAdapter, textView, this, SignatureHelpBroker, NavigatorService.GetTextStructureNavigator(textView.TextBuffer))); }; textView.Properties.GetOrCreateSingletonProperty(createCommandHandler); }
public void ReportTasks(ArrayList errors) { TaskProvider taskProvider = this.GetTaskProvider(); TaskReporter tr = this.GetTaskReporter(); if (null == taskProvider || null == tr) { Debug.Assert(false, "null task provider or task reporter - exiting ReportTasks"); return; } string fname = this.GetFilePath(); // Clear out this file's tasks tr.ClearBackgroundTasksForFile(fname); int errorMax = this.service.Preferences.MaxErrorMessages; RunningDocumentTable rdt = new RunningDocumentTable(this.service.Site); IVsHierarchy thisHeirarchy = rdt.GetHierarchyItem(fname); // Here we merge errors lists to reduce flicker. It is not a very intelligent merge // but that is ok, the worst case is the task list flickers a bit. But 99% of the time // one error is added or removed as the user is typing, and this merge will reduce flicker // in this case. errors = GroupBySeverity(errors); taskProvider.SuspendRefresh(); // batch updates. TaskErrorCategory mostSevere = TaskErrorCategory.Message; for (int i = 0, n = errors.Count; i < n; i++) { ErrorNode enode = (ErrorNode)errors[i]; string filename = enode.uri; string subcategory = enode.subcategory; bool thisFile = (!string.IsNullOrEmpty(filename) && NativeMethods.IsSamePath(fname, filename)); TextSpan span = enode.context; Severity severity = enode.severity; string message = enode.message; if (message == null) continue; message = NormalizeErrorString(message); //normalize text span if (thisFile) { FixupMarkerSpan(ref span); } else { TextSpanHelper.MakePositive(ref span); } //set options TaskPriority priority = TaskPriority.Normal; TaskCategory category = TaskCategory.BuildCompile; MARKERTYPE markerType = MARKERTYPE.MARKER_CODESENSE_ERROR; TaskErrorCategory errorCategory = TaskErrorCategory.Warning; if (severity == Severity.Fatal || severity == Severity.Error) { priority = TaskPriority.High; errorCategory = TaskErrorCategory.Error; } else if (severity == Severity.Hint) { category = TaskCategory.Comments; markerType = MARKERTYPE.MARKER_INVISIBLE; errorCategory = TaskErrorCategory.Message; } else if (severity == Severity.Warning) { markerType = MARKERTYPE.MARKER_COMPILE_ERROR; errorCategory = TaskErrorCategory.Warning; } if (errorCategory < mostSevere) { mostSevere = errorCategory; } IVsHierarchy hierarchy = thisHeirarchy; if (!thisFile) { // must be an error reference to another file. hierarchy = rdt.GetHierarchyItem(filename); markerType = MARKERTYPE.MARKER_OTHER_ERROR; // indicate to CreateErrorTaskItem } DocumentTask docTask = this.CreateErrorTaskItem(span, filename, subcategory, message, priority, category, markerType, errorCategory); docTask.HierarchyItem = hierarchy; tr.AddTask(docTask); } tr.OutputTaskList(); taskProvider.ResumeRefresh(); // batch updates. }