fix #88 fix #90 plugin with autocompletion

This commit is contained in:
sergeych committed 2025-12-08 03:28:27 +01:00
1 parent c35d684df1
commit 708b908415
9 files changed
+415 -27

No files matched your search

@@ -79,6 +79,51 @@ class CompletionEngineLightTest {
assertFalse(ns.contains("Path"))
}
@Test
fun stringLiteral_re_hasReturnTypeRegex() = runBlocking {
TestDocsBootstrap.ensure("lyng.stdlib")
val code = """
import lyng.stdlib
val s = "abc".<caret>
""".trimIndent()
val items = CompletionEngineLight.completeAtMarkerSuspend(code)
val reItem = items.firstOrNull { it.name == "re" }
assertTrue(reItem != null, "Expected to find 're' in String members, got: ${items.map { it.name }}")
// Type text should contain ": Regex"
assertTrue(reItem!!.typeText?.contains("Regex") == true, "Expected type text to contain 'Regex', was: ${reItem.typeText}")
}
@Test
fun stringLiteral_parenthesized_re_hasReturnTypeRegex() = runBlocking {
TestDocsBootstrap.ensure("lyng.stdlib")
val code = """
// No imports on purpose; stdlib must still be available
val s = ("abc").<caret>
""".trimIndent()
val items = CompletionEngineLight.completeAtMarkerSuspend(code)
val names = items.map { it.name }
assertTrue(names.isNotEmpty(), "Expected String members for parenthesized literal, got empty list")
val reItem = items.firstOrNull { it.name == "re" }
assertTrue(reItem != null, "Expected to find 're' for parenthesized String literal, got: $names")
assertTrue(reItem!!.typeText?.contains("Regex") == true, "Expected ': Regex' for re(), was: ${reItem.typeText}")
}
@Test
fun stringLiteral_noImports_stillHasStringMembers() = runBlocking {
TestDocsBootstrap.ensure("lyng.stdlib")
val code = """
val s = "super".<caret>
""".trimIndent()
val items = CompletionEngineLight.completeAtMarkerSuspend(code)
val names = items.map { it.name }
assertTrue(names.isNotEmpty(), "Expected String members without explicit imports, got empty list")
val reItem = items.firstOrNull { it.name == "re" }
assertTrue(reItem != null, "Expected to find 're' without explicit imports, got: $names")
assertTrue(reItem!!.typeText?.contains("Regex") == true, "Expected ': Regex' for re() without imports, was: ${reItem.typeText}")
}
@Test
fun shebang_and_fs_import_iterator_after_lines() = runBlocking {
TestDocsBootstrap.ensure("lyng.stdlib", "lyng.io.fs")