private bool IsDocString(ITextView textWindow, SnapshotPoint point) { var aggregator = _serviceProvider.GetComponentModel().GetService <IClassifierAggregatorService>(); IClassifier classifier = aggregator.GetClassifier(textWindow.TextBuffer); var curLine = point.GetContainingLine(); var tokens = classifier.GetClassificationSpans(curLine.Extent); // TODO: Is null the right check for not having tokens? for (int i = curLine.LineNumber - 1; i >= 0 && tokens == null; i--) { tokens = classifier.GetClassificationSpans(curLine.Extent); if (tokens != null) { break; } i = i - 1; } if (tokens == null) { return(false); } // Tokens is NOT None here. // If first token found on a line is only token and is string literal, // we're in a doc string. Because multiline, can't be "" or ''. return(tokens.Count == 1 && tokens[0].ClassificationType.IsOfType(PredefinedClassificationTypeNames.String)); }
private bool IsRealInterpreter(IPythonInterpreterFactory factory) { if (factory == null) { return(false); } var interpreterService = _serviceProvider.GetComponentModel().GetService <IInterpreterRegistryService>(); return(interpreterService != null && interpreterService.NoInterpretersValue != factory); }
public DataTipTextViewFilter(System.IServiceProvider serviceProvider, IVsTextView vsTextView) { _debugger = (IVsDebugger)NodejsPackage.GetGlobalService(typeof(IVsDebugger)); vsTextView.GetBuffer(out _vsTextLines); var editorAdaptersFactory = serviceProvider.GetComponentModel().GetService <IVsEditorAdaptersFactoryService>(); _wpfTextView = editorAdaptersFactory.GetWpfTextView(vsTextView); ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next)); }
public EditFilter(ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider) { _textView = textView; _textView.Properties[typeof(EditFilter)] = this; _editorOps = editorOps; _serviceProvider = serviceProvider; _componentModel = _serviceProvider.GetComponentModel(); _pyService = _serviceProvider.GetPythonToolsService(); BraceMatcher.WatchBraceHighlights(textView, _componentModel); InitializeScopeList(); }
internal static ITextBuffer GetBufferForDocument(System.IServiceProvider serviceProvider, string filename) { IVsTextView viewAdapter; IVsWindowFrame frame; VsUtilities.OpenDocument(serviceProvider, filename, out viewAdapter, out frame); IVsTextLines lines; ErrorHandler.ThrowOnFailure(viewAdapter.GetBuffer(out lines)); var adapter = serviceProvider.GetComponentModel().GetService<IVsEditorAdaptersFactoryService>(); return adapter.GetDocumentBuffer(lines); }
/// <summary> /// Moves the caret to the specified location, staying in the current text view /// if possible. /// /// https://pytools.codeplex.com/workitem/1649 /// </summary> private void GotoLocation(LocationInfo location) { Debug.Assert(location != null); Debug.Assert(location.Line > 0); Debug.Assert(location.Column > 0); if (CommonUtils.IsSamePath(location.FilePath, _textView.GetFilePath())) { var adapterFactory = _serviceProvider.GetComponentModel().GetService<IVsEditorAdaptersFactoryService>(); var viewAdapter = adapterFactory.GetViewAdapter(_textView); viewAdapter.SetCaretPos(location.Line - 1, location.Column - 1); viewAdapter.CenterLines(location.Line - 1, 1); } else { location.GotoSource(); } }
private ReplEditFilter( IVsTextView vsTextView, ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider, IOleCommandTarget next ) { _vsTextView = vsTextView; _textView = textView; _editorOps = editorOps; _serviceProvider = serviceProvider; _componentModel = _serviceProvider.GetComponentModel(); _pyService = _serviceProvider.GetPythonToolsService(); _interactive = _textView.TextBuffer.GetInteractiveWindow(); _next = next; if (_interactive != null) { _selectEval = _interactive.Evaluator as SelectableReplEvaluator; } if (_selectEval != null) { _selectEval.EvaluatorChanged += EvaluatorChanged; _selectEval.AvailableEvaluatorsChanged += AvailableEvaluatorsChanged; } var mse = _interactive?.Evaluator as IMultipleScopeEvaluator; if (mse != null) { _scopeListVisible = mse.EnableMultipleScopes; mse.AvailableScopesChanged += AvailableScopesChanged; mse.MultipleScopeSupportChanged += MultipleScopeSupportChanged; } if (_next == null && _interactive != null) { ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next)); } }
private EditFilter( IVsTextView vsTextView, ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider, IOleCommandTarget next ) { _vsTextView = vsTextView; _textView = textView; _editorOps = editorOps; _serviceProvider = serviceProvider; _componentModel = _serviceProvider.GetComponentModel(); _pyService = _serviceProvider.GetPythonToolsService(); _next = next; BraceMatcher.WatchBraceHighlights(textView, _componentModel); if (_next == null) { ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next)); } }