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

Stabilise returned completions by improving deduplication + extra completions for constructors #19976

Merged

Conversation

rochala
Copy link
Contributor

@rochala rochala commented Mar 18, 2024

This PR doesn't address all issues.
In the future we need to get rid of https://github.com/scala/scala3/compare/main...rochala:improved-deduplication-and-constructors-search?expand=1#diff-035851592480495dfdb20da6b615ec7dd77b3db70cda46aba56230d8cd690773R157-R167 as it is not working as intended. The future PR of shortened type printer refactor includes a proper way to split extension params.
CompletionValue.Interpolator should also be removed, and instead we should return workspace / completions as it is now hard to sort those completions.

Next refactor is reusing completion affix for other kinds of completions such as case completions, so prefix / suffix is handled in single place.

This PR will unblock fuzzy search in the compiler because of stabilizing returned completions.

@rochala rochala requested review from kasiaMarek and jkciesluk March 18, 2024 14:09
Comment on lines 53 to 54
"""|TestClass test.Wrapper (Module)
|TestClass(x: Int): TestClass (Method)
Copy link
Contributor

Choose a reason for hiding this comment

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

The module seems far less useful than method-constructor. I'd prefer we either not show the module if it's not explicitly defined by the user (rarely useful) or show it after TestClass(x: Int).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also thought about removing synthetic modules, but in the end they are still valid symbols in this context.

I like the idea of adding higher precedence for applies if there is synthetic companion.

@rochala rochala requested a review from kasiaMarek April 10, 2024 12:01
denot :: applyDenots
if shouldAddSnippet && isNew && hasNonSyntheticConstructor then
sym.info.member(nme.CONSTRUCTOR).allSymbols.map(_.asSingleDenotation)
.filter(_.symbol.isAccessibleFrom(denot.info))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that you're filtering using the correct scope here (also line 254).

Copy link
Contributor Author

@rochala rochala Apr 11, 2024

Choose a reason for hiding this comment

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

I've added a test that checks if private members are correctly filtered, and they are failing without this line

In my opinion we're filtering with correct scope, as denot.info is the type in a specific call site.

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.

lgtm

Comment on lines 1630 to 1631
"""|fooBar(n: Int): Int
|fooBar: List[Int]
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a follow up? I don't think that here the apply completion should exist here and if so it shouldn't be first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rebased the PR + fixed this, if you could give it one final look before we merge it.

@rochala rochala force-pushed the improved-deduplication-and-constructors-search branch from 04b3a77 to bc7c848 Compare April 12, 2024 09:10
@rochala rochala enabled auto-merge (squash) April 12, 2024 10:17
@rochala rochala merged commit 97313ed into scala:main Apr 12, 2024
17 checks passed
@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 added a commit that referenced this pull request Jul 5, 2024
…pletions for constructors (#19976)

This PR doesn't address all issues.
In the future we need to get rid of
https://github.com/scala/scala3/compare/main...rochala:improved-deduplication-and-constructors-search?expand=1#diff-035851592480495dfdb20da6b615ec7dd77b3db70cda46aba56230d8cd690773R157-R167
as it is not working as intended. The future PR of shortened type
printer refactor includes a proper way to split extension params.
`CompletionValue.Interpolator` should also be removed, and instead we
should return workspace / completions as it is now hard to sort those
completions.

Next refactor is reusing completion affix for other kinds of completions
such as case completions, so prefix / suffix is handled in single place.

This PR will unblock fuzzy search in the compiler because of stabilizing
returned completions.
[Cherry-picked 97313ed][modified]
WojciechMazur added a commit that referenced this pull request Jul 5, 2024
…pletions for constructors (#19976)

This PR doesn't address all issues.
In the future we need to get rid of
https://github.com/scala/scala3/compare/main...rochala:improved-deduplication-and-constructors-search?expand=1#diff-035851592480495dfdb20da6b615ec7dd77b3db70cda46aba56230d8cd690773R157-R167
as it is not working as intended. The future PR of shortened type
printer refactor includes a proper way to split extension params.
`CompletionValue.Interpolator` should also be removed, and instead we
should return workspace / completions as it is now hard to sort those
completions.

Next refactor is reusing completion affix for other kinds of completions
such as case completions, so prefix / suffix is handled in single place.

This PR will unblock fuzzy search in the compiler because of stabilizing
returned completions.
[Cherry-picked 97313ed][modified]
WojciechMazur added a commit that referenced this pull request Jul 5, 2024
… extra completions for constructors" to LTS (#21061)

Backports #19976 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.

4 participants