plugin no wworks with .lyng.d files. hurray
This commit is contained in:
1 parent
fdc044d1e0
commit
aba0048a83
10 files changed
+400
-271
No files matched your search
@@ -2936,7 +2936,9 @@ class Compiler(
|
||||
returnType = returnTypeMini,
|
||||
body = bodyRange?.let { MiniBlock(it) },
|
||||
doc = declDocLocal,
|
||||
nameStart = nameStartPos
|
||||
nameStart = nameStartPos,
|
||||
receiver = receiverMini,
|
||||
isExtern = actualExtern
|
||||
)
|
||||
miniSink?.onFunDecl(node)
|
||||
}
|
||||
|
||||
@@ -58,11 +58,11 @@ object CompletionEngineLight {
|
||||
return completeSuspend(text, idx)
|
||||
}
|
||||
|
||||
suspend fun completeSuspend(text: String, caret: Int): List<CompletionItem> {
|
||||
suspend fun completeSuspend(text: String, caret: Int, providedMini: MiniScript? = null): List<CompletionItem> {
|
||||
// Ensure stdlib Obj*-defined docs (e.g., String methods) are initialized before registry lookup
|
||||
StdlibDocsBootstrap.ensure()
|
||||
val prefix = prefixAt(text, caret)
|
||||
val mini = buildMiniAst(text)
|
||||
val mini = providedMini ?: buildMiniAst(text)
|
||||
val imported: List<String> = DocLookupUtils.canonicalImportedModules(mini ?: return emptyList(), text)
|
||||
|
||||
val cap = 200
|
||||
|
||||
@@ -430,6 +430,7 @@ object DocLookupUtils {
|
||||
|
||||
fun scanLocalClassMembersFromText(mini: MiniScript, text: String, cls: MiniClassDecl): Map<String, ScannedSig> {
|
||||
val src = mini.range.start.source
|
||||
if (cls.nameStart.source != src) return emptyMap()
|
||||
val start = src.offsetOf(cls.bodyRange?.start ?: cls.range.start)
|
||||
val end = src.offsetOf(cls.bodyRange?.end ?: cls.range.end).coerceAtMost(text.length)
|
||||
if (start !in 0..end) return emptyMap()
|
||||
|
||||
@@ -273,4 +273,42 @@ class MiniAstTest {
|
||||
assertNotNull(e1)
|
||||
assertEquals("Doc6", e1.doc?.summary)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun miniAst_captures_user_sample_extern_doc() = runTest {
|
||||
val code = """
|
||||
/*
|
||||
the plugin testing .d sample
|
||||
*/
|
||||
extern fun test(value: Int): String
|
||||
""".trimIndent()
|
||||
val (_, sink) = compileWithMini(code)
|
||||
val mini = sink.build()
|
||||
assertNotNull(mini)
|
||||
val test = mini.declarations.filterIsInstance<MiniFunDecl>().firstOrNull { it.name == "test" }
|
||||
assertNotNull(test, "function 'test' should be captured")
|
||||
assertNotNull(test.doc, "doc for 'test' should be captured")
|
||||
assertEquals("the plugin testing .d sample", test.doc.summary)
|
||||
assertTrue(test.isExtern, "function 'test' should be extern")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolve_object_member_doc() = runTest {
|
||||
val code = """
|
||||
object O3 {
|
||||
/* doc for name */
|
||||
fun name() = "ozone"
|
||||
}
|
||||
""".trimIndent()
|
||||
val (_, sink) = compileWithMini(code)
|
||||
val mini = sink.build()
|
||||
assertNotNull(mini)
|
||||
|
||||
val imported = listOf("lyng.stdlib")
|
||||
// Simulate looking up O3.name
|
||||
val resolved = DocLookupUtils.resolveMemberWithInheritance(imported, "O3", "name", mini)
|
||||
assertNotNull(resolved)
|
||||
assertEquals("O3", resolved.first)
|
||||
assertEquals("doc for name", resolved.second.doc?.summary)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user