-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove code for arbitrary diagnostic taggers #72409
Merged
CyrusNajmabadi
merged 10 commits into
dotnet:main
from
CyrusNajmabadi:simplifyInlineTagger
Mar 7, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
18cb45b
Move code needed only by inline-diagnostic tagger to that tagger's lo…
CyrusNajmabadi 0eb10ba
remove unused property
CyrusNajmabadi ea66645
move methods up
CyrusNajmabadi 1f4ca1c
remove intermediary type
CyrusNajmabadi 0afab5b
File scoped namespace
CyrusNajmabadi d94e083
Merge remote-tracking branch 'upstream/main' into simplifyInlineTagger
CyrusNajmabadi 05d1290
Merge branch 'main' into simplifyInlineTagger
CyrusNajmabadi 63a00ea
Remove dead tests
CyrusNajmabadi 8bfe2d0
Fix
CyrusNajmabadi 4c6384c
Delete optinos
CyrusNajmabadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 0 additions & 35 deletions
35
src/EditorFeatures/Core.Wpf/Diagnostics/UnnecessaryCodeFormatDefinition.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// 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 System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Tagging; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Utilities; | ||
|
@@ -63,12 +64,11 @@ SingleDiagnosticKindPullTaggerProvider CreateDiagnosticsTaggerProvider(Diagnosti | |
protected abstract ImmutableArray<IOption2> Options { get; } | ||
protected virtual ImmutableArray<IOption2> FeatureOptions { get; } = []; | ||
|
||
protected abstract bool IsEnabled { get; } | ||
|
||
protected abstract bool IncludeDiagnostic(DiagnosticData data); | ||
|
||
protected abstract bool TagEquals(TTag tag1, TTag tag2); | ||
protected abstract ITagSpan<TTag>? CreateTagSpan(Workspace workspace, SnapshotSpan span, DiagnosticData data); | ||
|
||
protected abstract TTag? CreateTag(Workspace workspace, DiagnosticData diagnostic); | ||
|
||
/// <summary> | ||
/// Get the <see cref="DiagnosticDataLocation"/> that should have the tag applied to it. | ||
|
@@ -111,4 +111,36 @@ private static ITaggerEventSource CreateEventSourceWorker(ITextBuffer subjectBuf | |
TaggerEventSources.OnDiagnosticsChanged(subjectBuffer, diagnosticService), | ||
TaggerEventSources.OnTextChanged(subjectBuffer)); | ||
} | ||
|
||
protected ITagSpan<TTag>? CreateTagSpan(Workspace workspace, SnapshotSpan span, DiagnosticData data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved from intermediary subclass to this type. methods unchanged. |
||
{ | ||
var errorTag = CreateTag(workspace, data); | ||
if (errorTag == null) | ||
return null; | ||
|
||
// Ensure the diagnostic has at least length 1. Tags must have a non-empty length in order to actually show | ||
// up in the editor. | ||
var adjustedSpan = AdjustSnapshotSpan(span, minimumLength: 1); | ||
if (adjustedSpan.Length == 0) | ||
return null; | ||
|
||
return new TagSpan<TTag>(adjustedSpan, errorTag); | ||
} | ||
|
||
protected virtual SnapshotSpan AdjustSnapshotSpan(SnapshotSpan span, int minimumLength) | ||
=> AdjustSnapshotSpan(span, minimumLength, maximumLength: int.MaxValue); | ||
|
||
protected static SnapshotSpan AdjustSnapshotSpan(SnapshotSpan span, int minimumLength, int maximumLength) | ||
{ | ||
var snapshot = span.Snapshot; | ||
|
||
// new length | ||
var length = Math.Min(Math.Max(span.Length, minimumLength), maximumLength); | ||
|
||
// make sure start + length is smaller than snapshot.Length and start is >= 0 | ||
var start = Math.Max(0, Math.Min(span.Start, snapshot.Length - length)); | ||
|
||
// make sure length is smaller than snapshot.Length which can happen if start == 0 | ||
return new SnapshotSpan(snapshot, start, Math.Min(start + length, snapshot.Length) - start); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no concept of 'enabled' or not. inline diagnostics aren't enabled/disabled depending on if we're using lsp diagnostics or not.