private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && LinterService.IsFileSupported(e.FilePath))
     {
         LinterService.Lint(false, e.FilePath);
     }
 }
        /* void AddCommandFilter(IWpfTextView textView, KeyBindingCommandFilter commandFilter)
         * {
         *  if (commandFilter.m_added == false)
         *  {
         *      //get the view adapter from the editor factory
         *      IOleCommandTarget next;
         *      IVsTextView view = editorFactory.GetViewAdapter(textView);
         *
         *      int hr = view.AddCommandFilter(commandFilter, out next);
         *
         *      if (hr == VSConstants.S_OK)
         *      {
         *          commandFilter.m_added = true;
         *          //you'll need the next target for Exec and QueryStatus
         *          if (next != null)
         *              commandFilter.m_nextTarget = next;
         *      }
         *  }
         * } */

        internal void OnFileActionOccurred(object sender, TextDocumentFileActionEventArgs args)
        {
            if (args.FileActionType == FileActionTypes.ContentLoadedFromDisk)
            {
                MyBookmarkManager.Reload(this);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Watch out for file name changes
 /// </summary>
 internal void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (this.FilePath != e.FilePath)
     {
         this.FilePath = e.FilePath;
     }
 }
 private void TextDocument_FileActionOccurred(object sender, TextDocumentFileActionEventArgs args)
 {
     if (args.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         _threadingService.ExecuteSynchronously(_editorState.SaveProjectFileAsync);
     }
 }
Ejemplo n.º 5
0
        private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                // Check if filename is absolute because when debugging, script files are sometimes dynamically created.
                if (string.IsNullOrEmpty(e.FilePath) || !Path.IsPathRooted(e.FilePath))
                {
                    return;
                }

                var item = WebCompilerPackage._dte.Solution.FindProjectItem(e.FilePath);

                if (item != null && item.ContainingProject != null)
                {
                    string configFile = item.ContainingProject.GetConfigFile();

                    ErrorList.CleanErrors(e.FilePath);

                    if (File.Exists(configFile))
                    {
                        CompilerService.SourceFileChanged(configFile, e.FilePath);
                    }
                }
            }
        }
 private void FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         Updated?.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 7
0
 private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         await SpriteService.GenerateSprite(e.FilePath);
     }
 }
Ejemplo n.º 8
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.º 9
0
 private void OnFileAction(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         Compute();
     }
 }
Ejemplo n.º 10
0
        private void OnSave(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk || Helper.IsSaving)
            {
                return;
            }

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

            if (!fileName.Equals(NPM.Constants.FileName) && !fileName.Equals(Bower.Constants.FileName))
            {
                return;
            }

            Options options = JSON_IntellisensePackage.Options;

            if (!options.NpmInstallOnSave && !options.BowerInstallOnSave)
            {
                return;
            }

            string rootFolder = Path.GetDirectoryName(e.FilePath);

            RestorePackages(fileName, options, rootFolder);
        }
 private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         await LinterService.LintAsync(false, e.FilePath);
     }
 }
 private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(SettingsStore.FileName, StringComparison.OrdinalIgnoreCase))
     {
         SettingsStore.Load();
     }
 }
Ejemplo n.º 13
0
        private void SafeOnFileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            // Handles callback from VS. Suppress non-critical errors to prevent them
            // propagating to VS, which would display a dialogue and disable the extension.
            try
            {
                if (e.FileActionType == FileActionTypes.DocumentRenamed)
                {
                    FilePath    = e.FilePath;
                    ProjectItem = dte.Solution.FindProjectItem(this.FilePath);

                    // Update and publish a new snapshow with the existing issues so
                    // that the name change propagates to items in the error list
                    RefreshIssues();
                }
                else if (e.FileActionType == FileActionTypes.ContentSavedToDisk &&
                         activeTaggers.Count > 0)
                {
                    RequestAnalysis();
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger.WriteLine(Strings.Daemon_Editor_ERROR, ex);
            }
        }
Ejemplo n.º 14
0
        public void FileActionOccurred(ITextDocument document, TextDocumentFileActionEventArgs args)
        {
            if (!_enabled)
            {
                return;
            }
            if (!FullPath.IsValid(document.FilePath))
            {
                return;
            }
            var path = new FullPath(document.FilePath);

            if (args.FileActionType.HasFlag(FileActionTypes.ContentSavedToDisk))
            {
                var entry = _trackingEntries.GetValue(path);
                if (entry != null)
                {
                    entry.UpdateSpansToLatestVersion(document.TextBuffer);
                }
            }

            if (args.FileActionType.HasFlag(FileActionTypes.ContentLoadedFromDisk))
            {
                // TODO(rpaquay): Maybe the tracking spans are still valid?
                _trackingEntries.Remove(path);
            }

            if (args.FileActionType.HasFlag(FileActionTypes.DocumentRenamed))
            {
                // TODO(rpaquay): Support for redirecting to another file name?
                _trackingEntries.Remove(path);
            }
        }
