Skip to content
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

Switch our copy/paste tagger over to using the same layering algorithm we use for normal classification. #72739

Merged
merged 39 commits into from
Mar 27, 2024

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner March 26, 2024 19:09
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 26, 2024
AddSyntacticSpansAsync,
AddSemanticSpansAsync,
AddEmbeddedSpansAsync,
/*unused*/ false).ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major switch is to call into this new helper to unify on this logic.

@@ -68,166 +69,198 @@ internal sealed class TotalClassificationTaggerProvider(

return new TotalClassificationAggregateTagger(syntacticTagger, semanticTagger, embeddedTagger);
}
}

internal sealed class TotalClassificationAggregateTagger(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't move this into its own file because i wanted the diff to be clear.

span => classificationService.AddSemanticClassificationsAsync(document, span, options, tempClassifiedSpans, cancellationToken)).ConfigureAwait(false);
}

async ValueTask AddEmbeddedSpansAsync(NormalizedSnapshotSpanCollection stringLiteralSpans, SegmentedList<ITagSpan<IClassificationTag>> result, bool _)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 It seems strange to have the TArg parameter here but not actually use it to make the method static

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enh. the amount of data needed to pass in in all these cases was a lot (something like 6 parameters). My pref is to keep things simple. The mainline classification case uses statics for efficiency. But this is for copy/paste, which is a user invoked operation, so 3 extra allocs is fine :)

String("\""),
Punctuation.CloseParen,
Punctuation.Semicolon,
Keyword("var"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keyword("var"),

out of curiosity, why is Keyword("var") duplicated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so currently we do not dedupe between tags created by both the underlying syntactic tagger (innacurate, but fast) and the semantic tagger (accurate, but slow). I will do a followup to do that on top of this PR.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@iMobCoding
Copy link

What is the expected VS version this merge will land on? Checked all previews of the 17.11 and didn't see this one

@stamminator
Copy link

I'm running 17.11.4 stable and the CommentsPlus VS 2022 extension which depends on this fix still isn't working. Do we know which version will have the fix? And if so, do we need to do anything special for it to work with older versions of .NET (like installing Microsoft.Net.Compilers.Toolset in our projects), or will it work automatically regardless of .NET version so long as Visual Studio is up-to-date?

@CyrusNajmabadi
Copy link
Member Author

The fix went into 17.11 preview 1

@IeuanWalker
Copy link

@CyrusNajmabadi im on 17.12.0 Preview 2, and can confirm this hasnt fixed the issue with CommentsPlus

@CyrusNajmabadi
Copy link
Member Author

I don't know what CommentsPlus is. They may need to do something on their end. Our impl should be following the contract of both IViewTaggerProvider and the IAccurateTagger

@IeuanWalker
Copy link

@CyrusNajmabadi Ok thanks.

The issue was raised a while ago and a Microsoft employee response was that this PR would fix the issue -
https://developercommunity.visualstudio.com/t/TagAggregatorGetTags-returns-no-resul/10622997#T-N10623786-N10625045

@CyrusNajmabadi
Copy link
Member Author

Casting the aggregator created by IBufferTagAggregatorFactoryService.CreateTagAggregator() to IAccurateTagAggregator and then calling IAccurateTagAggregator.GetAllTags() does not change overall behavior needed for this tagger to work. No comment tags are ever returned for C# or VB files.

This should work now. Do you own the extension that is not working? If so, I can try to work with you to figure out what is going wrong.

@stamminator
Copy link

stamminator commented Sep 19, 2024

@CyrusNajmabadi The owner of CommentsPlus is @mhoumann. It's not an urgent issue by any means, but it's a real "nice to have". Any help would be appreciated.

@iMobCoding
Copy link

There are more plugins affected by this issue, not just ComentPlus. I am using Supercharger:
https://marketplace.visualstudio.com/items?itemName=MichaelKissBG8.Supercharger22

And it stopped working at the same time as all the others. They have horizontal line, colorful comments and many many more things I rely on and it all stopped with this change

@CyrusNajmabadi
Copy link
Member Author

There are more plugins affected by this issue, not just ComentPlus. I am using Supercharger:
https://marketplace.visualstudio.com/items?itemName=MichaelKissBG8.Supercharger22

And it stopped working at the same time as all the others. They have horizontal line, colorful comments and many many more things I rely on and it all stopped with this change

It would be useful to know why these plugins are but working. The core issue reported on vscomunity (mentioned above) was resolved.

Note: using IBufferTaggerProvider and IAccurateTagger is slow and not recommended.

These plugins should use IViewTaggerProvide and a normal ITagger.

This is blazing fast and is the recommended way for doing anything special with the code the user is looking at.

1 similar comment
@CyrusNajmabadi
Copy link
Member Author

There are more plugins affected by this issue, not just ComentPlus. I am using Supercharger:
https://marketplace.visualstudio.com/items?itemName=MichaelKissBG8.Supercharger22

And it stopped working at the same time as all the others. They have horizontal line, colorful comments and many many more things I rely on and it all stopped with this change

It would be useful to know why these plugins are but working. The core issue reported on vscomunity (mentioned above) was resolved.

Note: using IBufferTaggerProvider and IAccurateTagger is slow and not recommended.

These plugins should use IViewTaggerProvide and a normal ITagger.

This is blazing fast and is the recommended way for doing anything special with the code the user is looking at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants