public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (!DocumentService.TryGetTextDocument(textView.TextBuffer, out ITextDocument doc))
            {
                return;
            }

            string fileName = Path.GetFileName(doc.FilePath);

            if (!fileName.Equals(Constants.ConfigFileName, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            new CompletionController(textViewAdapter, textView, CompletionBroker);


            _dependencies = Dependencies.FromConfigFile(doc.FilePath);
            _manifest     = Manifest.FromFileAsync(doc.FilePath, _dependencies, CancellationToken.None).Result;
            _manifestPath = doc.FilePath;
            _project      = VsHelpers.GetDTEProjectFromConfig(_manifestPath);

            if (_manifest == null)
            {
                AddErrorToList(PredefinedErrors.ManifestMalformed());
            }

            doc.FileActionOccurred += OnFileSaved;
            textView.Closed        += OnViewClosed;
        }
Example #2
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            if (_hasRun || _isProcessing)
            {
                return;
            }

            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            ITextDocument doc;

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out doc))
            {
                if (Path.IsPathRooted(doc.FilePath) && File.Exists(doc.FilePath))
                {
                    _isProcessing = true;
                    var dte  = (DTE2)Package.GetGlobalService(typeof(DTE));
                    var item = dte.Solution?.FindProjectItem(doc.FilePath);

                    System.Threading.Tasks.Task.Run(() =>
                    {
                        EnsureInitialized(item);
                        _hasRun = _isProcessing = false;
                    });
                }
            }
        }
Example #3
0
        public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
        {
            if (RoslynUtilities.IsRoslynInstalled(ServiceProvider) || !LanguageUtilities.IsRunning())
            {
                return;
            }

            if (!subjectBuffers.Any(b => b.ContentType.IsOfType("CSharp")))
            {
                return;
            }

            // VS2010 only creates TextViewAdapters later; wait for it to exist.
            await Dispatcher.Yield();

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            if (textViewAdapter == null)
            {
                return;
            }
            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionInterceptor(ReferenceProviders, ServiceProvider, textViewAdapter, textView, document));
        }
Example #4
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_hasRun || _isProcessing)
            {
                return;
            }

            IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);


            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out ITextDocument doc))
            {
                if (Path.IsPathRooted(doc.FilePath) && File.Exists(doc.FilePath))
                {
                    _isProcessing = true;
                    var         dte  = (DTE2)Package.GetGlobalService(typeof(DTE));
                    ProjectItem item = dte.Solution?.FindProjectItem(doc.FilePath);

                    ThreadHelper.JoinableTaskFactory.Run(async() =>
                    {
                        await EnsureInitializedAsync(item);
                        _hasRun = _isProcessing = false;
                    });
                }
            }
        }
Example #5
0
        /// <summary>
        /// Called when a IVsTextView adapter has been created and initialized.
        /// </summary>
        /// <param name="textViewAdapter">The newly created and initialized text view adapter.</param>
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView    = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);
            ViewContext  context     = new ViewContext(textView, textViewAdapter);
            string       contentType = textView.TextBuffer.ContentType.TypeName;

            // As of v2019 Visual Studio does not use projection buffer for JSX files and thus we cannot
            // detect JS and HTML buffers. So, in order to prevent unintended JS and Emmet snippets
            // collisions we require prefix for emmet abbreviations to work correctly.
            if (contentType.EndsWith("script", StringComparison.InvariantCultureIgnoreCase))
            {
                context.AbbreviationPrefix = JsxPrefix;
            }

            if ("CSharp" != contentType)
            {
                EmmetCommandTarget target = textView.Properties.GetOrCreateSingletonProperty(
                    "EmmetCommandTarget",
                    () => new EmmetCommandTarget(context, CompletionBroker));
            }
            else
            {
                textView.Properties.GetOrCreateSingletonProperty(
                    "ZenSharpCommandTarget",
                    () => new ZenSharpCommandTarget(context, CompletionBroker));
            }
        }