Ejemplo n.º 15
0
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         StylesheetUpdated?.Invoke(this, new StylesheetUpdatedEventArgs(e.FilePath));
     }
 }
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && IsValid(e.FilePath))
     {
         LinterService.Lint(e.FilePath);
     }
 }
Ejemplo n.º 17
0
        public async Task AbstractEditProjectFileCommand_NonSaveAction_DoesNotOverwriteProjectFile(FileActionTypes actionType)
        {
            var projectPath     = $"C:\\Project1\\Project1.{EditProjectFileCommand.Extension}";
            var tempFile        = "C:\\Temp\\asdf.xyz";
            var tempProjFile    = $"{tempFile}.{EditProjectFileCommand.Extension}";
            var expectedCaption = $"Project1.{EditProjectFileCommand.Extension}";
            var projectXml      = @"<Project></Project>";

            var fileSystem = new IFileSystemMock();
            var textDoc    = ITextDocumentFactory.Create();
            var frame      = IVsWindowFrameFactory.ImplementShowAndSetProperty(VSConstants.S_OK, (prop, obj) => VSConstants.S_OK);

            var command = SetupScenario(projectXml, tempFile, tempProjFile, projectPath, expectedCaption, fileSystem, textDoc, frame);
            var tree    = ProjectTreeParser.Parse(@"
Root (flags: {ProjectRoot})
");
            var nodes   = ImmutableHashSet.Create(tree);

            // Verify the frame was setup correctly
            Assert.True(await command.TryHandleCommandAsync(nodes, CommandId, true, 0, IntPtr.Zero, IntPtr.Zero));

            var args = new TextDocumentFileActionEventArgs(tempProjFile, DateTime.Now, actionType);

            Mock.Get(textDoc).Raise(t => t.FileActionOccurred += null, args);
            Assert.False(fileSystem.FileExists(projectPath));
        }
        private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.EnableJsHint))
            {
                return;
            }

            ITextDocument document = (ITextDocument)sender;

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

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

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

                goto case FileActionTypes.ContentSavedToDisk;

            case FileActionTypes.ContentSavedToDisk:
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(_runner.RunCompiler), DispatcherPriority.ApplicationIdle, null);
                break;
            }
        }
Ejemplo n.º 19
0
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         CompilerService.Process(e.FilePath);
     }
 }
Ejemplo n.º 20
0
 private void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         UpdateMargin(e.FilePath);
     }
 }
Ejemplo n.º 21
0
 private void TextDocument_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.DocumentRenamed)
     {
         OnBreakpointsChanged(null, null);
     }
 }
        private void OnFileSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            var textDocument = sender as ITextDocument;

            if (e.FileActionType == FileActionTypes.ContentSavedToDisk && textDocument != null)
            {
                Task.Run(async() =>
                {
                    try
                    {
                        Manifest newManifest = Manifest.FromJson(textDocument.TextBuffer.CurrentSnapshot.GetText(), _dependencies);
                        await RemoveFilesAsync(newManifest).ConfigureAwait(false);

                        _manifest = newManifest;

                        await LibraryHelpers.RestoreAsync(textDocument.FilePath, _manifest, CancellationToken.None).ConfigureAwait(false);
                        Telemetry.TrackOperation("restoresave");
                    }
                    catch (Exception ex)
                    {
                        string textMessage = string.Concat(Environment.NewLine, LibraryManager.Resources.Text.RestoreHasErrors, Environment.NewLine);

                        Logger.LogEvent(textMessage, LogLevel.Task);
                        Logger.LogEvent(ex.ToString(), LogLevel.Error);
                        Telemetry.TrackException("restoresavefailed", ex);
                    }
                });
            }
        }
Ejemplo n.º 23
0
        public void TextDocument_FileActionOccurred_Rename_UntracksOnlyIfNotRenamedToRazorContentType()
        {
            // Arrange
            var lspDocumentManager       = new Mock <TrackingLSPDocumentManager>(MockBehavior.Strict);
            var fileToContentTypeService = Mock.Of <IFileToContentTypeService>(detector => detector.GetContentTypeForFilePath(It.IsAny <string>()) == NonRazorContentType, MockBehavior.Strict);
            var tracked   = false;
            var untracked = false;

            lspDocumentManager.Setup(manager => manager.UntrackDocument(It.IsAny <ITextBuffer>()))
            .Callback(() =>
            {
                Assert.False(tracked);
                Assert.False(untracked);
                untracked = true;
            })
            .Verifiable();
            var listener = CreateListener(lspDocumentManager.Object, fileToContentTypeService: fileToContentTypeService);
            var args     = new TextDocumentFileActionEventArgs("C:/path/to/file.razor", DateTime.UtcNow, FileActionTypes.DocumentRenamed);

            // Act
            listener.TextDocument_FileActionOccurred(RazorTextDocument, args);

            // Assert
            lspDocumentManager.VerifyAll();
        }
 private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(Settings._fileName))
     {
         Task.Run(() => Settings.UpdateCache());
     }
 }
Ejemplo n.º 25
0
        public void TextDocument_FileActionOccurred_Rename_UntracksAndThenTracks()
        {
            // Arrange
            var lspDocumentManager = new Mock <TrackingLSPDocumentManager>(MockBehavior.Strict);
            var tracked            = false;
            var untracked          = false;

            lspDocumentManager.Setup(manager => manager.TrackDocument(It.IsAny <ITextBuffer>()))
            .Callback(() =>
            {
                Assert.False(tracked);
                Assert.True(untracked);

                tracked = true;
            })
            .Verifiable();
            lspDocumentManager.Setup(manager => manager.UntrackDocument(It.IsAny <ITextBuffer>()))
            .Callback(() =>
            {
                Assert.False(tracked);
                Assert.False(untracked);
                untracked = true;
            })
            .Verifiable();
            var listener = CreateListener(lspDocumentManager.Object);
            var args     = new TextDocumentFileActionEventArgs("C:/path/to/file.razor", DateTime.UtcNow, FileActionTypes.DocumentRenamed);

            // Act
            listener.TextDocument_FileActionOccurred(RazorTextDocument, args);

            // Assert
            lspDocumentManager.VerifyAll();
        }
        private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                var item = BundlerMinifierPackage._dte.Solution.FindProjectItem(e.FilePath);

                if (item != null && item.ContainingProject != null)
                {
                    string configFile = item.ContainingProject.GetConfigFile();

                    ErrorList.CleanErrors(e.FilePath);

                    if (File.Exists(configFile))
                    {
                        BundleService.SourceFileChanged(configFile, e.FilePath);
                    }

                    string minFile;

                    if (FileHelpers.HasMinFile(e.FilePath, out minFile))
                    {
                        BundleService.MinifyFile(e.FilePath);
                    }
                }
            }
        }
Ejemplo n.º 27
0
 private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(Settings._fileName))
     {
         Task.Run(() => Settings.UpdateCache());
     }
 }
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         CompilerService.Process(e.FilePath);
     }
 }
Ejemplo n.º 29
0
 private void OnFileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if ((e.FileActionType & FileActionTypes.ContentSavedToDisk) != 0)
     {
         MarkDirty(true);
     }
 }
 private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(SettingsStore.FileName, StringComparison.OrdinalIgnoreCase))
     {
         SettingsStore.Load();
     }
 }
Ejemplo n.º 31
0
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && LinterService.IsFileSupported(e.FilePath))
     {
         LinterService.Lint(false, e.FilePath);
     }
 }
 private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         await LinterService.LintAsync(false, e.FilePath);
     }
 }
Ejemplo n.º 33
0
 async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk && VSPackage.Options.RestoreOnSave)
     {
         await PackageService.RestorePackagesAsync(e.FilePath);
     }
 }
        private async void OnFileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                if (Options.IsDebugLoggingEnabled)
                    Logger.Log("Detected file saved: " + e.FilePath);

                if (!Options.GenerateCssOnSave) return;

                var filename = Path.GetFileName(e.FilePath);

                // ignore anything that isn't .scss and not a root document
                if (!filename.EndsWith(".scss", StringComparison.OrdinalIgnoreCase))
                    return;

                if (filename.StartsWith("_"))
                {
                    if (Options.IsDebugLoggingEnabled)
                        Logger.Log("Compiling all files referencing include file: " + filename);

                    foreach (var document in ResolveRootDocumentsInProject(e.FilePath))
                        await GenerateRootDocument(e.Time, document);
                }
                else
                {
                    if (Options.IsDebugLoggingEnabled)
                        Logger.Log("Compiling: " + filename);

                    await GenerateRootDocument(e.Time, e.FilePath);
                }
            }
        }
 void OnFileAction(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.DocumentRenamed)
     {
         filepath = ((ITextDocument)sender).FilePath;
     }
 }
