Beispiel #1
0
        /// <summary>
        /// Handles the Classification changed event that comes from the Classifier aggregator
        /// </summary>
        void OnClassificationChanged(object sender, ClassificationChangedEventArgs e)
        {
            if (!_isClosed)
            {
                // When classifications change, we just invalidate the lines. That invalidation will
                // create new lines based on the new classifications.

                // Map the classification change (from the edit buffer) to the visual buffer
                Span span = Span.FromBounds(
                    TextViewModel.GetNearestPointInVisualSnapshot(e.ChangeSpan.Start, VisualSnapshot, PointTrackingMode.Negative),
                    TextViewModel.GetNearestPointInVisualSnapshot(e.ChangeSpan.End, VisualSnapshot, PointTrackingMode.Positive));

                //Classifications changes invalidate only the characters contained in the span so a zero length change
                //will have no effect.
                if (span.Length > 0)
                {
                    //IsLineInvalid will invalidate a line if it intersects the end. The result is that any call to InvalidateSpan() implicitly
                    //invalidates any line that starts at the end of the invalidated span, which we do not want here. Reduce the length of the classification
                    //change span one so -- if someone invalidated an entire line including the line break -- the next line will not be invalidated.
                    span = new Span(span.Start, span.Length - 1);

// MONO: TODO: this

                    //lock (_invalidatedSpans)
                    //{
                    //	if ((_attachedLineCache.Count > 0) || (_unattachedLineCache.Count > 0))
                    //	{
                    //		_reclassifiedSpans.Add(span);
                    //		this.QueueLayout();
                    //	}
                    //}
                }
            }
        }
        private void OnClassificationChanged(object sender, ClassificationChangedEventArgs args)
        {
            var handler = _highlightingStateChanged;

            if (handler != null)
            {
                foreach (Mono.TextEditor.MdTextViewLineCollection.MdTextViewLine line in textView.TextViewLines)
                {
                    if (line.Start.Position > args.ChangeSpan.End.Position || line.End.Position < args.ChangeSpan.Start)
                    {
                        continue;
                    }
                    var oldSegments = line.layoutWrapper.HighlightedLine.Segments;
                    var newSegments = GetHighlightedLineAsync(line.line, CancellationToken.None).Result.Segments;
                    if (oldSegments.Count != newSegments.Count)
                    {
                        handler(this, new LineEventArgs(line.line));
                        continue;
                    }
                    for (int i = 0; i < oldSegments.Count; i++)
                    {
                        if (newSegments [i].ColorStyleKey != oldSegments [i].ColorStyleKey)
                        {
                            handler(this, new LineEventArgs(line.line));
                            break;
                        }
                    }
                }
            }
        }
Beispiel #3
0
 protected virtual void OnClassificationChanged(ClassificationChangedEventArgs e)
 {
     if (ClassificationChanged != null)
     {
         ClassificationChanged(this, e);
     }
 }
Beispiel #4
0
            private void Subclassification_Changed(object sender, ClassificationChangedEventArgs e)
            {
                var c            = (IClassifier)sender;
                var refreshSpans = c.GetClassificationSpans(e.ChangeSpan);

                ClassificationChanged?.Invoke(this, e);
            }
 private void GherkinLanguageServiceOnFileScopeChanged(object sender, GherkinFileScopeChange gherkinFileScopeChange)
 {
     if (ClassificationChanged != null)
     {
         ClassificationChangedEventArgs args = new ClassificationChangedEventArgs(gherkinFileScopeChange.CreateChangeSpan());
         ClassificationChanged(this, args);
     }
 }
 private void GherkinLanguageServiceOnFileScopeChanged(object sender, GherkinFileScopeChange gherkinFileScopeChange)
 {
     if (ClassificationChanged != null)
     {
         ClassificationChangedEventArgs args = new ClassificationChangedEventArgs(gherkinFileScopeChange.CreateChangeSpan());
         ClassificationChanged(this, args);
     }
 }
