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
REPL tab completion: skip deprecated things until double-tab #7869
Conversation
@som-snytt @retronym any thoughts on this, as I finish it up? |
@olafurpg do your presentation-compiler plans for Metals involve the REPL tab completion code, or do you (will you) be using other mechanisms to do completion? |
@SethTisue we currently use |
I would like to build on top of
It's normal that those completions are not covered by the |
Since we use
|
7ccb26a
to
f962eca
Compare
c8f7d81
to
9c7431f
Compare
so the changes I made here actually don't affect |
I found that sometimes but not always (not sure what determines it), the compiler creates a symbol for a companion object that doesn't exist and enters it as a member, which then turns up in tab completion. an example is scala 2.13.1> :power
scala 2.13.1> definitions.ScalaPackage.info.member(TermName("collection"))
res0: $r.intp.global.Symbol = package collection
scala 2.13.1> .info.member(TermName("DefaultMap"))
res1: $r.intp.global.Symbol = object DefaultMap
scala 2.13.1> res1.exists
res2: Boolean = false it would be better if we never offered these nonexistent companions as completions at all, but I kind of half-assed it in this PR by treating them as if they were deprecated: they are omitted on single-tab but then included again after double-tab. I accomplish that by checking |
We want to get completions for deprecated symbols since LSP has a Boolean to mark that a completion item is deprecated and it renders like this in vscode Ideally, we could call “completionsAt” with some configuration object to prevent regressions caused by changes like this. It’s not only Metals that uses this method, it’s also used by other tools like ScalaFiddle, Ammonite and more. |
9c7431f
to
433151c
Compare
@olafurpg okay, I'll keep that in mind if I decide to do any followup PRs in this area. this PR is safe. |
strike-thru rendering for deprecations is an old ask for REPL. |
after the JLine 3 upgrade lands, we'll have the option of offering completions in named groups. so one of the groups could be "deprecated" |
I see no reason to keep this open in the PR queue. I'll reopen it when the time comes |
Since 2.13.3, we have the version with the "(deprecated)" notices. Ideally, deprecated methods would be presented last, in their own group. That may yet happen under scala/bug#12272 |
motivation: it's a good change in general, I believe.
but also, this is motivated by all the new deprecations in 2.13. lots of people are trying out the new collections API; some of them will be doing it in the REPL; let's not confuse those people and make our API look bad by offering them deprecated completions
this is still a draft because although a lot of things work already, there are a couple commented-out test cases that fail that I'd like to attempt to fix as well (UPDATE: one of them was scala/bug#10152 rather than something I did wrong)also I might still decide to target 2.12.x instead. I can't addnahisDeprecated
toapi.Symbol
there, but that's nbd