Ejemplo n.º 36
0
        private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk)
            {
                return;
            }

            var document = (ITextDocument)sender;

            if (!document.TextBuffer.Properties.TryGetProperty("p_item", out ProjectItem item))
            {
                return;
            }


            TranspilerStatus status = await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                try
                {
                    return(await item.Transpile());
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                    return(TranspilerStatus.Exception);
                }
            });
        }
Ejemplo n.º 37
0
        // Internal for testing
        internal void TextDocument_FileActionOccurred(object sender, TextDocumentFileActionEventArgs args)
        {
            if (args.FileActionType != FileActionTypes.DocumentRenamed)
            {
                // We're only interested in document rename events.
                return;
            }

            var textDocument = sender as ITextDocument;
            var textBuffer   = textDocument?.TextBuffer;

            if (textBuffer == null)
            {
                return;
            }

            // Document was renamed, translate that rename into an untrack -> track to refresh state.

            RazorBufferDisposed(textBuffer);

            // Normally we could just look at the buffer again to see if the content type was still Razor; however,
            // there's a bug in the platform which prevents that from working:
            // https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1161307/
            // To counteract this we need to re-calculate the content type based off of the filepath.
            var newContentType = _fileToContentTypeService.GetContentTypeForFilePath(textDocument.FilePath);

            if (newContentType.IsOfType(RazorLSPConstants.RazorLSPContentTypeName))
            {
                // Renamed to another RazorLSP based document, lets treat it as a re-creation.
                RazorBufferCreated(textBuffer);
            }
        }
Ejemplo n.º 38
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;
            }
        }
 private void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         CompileAsync(e.FilePath).DoNotWait("compiling " + e.FilePath);
     }
 }
        /// <summary>
        /// Reloads the settings when the filename changes
        /// </summary>
        private void FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if ((e.FileActionType & FileActionTypes.DocumentRenamed) != 0)
                _settingsManager.LoadSettings(e.FilePath);

            if (_settings != null && _view.HasAggregateFocus)
                _globalSettings.Apply();
        }
Ejemplo n.º 41
0
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         string file = e.FilePath.Replace(Constants.DEFAULTS_FILENAME, Constants.CONFIG_FILENAME);
         CompilerService.Process(file);
     }
 }
        private void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.DocumentRenamed)
                return;

            _watcher.Path = Path.GetDirectoryName(TargetFilePath);
            _watcher.Filter = Path.GetFileName(TargetFilePath);
        }
        private void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!CompilerRunner.Settings.CompileOnSave && !CompilerRunner.MarginSettings.ShowPreviewPane ||
                e.FileActionType != FileActionTypes.ContentSavedToDisk)
                return;

            CompileAsync(e.FilePath).DoNotWait("compiling " + e.FilePath);
        }
 private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         BundleService.Process(e.FilePath);
         BundleOnSave.Instance.BundleConfigChanged(e.FilePath);
     }
 }
Ejemplo n.º 45
0
        private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                string file = e.FilePath.EndsWith(_ext) ? null : e.FilePath;

                System.Threading.Tasks.Task.Run(() => UpdateBundles(file, file == null));
            }
        }
        private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            ITextDocument document = (ITextDocument)sender;

            if (document.TextBuffer == null || e.FileActionType != FileActionTypes.ContentSavedToDisk)
                return;

            ProcessAsync(e.FilePath).DontWait("creating IntelliSense file(s) for " + e.FilePath);
        }
        private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            ITextDocument document = (ITextDocument)sender;

            if (document.TextBuffer == null || e.FileActionType != FileActionTypes.ContentSavedToDisk)
                return;

            Process(e.FilePath);
        }
        private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                string sourceFile = e.FilePath;

                TypeScriptCompiler.Compile(sourceFile);

            }
        }
Ejemplo n.º 49
0
 protected virtual void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         _dispatcher.BeginInvoke(new Action(() =>
         {
             _provider.Tasks.Clear();
             StartCompiler(File.ReadAllText(e.FilePath));
         }), DispatcherPriority.ApplicationIdle, null);
     }
 }
        private void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            //if (CompilerRunner.SourceContentType.TypeName == "css" && !WESettings.Instance.Css.RtlCss)
            //    return;

            if (CompilerRunner.Settings != null && !CompilerRunner.Settings.CompileOnSave && !CompilerRunner.MarginSettings.ShowPreviewPane ||
                e.FileActionType != FileActionTypes.ContentSavedToDisk)
                return;

            CompileAsync(e.FilePath).DoNotWait("compiling " + e.FilePath);
        }
 private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
     {
         Uri url = new Uri(e.FilePath, UriKind.Absolute);
         if (_cache.ContainsKey(url))
         {
             BeginGetGraphData(_cache[url]);
         }
     }
 }
        private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.EnableJsHint))
                return;

            ITextDocument document = (ITextDocument)sender;

            if (document.TextBuffer != null && !_isDisposed && e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => _runner.RunCompiler()), DispatcherPriority.ApplicationIdle, null);
            }
        }
