Ejemplo n.º 1
0
        private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!_runner.Settings.LintOnSave)
                return;

            ITextDocument document = (ITextDocument)sender;
            if (_isDisposed || document.TextBuffer == null)
                return;

            switch (e.FileActionType)
            {
                case FileActionTypes.ContentLoadedFromDisk:
                    break;
                case FileActionTypes.DocumentRenamed:
                    _runner.Dispose();
                    _runner = _creator(_document.FilePath);

                    goto case FileActionTypes.ContentSavedToDisk;
                case FileActionTypes.ContentSavedToDisk:
                    Dispatcher.CurrentDispatcher.InvokeAsync(
                        () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                        DispatcherPriority.ApplicationIdle
                    );
                    break;
            }
        }
Ejemplo n.º 2
0
        private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!_runner.Settings.LintOnSave)
            {
                return;
            }

            ITextDocument document = (ITextDocument)sender;

            if (_isDisposed || document.TextBuffer == null)
            {
                return;
            }

            switch (e.FileActionType)
            {
            case FileActionTypes.ContentLoadedFromDisk:
                break;

            case FileActionTypes.DocumentRenamed:
                _runner.Dispose();
                _runner = _creator(_document.FilePath);

                goto case FileActionTypes.ContentSavedToDisk;

            case FileActionTypes.ContentSavedToDisk:
                Dispatcher.CurrentDispatcher.InvokeAsync(
                    () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                    DispatcherPriority.ApplicationIdle
                    );
                break;
            }
        }
Ejemplo n.º 3
0
        private void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
        {
            bool success = _dte.Solution.SolutionBuild.LastBuildInfo == 0;

            if (!success)
            {
                string text = _dte.StatusBar.Text; // respect localization of "Build failed"
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    _dte.StatusBar.Text = text;
                }), DispatcherPriority.ApplicationIdle, null);

                return;
            }

            if (Action != vsBuildAction.vsBuildActionClean)
            {
                var compiler = WebEditor.Host.ExportProvider.GetExport <ProjectCompiler>();
                ThreadingTask.Task.Run(() =>
                {
                    Parallel.ForEach(
                        Mef.GetSupportedContentTypes <ICompilerRunnerProvider>()
                        .Where(c => WESettings.Instance.ForContentType <ICompilerInvocationSettings>(c).CompileOnBuild),
                        c => compiler.Value.CompileSolutionAsync(c).DontWait("compiling solution-wide " + c.DisplayName)
                        );
                    BuildMenu.UpdateBundleFiles();
                }).DontWait("running solution-wide compilers");

                if (WESettings.Instance.JavaScript.LintOnBuild)
                {
                    LintFileInvoker.RunOnAllFilesInProjectAsync(new[] { "*.js" }, f => new JavaScriptLintReporter(new JsHintCompiler(), f))
                    .DontWait("running solution-wide JSHint");
                    LintFileInvoker.RunOnAllFilesInProjectAsync(new[] { "*.js" }, f => new JavaScriptLintReporter(new JsCodeStyleCompiler(), f))
                    .DontWait("running solution-wide JSCS");
                }

                if (WESettings.Instance.TypeScript.LintOnBuild)
                {
                    LintFileInvoker.RunOnAllFilesInProjectAsync(new[] { "*.ts" }, f => new LintReporter(new TsLintCompiler(), WESettings.Instance.TypeScript, f))
                    .DontWait("running solution-wide TSLint");
                }

                if (WESettings.Instance.CoffeeScript.LintOnBuild)
                {
                    LintFileInvoker.RunOnAllFilesInProjectAsync(new[] { "*.coffee", "*.iced" }, f => new LintReporter(new CoffeeLintCompiler(), WESettings.Instance.CoffeeScript, f))
                    .DontWait("running solution-wide CoffeeLint");
                }
            }
            else if (Action == vsBuildAction.vsBuildActionClean)
            {
                LintReporter.Reset();
            }
        }
Ejemplo n.º 4
0
        public LintFileInvoker(LinterCreator creator, ITextDocument document)
        {
            _creator = creator;
            _document = document;
            _document.FileActionOccurred += DocumentSavedHandler;
            _runner = _creator(_document.FilePath);

            if (_runner.Settings.LintOnSave)
            {
                Dispatcher.CurrentDispatcher.InvokeAsync(
                    () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                    DispatcherPriority.ApplicationIdle
                );
            }
        }
Ejemplo n.º 5
0
        public LintFileInvoker(LinterCreator creator, ITextDocument document)
        {
            _creator  = creator;
            _document = document;
            _document.FileActionOccurred += DocumentSavedHandler;
            _runner = _creator(_document.FilePath);

            if (_runner.Settings.LintOnSave)
            {
                Dispatcher.CurrentDispatcher.InvokeAsync(
                    () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                    DispatcherPriority.ApplicationIdle
                    );
            }
        }
Ejemplo n.º 6
0
        private void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
        {
            if (_dte.Solution.SolutionBuild.LastBuildInfo != 0)
            {
                string text = _dte.StatusBar.Text; // respect localization of "Build failed"
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    _dte.StatusBar.Text = text;
                }), DispatcherPriority.ApplicationIdle, null);

                return;
            }

            if (Action == vsBuildAction.vsBuildActionClean)
            {
                LintReporter.Reset();
                return;
            }

            InitiateExecutors();
        }