-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
EmmyLua-Common/src/main/ext/com/tang/intellij/lua/psi/LuaConst.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tang.intellij.lua.psi | ||
|
||
import com.tang.intellij.lua.Constants | ||
import com.tang.intellij.lua.search.SearchContext | ||
import com.tang.intellij.lua.stubs.index.LuaConstIndex | ||
|
||
object LuaConst { | ||
|
||
fun isConst(className: String, fieldName: String, context: SearchContext): Boolean{ | ||
return LuaConstIndex.instance.isConst(className, fieldName, context) | ||
} | ||
|
||
fun isConst(name: String, context: SearchContext): Boolean{ | ||
return LuaConstIndex.instance.isConst(Constants.WORD_G, name, context) | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
EmmyLua-Common/src/main/ext/com/tang/intellij/lua/stubs/index/LuaConstIndex.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.tang.intellij.lua.stubs.index | ||
|
||
import com.intellij.util.Processor | ||
import com.intellij.util.containers.ContainerUtil | ||
import com.tang.intellij.lua.comment.psi.LuaDocTagField | ||
import com.tang.intellij.lua.psi.LuaClassMember | ||
import com.tang.intellij.lua.psi.LuaClassMethod | ||
import com.tang.intellij.lua.psi.LuaPsiElement | ||
import com.tang.intellij.lua.psi.LuaTableField | ||
import com.tang.intellij.lua.search.SearchContext | ||
import com.tang.intellij.lua.stubs.StubKeys | ||
import com.tang.intellij.lua.ty.ITyClass | ||
import com.tang.intellij.lua.ty.TyParameter | ||
|
||
class LuaConstIndex: StubIndex<Int, LuaPsiElement>() { | ||
override fun getKey() = StubKeys.CONST | ||
|
||
fun isConst(className: String, fieldName: String, context: SearchContext): Boolean { | ||
val key = "$className*$fieldName" | ||
return LuaClassMemberIndex.instance.get(key.hashCode(), context.project, context.scope).size == 1 | ||
} | ||
|
||
companion object { | ||
val instance = LuaConstIndex() | ||
|
||
/*fun indexStub(indexSink: IndexSink, className: String, memberName: String) { | ||
indexSink.occurrence(StubKeys.CLASS_MEMBER, className.hashCode()) | ||
indexSink.occurrence(StubKeys.CLASS_MEMBER, "$className*$memberName".hashCode()) | ||
}*/ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters