// // Reset the contents of the project to a pristine state. // // This method is designed to return the Project object to a blank // configuration as if no code had been parsed. This should be done // prior to any large-scale parsing operation to ensure that the // data extracted from the parsed code does not contain duplicated // or stale information. // private void ResetContents() { Files = new Dictionary <string, SourceFile>(); Scopes = new Dictionary <string, List <LexicalScope> >(); GlobalScope = new LexicalScope(); FunctionSignatures = new Dictionary <string, FunctionSignature>(); StructureDefinitions = new Dictionary <string, Structure>(); SumTypes = new Dictionary <string, SumType>(); StrongAliases = new Dictionary <string, StrongAlias>(); WeakAliases = new Dictionary <string, WeakAlias>(); var helper = new ParseSession.ErrorListHelper(); var ErrorProvider = new ErrorListProvider(helper); ErrorProvider.ProviderName = "Epoch Language"; ErrorProvider.ProviderGuid = new Guid(VsPackage.PackageGuid); ErrorProvider.Tasks.Clear(); // TODO - this is probably too brute force }
// // Plumbing - an event handler for when a Task is double-clicked, i.e. // to navigate to the code causing a parser error. // internal async void NavigationHandler(object sender, EventArgs args) { var task = sender as Microsoft.VisualStudio.Shell.Task; if (string.IsNullOrEmpty(task.Document)) { return; } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var serviceProvider = new ParseSession.ErrorListHelper(); var openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } IVsTextManager mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } // This whole mess could arguably be a lot simpler as a call to ErrorProvider.Navigate(). // Unfortunately that API assumes 1-based column/line indices, whereas our task (in order // to display correctly in the task list) assumes 0-based. This can be worked around with // a trivial addition/substraction, but the kicker is that the column is not used by that // particular API. Therefore to preserve the column we do all this crazy stuff instead. mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }