Skip to content

Commit 7d813ff

Browse files
committed
bug fix
1 parent 5ac6293 commit 7d813ff

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/main/java/com/tang/intellij/lua/codeInsight/highlighting/LuaHighlightUsagesHandlerFactory.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,8 @@ private class LoopHandler(editor: Editor, psiFile: PsiFile, val psi:PsiElement,
9898
override fun getTargets() = arrayListOf(psi)
9999

100100
override fun computeUsages(list: MutableList<PsiElement>?) {
101-
addOccurrence(loop.firstChild)
102-
when (loop) {
103-
is LuaRepeatStat -> { val until = loop.until; if (until != null) addOccurrence(until) }
104-
else -> {
105-
val end = loop.node.findChildByType(LuaTypes.END)
106-
end?.let { addOccurrence(end.psi) }
107-
}
108-
}
101+
loop.head?.let { addOccurrence(it) }
102+
loop.end?.let { addOccurrence(it) }
109103
addOccurrence(psi)
110104
}
111105

src/main/java/com/tang/intellij/lua/psi/LuaLoop.java renamed to src/main/java/com/tang/intellij/lua/psi/LuaLoop.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,31 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.tang.intellij.lua.psi;
17+
package com.tang.intellij.lua.psi
18+
19+
import com.intellij.psi.PsiElement
1820

1921
/**
2022
* for, repeat, while
2123
* Created by Administrator on 2017/6/28.
2224
*/
23-
public interface LuaLoop extends LuaPsiElement {
25+
interface LuaLoop : LuaPsiElement
26+
27+
28+
val LuaLoop.head:PsiElement? get() {
29+
val type = when (this) {
30+
is LuaWhileStat -> LuaTypes.WHILE
31+
is LuaRepeatStat -> LuaTypes.REPEAT
32+
else -> LuaTypes.FOR
33+
}
34+
val headNode = node.findChildByType(type)
35+
return headNode?.psi
36+
}
37+
val LuaLoop.end:PsiElement? get() {
38+
val type = when (this) {
39+
is LuaRepeatStat -> LuaTypes.UNTIL
40+
else -> LuaTypes.END
41+
}
42+
val endNode = node.findChildByType(type)
43+
return endNode?.psi
2444
}

0 commit comments

Comments
 (0)