Skip to content

Commit 1f09fa4

Browse files
committed
处理有扩展类的时候继承找不到成员
1 parent ae31065 commit 1f09fa4

2 files changed

Lines changed: 36 additions & 9 deletions

File tree

EmmyLua-Common/src/main/ext/com/tang/intellij/lua/stubs/index/LuaClassMemberIndex.kt

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.tang.intellij.lua.comment.psi.LuaDocTagField
2222
import com.tang.intellij.lua.psi.LuaClassMember
2323
import com.tang.intellij.lua.psi.LuaClassMethod
2424
import com.tang.intellij.lua.psi.LuaTableField
25+
import com.tang.intellij.lua.psi.search.LuaShortNamesManager
2526
import com.tang.intellij.lua.search.SearchContext
2627
import com.tang.intellij.lua.stubs.StubKeys
2728
import com.tang.intellij.lua.ty.ITyClass
@@ -41,6 +42,25 @@ class LuaClassMemberIndex : StubIndex<Int, LuaClassMember>() {
4142
return ContainerUtil.process(all, processor)
4243
}
4344

45+
// fun processNonIndex(
46+
// className: String,
47+
// fieldName: String,
48+
// context: SearchContext,
49+
// processor: Processor<LuaClassMember>
50+
// ) {
51+
// val classDef = LuaShortNamesManager.getInstance(context.project).findClass(className, context)
52+
// if (classDef != null) {
53+
// val type = classDef.type
54+
// if (type is)
55+
// // from alias
56+
// type.lazyInit(context)
57+
// val member = LuaShortNamesManager.getInstance(context.project).findMember(type, fieldName, context)
58+
// if (member != null) {
59+
// processor.process(member)
60+
// }
61+
// }
62+
// }
63+
4464
fun process(
4565
className: String,
4666
fieldName: String,
@@ -66,9 +86,12 @@ class LuaClassMemberIndex : StubIndex<Int, LuaClassMember>() {
6686

6787
var founded = false
6888
TyClass.processSuperClass(type, context) { superType ->
69-
if(process(superType.className, fieldName, context, processor, false)){
70-
founded = true
71-
}
89+
LuaShortNamesManager.getInstance(context.project)
90+
.processAllMembers(superType, fieldName, context, Processor {
91+
processor.process(it)
92+
founded = true
93+
true
94+
})
7295
true
7396
}
7497
return founded
@@ -101,9 +124,9 @@ class LuaClassMemberIndex : StubIndex<Int, LuaClassMember>() {
101124
return false
102125

103126
val superClassName = type.superClassName
104-
if(superClassName != null) {
127+
if (superClassName != null) {
105128
val superClass = LuaClassIndex.find(superClassName, context)
106-
if(superClass is TyClass && !superClass.isInterface){
129+
if (superClass is TyClass && !superClass.isInterface) {
107130
return process(superClassName, fieldName, context, processor, true)
108131
}
109132
}
@@ -122,10 +145,12 @@ class LuaClassMemberIndex : StubIndex<Int, LuaClassMember>() {
122145
docField = it
123146
false
124147
}
148+
125149
is LuaTableField -> {
126150
tableField = it
127151
true
128152
}
153+
129154
else -> {
130155
if (perfect == null)
131156
perfect = it
@@ -142,16 +167,18 @@ class LuaClassMemberIndex : StubIndex<Int, LuaClassMember>() {
142167
var perfect: LuaClassMember? = null
143168
var docField: LuaDocTagField? = null
144169
var tableField: LuaTableField? = null
145-
processOrigin(type.className, fieldName, context, {
170+
processOrigin(type.className, fieldName, context, {
146171
when (it) {
147172
is LuaDocTagField -> {
148173
docField = it
149174
false
150175
}
176+
151177
is LuaTableField -> {
152178
tableField = it
153179
true
154180
}
181+
155182
else -> {
156183
if (perfect == null)
157184
perfect = it

EmmyLua-Common/src/main/java/com/tang/intellij/lua/ty/TyClass.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ abstract class TyClass(
177177

178178
return member?.guessType(context)
179179
}
180+
180181
LuaLiteralKind.String -> {
181182
var member = LuaClassMemberIndex.find(this, element.text, context)
182183
if (member == null) {
@@ -265,7 +266,7 @@ abstract class TyClass(
265266

266267
override fun getClassCallType(context: SearchContext): ITyFunction? {
267268
val ty = findMemberType("ctor", context)
268-
if(ty is ITyFunction){
269+
if (ty is ITyFunction) {
269270
return ty
270271
}
271272
return null
@@ -421,8 +422,7 @@ class TyPsiDocClass(tagClass: LuaDocTagClass) : TyClass(tagClass.name) {
421422
}
422423
if (tagClass.`interface` != null) {
423424
isInterface = true
424-
}
425-
else if(tagClass.enum != null){
425+
} else if (tagClass.enum != null) {
426426
isEnum = true
427427
}
428428

0 commit comments

Comments
 (0)