Skip to content

Commit 0ce7e54

Browse files
author
ale
committed
支持 根据字符串推导 扩展类型
1 parent 4143c15 commit 0ce7e54

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

gen/com/tang/intellij/lua/psi/impl/LuaCallExprImpl.java

Lines changed: 32 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/tang/intellij/lua/psi/LuaPsiImplUtil.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,27 @@ fun getNameExprStringValue(valueExpr: PsiElement): String {
387387
return "";
388388
}
389389

390-
fun newType(typeName: String): ITy {
391-
return TyLazyClass(typeName);
390+
fun newType(typeName: String, ty: ITy, sourceStr: String, targetStr: String): ITy {
391+
if (ty is TyArray) {
392+
val t = typeName.substringBefore('[').trim()
393+
val ty = TyLazyClass(t)
394+
return TyArray(ty);
395+
}
396+
else if(ty is TySerializedGeneric){
397+
val list = mutableListOf<ITy>();
398+
ty.params.forEach {
399+
var name = it.displayName
400+
if(name.contains(sourceStr))
401+
{
402+
name = name.replace(sourceStr, targetStr)
403+
}
404+
list.add(newType(name, it, sourceStr, targetStr))
405+
}
406+
return TySerializedGeneric(list.toTypedArray(), ty.base)
407+
}
408+
else {
409+
return TyLazyClass(typeName);
410+
}
392411
}
393412

394413
fun guessParentType(indexExpr: LuaIndexExpr, context: SearchContext): ITy {

0 commit comments

Comments
 (0)