Example #6
0
        public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
        {
            if (!subjectBuffers.Any(b => b.ContentType.IsOfType("CSharp") || b.ContentType.IsOfType("Basic")))
            {
                return;
            }

            // VS2010 only creates TextViewAdapters later; wait for it to exist.
            await Dispatcher.Yield();

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            if (textViewAdapter == null)
            {
                return;
            }
            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            // Register the native command first, so that it ends up earlier in
            // the command chain than our interceptor. This prevents the native
            // comand from being intercepted too.
            textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefintionNativeCommand(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionInterceptor(ReferenceProviders, ServiceProvider, textViewAdapter, textView, document));
        }
        int IVsImmediateStatementCompletion2.SetCompletionContext(string filePath,
                                                                  IVsTextLines buffer,
                                                                  Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan,
                                                                  object punkContext,
                                                                  IVsTextView textView)
        {
            // The immediate window is always marked read-only and the language service is
            // responsible for asking the buffer to make itself writable. We'll have to do that for
            // commit, so we need to drag the IVsTextLines around, too.
            IVsTextLines debuggerBuffer;

            Marshal.ThrowExceptionForHR(textView.GetBuffer(out debuggerBuffer));

            var view = EditorAdaptersFactoryService.GetWpfTextView(textView);

            // Sometimes, they give us a null context buffer. In that case, there's probably not any
            // work to do.
            if (buffer != null)
            {
                var contextBuffer = EditorAdaptersFactoryService.GetDataBuffer(buffer);
                var context       = CreateContext(view, textView, debuggerBuffer, contextBuffer, currentStatementSpan);
                if (context.TryInitialize())
                {
                    this.filters[textView].SetContext(context);
                }
                else
                {
                    this.filters[textView].RemoveContext();
                }
            }

            return(VSConstants.S_OK);
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionCommandTarget(textViewAdapter, textView, GoToDefinitionProviderService, ServiceProvider));
            textView.Properties.GetOrCreateSingletonProperty(() => new OpenIncludeFileCommandTarget(textViewAdapter, textView, ServiceProvider, SourceTextFactory));
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Closed += TextviewClosed;

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document))
            {
                Task.Run(async() =>
                {
                    if (!LinterService.IsFileSupported(_document.FilePath))
                    {
                        return;
                    }

                    _document.FileActionOccurred += DocumentSaved;
                    textView.Properties.AddProperty("lint_filename", _document.FilePath);

                    // Don't run linter again if error list already contains errors for the file.
                    if (!TableDataSource.Instance.HasErrors(_document.FilePath))
                    {
                        await LinterService.Lint(false, _document.FilePath);
                    }
                });
            }
        }
        /// <summary>
        /// Called when a <see cref="T:Microsoft.VisualStudio.TextManager.Interop.IVsTextView" /> adapter has
        /// been created and initialized.
        /// </summary>
        /// <param name="textViewAdapter">The newly created and initialized text view adapter.</param>
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(
                () => new ViewCommandFilter(textView, textViewAdapter, CompletionBroker, Syntax));
        }
Example #11
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextDocument document;

            var view = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document))
            {
                string filePath = document.FilePath;

                if (!IsPaketLockFile(filePath))
                {
                    return;
                }

                PaketLockClassifier classifier;
                view.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(PaketLockClassifier), out classifier);
                view.Properties.GetOrCreateSingletonProperty(() => new CommentCommandTarget(textViewAdapter, view, "#"));

                if (classifier != null)
                {
                    ITextSnapshot snapshot = view.TextBuffer.CurrentSnapshot;
                    classifier.OnClassificationChanged(new SnapshotSpan(snapshot, 0, snapshot.Length));
                }
            }
        }
Example #12
0
        public void TextViewCreated(IWpfTextView textView)
        {
            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            if (textViewAdapter == null)
            {
                return;
            }

            if (BuilderInfo.Supports(document.FilePath))
            {
                // add commands to view form or code
                textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => ViewDesigner(document)));
                textView.Properties.AddProperty(ViewCodeKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewCode, () => ViewCode(document)));
            }
            else if (BuilderInfo.IsCodeBehind(document.FilePath))
            {
                textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => ViewDesignSource(document)));
            }
        }
