Skip to content

Commit 49408b1

Browse files
committed
completions: do not complete package
There is an issue with completions for package in Metals. ```scala // code package one@@ // compeltions oneCURSOR ``` It seems there is no need in completions for Package at all.
1 parent 27a3f80 commit 49408b1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Diff for: compiler/src/dotty/tools/dotc/interactive/Completion.scala

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ object Completion:
211211
val completer = new Completer(mode, pos, untpdPath, matches0)
212212

213213
val result = adjustedPath match
214+
// Ignore `package foo@@` and `package foo.bar@@`
215+
case ((_: tpd.Select) | (_: tpd.Ident)):: (_ : tpd.PackageDef) :: _ => Map.empty
214216
// Ignore synthetic select from `This` because in code it was `Ident`
215217
// See example in dotty.tools.languageserver.CompletionTest.syntheticThis
216218
case tpd.Select(qual @ tpd.This(_), _) :: _ if qual.span.isSynthetic => completer.scopeCompletions

Diff for: presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

+14
Original file line numberDiff line numberDiff line change
@@ -1952,3 +1952,17 @@ class CompletionSuite extends BaseCompletionSuite:
19521952
"""TestEnum test
19531953
|""".stripMargin,
19541954
)
1955+
1956+
@Test def `packageIssueIdent` =
1957+
check(
1958+
"""package one@@
1959+
|""".stripMargin,
1960+
""
1961+
)
1962+
1963+
@Test def `packageIssueSelect` =
1964+
check(
1965+
"""package one.two@@
1966+
|""".stripMargin,
1967+
""
1968+
)

0 commit comments

Comments
 (0)