コード例 #1
0
        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);
                    }
                });
            }
        }
コード例 #2
0
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && LinterService.IsFileSupported(e.FilePath))
     {
         LinterService.Lint(false, e.FilePath);
     }
 }
コード例 #3
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);
            }
        }
コード例 #4
0
 private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         await LinterService.LintAsync(false, e.FilePath);
     }
 }
コード例 #5
0
        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);
                    }
                });
            }
        }
コード例 #6
0
 private static async Task CallLinterService(string filePath)
 {
     if (WebLinterPackage.Settings.UseTsConfig)
     {
         Tsconfig tsconfig = TsconfigLocations.FindFromProjectItem(filePath);
         if (tsconfig == null)
         {
             return;
         }
         await LinterService.Lint(false, false, false, new string[] { tsconfig.FullName },
                                  new string[] { filePath });
     }
     else
     {
         await LinterService.Lint(false, false, false, new string[] { filePath });
     }
 }
コード例 #7
0
 private static async Task LintFile(string filePath)
 {
     Benchmark.Start();
     Benchmark.Log("In SourceFileCreationListener.LintFile, path=" + filePath);
     if (WebLinterPackage.Settings.UseTsConfig)
     {
         string tsconfig = TsconfigLocations.FindParentTsconfig(filePath);
         if (tsconfig == null)
         {
             return;
         }
         await LinterService.Lint(false, false, false, new string[] { tsconfig },
                                  clearAllErrors : false, CreateFileToProjectMap(filePath));
     }
     else
     {
         await LinterService.Lint(false, false, false, new string[] { filePath },
                                  clearAllErrors : false, CreateFileToProjectMap(filePath));
     }
     Benchmark.End();
 }