private TagSpan <IErrorTag> GenerateTag(Error error) { var span = new SnapshotSpan(_buffer.CurrentSnapshot, error.Span); var tag = new ErrorTag("Intellisense", error.Message); return(new TagSpan <IErrorTag>(span, tag)); }
private TagSpan <IErrorTag> GetErrorTag(NormalizedSnapshotSpanCollection spans) { if (_error?.LineNumber == null) { return(null); } var line = _error.LineNumber.Value - 1; var col = (_error?.LinePosition ?? 1) - 1; if (line < 0 || line >= _buffer.CurrentSnapshot.LineCount || col < 0) { return(null); } var snapshotline = _buffer.CurrentSnapshot.GetLineFromLineNumber(line); if (snapshotline.Start.Position + col >= snapshotline.Snapshot.Length) { return(null); } var start = snapshotline.Start + col; var startSpan = new SnapshotSpan(start, start + 1); var span = _navigator.GetSpanOfFirstChild(startSpan); var tag = new ErrorTag(PredefinedErrorTypeNames.CompilerError, _error.Message); if (!spans.IntersectsWith(span)) { return(null); } return(new TagSpan <IErrorTag>(span, tag)); }
private ITagSpan <IErrorTag> CreateTagSpan(ITextSnapshot snapshot, TextSpan textSpan, Diagnostic diagnostic, bool squigglesEnabled) { var span = new Span(textSpan.Start, textSpan.Length); var snapshotSpan = new SnapshotSpan(snapshot, span); var errorTag = new ErrorTag(_errorType, diagnostic.Message); var errorTagSpan = new TagSpan <IErrorTag>(snapshotSpan, errorTag); return(errorTagSpan); }
protected override ITagSpan <IErrorTag> CreateTagSpan(ITextSnapshot snapshot, Diagnostic rawTag) { var span = new Span(rawTag.Span.Start, rawTag.Span.Length); var snapshotSpan = new SnapshotSpan(snapshot, span); var errorTag = new ErrorTag(_errorType, rawTag.Message); var errorTagSpan = new TagSpan <IErrorTag>(snapshotSpan, errorTag); return(errorTagSpan); }
// Syntax errors public IEnumerable <ITagSpan <ErrorTag> > GetSyntaxErrorTags(ITextBuffer buffer, SnapshotSpan span) { var semanticModel = GetSemanticModel(buffer); var tokens = semanticModel.GetErrorTokens(span.Span); foreach (var token in tokens) { var tag = new ErrorTag(token.IsError ? Classifications.SyntaxError : Classifications.Warning, token.QuickInfo); yield return(new TagSpan <ErrorTag>(new SnapshotSpan(span.Snapshot, token.Start, token.Length), tag)); } }
protected override ITagSpan <IErrorTag> CreateTagSpan(ITextSnapshot snapshot, CodeIssue rawTag) { var name = rawTag.Kind == CodeIssueKind.Warning ? PredefinedErrorTypeNames.Warning : PredefinedErrorTypeNames.CompilerError; var span = new SnapshotSpan(snapshot, rawTag.Span.Start, rawTag.Span.Length); var tag = new ErrorTag(name, rawTag.Description); return(new TagSpan <IErrorTag>(span, tag)); }
protected override IEnumerable <ITagSpan <IErrorTag> > Tags(Span x) { var snapshot = this.buffer.CurrentSnapshot; // FIXME: Tree.GetErrors gives a sorted collection, so we must use some kind of binary search. var errors = this.buffer.ObtainOrAttachTree().GetErrors(); return(errors.Where(a => Span.FromBounds(a.Begin, a.End).IntersectsWith(x)).Select(a => { var span = new SnapshotSpan(snapshot, Span.FromBounds(a.Begin, a.End)); var mesage = new ErrorTag(PredefinedErrorTypeNames.SyntaxError, a.RawMessage); return new TagSpan <IErrorTag>(span, mesage); })); }
public IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { var tags = aggregator.GetTags(spans).ToList(); var errorTags = tags .Where(_ => _.Tag.Type == GherkinTokenType.SyntaxError) .ToList(); foreach (var tagSpan in errorTags) { var tagSpans = tagSpan.Span.GetSpans(spans[0].Snapshot); //TODO: Add tooltip & get error from parser string errorType = "Failed to parse text!!"; var t = new ErrorTag(errorType); yield return(new TagSpan <ErrorTag>(tagSpans[0], t)); } }
protected ITagSpan <IErrorTag> CreateTagSpan(ITextSnapshot snapshot, Diagnostic diagnostic, bool squigglesEnabled) { _errorListHelper.AddError(snapshot, diagnostic, diagnostic.Span); if (!diagnostic.Span.IsInRootFile || !squigglesEnabled) { return(null); } var span = new Span(diagnostic.Span.Start, diagnostic.Span.Length); var snapshotSpan = new SnapshotSpan(snapshot, span); var errorTag = new ErrorTag(_errorType, diagnostic.Message); var errorTagSpan = new TagSpan <IErrorTag>(snapshotSpan, errorTag); return(errorTagSpan); }
public IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (_error?.LineNumber != null) { var line = _buffer.CurrentSnapshot.GetLineFromLineNumber(Math.Max(_error.LineNumber.Value - 1, 0)); var start = line.Start + Math.Max(((_error?.LinePosition ?? 1) - 1), 0); var startSpan = new SnapshotSpan(start, start + 1); var span = _navigator.GetSpanOfFirstChild(startSpan); var tag = new ErrorTag(PredefinedErrorTypeNames.CompilerError, _error.Message); if (spans.OverlapsWith(span)) { return(new[] { new TagSpan <IErrorTag>(span, tag) }); } } return(Array.Empty <ITagSpan <IErrorTag> >()); }
public IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { var list = new List <TagSpan <ErrorTag> >(); foreach (SnapshotSpan currSpan in spans) { var text = currSpan.GetText(); if (text.Contains(_relativePattern)) { var length = text.Contains(" ") ? text.IndexOf(" ") : text.Length; var span = new SnapshotSpan(currSpan.Snapshot, currSpan.Start, length); var tag = new ErrorTag(PredefinedErrorTypeNames.SyntaxError, "foo bar"); list.Add(new TagSpan <ErrorTag>(span, tag)); } } return(list); }
/// <summary> /// Gets the tags for the specified document. /// </summary> /// <param name="span">The snapshot span from which the document was generated.</param> /// <returns>A collection containing the tags for the specified document.</returns> public IEnumerable <ITagSpan <IErrorTag> > GetTags(SnapshotSpan span) { var result = new List <ITagSpan <IErrorTag> >(); var errorList = span.Snapshot.TextBuffer.GetErrorList(); if (errorList == null) { return(Enumerable.Empty <ITagSpan <IErrorTag> >()); } var errors = errorList.GetErrorsInSpan(span); return(errors.Select(x => { var tagSpan = x.TagSafeSpan; var tag = new ErrorTag(x.DiagnosticInfo.Message, x.DiagnosticInfo.Message); return new TagSpan <IErrorTag>(tagSpan, tag); })); }
private static void AddDiagnostics(TaggerContext <IErrorTag> context, IEnumerable <MappedDiagnostic> mappedDiagnostics, ITextSnapshot snapshot) { foreach (var mappedDiagnostic in mappedDiagnostics) { context.CancellationToken.ThrowIfCancellationRequested(); if (!mappedDiagnostic.FileSpan.IsInRootFile) { continue; } var errorType = mappedDiagnostic.Diagnostic.Severity == DiagnosticSeverity.Warning ? PredefinedErrorTypeNames.Warning : (mappedDiagnostic.Source == DiagnosticSource.SyntaxParsing ? PredefinedErrorTypeNames.SyntaxError : PredefinedErrorTypeNames.CompilerError); var tag = new ErrorTag(errorType, mappedDiagnostic.Diagnostic.Message); context.AddTag(snapshot.GetTagSpan(mappedDiagnostic.FileSpan.Span.ToSpan(), tag)); } }
public IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection inputSpans) { if (!errors.Any()) { yield break; } //TODO: parse error.message for offending words to narrow down span //error.Message. foreach (var inputSpan in inputSpans) { foreach (var error in errors) { var lineNumber = inputSpan.Start.GetContainingLine().LineNumber + 1; if (error.LineNumber == lineNumber) { var tag = new ErrorTag(ConvertErrorType(error.Type), error.Message); var span = new TagSpan <IErrorTag>(inputSpan, tag); yield return(span); } } } }
// Syntax errors public IEnumerable<ITagSpan<ErrorTag>> GetSyntaxErrorTags(ITextBuffer buffer, SnapshotSpan span) { var semanticModel = GetSemanticModel(buffer); var tokens = semanticModel.GetErrorTokens(span.Span); foreach (var token in tokens) { var tag = new ErrorTag(Classifications.SyntaxError, token.QuickInfo); yield return new TagSpan<ErrorTag>(new SnapshotSpan(span.Snapshot, token.Start, token.Length), tag); } }
string DisplayStringForTag(ITag tag, out object toolTipContent) { toolTipContent = null; List <string> content = new List <string>(); ClassificationTag classification = tag as ClassificationTag; if (classification != null) { content.Add(classification.ClassificationType.ToString()); } ErrorTag error = tag as ErrorTag; if (error != null) { toolTipContent = error.ToolTipContent; content.Add(error.ErrorType); } IOutliningRegionTag region = tag as IOutliningRegionTag; if (region != null) { toolTipContent = region.CollapsedHintForm; content.Add(string.Format("IsImplementation: {0}, IsDefaultCollapsed: {1}", region.IsImplementation, region.IsDefaultCollapsed)); } TextMarkerTag marker = tag as TextMarkerTag; if (marker != null) { content.Add(marker.Type); } SpaceNegotiatingAdornmentTag snat = tag as SpaceNegotiatingAdornmentTag; if (snat != null) { content.Add(string.Format("TextHeight: {0}, Width: {1}, Affinity: {2}", snat.TextHeight, snat.Width, snat.Affinity)); } IntraTextAdornmentTag itat = tag as IntraTextAdornmentTag; if (itat != null) { content.Add("Content: " + itat.Adornment.ToString()); } IUrlTag url = tag as IUrlTag; if (url != null) { content.Add(url.Url.ToString()); } if (content.Count > 0) { return(string.Join(Environment.NewLine, content)); } else { return(tag?.ToString()); } }