-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stabilise returned completions by improving deduplication + extra completions for constructors #19976
Conversation
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala
Show resolved
Hide resolved
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala
Show resolved
Hide resolved
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala
Outdated
Show resolved
Hide resolved
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionInterpolatorSuite.scala
Outdated
Show resolved
Hide resolved
"""|TestClass test.Wrapper (Module) | ||
|TestClass(x: Int): TestClass (Method) |
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.
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.
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.
presentation-compiler/src/main/dotty/tools/pc/completions/CompletionAffix.scala
Show resolved
Hide resolved
presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala
Outdated
Show resolved
Hide resolved
presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala
Outdated
Show resolved
Hide resolved
presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala
Outdated
Show resolved
Hide resolved
presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala
Outdated
Show resolved
Hide resolved
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala
Outdated
Show resolved
Hide resolved
presentation-compiler/src/main/dotty/tools/pc/completions/CompletionAffix.scala
Show resolved
Hide resolved
presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala
Outdated
Show resolved
Hide resolved
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.
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
).
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.
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.
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.
lgtm
"""|fooBar(n: Int): Int | ||
|fooBar: List[Int] |
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.
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.
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.
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.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.