Ejemplo n.º 53
0
        private void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                string file = e.FilePath.EndsWith(_ext, StringComparison.OrdinalIgnoreCase) ? e.FilePath : null;

                System.Threading.Tasks.Task.Run(() =>
                {
                    UpdateBundles(file, true);
                });
            }
        }
Ejemplo n.º 54
0
        /// <summary>
        /// Reloads the settings when the filename changes
        /// </summary>
        void FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!e.FileActionType.HasFlag(FileActionTypes.DocumentRenamed))
                return;

            LoadSettings(e.FilePath);
            viewSettingsContainer.Update(documentPath, e.FilePath, view, settings);

            documentPath = e.FilePath;

            if (settings != null && view.HasAggregateFocus)
                ApplyGlobalSettings();
        }
Ejemplo n.º 55
0
    private void TextDocumentOnFileActionOccurred(object sender, TextDocumentFileActionEventArgs args) {
      if (args.FileActionType.HasFlag(FileActionTypes.DocumentRenamed)) {
        var document = (ITextDocument)sender;

        if (FullPath.IsValid(args.FilePath)) {
          var newPath = new FullPath(args.FilePath);
          _openDocuments[newPath] = document;
        }

        if (FullPath.IsValid(document.FilePath)) {
          var oldPath = new FullPath(document.FilePath);
          _openDocuments.Remove(oldPath);
        }
      }
    }
Ejemplo n.º 56
0
        void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.EnableCssMinification))
                return;

            if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(".css"))
            {
                string minFile = e.FilePath.Insert(e.FilePath.Length - 3, "min.");

                if (File.Exists(minFile) && EditorExtensionsPackage.DTE.Solution.FindProjectItem(minFile) != null)
                {
                    Task.Run(() => Minify(e.FilePath, minFile));
                }
            }
        }
        private void DocumentSaved(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType == FileActionTypes.ContentSavedToDisk)
            {
                var item = WebCompilerPackage._dte.Solution.FindProjectItem(e.FilePath);

                if (item != null && item.ContainingProject != null)
                {
                    string configFile = item.ContainingProject.GetConfigFile();

                    ErrorList.CleanErrors(e.FilePath);

                    if (File.Exists(configFile))
                        CompilerService.SourceFileChanged(configFile, e.FilePath);
                }
            }
        }
        void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.EnableJsMinification))
                return;

            ITextDocument document = (ITextDocument)sender;

            if (document.TextBuffer != null && e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
            {
                string minFile = e.FilePath.Insert(e.FilePath.Length - 2, "min.");
                string bundleFile = e.FilePath + ".bundle";

                if (!File.Exists(bundleFile) && File.Exists(minFile) && EditorExtensionsPackage.DTE.Solution.FindProjectItem(minFile) != null)
                {
                    Task.Run(() => Minify(e.FilePath, minFile, false));
                }
            }
        }
Ejemplo n.º 59
0
        void document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!WESettings.GetBoolean(WESettings.Keys.EnableCssMinification))
                return;

            if (e.FileActionType == FileActionTypes.ContentSavedToDisk && e.FilePath.EndsWith(".css", StringComparison.OrdinalIgnoreCase))
            {
                string minFile = e.FilePath.Insert(e.FilePath.Length - 3, "min.");

                if (File.Exists(minFile) && ProjectHelpers.GetProjectItem(minFile) != null)
                {
                    Task.Run(() =>
                    {
                        Minify(e.FilePath, minFile);
                    });
                }
            }
        }
Ejemplo n.º 60
0
        private void OnSave(object sender, TextDocumentFileActionEventArgs e)
        {
            if (e.FileActionType != FileActionTypes.ContentSavedToDisk || Helper.IsSaving)
                return;

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

            if (!fileName.Equals(NPM.Constants.FileName) && !fileName.Equals(Bower.Constants.FileName))
                return;

            Options options = JSON_IntellisensePackage.Options;

            if (!options.NpmInstallOnSave && !options.BowerInstallOnSave)
                return;

            string rootFolder = Path.GetDirectoryName(e.FilePath);

            RestorePackages(fileName, options, rootFolder);
        }