public QuickInfoManager(ITextView textView, IQuickInfoBroker quickInfoBroker, QuickInfoModelProviderService quickInfoModelProviderService, VisualStudioSourceTextFactory sourceTextFactory) { _textView = textView; _quickInfoBroker = quickInfoBroker; _quickInfoModelProviderService = quickInfoModelProviderService; _sourceTextFactory = sourceTextFactory; }
public SyntaxVisualizerToolWindowControl() { InitializeComponent(); InitializeRunningDocTable(); var componentModel = HlslToolsPackage.Instance.AsVsServiceProvider().GetComponentModel(); _sourceTextFactory = componentModel.GetService<VisualStudioSourceTextFactory>(); }
public SignatureHelpManager(ITextView textView, ISignatureHelpBroker signatureHelpBroker, SignatureHelpModelProviderService signatureHelpModelProviderService, VisualStudioSourceTextFactory sourceTextFactory) { _textView = textView; _textView.Caret.PositionChanged += CaretOnPositionChanged; _textView.TextBuffer.PostChanged += TextBufferOnPostChanged; _signatureHelpBroker = signatureHelpBroker; _signatureHelpModelProviderService = signatureHelpModelProviderService; _sourceTextFactory = sourceTextFactory; }
public static SemanticModel GetSemanticModel(this ITextSnapshot snapshot, VisualStudioSourceTextFactory sourceTextFactory, CancellationToken cancellationToken) { return CachedSemanticModels.GetValue(snapshot, key => { var syntaxTree = key.GetSyntaxTree(sourceTextFactory, cancellationToken); var compilation = new Compilation.Compilation(syntaxTree); return compilation.GetSemanticModel(); }); }
public EditorNavigationSource(ITextBuffer textBuffer, BackgroundParser backgroundParser, DispatcherGlyphService glyphService, VisualStudioSourceTextFactory sourceTextFactory) { _textBuffer = textBuffer; _glyphService = glyphService; _sourceTextFactory = sourceTextFactory; _navigationTargets = new List<EditorTypeNavigationTarget>(); backgroundParser.RegisterSyntaxTreeHandler(BackgroundParserHandlerPriority.Medium, this); }
public static void Format(this ITextBuffer buffer, TextSpan span, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory) { SyntaxTree syntaxTree; if (!TryGetSyntaxTree(buffer, sourceTextFactory, out syntaxTree)) return; var edits = Formatter.GetEdits(syntaxTree, span, optionsService.FormattingOptions); ApplyEdits(buffer, edits); }
public BraceCompletionContext( ISmartIndentationService smartIndentationService, ITextBufferUndoManagerProvider undoManager, HlslClassificationService classificationService, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory) { _smartIndentationService = smartIndentationService; _undoManager = undoManager; _classificationService = classificationService; _optionsService = optionsService; _sourceTextFactory = sourceTextFactory; }
public FormatCommandTarget(IVsTextView adapter, IWpfTextView textView, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory) { _textView = textView; _optionsService = optionsService; _sourceTextFactory = sourceTextFactory; Dispatcher.CurrentDispatcher.InvokeAsync(() => { // Add the target later to make sure it makes it in before other command handlers ErrorHandler.ThrowOnFailure(adapter.AddCommandFilter(this, out _nextCommandTarget)); }, DispatcherPriority.ApplicationIdle); }
public NavigateToItemProvider( IBufferGraphFactoryService bufferGraphFactoryService, NavigateToItemProviderFactory navigateToItemProviderFactory, DispatcherGlyphService glyphService, IServiceProvider serviceProvider, VisualStudioSourceTextFactory sourceTextFactory) { _bufferGraphFactoryService = bufferGraphFactoryService; _navigateToItemProviderFactory = navigateToItemProviderFactory; _glyphService = glyphService; _serviceProvider = serviceProvider; _sourceTextFactory = sourceTextFactory; }
public static SyntaxTree GetSyntaxTree(this ITextSnapshot snapshot, VisualStudioSourceTextFactory sourceTextFactory, CancellationToken cancellationToken) { return CachedSyntaxTrees.GetValue(snapshot, key => { var sourceText = key.ToSourceText(); var options = new ParserOptions(); options.PreprocessorDefines.Add("__INTELLISENSE__"); var fileSystem = key.TextBuffer.GetIncludeFileSystem(sourceTextFactory); return SyntaxFactory.ParseSyntaxTree(sourceText, options, fileSystem, cancellationToken); }); }
// https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Nodejs/EditFilter.cs#L866 public static void FormatAfterTyping(this ITextView textView, char ch, IOptionsService optionsService, VisualStudioSourceTextFactory sourceTextFactory) { if (!ShouldFormatOnCharacter(ch, optionsService)) return; SyntaxTree syntaxTree; if (!TryGetSyntaxTree(textView.TextBuffer, sourceTextFactory, out syntaxTree)) return; var edits = Formatter.GetEditsAfterKeystroke(syntaxTree, textView.Caret.Position.BufferPosition.Position, ch, optionsService.FormattingOptions); ApplyEdits(textView.TextBuffer, edits); }
public BackgroundParser(ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory) { _textBuffer = textBuffer; _sourceTextFactory = sourceTextFactory; _shutdownToken = new CancellationTokenSource(); _hasWork = new ManualResetEventSlim(false); _syntaxTreeAvailableEventHandlers = new SortedList<BackgroundParserHandlerPriority, List<IBackgroundParserSyntaxTreeHandler>>(); _textBuffer.ChangedHighPriority += OnTextBufferChanged; Task.Run(() => DoWork(), _shutdownToken.Token); }
private static bool TryGetSyntaxTree(ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory, out SyntaxTree syntaxTree) { try { var syntaxTreeTask = Task.Run(() => textBuffer.CurrentSnapshot.GetSyntaxTree(sourceTextFactory, CancellationToken.None)); if (!syntaxTreeTask.Wait(TimeSpan.FromSeconds(5))) { Logger.Log("Parsing timeout"); syntaxTree = null; return false; } syntaxTree = syntaxTreeTask.Result; return true; } catch (Exception ex) { Logger.Log("Parsing error: " + ex); syntaxTree = null; return false; } }
public static BackgroundParser GetBackgroundParser(this ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory) { return textBuffer.Properties.GetOrCreateSingletonProperty(BackgroundParserKey, () => new BackgroundParser(textBuffer, sourceTextFactory)); }
public static IIncludeFileSystem GetIncludeFileSystem(this ITextBuffer textBuffer, VisualStudioSourceTextFactory sourceTextFactory) { return textBuffer.Properties.GetOrCreateSingletonProperty(IncludeFileSystemKey, () => new VisualStudioFileSystem(textBuffer.GetTextContainer(), sourceTextFactory)); }
public SmartIndent(SVsServiceProvider serviceProvider, VisualStudioSourceTextFactory sourceTextFactory) { _languagePreferences = serviceProvider.GetHlslToolsService().LanguagePreferences; _sourceTextFactory = sourceTextFactory; }
public VisualStudioFileSystem(VisualStudioSourceTextContainer textContainer, VisualStudioSourceTextFactory sourceTextFactory) { _sourceTextFactory = sourceTextFactory; if (textContainer.Filename != null) _parentDirectory = Path.GetDirectoryName(textContainer.Filename); }