-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64802 from CyrusNajmabadi/tagEquality
Implemen equality semantics for async tagger tags.
- Loading branch information
Showing
30 changed files
with
375 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...torFeatures/Core/Diagnostics/AbstractDiagnosticsAdornmentTaggerProvider.RoslynErrorTag.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using Microsoft.CodeAnalysis.Classification; | ||
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo; | ||
using Microsoft.VisualStudio.Text.Adornments; | ||
using Microsoft.VisualStudio.Text.Tagging; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.Diagnostics | ||
{ | ||
internal partial class AbstractDiagnosticsAdornmentTaggerProvider<TTag> | ||
{ | ||
protected sealed class RoslynErrorTag : ErrorTag, IEquatable<RoslynErrorTag> | ||
{ | ||
private readonly DiagnosticData _data; | ||
|
||
public RoslynErrorTag(string errorType, Workspace workspace, DiagnosticData data) | ||
: base(errorType, CreateToolTipContent(workspace, data)) | ||
{ | ||
_data = data; | ||
} | ||
|
||
private static object CreateToolTipContent(Workspace workspace, DiagnosticData diagnostic) | ||
{ | ||
Action? navigationAction = null; | ||
string? tooltip = null; | ||
if (workspace != null) | ||
{ | ||
var helpLinkUri = diagnostic.GetValidHelpLinkUri(); | ||
if (helpLinkUri != null) | ||
{ | ||
navigationAction = new QuickInfoHyperLink(workspace, helpLinkUri).NavigationAction; | ||
tooltip = diagnostic.HelpLink; | ||
} | ||
} | ||
|
||
var diagnosticIdTextRun = navigationAction is null | ||
? new ClassifiedTextRun(ClassificationTypeNames.Text, diagnostic.Id) | ||
: new ClassifiedTextRun(ClassificationTypeNames.Text, diagnostic.Id, navigationAction, tooltip); | ||
|
||
return new ContainerElement( | ||
ContainerElementStyle.Wrapped, | ||
new ClassifiedTextElement( | ||
diagnosticIdTextRun, | ||
new ClassifiedTextRun(ClassificationTypeNames.Punctuation, ":"), | ||
new ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "), | ||
new ClassifiedTextRun(ClassificationTypeNames.Text, diagnostic.Message))); | ||
} | ||
|
||
public override bool Equals(object? obj) | ||
=> Equals(obj as RoslynErrorTag); | ||
|
||
public bool Equals(RoslynErrorTag? other) | ||
{ | ||
return other != null && | ||
this.ErrorType == other.ErrorType && | ||
this._data.GetValidHelpLinkUri() == other._data.GetValidHelpLinkUri() && | ||
this._data.Id == other._data.Id && | ||
this._data.Message == other._data.Message; | ||
} | ||
|
||
public override int GetHashCode() | ||
=> throw ExceptionUtilities.Unreachable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.