Skip to content

Commit df11064

Browse files
committed
Apply review suggestions
1 parent 906beb4 commit df11064

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,15 @@ case class CompletionPos(
2525
sourceUri: URI
2626
):
2727
def queryEnd: Int = originalCursorPosition.point
28-
def point: Int = originalCursorPosition.point
2928
def stripSuffixEditRange: l.Range = new l.Range(originalCursorPosition.offsetToPos(queryStart), originalCursorPosition.offsetToPos(identEnd))
3029
def toEditRange: l.Range = originalCursorPosition.withStart(queryStart).withEnd(originalCursorPosition.point).toLsp
31-
def toSourcePosition: SourcePosition = originalCursorPosition.withSpan(Span(queryStart, queryEnd, point))
30+
def toSourcePosition: SourcePosition = originalCursorPosition.withSpan(Span(queryStart, queryEnd, queryEnd))
3231

3332
object CompletionPos:
3433

35-
def infer(
36-
sourcePosition: SourcePosition,
37-
offsetParams: OffsetParams,
38-
adjustedPath: List[Tree]
39-
)(using Context): CompletionPos =
40-
infer(sourcePosition, offsetParams.uri().nn, String(sourcePosition.source.content()), adjustedPath)
41-
4234
def infer(
4335
sourcePos: SourcePosition,
44-
uri: URI,
45-
text: String,
36+
offsetParams: OffsetParams,
4637
adjustedPath: List[Tree]
4738
)(using Context): CompletionPos =
4839
val identEnd = adjustedPath match
@@ -53,8 +44,7 @@ object CompletionPos:
5344
val query = Completion.completionPrefix(adjustedPath, sourcePos)
5445
val start = sourcePos.end - query.length()
5546

56-
CompletionPos(start, identEnd, query.nn, sourcePos, uri)
57-
end infer
47+
CompletionPos(start, identEnd, query.nn, sourcePos, offsetParams.uri.nn)
5848

5949
/**
6050
* Infer the indentation by counting the number of spaces in the given line.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Completions(
8383
else
8484
val realNameLength = sym.decodedName.length() - Cursor.value.length()
8585
sym.source == completionPos.originalCursorPosition.source &&
86-
sym.span.start + realNameLength == completionPos.point
86+
sym.span.start + realNameLength == completionPos.queryEnd
8787

8888
val generalExclude =
8989
isUninterestingSymbol(sym) ||

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ 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.point - interpolator.name.size, completionPos.queryEnd)
231+
val nameStart = Spans.Span(completionPos.queryEnd - interpolator.name.size, completionPos.queryEnd)
232232
val nameRange = completionPos.originalCursorPosition.withSpan(nameStart).toLsp
233-
val hasClosingBrace: Boolean = text.charAt(completionPos.point) == '}'
233+
val hasClosingBrace: Boolean = text.charAt(completionPos.queryEnd) == '}'
234234
val hasOpeningBrace: Boolean = text.charAt(nameStart.start - 1) == '{'
235235

236236
def additionalEdits(): List[l.TextEdit] =

0 commit comments

Comments
 (0)