Beispiel #7
0
        private void OnClassificationChanged(object sender, ClassificationChangedEventArgs args)
        {
            var handler = _highlightingStateChanged;

            if (handler != null)
            {
            }
        }
Beispiel #8
0
        /// <summary>
        /// This is used to raise the <see cref="TagsChanged"/> event
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void ClassificationChanged(object sender, ClassificationChangedEventArgs e)
        {
            var handler = TagsChanged;

            if (handler != null)
            {
                handler(this, new SnapshotSpanEventArgs(e.ChangeSpan));
            }
        }
 private void Classifier_ClassificationChanged(object sender, ClassificationChangedEventArgs e)
 {
     WriteOutputMessage("ClassificationChanged()");
     if (_suspendSync)
     {
         return;
     }
     ApplyPendingChanges();
 }
        void ClassificationChanged(object sender, ClassificationChangedEventArgs e)
        {
            var temp = TagsChanged;

            if (temp != null)
            {
                temp(this, new SnapshotSpanEventArgs(e.ChangeSpan));
            }
        }
        private void RaiseClassificationChangedEvent(ClassificationChangedEventArgs args)
        {
            EventHandler <ClassificationChangedEventArgs> eventHandler = this.ClassificationChanged;

            if (eventHandler == null)
            {
                return;
            }
            eventHandler((object)this, args);
        }
        public void Update(AmmyFile <Top> file)
        {
            _latestFile = file;

            var snapshot     = (ITextSnapshot)_latestFile.Meta.Snapshot;
            var snapshotSpan = new SnapshotSpan(snapshot, 0, snapshot.Length);
            var eventArgs    = new ClassificationChangedEventArgs(snapshotSpan);

            ClassificationChanged?.Invoke(this, eventArgs);
        }
        protected virtual void OnClassificationChanged(ClassificationChangedEventArgs e)
        {
            Contract.Requires <ArgumentNullException>(e != null, "e");

            var t = ClassificationChanged;

            if (t != null)
            {
                t(this, e);
            }
        }
Beispiel #14
0
        protected virtual void OnClassificationChanged([NotNull] ClassificationChangedEventArgs e)
        {
            Requires.NotNull(e, nameof(e));

            var t = ClassificationChanged;

            if (t != null)
            {
                t(this, e);
            }
        }
        public virtual void ForceReclassifyLines(int startLine, int endLine)
        {
            _firstDirtyLine = _firstDirtyLine.HasValue ? Math.Min(_firstDirtyLine.Value, startLine) : startLine;
            _lastDirtyLine  = _lastDirtyLine.HasValue ? Math.Max(_lastDirtyLine.Value, endLine) : endLine;

            ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;
            int           start    = snapshot.GetLineFromLineNumber(startLine).Start;
            int           end      = snapshot.GetLineFromLineNumber(endLine).EndIncludingLineBreak;
            var           e        = new ClassificationChangedEventArgs(new SnapshotSpan(_textBuffer.CurrentSnapshot, Span.FromBounds(start, end)));

            OnClassificationChanged(e);
        }
Beispiel #16
0
        protected virtual void ForceReclassifyLines(ClassifierState classifierState, int startLine, int endLine)
        {
            classifierState._firstDirtyLine = Math.Min(classifierState._firstDirtyLine ?? startLine, startLine);
            classifierState._lastDirtyLine  = Math.Max(classifierState._lastDirtyLine ?? endLine, endLine);

            ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;
            int           start    = snapshot.GetLineFromLineNumber(startLine).Start;
            int           end      = snapshot.GetLineFromLineNumber(endLine).EndIncludingLineBreak;
            var           e        = new ClassificationChangedEventArgs(new SnapshotSpan(_textBuffer.CurrentSnapshot, Span.FromBounds(start, end)));

            OnClassificationChanged(e);
        }
Beispiel #17
0
        private void OnClassificationChanged(object sender, ClassificationChangedEventArgs args)
        {
            var handler = _highlightingStateChanged;

            if (handler != null)
            {
                foreach (Mono.TextEditor.MdTextViewLineCollection.MdTextViewLine line in textView.TextViewLines)
                {
                    if (line.Start.Position > args.ChangeSpan.End.Position || line.End.Position < args.ChangeSpan.Start)
                    {
                        continue;
                    }
                    handler(this, new LineEventArgs(line.line));
                }
            }
        }
        private void OnClassificationChanged(object sender, ClassificationChangedEventArgs args)
        {
            var handler = _highlightingStateChanged;

            if (handler != null)
            {
                int startLineIndex = this.textDocument.OffsetToLineNumber(args.ChangeSpan.Start);
                int endLineIndex   = this.textDocument.OffsetToLineNumber(args.ChangeSpan.End);

                IEnumerable <IDocumentLine> documentLines = this.textDocument.GetLinesBetween(startLineIndex, endLineIndex);
                foreach (IDocumentLine documentLine in documentLines)
                {
                    handler(this, new LineEventArgs(documentLine));
                }
            }
        }
        private void OnClassificationChanged(object sender, ClassificationChangedEventArgs args)
        {
            var handler = _highlightingStateChanged;

            if (handler != null)
            {
                int startLineIndex = this.textDocument.OffsetToLineNumber(args.ChangeSpan.Start);
                int endLineIndex   = this.textDocument.OffsetToLineNumber(args.ChangeSpan.End);

                for (int curLineIndex = startLineIndex; curLineIndex <= endLineIndex; curLineIndex++)
                {
                    IDocumentLine documentLine = this.textDocument.GetLine(curLineIndex);
                    handler(this, new LineEventArgs(documentLine));
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// Rescans the part of the buffer affected by a change.
        /// Scans a contiguous sub-<paramref name="span"/> of a larger code span which starts at <paramref name="codeStartLine"/>.
        /// </summary>
        private void ApplyChange(Tokenizer tokenizer, ITextSnapshot snapshot, Span span, int codeStartLine, int codeStartLineOffset)
        {
            int firstLine = snapshot.GetLineNumberFromPosition(span.Start);
            int lastLine  = snapshot.GetLineNumberFromPosition(span.Length > 0 ? span.End - 1 : span.End);

            Contract.Assert(codeStartLineOffset >= 0);
            Contract.Assert(firstLine >= codeStartLine);

            // find the closest line preceding firstLine for which we know categorizer state, stop at the codeStartLine:
            LineTokenization lineTokenization;

            firstLine = _tokenCache.IndexOfPreviousTokenization(firstLine, codeStartLine, out lineTokenization) + 1;
            object state = lineTokenization.State;

            int    currentLine = firstLine;
            object previousState;

            while (currentLine < snapshot.LineCount)
            {
                previousState            = _tokenCache.TryGetTokenization(currentLine, out lineTokenization) ? lineTokenization.State : null;
                _tokenCache[currentLine] = lineTokenization = TokenizeLine(tokenizer, snapshot, state, currentLine, (currentLine == codeStartLine) ? codeStartLineOffset : 0);
                state = lineTokenization.State;

                // stop if we visted all affected lines and the current line has no tokenization state or its previous state is the same as the new state:
                if (currentLine > lastLine && (previousState == null || previousState.Equals(state)))
                {
                    break;
                }

                currentLine++;
            }

            // classification spans might have changed between the start of the first and end of the last visited line:
            int changeStart = snapshot.GetLineFromLineNumber(firstLine).Start;
            int changeEnd   = (currentLine < snapshot.LineCount) ? snapshot.GetLineFromLineNumber(currentLine).End : snapshot.Length;

            if (changeStart < changeEnd)
            {
                var classificationChanged = ClassificationChanged;
                if (classificationChanged != null)
                {
                    var args = new ClassificationChangedEventArgs(new SnapshotSpan(snapshot, new Span(changeStart, changeEnd - changeStart)));
                    classificationChanged(this, args);
                }
            }
        }
        private void OnClassificationChanged(object sender, ClassificationChangedEventArgs args)
        {
            var handler = _highlightingStateChanged;

            if (handler != null)
            {
                foreach (Mono.TextEditor.MdTextViewLineCollection.MdTextViewLine line in textView.TextViewLines)
                {
                    if (!line.HasDrawn)
                    {
                        line.HasDrawn = true;
                        handler(this, new LineEventArgs(line.line));
                        continue;
                    }
                }
            }
        }
		public Classifier(CoffeeOverview overview, IClassificationTypeRegistryService classificationRegistry) {
			this.overview = overview;
			this.clsCoffeeString = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeString);
			this.clsCoffeeIdentifier = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeIdentifier);
			this.clsCoffeeKeyword = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeKeyword);
			this.clsCoffeeNumericLiteral = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeNumericLiteral);
			this.clsCoffeeComment = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeComment);
			overview.MultiLinesChanged += (o, e) => {
				if (this.latestSnapshot != null && this.ClassificationChanged != null) {
					var spans = new NormalizedSnapshotSpanCollection(
						e.Added.Concat(e.Removed)
						.Select(x => x.Span.GetSpan(this.latestSnapshot)));
					foreach (var span in spans) {
						var args = new ClassificationChangedEventArgs(span);
						this.ClassificationChanged(this, args);
					}
				}
			};
		}
