Skip to content

Commit 4733fbf

Browse files
committed
Remove unnecessary cases, fix CI, remove never used files
1 parent 86bf70d commit 4733fbf

File tree

5 files changed

+123
-304
lines changed

5 files changed

+123
-304
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ object Completion:
9090

9191
val completionSymbolKind: Mode =
9292
path match
93-
case untpd.Ident(_) :: (_: untpd.ImportSelector) :: _ => Mode.ImportOrExport // import scala.@@
94-
case untpd.Ident(_) :: (_: untpd.ImportOrExport) :: _ => Mode.ImportOrExport | Mode.Scope // import TrieMa@@
93+
case GenericImportSelector(_) => Mode.ImportOrExport // import scala.@@
94+
case GenericImportOrExport(_) => Mode.ImportOrExport | Mode.Scope // import TrieMa@@
9595

9696
case untpd.Literal(Constants.Constant(_: String)) :: _ => Mode.Term | Mode.Scope // literal completions
9797
case (ref: untpd.RefTree) :: _ =>
@@ -132,7 +132,7 @@ object Completion:
132132
i + 1
133133

134134
path match
135-
case untpd.Ident(_) :: (sel: untpd.ImportSelector) :: _ if !sel.isGiven =>
135+
case GenericImportSelector(sel) if !sel.isGiven =>
136136
if sel.isWildcard then pos.source.content()(pos.point - 1).toString
137137
else completionPrefix(sel.imported :: Nil, pos)
138138

@@ -152,6 +152,20 @@ object Completion:
152152

153153
end completionPrefix
154154

155+
private object GenericImportSelector:
156+
def unapply(path: List[untpd.Tree]): Option[untpd.ImportSelector] =
157+
path match
158+
case untpd.Ident(_) :: (sel: untpd.ImportSelector) :: _ => Some(sel)
159+
case (sel: untpd.ImportSelector) :: _ => Some(sel)
160+
case _ => None
161+
162+
private object GenericImportOrExport:
163+
def unapply(path: List[untpd.Tree]): Option[untpd.ImportOrExport] =
164+
path match
165+
case untpd.Ident(_) :: (importOrExport: untpd.ImportOrExport) :: _ => Some(importOrExport)
166+
case (importOrExport: untpd.ImportOrExport) :: _ => Some(importOrExport)
167+
case _ => None
168+
155169
/** Inspect `path` to determine the offset where the completion result should be inserted. */
156170
def completionOffset(untpdPath: List[untpd.Tree]): Int =
157171
untpdPath match

compiler/test/dotty/tools/dotc/interactive/CustomCompletion.scala

Lines changed: 0 additions & 130 deletions
This file was deleted.

compiler/test/dotty/tools/dotc/interactive/CustomCompletionTests.scala

Lines changed: 0 additions & 171 deletions
This file was deleted.

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,4 +1679,20 @@ class CompletionTest {
16791679
("Numeric", Field, "Numeric"),
16801680
("Numeric", Field, "scala.math.Numeric")
16811681
))
1682+
1683+
@Test def `empty-import-selector`: Unit =
1684+
code"""|import java.$m1
1685+
|"""
1686+
.completion(results => {
1687+
val interestingResults = results.filter(_.getLabel().startsWith("util"))
1688+
assertEquals(1, interestingResults.size)
1689+
})
1690+
1691+
@Test def `empty-export-selector`: Unit =
1692+
code"""|export java.$m1
1693+
|"""
1694+
.completion(results => {
1695+
val interestingResults = results.filter(_.getLabel().startsWith("util"))
1696+
assertEquals(1, interestingResults.size)
1697+
})
16821698
}

0 commit comments

Comments
 (0)