Skip to content

Commit 196470d

Browse files
committed
初步完成外部插件扩展
1 parent bdb400a commit 196470d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

EmmyLua-LS/src/main/kotlin/com/tang/vscode/LuaTextDocumentService.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
222222
}
223223
} else if (arr.size == 3 && arr[0] == "extendApi") {
224224
val doc = documentProvider.generateExtendDoc(arr[1], arr[2])
225-
if(doc != null) {
225+
if (doc != null) {
226226
val content = MarkupContent()
227227
content.kind = "markdown"
228228
content.value = doc
@@ -303,6 +303,16 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
303303
val target = TargetElementUtil.findTarget(psiFile, i)
304304
val resolve = target?.reference?.resolve()
305305
if (resolve != null) {
306+
if (resolve is ExtendApiBase) {
307+
val locationText = resolve.getLocation();
308+
val locationList = locationText.split('#')
309+
if (locationList.size == 2) {
310+
val line = locationList[1].toInt()
311+
list.add(Location(locationList[0], Range(Position(line - 1, 0), Position(line, 0))))
312+
}
313+
314+
return@withPsiFile
315+
}
306316
val sourceFile = resolve.containingFile?.virtualFile as? LuaFile
307317
val range = resolve.nameRange
308318
if (range != null && sourceFile != null)

EmmyLua-LS/src/main/kotlin/com/tang/vscode/extendApi/ExtendApiService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object ExtendApiService {
4646
for (luaMethod in luaClass.methods) {
4747
val paramList = mutableListOf<LuaParamInfo>()
4848
for (param in luaMethod.params) {
49-
paramList.add(LuaParamInfo(param, Ty.create("any")))
49+
paramList.add(LuaParamInfo(param.name, Ty.create(param.typeName)))
5050
}
5151

5252
val retType = Ty.create(luaMethod.returnTypeName)

EmmyLua-LS/src/main/kotlin/com/tang/vscode/extendApi/ExtendClassApi.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ open class LuaApiBase(val name: String = "", val comment: String = "", val locat
44

55
data class LuaApiField(val typeName: String) : LuaApiBase()
66

7+
data class LuaParam(val name: String, val typeName: String)
8+
79
data class LuaApiMethod(
810
val returnTypeName: String,
911
val typeName: String,
1012
val isStatic: Boolean,
11-
val params: List<String>
13+
val params: List<LuaParam>
1214
) : LuaApiBase()
1315

1416
data class LuaApiClass(

0 commit comments

Comments
 (0)