public override int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (pguidCmdGroup == _commandGroup && nCmdID == _commandId) { var document = EditorConfigDocument.FromTextBuffer(_buffer); EditorConfigDocument parent = document?.Parent; if (parent != null) { VsHelpers.PreviewDocument(parent.FileName); } else { var statusBar = Package.GetGlobalService(typeof(SVsStatusbar)) as IVsStatusbar; statusBar.IsFrozen(out int frozen); if (frozen == 0) { statusBar.SetText("This is a root document with no inheritance"); } } return(VSConstants.S_OK); } return(Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut)); }
public OutliningTagger(ITextBuffer buffer) { _buffer = buffer; _snapshot = buffer.CurrentSnapshot; _document = EditorConfigDocument.FromTextBuffer(buffer); _document.Parsed += DocumentChanged; StartParsing(); }
public EditorConfigClassifier(IClassificationTypeRegistryService registry, ITextBuffer buffer) { _map = _map ?? new Dictionary <ItemType, IClassificationType> { { ItemType.Comment, registry.GetClassificationType(PredefinedClassificationTypeNames.Comment) }, { ItemType.Section, registry.GetClassificationType(PredefinedClassificationTypeNames.String) }, { ItemType.Keyword, registry.GetClassificationType(PredefinedClassificationTypeNames.Identifier) }, { ItemType.Value, registry.GetClassificationType(PredefinedClassificationTypeNames.Keyword) }, { ItemType.Severity, registry.GetClassificationType(PredefinedClassificationTypeNames.SymbolDefinition) }, { ItemType.Suppression, registry.GetClassificationType(PredefinedClassificationTypeNames.ExcludedCode) }, }; _buffer = buffer; _document = EditorConfigDocument.FromTextBuffer(buffer); }
public void TextViewCreated(IWpfTextView view) { if (_documentService.TryGetTextDocument(view.TextBuffer, out var doc)) { _file = doc.FilePath; view.Properties.AddProperty("file", doc.FilePath); } _document = EditorConfigDocument.FromTextBuffer(view.TextBuffer); _validator = EditorConfigValidator.FromDocument(_document); _project = VsHelpers.DTE.Solution?.FindProjectItem(_file)?.ContainingProject; view.Closed += ViewClosed; _validator.Validated += Validated; }
public ErrorTagger(IWpfTextView view) { _view = view; _document = EditorConfigDocument.FromTextBuffer(view.TextBuffer); _validator = EditorConfigValidator.FromDocument(_document); _validator.Validated += DocumentValidated; ThreadHelper.Generic.BeginInvoke(DispatcherPriority.ApplicationIdle, () => { _hasLoaded = true; var span = new SnapshotSpan(view.TextBuffer.CurrentSnapshot, 0, view.TextBuffer.CurrentSnapshot.Length); TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span)); }); }
private void Execute(object sender, EventArgs e) { try { if (TextViewUtil.TryGetWpfTextView(_filePath, out var view)) { var document = EditorConfigDocument.FromTextBuffer(view.TextBuffer); var validator = EditorConfigValidator.FromDocument(document); validator.SuppressError(_selectedError.Code); } } catch (Exception ex) { Telemetry.TrackException("SuppressError", ex); } }
public ErrorTagger(IWpfTextView view) { _view = view; _document = EditorConfigDocument.FromTextBuffer(view.TextBuffer); _validator = EditorConfigValidator.FromDocument(_document); _validator.Validated += DocumentValidated; ThreadHelper.JoinableTaskFactory.StartOnIdle( () => { _hasLoaded = true; var span = new SnapshotSpan(view.TextBuffer.CurrentSnapshot, 0, view.TextBuffer.CurrentSnapshot.Length); TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span)); return(Task.CompletedTask); }, VsTaskRunContext.UIThreadIdlePriority); }
public DropDownBars(LanguageService languageService, IVsTextView view) : base(languageService) { _languageService = languageService; var componentModel = (IComponentModel)languageService.GetService(typeof(SComponentModel)); IVsEditorAdaptersFactoryService editorAdapterFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); IWpfTextView textView = editorAdapterFactoryService.GetWpfTextView(view); textView.Caret.PositionChanged += CaretPositionChanged; _buffer = textView.TextBuffer; _document = EditorConfigDocument.FromTextBuffer(_buffer); _document.Parsed += DocumentParsed; UpdateElements(); }
public override int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (pguidCmdGroup == _commandGroup && prgCmds[0].cmdID == _commandId) { var document = EditorConfigDocument.FromTextBuffer(_buffer); EditorConfigDocument parent = document?.Parent; if (parent != null) { prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_ENABLED | (uint)OLECMDF.OLECMDF_SUPPORTED; return(VSConstants.S_OK); } return(VSConstants.S_OK); } return(Next.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
public InheritanceAdornment(IWpfTextView view, ITextDocument doc) { _adornmentLayer = view.GetAdornmentLayer(InheritanceAdornmentLayer.LayerName); _document = EditorConfigDocument.FromTextBuffer(view.TextBuffer); Visibility = System.Windows.Visibility.Hidden; Loaded += (s, e) => { CreateImage(); doc.FileActionOccurred += FileActionOccurred; Updated += InheritanceUpdated; view.ViewportHeightChanged += SetAdornmentLocation; view.ViewportWidthChanged += SetAdornmentLocation; }; if (_adornmentLayer.IsEmpty) { _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, this, null); } }
public SuggestedActionsSource(ITextView view, ITextBuffer buffer) { _view = view; _document = EditorConfigDocument.FromTextBuffer(buffer); }
public EditorConfigCompletionSource(ITextBuffer buffer, ITextStructureNavigatorSelectorService navigator) { _buffer = buffer; _navigator = navigator; _document = EditorConfigDocument.FromTextBuffer(buffer); }
bool Commit(bool force) { if (_currentSession == null) { return(false); } if (!_currentSession.SelectedCompletionSet.SelectionStatus.IsSelected && !force) { _currentSession.Dismiss(); return(false); } else { string moniker = _currentSession.SelectedCompletionSet.Moniker; _currentSession.Commit(); if (!EditorConfigPackage.CompletionOptions.AutoInsertDelimiters) { return(true); } SnapshotPoint position = TextView.Caret.Position.BufferPosition; ITextSnapshotLine line = TextView.TextBuffer.CurrentSnapshot.GetLineFromPosition(position); string lineText = line.GetText(); if (moniker == "keyword" && !lineText.Contains("=")) { TextView.TextBuffer.Insert(position, " = "); // Contains placeholders int start = lineText.IndexOf('<'); int end = lineText.IndexOf('>'); if (start > -1 && start < end) { var span = new SnapshotSpan(TextView.TextBuffer.CurrentSnapshot, Span.FromBounds(line.Start + start, line.Start + end + 1)); TextView.Selection.Select(span, false); TextView.Caret.MoveTo(span.Start); return(true); } if (EditorConfigPackage.Language.Preferences.AutoListMembers) { StartSession(); } } else if (moniker == "value" && !lineText.Contains(":")) { var document = EditorConfigDocument.FromTextBuffer(TextView.TextBuffer); Property prop = document.PropertyAtPosition(position - 1); if (SchemaCatalog.TryGetKeyword(prop.Keyword.Text, out Keyword keyword) && prop.Value != null) { if (keyword.RequiresSeverity) { TextView.TextBuffer.Insert(position, ":"); if (EditorConfigPackage.Language.Preferences.AutoListMembers) { StartSession(); } } } } return(true); } }
public EditorConfigQuickInfo(ITextBuffer buffer) { _buffer = buffer; _document = EditorConfigDocument.FromTextBuffer(buffer); }
public EditorConfigFormatter(ITextBuffer buffer) { _document = EditorConfigDocument.FromTextBuffer(buffer); }