diff --git a/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala b/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala index 4df2bdec9..6918e30e8 100644 --- a/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala +++ b/sql-client/src/main/scala/raw/client/sql/SqlCompilerService.scala @@ -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) diff --git a/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala b/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala index e68541373..4b3a32c5a 100644 --- a/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala +++ b/sql-client/src/test/scala/raw/client/sql/TestSqlCompilerServiceAirports.scala @@ -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"), @@ -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"), @@ -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"), @@ -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) } @@ -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"),