Skip to content

Commit 9960977

Browse files
committed
Bring back old completions as a deprecated method in the LTS
1 parent 19d673b commit 9960977

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Diff for: compiler/src/dotty/tools/repl/ReplDriver.scala

+18-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class ReplDriver(settings: Array[String],
162162
/* complete = */ false // if true adds space when completing
163163
)
164164
}
165-
val comps = completions(line.cursor, line.line, state)
165+
val comps = completionsWithSignatures(line.cursor, line.line, state)
166166
candidates.addAll(comps.map(_.label).distinct.map(makeCandidate).asJava)
167167
val lineWord = line.word()
168168
comps.filter(c => c.label == lineWord && c.symbols.nonEmpty) match
@@ -254,8 +254,23 @@ class ReplDriver(settings: Array[String],
254254
else
255255
label
256256

257+
@deprecated("Use completionsWithSignatures instead", "3.3.4")
258+
protected final def completions(cursor: Int, expr: String, state0: State): List[Candidate] =
259+
completionsWithSignatures(cursor, expr, state0).map: c =>
260+
new Candidate(
261+
/* value = */ c.label,
262+
/* displ = */ stripBackTicks(c.label), // displayed value
263+
/* group = */ null, // can be used to group completions together
264+
/* descr = */ null, // TODO use for documentation?
265+
/* suffix = */ null,
266+
/* key = */ null,
267+
/* complete = */ false // if true adds space when completing
268+
)
269+
end completions
270+
271+
257272
/** Extract possible completions at the index of `cursor` in `expr` */
258-
protected final def completions(cursor: Int, expr: String, state0: State): List[Completion] =
273+
protected final def completionsWithSignatures(cursor: Int, expr: String, state0: State): List[Completion] =
259274
if expr.startsWith(":") then
260275
ParseResult.commands.collect {
261276
case command if command._1.startsWith(expr) => Completion(command._1, "", List())
@@ -274,7 +289,7 @@ class ReplDriver(settings: Array[String],
274289
try Completion.completions(srcPos)._2 catch case NonFatal(_) => Nil
275290
}
276291
.getOrElse(Nil)
277-
end completions
292+
end completionsWithSignatures
278293

279294
protected def interpret(res: ParseResult, quiet: Boolean = false)(using state: State): State = {
280295
res match {

Diff for: compiler/test/dotty/tools/repl/TabcompleteTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TabcompleteTests extends ReplTest {
1010

1111
/** Returns the `(<instance completions>, <companion completions>)`*/
1212
private def tabComplete(src: String)(implicit state: State): List[String] =
13-
completions(src.length, src, state).map(_.value).sorted
13+
completionsWithSignatures(src.length, src, state).map(_.label).sorted.distinct
1414

1515
@Test def tabCompleteList = initially {
1616
val comp = tabComplete("List.r")

0 commit comments

Comments
 (0)