Skip to content

Commit

Permalink
Bring back old completions as a deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
Kordyjan committed Mar 28, 2024
1 parent c251f36 commit 845ee0c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ReplDriver(settings: Array[String],
/* complete = */ false // if true adds space when completing
)
}
val comps = completions(line.cursor, line.line, state)
val comps = completionsWithSignatures(line.cursor, line.line, state)
candidates.addAll(comps.map(_.label).distinct.map(makeCandidate).asJava)
val lineWord = line.word()
comps.filter(c => c.label == lineWord && c.symbols.nonEmpty) match
Expand Down Expand Up @@ -255,8 +255,22 @@ class ReplDriver(settings: Array[String],
else
label

@deprecated("Use completionsWithSignatures instead", "3.4.2")
protected final def completions(cursor: Int, expr: String, state0: State): List[Candidate] =
completionsWithSignatures(cursor, expr, state0).map: c =>
new Candidate(
/* value = */ c.label,
/* displ = */ stripBackTicks(c.label), // displayed value
/* group = */ null, // can be used to group completions together
/* descr = */ null, // TODO use for documentation?
/* suffix = */ null,
/* key = */ null,
/* complete = */ false // if true adds space when completing
)
end completions

/** Extract possible completions at the index of `cursor` in `expr` */
protected final def completions(cursor: Int, expr: String, state0: State): List[Completion] =
protected final def completionsWithSignatures(cursor: Int, expr: String, state0: State): List[Completion] =
if expr.startsWith(":") then
ParseResult.commands.collect {
case command if command._1.startsWith(expr) => Completion(command._1, "", List())
Expand All @@ -275,7 +289,7 @@ class ReplDriver(settings: Array[String],
try Completion.completions(srcPos)._2 catch case NonFatal(_) => Nil
}
.getOrElse(Nil)
end completions
end completionsWithSignatures

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

0 comments on commit 845ee0c

Please sign in to comment.