public static LinePositionSpan GetLinePositionSpan(DiagnosticDataLocation?dataLocation, SourceText text, bool useMapped) { var lines = text.Lines; if (lines.Count == 0) { return(default);
public static TextSpan GetTextSpan(DiagnosticDataLocation?dataLocation, SourceText text) { var lines = text.Lines; if (lines.Count == 0) { return(default);
public static async ValueTask <Location> ConvertLocationAsync( this DiagnosticDataLocation?dataLocation, Project project, CancellationToken cancellationToken) { if (dataLocation?.DocumentId == null) { return(Location.None); } var textDocument = project.GetTextDocument(dataLocation.DocumentId) ?? await project.GetSourceGeneratedDocumentAsync(dataLocation.DocumentId, cancellationToken).ConfigureAwait(false); if (textDocument == null) { return(Location.None); } if (textDocument is Document document && document.SupportsSyntaxTree) { var syntacticDocument = await SyntacticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false); return(dataLocation.ConvertLocation(syntacticDocument)); } return(dataLocation.ConvertLocation()); }
public static TextSpan GetExistingOrCalculatedTextSpan(DiagnosticDataLocation?diagnosticLocation, SourceText text) { if (diagnosticLocation?.SourceSpan != null) { return(EnsureInBounds(diagnosticLocation.SourceSpan.Value, text)); } else { return(GetTextSpan(diagnosticLocation, text)); } }
public DiagnosticData( string id, string category, string?message, string?enuMessageForBingSearch, DiagnosticSeverity severity, DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, int warningLevel, ImmutableArray <string> customTags, ImmutableDictionary <string, string?> properties, ProjectId?projectId, DiagnosticDataLocation?location = null, ImmutableArray <DiagnosticDataLocation> additionalLocations = default, string?language = null, string?title = null, string?description = null, string?helpLink = null, bool isSuppressed = false ) { Id = id; Category = category; Message = message; ENUMessageForBingSearch = enuMessageForBingSearch; Severity = severity; DefaultSeverity = defaultSeverity; IsEnabledByDefault = isEnabledByDefault; WarningLevel = warningLevel; CustomTags = customTags; Properties = properties; ProjectId = projectId; DataLocation = location; AdditionalLocations = additionalLocations.NullToEmpty(); Language = language; Title = title; Description = description; HelpLink = helpLink; IsSuppressed = isSuppressed; }