Beispiel #23
0
 public Classifier(CoffeeOverview overview, IClassificationTypeRegistryService classificationRegistry)
 {
     this.overview                = overview;
     this.clsCoffeeString         = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeString);
     this.clsCoffeeIdentifier     = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeIdentifier);
     this.clsCoffeeKeyword        = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeKeyword);
     this.clsCoffeeNumericLiteral = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeNumericLiteral);
     this.clsCoffeeComment        = classificationRegistry.GetClassificationType(VisualFormatNames.CoffeeComment);
     overview.MultiLinesChanged  += (o, e) => {
         if (this.latestSnapshot != null && this.ClassificationChanged != null)
         {
             var spans = new NormalizedSnapshotSpanCollection(
                 e.Added.Concat(e.Removed)
                 .Select(x => x.Span.GetSpan(this.latestSnapshot)));
             foreach (var span in spans)
             {
                 var args = new ClassificationChangedEventArgs(span);
                 this.ClassificationChanged(this, args);
             }
         }
     };
 }
 private void Classifier_ClassificationChanged(Object sender, ClassificationChangedEventArgs e)
 {
     ClassificationChanged?.Invoke(sender, e);
 }
Beispiel #25
0
 void Classifier_ClassificationChanged(object sender, ClassificationChangedEventArgs e) =>
 TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(e.ChangeSpan));
Beispiel #26
0
 void AggregateClassifier_ClassificationChanged(object sender, ClassificationChangedEventArgs e) =>
 Dispatcher.BeginInvoke(new Action(() => InvalidateSpan(e.ChangeSpan)), DispatcherPriority.Normal);
		void SignatureClassifier_ClassificationChanged(object sender, ClassificationChangedEventArgs e) => DelayReclassifySignature();
        public virtual void ForceReclassifyLines(int startLine, int endLine)
        {
            _firstDirtyLine = _firstDirtyLine.HasValue ? Math.Min(_firstDirtyLine.Value, startLine) : startLine;
            _lastDirtyLine = _lastDirtyLine.HasValue ? Math.Max(_lastDirtyLine.Value, endLine) : endLine;

            ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;
            int start = snapshot.GetLineFromLineNumber(startLine).Start;
            int end = snapshot.GetLineFromLineNumber(endLine).EndIncludingLineBreak;
            var e = new ClassificationChangedEventArgs(new SnapshotSpan(_textBuffer.CurrentSnapshot, Span.FromBounds(start, end)));
            OnClassificationChanged(e);
        }
 /// <summary>
 /// Изменение классификатора.
 /// </summary>
 /// <param name="sender">Отправитель.</param>
 /// <param name="eventArgs">Параметр события.</param>
 private void ClassificationChanged(object sender, ClassificationChangedEventArgs eventArgs)
 {
     //AddNotCheckedSpan(eventArgs.ChangeSpan);
     RaiseTagsChanged(eventArgs.ChangeSpan);
 }
