Stabilise returned completions by improving deduplication + extra completions for constructors#19976
Conversation
| """|TestClass test.Wrapper (Module) | ||
| |TestClass(x: Int): TestClass (Method) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
| denot :: applyDenots | ||
| if shouldAddSnippet && isNew && hasNonSyntheticConstructor then | ||
| sym.info.member(nme.CONSTRUCTOR).allSymbols.map(_.asSingleDenotation) | ||
| .filter(_.symbol.isAccessibleFrom(denot.info)) |
There was a problem hiding this comment.
I'm not sure that you're filtering using the correct scope here (also line 254).
There was a problem hiding this comment.
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.
| """|fooBar(n: Int): Int | ||
| |fooBar: List[Int] |
There was a problem hiding this comment.
Maybe a follow up? I don't think that here the apply completion should exist here and if so it shouldn't be first.
There was a problem hiding this comment.
I rebased the PR + fixed this, if you could give it one final look before we merge it.
04b3a77 to
bc7c848
Compare
…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]
…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]
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.Interpolatorshould 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.