예제 #1
0
        public TaggerProvider(
            [Import] ITableManagerProvider tableManagerProvider,
            [Import] ITextDocumentFactoryService textDocumentFactoryService,
            [Import] IVisualLinterOptions options,
            [Import] ILinter linter)
        {
            _tableManager = tableManagerProvider
                            .GetTableManager(StandardTables.ErrorsTable);

            _textDocumentFactoryService = textDocumentFactoryService;

            _linter = linter;

            _optionsMap.Add(".html", () => options.EnableHtmlLanguageSupport);
            _optionsMap.Add(".js", () => options.EnableJavaScriptLanguageSupport);
            _optionsMap.Add(".jsx", () => options.EnableReactLanguageSupport);
            _optionsMap.Add(".vue", () => options.EnableVueLanguageSupport);

            var columns = new[]
            {
                StandardTableColumnDefinitions.BuildTool,
                StandardTableColumnDefinitions.Column,
                StandardTableColumnDefinitions.DetailsExpander,
                StandardTableColumnDefinitions.DocumentName,
                StandardTableColumnDefinitions.ErrorCategory,
                StandardTableColumnDefinitions.ErrorCode,
                StandardTableColumnDefinitions.ErrorSeverity,
                StandardTableColumnDefinitions.ErrorSource,
                StandardTableColumnDefinitions.Line,
                StandardTableColumnDefinitions.Text
            };

            _tableManager.AddSource(this, columns);
        }
예제 #2
0
 internal virtual void AddSource()
 {
     tableManager.AddSource(this,
                            StandardTableColumnDefinitions.Priority, StandardTableColumnDefinitions.Text,
                            StandardTableColumnDefinitions.ProjectName, StandardTableColumnDefinitions.DocumentName,
                            StandardTableColumnDefinitions.Line, StandardTableColumnDefinitions.Column);
 }
 internal ErrorListProvider(ITableManagerProvider provider)
 {
     ErrorTableManager = provider.GetTableManager(StandardTables.ErrorsTable);
     ErrorTableManager.AddSource(this, StandardTableColumnDefinitions.DetailsExpander, StandardTableColumnDefinitions.ProjectName,
                                 StandardTableColumnDefinitions.ErrorSeverity, StandardTableColumnDefinitions.ErrorCode,
                                 StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.ErrorCategory,
                                 StandardTableColumnDefinitions.Text, StandardTableColumnDefinitions.DocumentName,
                                 StandardTableColumnDefinitions.Line, StandardTableColumnDefinitions.Column);
 }
예제 #4
0
 internal virtual void AddSource()
 {
     tableManager.AddSource(this, StandardTableColumnDefinitions.DetailsExpander, StandardTableColumnDefinitions.ProjectName,
                            StandardTableColumnDefinitions.ErrorSeverity, StandardTableColumnDefinitions.ErrorCode,
                            StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.ErrorCategory,
                            StandardTableColumnDefinitions.Text, StandardTableColumnDefinitions.DocumentName,
                            StandardTableColumnDefinitions.Line, StandardTableColumnDefinitions.Column,
                            StandardTableColumnDefinitions.BuildTool);
 }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (pguidCmdGroup == _vSStd97CmdIDGuid && nCmdID == (uint)VSConstants.VSStd97CmdID.GotoDefn)
            {
                TextView.TextBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out ITextDocument textDoc);

                if (PackageCompletionSource.IsInRangeForPackageCompletion(TextView.TextSnapshot, TextView.Caret.Position.BufferPosition.Position, out Span targetSpan, out string packageName, out string packageVersion, out string completionType))
                {
                    if (PackageExistsOnNuGet(packageName, packageVersion, out string url))
                    {
                        System.Diagnostics.Process.Start(url);
                        return(VSConstants.S_OK);
                    }
                }

                IWorkspace        workspace   = _workspaceManager.GetWorkspace(textDoc.FilePath);
                List <Definition> definitions = workspace.ResolveDefinition(textDoc.FilePath, TextView.TextSnapshot.GetText(), TextView.Caret.Position.BufferPosition.Position);

                if (definitions.Count == 1)
                {
                    DTE dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE;
                    dte.MainWindow.Activate();

                    using (var state = new NewDocumentStateScope(Microsoft.VisualStudio.Shell.Interop.__VSNEWDOCUMENTSTATE.NDS_Provisional, Guid.Parse(ProjectFileToolsPackage.PackageGuidString)))
                    {
                        EnvDTE.Window w = dte.ItemOperations.OpenFile(definitions[0].File, EnvDTE.Constants.vsViewKindTextView);

                        if (definitions[0].Line.HasValue)
                        {
                            ((EnvDTE.TextSelection)dte.ActiveDocument.Selection).GotoLine(definitions[0].Line.Value, true);
                        }
                    }

                    return(VSConstants.S_OK);
                }

                else if (definitions.Count > 1)
                {
                    IFindAllReferencesService farService = (IFindAllReferencesService)Package.GetGlobalService(typeof(SVsFindAllReferences));
                    FarDataSource             dataSource = new FarDataSource(1);
                    dataSource.Snapshots[0] = new FarDataSnapshot(definitions);

                    IFindAllReferencesWindow farWindow   = farService.StartSearch(definitions[0].Type);
                    ITableManager            _farManager = farWindow.Manager;
                    _farManager.AddSource(dataSource);

                    dataSource.Sink.IsStable = false;
                    dataSource.Sink.AddSnapshot(dataSource.Snapshots[0]);
                    dataSource.Sink.IsStable = true;

                    return(VSConstants.S_OK);
                }
            }

            return(Next?.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut) ?? (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED);
        }
예제 #6
0
        public UnusedReferencesTableProvider(
            ITableManagerProvider tableMangerProvider,
            IWpfTableControlProvider tableControlProvider)
        {
            _tableManager         = tableMangerProvider.GetTableManager(UnusedReferencesDataSource.Name);
            _tableControlProvider = tableControlProvider;

            _dataSource = new UnusedReferencesDataSource();
            _tableManager.AddSource(_dataSource, UnusedReferencesColumnDefinitions.ColumnNames);
        }
 protected SettingsViewModelBase(ISettingsProvider <T> data,
                                 IWpfTableControlProvider controlProvider,
                                 ITableManagerProvider tableMangerProvider)
 {
     _data            = data;
     _controlProvider = controlProvider;
     _data.RegisterViewModel(this);
     _tableManager    = tableMangerProvider.GetTableManager(Identifier);
     _snapshotFactory = CreateSnapshotFactory(_data);
     _ = _tableManager.AddSource(this);
 }
예제 #8
0
        private TableDataSource()
        {
            var compositionService = ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)) as IComponentModel;

            compositionService.DefaultCompositionService.SatisfyImportsOnce(this);

            ITableManager manager = TableManagerProvider.GetTableManager(StandardTables.ErrorsTable);

            manager.AddSource(this, /*StandardTableColumnDefinitions.DetailsExpander,*/ StandardTableColumnDefinitions.ErrorCategory,
                              StandardTableColumnDefinitions.ErrorSeverity, StandardTableColumnDefinitions.ErrorCode,
                              StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.BuildTool,
                              StandardTableColumnDefinitions.Text, StandardTableColumnDefinitions.DocumentName,
                              StandardTableColumnDefinitions.Line, StandardTableColumnDefinitions.Column);
        }
예제 #9
0
        private static int ShowInFar(string title, List <Definition> definitions)
        {
            IFindAllReferencesService farService = ServiceUtil.GetService <SVsFindAllReferences, IFindAllReferencesService>();
            FarDataSource             dataSource = new FarDataSource(1);

            dataSource.Snapshots[0] = new FarDataSnapshot(definitions);

            IFindAllReferencesWindow farWindow   = farService.StartSearch(title);
            ITableManager            _farManager = farWindow.Manager;

            _farManager.AddSource(dataSource);

            dataSource.Sink.IsStable = false;
            dataSource.Sink.AddSnapshot(dataSource.Snapshots[0]);
            dataSource.Sink.IsStable = true;

            return(VSConstants.S_OK);
        }
        protected void Initialize(IReadOnlyCollection <string> columns)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var compositionService = ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)) as IComponentModel;

            // The composition service will only be null in unit tests.
            if (compositionService == null)
            {
                return;
            }

            compositionService.DefaultCompositionService.SatisfyImportsOnce(this);

            if (this.TableManagerProvider == null)
            {
                this.TableManagerProvider = compositionService.GetService <ITableManagerProvider>();
            }

            ITableManager manager = this.TableManagerProvider.GetTableManager(StandardTables.ErrorsTable);

            manager.AddSource(this, columns);
        }
        // Lock before calling
        private void EnsureInitialized()
        {
            if (!_initialized)
            {
                // Double check around locking since this is called often.
                lock (_initLockObj)
                {
                    if (!_initialized)
                    {
                        NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
                        {
                            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                            // Get the error list service from the UI thread
                            _errorList    = await _asyncServiceProvider.GetServiceAsync <SVsErrorList, IErrorList>();
                            _tableManager = _errorList.TableControl.Manager;

                            _tableManager.AddSource(this);
                            _initialized = true;
                        });
                    }
                }
            }
        }