protected override void ReParseImpl() { try { Stopwatch stopwatch = Stopwatch.StartNew(); ITextSnapshot snapshot = TextBuffer.CurrentSnapshot; ITextDocument textDocument; if (!TextDocumentFactoryService.TryGetTextDocument(DocumentBuffer, out textDocument)) { textDocument = null; } IEnumerable <HunkRangeInfo> diff; if (textDocument != null) { diff = _commands.GetGitDiffFor(textDocument, snapshot); } else { diff = Enumerable.Empty <HunkRangeInfo>(); } DiffParseResultEventArgs result = new DiffParseResultEventArgs(snapshot, stopwatch.Elapsed, diff.ToList()); OnParseComplete(result); } catch (InvalidOperationException) { base.MarkDirty(true); throw; } }
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) { 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); } }
internal DiffUpdateBackgroundParser(ITextBuffer textBuffer, ITextBuffer documentBuffer, string originalPath, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService, IGitCommands commands) : base(textBuffer, taskScheduler, textDocumentFactoryService) { _documentBuffer = documentBuffer; _commands = commands; ReparseDelay = TimeSpan.FromMilliseconds(500); if (TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out _textDocument)) { _originalPath = originalPath; if (_commands.IsGitRepository(_textDocument.FilePath, _originalPath)) { _textDocument.FileActionOccurred += OnFileActionOccurred; var repositoryDirectory = _commands.GetGitRepository(_textDocument.FilePath, _originalPath); if (repositoryDirectory != null) { _watcher = new FileSystemWatcher(repositoryDirectory); _watcher.Changed += HandleFileSystemChanged; _watcher.Created += HandleFileSystemChanged; _watcher.Deleted += HandleFileSystemChanged; _watcher.Renamed += HandleFileSystemChanged; _watcher.EnableRaisingEvents = true; } } } }
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; }); } } }
public IEnumerable <JSONCompletionEntry> GetListEntries(JSONCompletionContext context) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(context.Snapshot.TextBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); if (string.IsNullOrEmpty(fileName) || !fileName.Equals(Constants.FILENAME, StringComparison.OrdinalIgnoreCase)) { yield break; } } else { yield break; } JSONMember member = context.ContextItem.FindType <JSONMember>(); while (member != null && member.Parent != null && member.UnquotedNameText != Constants.ELEMENT_NAME) { member = member.Parent.FindType <JSONMember>(); } if (member == null || member.UnquotedNameText != Constants.ELEMENT_NAME) { yield break; } foreach (var task in GetTasks(context.ContextItem.JSONDocument)) { yield return(new SimpleCompletionEntry(task.Item1, task.Item2, StandardGlyphGroup.GlyphGroupEvent, context.Session)); } }
public IEnumerable <JSONCompletionEntry> GetListEntries(JSONCompletionContext context) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(context.Snapshot.TextBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); if (string.IsNullOrEmpty(fileName) || !fileName.Equals(Constants.FILENAME, StringComparison.OrdinalIgnoreCase)) { yield break; } } else { yield break; } JSONMember member = context.ContextItem.Parent?.FindType <JSONMember>(); if (member == null || member.UnquotedNameText != Constants.ELEMENT_NAME) { yield break; } yield return(new SimpleCompletionEntry("AfterBuild", "Fires after the MSBuild process ended.", _glyph, context.Session)); yield return(new SimpleCompletionEntry("BeforeBuild", "Fires before the MSBuild process ended.", _glyph, context.Session)); yield return(new SimpleCompletionEntry("Clean", "Fires after the MSBuild 'Clean' process ended.", _glyph, context.Session)); yield return(new SimpleCompletionEntry("ProjectOpen", "Fires when the project is opened in Visual Studio.", _glyph, context.Session)); }
/// <summary> /// Creates an <see cref="IWpfTextViewMargin"/> for the given <see cref="IWpfTextViewHost"/>. /// </summary> /// <param name="wpfTextViewHost">The <see cref="IWpfTextViewHost"/> for which to create the <see cref="IWpfTextViewMargin"/>.</param> /// <param name="marginContainer">The margin that will contain the newly-created margin.</param> /// <returns>The <see cref="IWpfTextViewMargin"/>. /// The value may be null if this <see cref="IWpfTextViewMarginProvider"/> does not participate for this context. /// </returns> public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { IWpfTextViewMargin result = null; // Github issue 9 // https://github.com/PhilJollans/AnkhSVN2019/issues/9 // Make sure that this method returns null if any error occurs. // This probably means that we will never find the error. // Note: I intend to add a log file to AnkhSvn, in which case we could at least log the error. try { // From https://github.com/madskristensen/MarkdownEditor/blob/master/src/Margin/BrowserMarginProvider.cs ITextDocument document; bool isok = TextDocumentFactoryService.TryGetTextDocument(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer, out document); // Get the filename var fn = document.FilePath; // Is there an annotation view model? var vm = AnnotateService.GetModel(fn); if (vm != null) { wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); result = new AnnotationMargin(wpfTextViewHost.TextView, vm); } } catch (Exception) { // Set result to null as a matter of form. // To do, log the error in a log file. result = null; } return(result); }
public IEnumerable <JSONCompletionEntry> GetListEntries(JSONCompletionContext context) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(context.Snapshot.TextBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); if (string.IsNullOrEmpty(fileName) || !_files.Contains(fileName)) { yield break; } } else { yield break; } JSONMember member = context.ContextItem as JSONMember; if (member == null || member.Name == null || member.UnquotedNameText != "license") { yield break; } foreach (string prop in _props) { yield return(new SimpleCompletionEntry(prop, context.Session)); } }
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; }); } } }
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, () => ViewDesigner(document))); } }
public DiffUpdateBackgroundParser(ITextBuffer textBuffer, ITextBuffer documentBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService, IGitCommands commands) : base(textBuffer, taskScheduler, textDocumentFactoryService) { _documentBuffer = documentBuffer; _commands = commands; ReparseDelay = TimeSpan.FromMilliseconds(500); if (TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out _textDocument)) { if (_commands.IsGitRepository(_textDocument.FilePath)) { _textDocument.FileActionOccurred += OnFileActionOccurred; var solutionDirectory = _commands.GetGitRepository(_textDocument.FilePath); if (!string.IsNullOrWhiteSpace(solutionDirectory)) { var gitDirectory = Path.Combine(solutionDirectory, ".git"); _watcher = new FileSystemWatcher(gitDirectory); _watcher.Changed += HandleFileSystemChanged; _watcher.Created += HandleFileSystemChanged; _watcher.Deleted += HandleFileSystemChanged; _watcher.Renamed += HandleFileSystemChanged; _watcher.EnableRaisingEvents = true; } } } }
public void VsTextViewCreated(IVsTextView textViewAdapter) { var textView = GetInitializedTextView(textViewAdapter); ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { return; } var saveListeners = Mef.GetAllImports <IFileSaveListener>(document.TextBuffer.ContentType); if (saveListeners.Count == 0) { return; } EventHandler <TextDocumentFileActionEventArgs> saveHandler = (s, e) => { if (e.FileActionType != FileActionTypes.ContentSavedToDisk) { return; } foreach (var listener in saveListeners) { listener.FileSaved(document.TextBuffer.ContentType, e.FilePath, false, false); } }; document.FileActionOccurred += saveHandler; textView.Closed += delegate { document.FileActionOccurred -= saveHandler; }; }
public IEnumerable <JSONCompletionEntry> GetListEntries(JSONCompletionContext context) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(context.Snapshot.TextBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); if (string.IsNullOrEmpty(fileName) || (Path.GetExtension(fileName) != Constants.EXTENSION && fileName != Constants.SUGGESTIONS_FILENAME)) { yield break; } } else { yield break; } JSONMember member = context.ContextItem as JSONMember; if (member == null || member.Name == null) { yield break; } string property = member.UnquotedNameText.ToLowerInvariant(); if (!_supported.Contains(property)) { yield break; } foreach (var extension in ExtensionInstalledChecker.Instance.GetInstalledExtensions()) { ImageSource glyph = GetExtensionIcon(extension); if (property == "productid") { yield return(new SimpleCompletionEntry(extension.Header.Name, extension.Header.Identifier, glyph, context.Session)); } else if (property == "name") { yield return(new SimpleCompletionEntry(extension.Header.Name, Normalize(extension.Header.Name), glyph, context.Session)); } else if (property == "description") { yield return(new SimpleCompletionEntry(extension.Header.Name, Normalize(extension.Header.Description), glyph, context.Session)); } else if (property == "link") { string url = extension.Header.MoreInfoUrl?.ToString() ?? extension.Header.GettingStartedGuide?.ToString() ?? "<no link found>"; yield return(new SimpleCompletionEntry(extension.Header.Name, url, glyph, context.Session)); } } }
public ISuggestedActionsSource CreateSuggestedActionsSource(ITextView textView, ITextBuffer textBuffer) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextBuffer, out document)) { return(textView.Properties.GetOrCreateSingletonProperty(() => new SuggestedActionsSource(ViewTagAggregatorFactoryService, textView, document.FilePath))); } return(null); }
public void VsTextViewCreated(IVsTextView textViewAdapter) { var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter); ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextBuffer, out document)) { textView.Properties.GetOrCreateSingletonProperty(() => new PasteImage(textViewAdapter, textView, document.FilePath)); textView.Properties.GetOrCreateSingletonProperty(() => new BoldCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new ItalicCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new SmartIndentCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new IndentationCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new ToogleTaskCommandTarget(textViewAdapter, textView)); } }
protected IMarginCore TryGetMarginCore(IWpfTextViewHost textViewHost) { MarginCore marginCore; if (textViewHost.TextView.Properties.TryGetProperty(typeof(MarginCore), out marginCore)) { return(marginCore); } // play nice with other source control providers ITextView textView = textViewHost.TextView; ITextDataModel textDataModel = textView != null ? textView.TextDataModel : null; ITextBuffer documentBuffer = textDataModel != null ? textDataModel.DocumentBuffer : null; if (documentBuffer == null) { return(null); } ITextDocument textDocument; if (!TextDocumentFactoryService.TryGetTextDocument(documentBuffer, out textDocument)) { return(null); } var fullPath = GetFullPath(textDocument.FilePath); if (fullPath == null) { return(null); } if (!GitCommands.TryGetOriginalPath(fullPath, out string originalPath)) { return(null); } var repositoryPath = GitCommands.GetGitRepository(fullPath, originalPath); if (repositoryPath == null) { return(null); } return(textViewHost.TextView.Properties.GetOrCreateSingletonProperty( () => new MarginCore(textViewHost.TextView, originalPath, TextDocumentFactoryService, ClassificationFormatMapService, EditorFormatMapService, GitCommands))); }
//private void AdornmentVisibilityChanged(object sender, bool isVisible) //{ // WritableSettingsStore wstore = _settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); // _isVisible = isVisible; // if (!wstore.CollectionExists(Constants.FILENAME)) // wstore.CreateCollection(Constants.FILENAME); // wstore.SetBoolean(Constants.FILENAME, _propertyName, isVisible); //} public void TextViewCreated(IWpfTextView textView) { if (!_hasLoaded) LoadSettings(); ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); if (string.IsNullOrEmpty(fileName)) return; CreateAdornments(document, textView); } }
internal DiffUpdateBackgroundParser(ITextBuffer textBuffer, ITextBuffer documentBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService) : base(textBuffer, taskScheduler, textDocumentFactoryService) { _documentBuffer = documentBuffer; ReparseDelay = TimeSpan.FromMilliseconds(500); if (TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out _textDocument)) { if (PerforceCommands.GetInstance().IsDiffPerformed(_textDocument.FilePath)) { _textDocument.FileActionOccurred += OnFileActionOccurred; // TODO: implement a mechanism that will monitor perforce submit and update diff after submit // Probably class which will check if current changelist already submitted using p4 describe every second can work as workaround // or "Custom Tool": https://stackoverflow.com/questions/16053503/perforce-client-side-pre-commit-hook } } }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { Func <ITextDocument, IWpfTextView, IWpfTextViewMargin> creator; if (!marginFactories.TryGetValue(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer.ContentType.TypeName, out creator)) { return(null); } ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer, out document)) { return(null); } return(creator(document, wpfTextViewHost.TextView)); }
public void TextViewCreated(IWpfTextView textView) { if (!_hasLoaded) { LoadSettings(); } ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); if (string.IsNullOrEmpty(fileName) || !_map.ContainsKey(fileName)) { return; } LogoAdornment highlighter = new LogoAdornment(textView, _map[fileName], _isVisible, _initOpacity); } }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType("CSharp") || b.ContentType.IsOfType("Basic"))) { return; } await Dispatcher.Yield(); IVsTextView textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) { return; } if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _)) { return; } }
public IEnumerable <JSONCompletionEntry> GetListEntries(JSONCompletionContext context) { if (!VSPackage.Manager.Provider.IsInitialized || !context.ContextItem.JSONDocument.HasSchema(_reportCache)) { return(_empty); } ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(context.Snapshot.TextBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath); if (fileName.Equals(VSPackage.ManifestFileName, StringComparison.OrdinalIgnoreCase)) { return(GetEntries(context)); } } return(_empty); }
public void TextViewCreated(IWpfTextView textView) { if (!_hasLoaded) { LoadSettings(); } ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { string fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); // Check if filename is absolute because when debugging, script files are sometimes dynamically created. if (string.IsNullOrEmpty(fileName) || !Path.IsPathRooted(document.FilePath)) { return; } CreateAdornments(document, textView); } }
protected override void ReParseImpl() { try { var stopwatch = Stopwatch.StartNew(); var snapshot = TextBuffer.CurrentSnapshot; ITextDocument textDocument; if (!TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out textDocument)) { return; } var diff = _commands.GetGitDiffFor(textDocument, _originalPath, snapshot); var result = new DiffParseResultEventArgs(snapshot, stopwatch.Elapsed, diff.ToList()); OnParseComplete(result); } catch (InvalidOperationException) { MarkDirty(true); throw; } }
public void TextViewCreated(IWpfTextView textView) { ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { return; } LoadSettings(); var fileName = Path.GetFileName(document.FilePath).ToLowerInvariant(); // Check if filename is absolute because when debugging, script files are sometimes dynamically created. if (string.IsNullOrEmpty(fileName) || !Path.IsPathRooted(document.FilePath)) { return; } if (fileName.EndsWith(".cake")) { textView.Properties.GetOrCreateSingletonProperty(() => new LogoAdornment(textView, _isVisible, InitOpacity)); } }
public void VsTextViewCreated(IVsTextView textViewAdapter) { var wpfTextView = EditorFactory.GetWpfTextView(textViewAdapter); if (wpfTextView == null) { return; } GeneralOptionsPage generalOptions = (GeneralOptionsPage)(Package.GetGlobalService(typeof(GeneralOptionsPage))); if (!generalOptions.XMLDocEnabled) { Debug.WriteLine("[XMLDoc] The feature is disabled in General option page."); return; } ITextDocument doc; if (TextDocumentFactoryService.TryGetTextDocument(wpfTextView.TextBuffer, out doc)) { new XmlDocFilter(textViewAdapter, wpfTextView, doc.FilePath); } }
/// <summary> /// Creates an <see cref="IWpfTextViewMargin"/> for the given <see cref="IWpfTextViewHost"/>. /// </summary> /// <param name="wpfTextViewHost">The <see cref="IWpfTextViewHost"/> for which to create the <see cref="IWpfTextViewMargin"/>.</param> /// <param name="marginContainer">The margin that will contain the newly-created margin.</param> /// <returns>The <see cref="IWpfTextViewMargin"/>. /// The value may be null if this <see cref="IWpfTextViewMarginProvider"/> does not participate for this context. /// </returns> public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { // From https://github.com/madskristensen/MarkdownEditor/blob/master/src/Margin/BrowserMarginProvider.cs ITextDocument document; bool isok = TextDocumentFactoryService.TryGetTextDocument(wpfTextViewHost.TextView.TextDataModel.DocumentBuffer, out document); // Get the filename var fn = document.FilePath; // Is there an annotation view model? var vm = AnnotateService.GetModel(fn); if (vm == null) { return(null); } else { wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); return(new AnnotationMargin(wpfTextViewHost.TextView, vm)); } }
public void VsTextViewCreated(IVsTextView textViewAdapter) { ThreadHelper.Generic.BeginInvoke(DispatcherPriority.ApplicationIdle, () => { var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter); ITextDocument document = null; if (textView == null || !TextDocumentFactoryService.TryGetTextDocument(textView.TextBuffer, out document)) { return; } textView.Properties.GetOrCreateSingletonProperty(() => new PasteImage(textViewAdapter, textView, document.FilePath)); textView.Properties.GetOrCreateSingletonProperty(() => new BoldCommandTarget(textViewAdapter, textView, NavigatorService)); textView.Properties.GetOrCreateSingletonProperty(() => new ItalicCommandTarget(textViewAdapter, textView, NavigatorService)); textView.Properties.GetOrCreateSingletonProperty(() => new InlineCodeCommandTarget(textViewAdapter, textView, NavigatorService)); textView.Properties.GetOrCreateSingletonProperty(() => new SmartIndentCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new IndentationCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new ToogleTaskCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new Navigate(textViewAdapter, textView)); document.FileActionOccurred += Document_FileActionOccurred; }); }
public DiffUpdateBackgroundParser(ITextBuffer textBuffer, ITextBuffer documentBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService, IGitCommands commands) : base(textBuffer, taskScheduler, textDocumentFactoryService) { _documentBuffer = documentBuffer; _commands = commands; ReparseDelay = TimeSpan.FromMilliseconds(500); ITextDocument textDocument; if (TextDocumentFactoryService.TryGetTextDocument(TextBuffer, out textDocument)) { GitFileStatusTracker tracker = new GitFileStatusTracker(Path.GetDirectoryName(textDocument.FilePath)); if (tracker.IsGit) { _watcher = new FileSystemWatcher(tracker.WorkingDirectory); _watcher.IncludeSubdirectories = true; _watcher.Changed += HandleFileSystemChanged; _watcher.Created += HandleFileSystemChanged; _watcher.Deleted += HandleFileSystemChanged; _watcher.Renamed += HandleFileSystemChanged; _watcher.EnableRaisingEvents = true; } } }