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

Missing completions when give a backticked prefix in various positions #14647

Open
ckipp01 opened this issue Mar 8, 2022 · 0 comments
Open

Comments

@ckipp01
Copy link
Member

ckipp01 commented Mar 8, 2022

Compiler version

3.2.0-RC1-bin-20220307-6dc591a-NIGHTLY-git-6dc591a

Explanation

As a follow-up to the work done in #14594 there are still a couple situations that still don't offer you a completions if your preface already includes an opened backtick.

Minimized code

The first case be illustrated by the following:

val `foo-bar` = 3

val x = `foo<TAB>

In this situation no completion is offered because the tree that is contained for the current position is Literal(Constant(null)). This seems to come from:

https://github.com/lampepfl/dotty/blob/808c66925daa518294e15419dffec9b7c1490848/compiler/src/dotty/tools/dotc/parsing/Parsers.scala#L386

The second situation is when this is a type instead of a term like so:

type Foo = `Lis<TAB>

The tree that is returned here is TypeDef(Foo,Ident(<error>))

One final example is:

val `foo-bar` = 3

`foo<TAB>

In this situation Interactive.patTo just returns the entire document.

Expectation

I'd expect the correct backticked completions to be offered in all 3 of these examples.

Potential solutions

The first way I tried to solve this was by adding specific cases for the first two in various places to catch those trees. For example in:

https://github.com/lampepfl/dotty/blob/808c66925daa518294e15419dffec9b7c1490848/compiler/src/dotty/tools/dotc/interactive/Completion.scala#L61-L79
and
https://github.com/lampepfl/dotty/blob/808c66925daa518294e15419dffec9b7c1490848/compiler/src/dotty/tools/dotc/interactive/Completion.scala#L85-L110
and
https://github.com/lampepfl/dotty/blob/808c66925daa518294e15419dffec9b7c1490848/compiler/src/dotty/tools/dotc/interactive/Completion.scala#L128-L137

While this works for those two situations it's quite a bit of code for very specific scenarios, and we're probably missing some as well that would also need to be added in. An alternative proposed by @bishabosha here is as follows:

We had a small discussion and it could be worth trying to make a new Token for an unfinished backticked identifier, which we can then make a valid tree for

@ckipp01 ckipp01 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 8, 2022
@ckipp01 ckipp01 changed the title Missing backticks for various completions Missing completions when give a backtick prefix in various positions Mar 8, 2022
@ckipp01 ckipp01 changed the title Missing completions when give a backtick prefix in various positions Missing completions when give a backticked prefix in various positions Mar 8, 2022
@prolativ prolativ added area:repl and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 9, 2022
@prolativ prolativ self-assigned this Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants