Skip to content

Commit d462007

Browse files
committed
apply review comments, remove unnecessary param
1 parent e333aaf commit d462007

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ object CompletionPos:
3737
adjustedPath: List[Tree]
3838
)(using Context): CompletionPos =
3939
val identEnd = adjustedPath match
40-
case (ident: Ident) :: _ if ident.toString.contains(Cursor.value) =>
41-
ident.span.end - Cursor.value.length
40+
case (refTree: RefTree) :: _ if refTree.name.toString.contains(Cursor.value) =>
41+
refTree.span.end - Cursor.value.length
4242
case _ => sourcePos.end
4343

4444
val query = Completion.completionPrefix(adjustedPath, sourcePos)

presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Completions(
106106
end includeSymbol
107107

108108
def completions(): (List[CompletionValue], SymbolSearch.Result) =
109-
val (advanced, exclusive) = advancedCompletions(path, completionPos.originalCursorPosition, completionPos)
109+
val (advanced, exclusive) = advancedCompletions(path, completionPos)
110110
val (all, result) =
111111
if exclusive then (advanced, SymbolSearch.Result.COMPLETE)
112112
else
@@ -264,9 +264,9 @@ class Completions(
264264
*/
265265
private def advancedCompletions(
266266
path: List[Tree],
267-
pos: SourcePosition,
268267
completionPos: CompletionPos
269268
): (List[CompletionValue], Boolean) =
269+
val pos = completionPos.originalCursorPosition
270270
lazy val rawPath = Paths
271271
.get(pos.source.path).nn
272272
lazy val rawFileName = rawPath
@@ -443,7 +443,7 @@ class Completions(
443443
// From Scala 3.1.3-RC3 (as far as I know), path contains
444444
// `Literal(Constant(null))` on head for an incomplete program, in this case, just ignore the head.
445445
case Literal(Constant(null)) :: tl =>
446-
advancedCompletions(tl, pos, completionPos)
446+
advancedCompletions(tl, completionPos)
447447

448448
case _ =>
449449
val args = NamedArgCompletions.contribute(

presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,15 @@ object InterpolatorCompletions:
228228
)(using ctx: Context, reportsContext: ReportContext): List[CompletionValue] =
229229
val litStartPos = lit.span.start
230230
val litEndPos = lit.span.end - Cursor.value.length()
231-
val nameStart = Spans.Span(completionPos.queryEnd - interpolator.name.size, completionPos.queryEnd)
232-
val nameRange = completionPos.originalCursorPosition.withSpan(nameStart).toLsp
233-
val hasClosingBrace: Boolean = text.charAt(completionPos.queryEnd) == '}'
234-
val hasOpeningBrace: Boolean = text.charAt(nameStart.start - 1) == '{'
231+
val position = completionPos.originalCursorPosition
232+
val span = position.span
233+
val nameStart =
234+
span.withStart(span.start - interpolator.name.size)
235+
val nameRange = position.withSpan(nameStart).toLsp
236+
val hasClosingBrace: Boolean = text.charAt(span.point) == '}'
237+
val hasOpeningBrace: Boolean = text.charAt(
238+
span.start - interpolator.name.size - 1
239+
) == '{'
235240

236241
def additionalEdits(): List[l.TextEdit] =
237242
val interpolatorEdit =

presentation-compiler/src/main/dotty/tools/pc/completions/ScalaCliCompletions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ScalaCliCompletions(
2626

2727
def contribute(dependency: String) =
2828
val completions = coursierComplete.complete(dependency)
29-
val (editStart, editEnd) = CoursierComplete.inferEditRange(pos.end, text)
29+
val (editStart, editEnd) = CoursierComplete.inferEditRange(pos.point, text)
3030
val editRange = pos.withStart(editStart).withEnd(editEnd).toLsp
3131
completions
3232
.map(insertText =>

0 commit comments

Comments
 (0)