Beispiel #30
0
 public void InvokeClassificationChanged(ClassificationChangedEventArgs eventArgs)
 {
     ClassificationChanged?.Invoke(this, eventArgs);
 }
 private void LexerClassificationChanged(object sender, ClassificationChangedEventArgs e)
 {
     ClassificationChanged?.Invoke(sender, e);
 }
Beispiel #32
0
 private void Classifier_ClassificationChanged(Object sender, ClassificationChangedEventArgs e)
 {
     ClassificationChanged?.Invoke(sender, e);
 }
		protected virtual void OnClassificationChanged(ClassificationChangedEventArgs e)
		{
			if (ClassificationChanged != null)
			{
				ClassificationChanged(this, e);
			}
		}
        protected virtual void OnClassificationChanged(ClassificationChangedEventArgs e)
        {
            Contract.Requires<ArgumentNullException>(e != null, "e");

            var t = ClassificationChanged;
            if (t != null)
                t(this, e);
        }
Beispiel #35
0
        /// <summary>
        /// Rescans the part of the buffer affected by a change. 
        /// Scans a contiguous sub-<paramref name="span"/> of a larger code span which starts at <paramref name="codeStartLine"/>.
        /// </summary>
        private void ApplyChange(Tokenizer tokenizer, ITextSnapshot snapshot, Span span)
        {
            int firstLine = snapshot.GetLineNumberFromPosition(span.Start);
            int lastLine = snapshot.GetLineNumberFromPosition(span.Length > 0 ? span.End - 1 : span.End);

            Contract.Assert(firstLine >= 0);

            // find the closest line preceding firstLine for which we know categorizer state, stop at the codeStartLine:
            LineTokenization lineTokenization;
            firstLine = _tokenCache.IndexOfPreviousTokenization(firstLine, 0, out lineTokenization) + 1;
            object state = lineTokenization.State;

            int currentLine = firstLine;
            object previousState;
            while (currentLine < snapshot.LineCount) {
                previousState = _tokenCache.TryGetTokenization(currentLine, out lineTokenization) ? lineTokenization.State : null;
                _tokenCache[currentLine] = lineTokenization = TokenizeLine(tokenizer, snapshot, state, currentLine);
                state = lineTokenization.State;

                // stop if we visted all affected lines and the current line has no tokenization state or its previous state is the same as the new state:
                if (currentLine > lastLine && (previousState == null || previousState.Equals(state))) {
                    break;
                }

                currentLine++;
            }

            // classification spans might have changed between the start of the first and end of the last visited line:
            int changeStart = snapshot.GetLineFromLineNumber(firstLine).Start;
            int changeEnd = (currentLine < snapshot.LineCount) ? snapshot.GetLineFromLineNumber(currentLine).End : snapshot.Length;
            if (changeStart < changeEnd) {
                var classificationChanged = ClassificationChanged;
                if (classificationChanged != null) {
                    var args = new ClassificationChangedEventArgs(new SnapshotSpan(snapshot, new Span(changeStart, changeEnd - changeStart)));
                    classificationChanged(this, args);
                }
            }
        }
 protected virtual void OnClassificationChanged(ClassificationChangedEventArgs e)
 {
     ClassificationChanged?.Invoke(this, e);
 }
Beispiel #37
0
		void AggregateClassifier_ClassificationChanged(object sender, ClassificationChangedEventArgs e) =>
			Dispatcher.BeginInvoke(new Action(() => InvalidateSpan(e.ChangeSpan)), DispatcherPriority.Normal);