Skip to content

Commit ab06ff6

Browse files
committed
Bring back old completions as a deprecated method
1 parent 301c977 commit ab06ff6

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class ReplDriver(settings: Array[String],
163163
/* complete = */ false // if true adds space when completing
164164
)
165165
}
166-
val comps = completions(line.cursor, line.line, state)
166+
val comps = completionsWithSignatures(line.cursor, line.line, state)
167167
candidates.addAll(comps.map(_.label).distinct.map(makeCandidate).asJava)
168168
val lineWord = line.word()
169169
comps.filter(c => c.label == lineWord && c.symbols.nonEmpty) match
@@ -255,8 +255,22 @@ class ReplDriver(settings: Array[String],
255255
else
256256
label
257257

258+
@deprecated("Use completionsWithSignatures instead", "3.4.2")
259+
protected final def completions(cursor: Int, expr: String, state0: State): List[Candidate] =
260+
completionsWithSignatures(cursor, expr, state0).map: c =>
261+
new Candidate(
262+
/* value = */ c.label,
263+
/* displ = */ stripBackTicks(c.label), // displayed value
264+
/* group = */ null, // can be used to group completions together
265+
/* descr = */ null, // TODO use for documentation?
266+
/* suffix = */ null,
267+
/* key = */ null,
268+
/* complete = */ false // if true adds space when completing
269+
)
270+
end completions
271+
258272
/** Extract possible completions at the index of `cursor` in `expr` */
259-
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] =
260274
if expr.startsWith(":") then
261275
ParseResult.commands.collect {
262276
case command if command._1.startsWith(expr) => Completion(command._1, "", List())
@@ -275,7 +289,7 @@ class ReplDriver(settings: Array[String],
275289
try Completion.completions(srcPos)._2 catch case NonFatal(_) => Nil
276290
}
277291
.getOrElse(Nil)
278-
end completions
292+
end completionsWithSignatures
279293

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

compiler/test/dotty/tools/repl/ReplTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
4242

4343
/** Returns the `(<instance completions>, <companion completions>)`*/
4444
def tabComplete(src: String)(implicit state: State): List[String] =
45-
completions(src.length, src, state).map(_.label).sorted.distinct
45+
completionsWithSignatures(src.length, src, state).map(_.label).sorted.distinct
4646

4747
extension [A](state: State)
4848
infix def andThen(op: State ?=> A): A = op(using state)

0 commit comments

Comments
 (0)