Example #13
0
        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
        {
            if (subjectBuffers.Any(b => b.ContentType.IsOfType(LiveScriptContentTypeDefinition.LiveScriptContentType)))
            {
                return;
            }

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            textView.Properties.GetOrCreateSingletonProperty(() => new EnterIndentation(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new CommentCommandTarget(textViewAdapter, textView, "#"));

            ITextDocument document;

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                var lintInvoker = new LintFileInvoker(
                    f => new LintReporter(new CoffeeLintCompiler(), WESettings.Instance.CoffeeScript, f),
                    document
                    );
                textView.Closed += (s, e) => lintInvoker.Dispose();

                textView.TextBuffer.Properties.GetOrCreateSingletonProperty(() => lintInvoker);
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new ControllerGoToDefinition(textViewAdapter, textView, AngularPackage.DTE, this.StandardClassificationService, this.HierarchyProvider));
            textView.Properties.GetOrCreateSingletonProperty(() => new DirectiveGoToDefinition(textViewAdapter, textView, AngularPackage.DTE, this.HierarchyProvider));
        }
Example #15
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (!DocumentService.TryGetTextDocument(textView.TextBuffer, out ITextDocument doc))
            {
                return;
            }

            string fileName = Path.GetFileName(doc.FilePath);

            if (!fileName.Equals(Constants.ConfigFileName, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            new CompletionController(textViewAdapter, textView, CompletionBroker);

            _dependencies = Dependencies.FromConfigFile(doc.FilePath);
            _manifest     = Manifest.FromFileAsync(doc.FilePath, _dependencies, CancellationToken.None).Result;
            _manifestPath = doc.FilePath;
            _project      = VsHelpers.GetDTEProjectFromConfig(_manifestPath);

            doc.FileActionOccurred += OnFileSaved;
            textView.Closed        += OnViewClosed;

            Task.Run(async() =>
            {
                IEnumerable <ILibraryOperationResult> results = await LibrariesValidator.GetManifestErrorsAsync(_manifest, _dependencies, CancellationToken.None).ConfigureAwait(false);
                if (!results.All(r => r.Success))
                {
                    AddErrorsToList(results);
                }
            });
        }
Example #16
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty <CssSortProperties>(() => new CssSortProperties(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <CssExtractToFile>(() => new CssExtractToFile(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <CssAddMissingStandard>(() => new CssAddMissingStandard(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <CssAddMissingVendor>(() => new CssAddMissingVendor(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <CssRemoveDuplicates>(() => new CssRemoveDuplicates(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <MinifySelection>(() => new MinifySelection(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <CssFindReferences>(() => new CssFindReferences(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <F1Help>(() => new F1Help(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <CssSelectBrowsers>(() => new CssSelectBrowsers(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty <RetriggerTarget>(() => new RetriggerTarget(textViewAdapter, textView, CompletionBroker));

            uint cssFormatProperties;

            EditorExtensionsPackage.PriorityCommandTarget.RegisterPriorityCommandTarget(0, new CssFormatProperties(textView), out cssFormatProperties);
            textView.Closed += delegate { EditorExtensionsPackage.PriorityCommandTarget.UnregisterPriorityCommandTarget(cssFormatProperties); };

            uint cssSpeedTyping;

            EditorExtensionsPackage.PriorityCommandTarget.RegisterPriorityCommandTarget(0, new SpeedTypingTarget(this, textViewAdapter, textView), out cssSpeedTyping);
            textView.Closed += delegate { EditorExtensionsPackage.PriorityCommandTarget.UnregisterPriorityCommandTarget(cssSpeedTyping); };
        }
Example #17
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            DTE2         dte      = serviceProvider.GetService(typeof(DTE)) as DTE2;
            IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new QuoteItCommand(textViewAdapter, textView, dte));
        }
Example #18
0
        public void TextViewCreated(IWpfTextView textView)
        {
            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            if (textViewAdapter == null)
            {
                return;
            }

            var info = BuilderInfo.Find(document.FilePath);

            if (info != null)
            {
                // add commands to view form or code
                //textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => ViewDesigner(document)));
                //textView.Properties.AddProperty(ViewCodeKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewCode, () => ViewCode(document)));
                if (string.Equals(info.Extension, ".xeto", StringComparison.OrdinalIgnoreCase))
                {
                    textView.Properties.GetOrCreateSingletonProperty(() => new XamlCompletionHandler(textViewAdapter, textView, this));
                }
            }
            else if (BuilderInfo.IsCodeBehind(document.FilePath))
            {
                textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => ViewDesigner(document)));
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new HtmlGoToDefinition(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new HtmlFindAllReferences(textViewAdapter, textView));
        }
Example #20
0
        public void VsTextViewCreated(Microsoft.VisualStudio.TextManager.Interop.IVsTextView textViewAdapter)
        {
            ITextDocument       document;
            RobotsTxtClassifier classifier;

            var view = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document))
            {
                TextType type = GetTextType(document.FilePath);
                if (type == TextType.Unsupported)
                {
                    return;
                }

                view.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(RobotsTxtClassifier), out classifier);
                view.Properties.GetOrCreateSingletonProperty(() => new CommentCommandTarget(textViewAdapter, view, "#"));

                if (classifier != null)
                {
                    ITextSnapshot snapshot = view.TextBuffer.CurrentSnapshot;
                    classifier.OnClassificationChanged(new SnapshotSpan(snapshot, 0, snapshot.Length), type);
                }
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new MinifySelection(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new JavaScriptFindReferences(textViewAdapter, textView, Navigator));
            textView.Properties.GetOrCreateSingletonProperty(() => new CssExtractToFile(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new NodeModuleGoToDefinition(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new ReferenceTagGoToDefinition(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new CommentCompletionCommandTarget(textViewAdapter, textView, AggregatorService));
            textView.Properties.GetOrCreateSingletonProperty(() => new CommentIndentationCommandTarget(textViewAdapter, textView, AggregatorService, CompletionBroker));

            ITextDocument document;

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                if (ProjectHelpers.GetProjectItem(document.FilePath) == null)
                {
                    return;
                }

                var jsHintLintInvoker = new LintFileInvoker(f => new JavaScriptLintReporter(new JsHintCompiler(), f), document);
                textView.Closed += (s, e) => jsHintLintInvoker.Dispose();

                textView.TextBuffer.Properties.GetOrCreateSingletonProperty(() => jsHintLintInvoker);

                var jsCodeStyleLintInvoker = new LintFileInvoker(f => new JavaScriptLintReporter(new JsCodeStyleCompiler(), f), document);
                textView.Closed += (s, e) => jsCodeStyleLintInvoker.Dispose();

                textView.TextBuffer.Properties.GetOrCreateSingletonProperty(() => jsCodeStyleLintInvoker);
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Closed += TextviewClosed;

            // Both "Web Compiler" and "Bundler & Minifier" extensions add this property on their
            // generated output files. Generated output should be ignored from linting
            bool generated;

            if (textView.Properties.TryGetProperty("generated", out generated) && generated)
            {
                return;
            }

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document))
            {
                Task.Run(async() =>
                {
                    if (!LinterService.IsFileSupported(_document.FilePath))
                    {
                        return;
                    }

                    _document.FileActionOccurred += DocumentSaved;
                    textView.Properties.AddProperty("lint_filename", _document.FilePath);

                    // Don't run linter again if error list already contains errors for the file.
                    if (!TableDataSource.Instance.HasErrors(_document.FilePath))
                    {
                        await LinterService.LintAsync(false, _document.FilePath);
                    }
                });
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            var provider = CommenterProviders.FirstOrDefault(providerInfo => providerInfo.Metadata.ContentTypes.Any(contentType => textView.TextBuffer.ContentType.IsOfType(contentType)));

            if (provider == null)
            {
                return;
            }

            var commenter = provider.Value.GetCommenter(textView);

            if (commenter == null)
            {
                return;
            }

            CommenterFilter filter = new CommenterFilter(textViewAdapter, textView, commenter);

            filter.Enabled = true;
            textView.Properties.AddProperty(typeof(CommenterFilter), filter);
        }
Example #24
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Closed += TextviewClosed;

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document))
            {
                if (!LinterService.IsFileSupported(_document.FilePath))
                {
                    return;
                }

                WebLinterPackage.Dispatcher.BeginInvoke(new Action(() =>
                {
                    _document.FileActionOccurred += DocumentSaved;
                    textView.Properties.AddProperty("lint_filename", _document.FilePath);

                    // Don't run linter again if error list already contains errors for the file.
                    if (!TableDataSource.Instance.HasErrors(_document.FilePath))
                    {
                        LinterService.Lint(false, _document.FilePath);
                    }
                }), DispatcherPriority.ApplicationIdle, null);
            }
        }
Example #25
0
        protected override bool TryInvokeInsertionUI(
            ITextView textView,
            ITextBuffer subjectBuffer,
            bool surroundWith = false
            )
        {
            if (!TryGetExpansionManager(out var expansionManager))
            {
                return(false);
            }

            expansionManager.InvokeInsertionUI(
                EditorAdaptersFactoryService.GetViewAdapter(textView),
                GetSnippetExpansionClient(textView, subjectBuffer),
                Guids.CSharpLanguageServiceId,
                bstrTypes: surroundWith
                  ? new[] { "SurroundsWith" }
                  : new[] { "Expansion", "SurroundsWith" },
                iCountTypes: surroundWith ? 1 : 2,
                fIncludeNULLType: 1,
                bstrKinds: null,
                iCountKinds: 0,
                fIncludeNULLKind: 0,
                bstrPrefixText: surroundWith
                  ? CSharpVSResources.Surround_With
                  : CSharpVSResources.Insert_Snippet,
                bstrCompletionChar: null
                );

            return(true);
        }
Example #26
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView   = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);
            var classifier = ClassifierService.GetClassifier(textView.TextBuffer);

            AddCommandFilter(textViewAdapter, new ExpandCommand(textView, CompletionBroker, UndoProvider, classifier));
        }
Example #27
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView    = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);
            var contentType = textView.TextBuffer.ContentType;

            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            var settings = WESettings.Instance.ForContentType <IChainableCompilerSettings>(contentType);

            var notifierProvider = Mef.GetImport <ICompilationNotifierProvider>(contentType);

            if (notifierProvider == null)
            {
                return;
            }

            var notifier = notifierProvider.GetCompilationNotifier(document);

            var compilerProvider = Mef.GetImport <ICompilerRunnerProvider>(contentType);

            if (compilerProvider == null)
            {
                return;
            }

            var compilerRunner = compilerProvider.GetCompiler(contentType);

            var graph = GetGraph(contentType);

            notifier.CompilationReady += async(s, e) =>
            {
                if (!e.CompilerResult.IsSuccess)
                {
                    return;
                }

                if (!settings.CompileOnSave || !settings.EnableChainCompilation || (bool)s)
                {
                    return;
                }

                var count = 0;
                foreach (var file in await graph.GetRecursiveDependentsAsync(e.CompilerResult.SourceFileName))
                {
                    if (File.Exists(compilerRunner.GetTargetPath(file)))
                    {
                        compilerRunner.CompileToDefaultOutputAsync(file).DoNotWait("compiling " + file);
                        count++;
                    }
                }
                WebEssentialsPackage.DTE.StatusBar.Text = "Compiling " + count + " dependent file" + (count == 1 ? "s" : "")
                                                          + " for " + Path.GetFileName(e.CompilerResult.SourceFileName);
            };
        }
Example #28
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);
            var completionModelManager = CompletionModelManagerProvider.GetCompletionModel(textView);

            textView.Properties.GetOrCreateSingletonProperty(() => new CompletionCommandHandlerTriggers(textViewAdapter, textView, completionModelManager));
            textView.Properties.GetOrCreateSingletonProperty(() => new CompletionCommandHandler(textViewAdapter, textView, completionModelManager));
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView             = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);
            var signatureHelpManager = SignatureHelpManagerProvider.GetSignatureHelpManager(textView);

            textView.Properties.GetOrCreateSingletonProperty(() => new SignatureHelpCommandHandlerParamInfo(textViewAdapter, textView, signatureHelpManager));
            textView.Properties.GetOrCreateSingletonProperty(() => new SignatureHelpCommandHandlerTypeChar(textViewAdapter, textView, signatureHelpManager));
        }
Example #30
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new ZenCoding(textViewAdapter, textView, CompletionBroker));

            textView.MouseHover += textView_MouseHover;
            textView.Closed     += textView_Closed;
        }