private void OnTextChanged(object sender, EventArgs e) { if (!_textView.VisualElement.IsVisible) { return; } _structureDebouncer.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentAnalyzerService"/> class. /// </summary> /// <param name="textView">The <see cref="IWpfTextView"/>.</param> /// <param name="syntaxWalkerProvider">The <see cref="ISyntaxWalkerProvider"/>.</param> public DocumentAnalyzerService( IWpfTextView textView, ISyntaxWalkerProvider syntaxWalkerProvider) { _textView = textView ?? throw new ArgumentNullException(nameof(textView)); _syntaxWalkerProvider = syntaxWalkerProvider ?? throw new ArgumentNullException(nameof(syntaxWalkerProvider)); IsAnalyzeable = _analyzeableContentTypes.Contains(textView.TextSnapshot.ContentType.TypeName); WeakEventManager <ITextBuffer, EventArgs> .AddHandler(_textView.TextBuffer, nameof(ITextBuffer.PostChanged), OnTextChanged); _structureDebouncer = new Debouncer(Analysis, TimeSpan.FromSeconds(1.5)); _structureDebouncer.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentAnalyzerService"/> class. /// </summary> public DocumentAnalyzerService( IEditor editor, ICancellationServiceFactory cancellationServiceFactory) { if (cancellationServiceFactory is null) { throw new ArgumentNullException(nameof(cancellationServiceFactory)); } _editor = editor ?? throw new ArgumentNullException(nameof(editor)); _cancellationService = cancellationServiceFactory.Create(); _syntaxAnalyzer = TreeAnalyzerFactory.Create(editor.ContentType); IsAnalyzeable = _syntaxAnalyzer is object; _editor.ContentChanged += OnContentChanged; _structureDebouncer = new Debouncer(Analysis, TimeSpan.FromSeconds(1.5)); _structureDebouncer.Start(); }
private void OnContentChanged(object sender, EventArgs e) { _structureDebouncer.Start(); }