Skip to content

Commit

Permalink
Quick fix for the auto-complete with quotes (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
torcato authored Jan 25, 2024
1 parent 60f038d commit 322c9e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ class SqlCompilerService(maybeClassLoader: Option[ClassLoader] = None)(implicit
override def dotAutoComplete(source: String, environment: ProgramEnvironment, position: Pos): AutoCompleteResponse = {
logger.debug(s"dotAutocompleting at position: $position")
val analyzer = new SqlCodeUtils(source)
val idns = analyzer.getIdentifierUpTo(position)
// The editor removes the dot in the this completion event
// So we call the identifier with +1 column
val idns = analyzer.getIdentifierUpTo(Pos(position.line, position.column + 1))

val schemas = getSchemas(environment)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
)
)

val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 16))
// The calls to the dotAutoComplete have to point to the place before the dot
val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 15))
assert(
dotCompletion.completions.toSet === Set(
LetBindCompletion("icao", "character varying"),
Expand Down Expand Up @@ -147,8 +148,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
LetBindCompletion("airports", "table")
)
)

val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 18))
// The calls to the dotAutoComplete have to point to the place before the dot
val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 17))
assert(
dotCompletion.completions.toSet === Set(
LetBindCompletion("icao", "character varying"),
Expand Down Expand Up @@ -184,7 +185,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
)
)

val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 16))
// The calls to the dotAutoComplete have to point to the place before the dot
val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 15))
assert(
dotCompletion.completions.toSet === Set(
LetBindCompletion("icao", "character varying"),
Expand Down Expand Up @@ -215,7 +217,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val completion = compilerService.wordAutoComplete(t.q, environment, "", Pos(2, 9))
assert(completion.completions.isEmpty)

val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 18))
// The calls to the dotAutoComplete have to point to the place before the dot
val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(2, 17))
assert(dotCompletion.completions.isEmpty)
}

Expand All @@ -230,7 +233,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
assert(hover.completion.contains(TypeCompletion("example", "schema")))
val completion = compilerService.wordAutoComplete(t.q, environment, "exa", Pos(1, 18))
assert(completion.completions sameElements Array(LetBindCompletion("example", "schema")))
val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(1, 23))
// The calls to the dotAutoComplete have to point to the place before the dot
val dotCompletion = compilerService.dotAutoComplete(t.q, environment, Pos(1, 22))
assert(
dotCompletion.completions.toSet === Set(
LetBindCompletion("airports", "table"),
Expand Down

0 comments on commit 322c9e6

Please sign in to comment.