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

Don't show enum completions in new keyword context #20304

Merged
merged 1 commit into from
May 6, 2024

Conversation

rochala
Copy link
Contributor

@rochala rochala commented Apr 30, 2024

Fixes #19968
Kudos to @aherlihy and @nmcb for solving this together during a spree. I hope you had fun :D

@rochala rochala requested a review from kasiaMarek April 30, 2024 19:55
Copy link
Contributor

@kasiaMarek kasiaMarek left a comment

Choose a reason for hiding this comment

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

Otherwise lgtm

@@ -535,7 +532,7 @@ class Completions(
val query = completionPos.query
if completionMode.is(Mode.Scope) && query.nonEmpty then
val visitor = new CompilerSearchVisitor(sym =>
if Completion.isValidCompletionSymbol(sym, completionMode) &&
if Completion.isValidCompletionSymbol(sym, completionMode, isNew) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like maybe it would be a bit more natural to pass untyped tree here instead of isNew, since isNew is always calculated via the same function and can be postponed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would compute it on every isValidSymbol call, and it can be hundreds of calls, tho ? I did especially this way because we don't recompute this check

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is still duplication, as we're first filtering them in the compiler completions, and then again in Completions.scala from presentation compiler, but I think that this check is fast enough, that eliminating completions before searching for apply / constructors in withCompletionSuffix is completely worth it.

@rochala rochala merged commit c5f2064 into scala:main May 6, 2024
19 checks passed
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request May 6, 2024
@tgodzik tgodzik added the area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools label May 8, 2024
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
WojciechMazur pushed a commit that referenced this pull request Jul 6, 2024
WojciechMazur added a commit that referenced this pull request Jul 6, 2024
…21093)

Backports #20304 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum completions in new context should be filtered
4 participants