Skip to content

Commit 6adf44c

Browse files
committed
highlight @return
1 parent 454a4bf commit 6adf44c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerBase
2020
import com.intellij.openapi.editor.Editor
2121
import com.intellij.psi.PsiElement
2222
import com.intellij.psi.PsiFile
23+
import com.intellij.psi.util.PsiTreeUtil
2324
import com.intellij.util.Consumer
25+
import com.tang.intellij.lua.comment.psi.LuaDocReturnDef
26+
import com.tang.intellij.lua.comment.psi.api.LuaComment
2427
import com.tang.intellij.lua.psi.*
2528

2629
import java.util.Collections
@@ -29,7 +32,7 @@ import java.util.Collections
2932
3033
* Created by tangzx on 2017/3/18.
3134
*/
32-
class LuaHighlightExitPointsHandler internal constructor(editor: Editor, file: PsiFile, private val target: LuaReturnStat, private val funcBody: LuaFuncBody?) : HighlightUsagesHandlerBase<PsiElement>(editor, file) {
35+
class LuaHighlightExitPointsHandler internal constructor(editor: Editor, file: PsiFile, private val target: LuaReturnStat, private val funcBody: LuaFuncBody) : HighlightUsagesHandlerBase<PsiElement>(editor, file) {
3336

3437
override fun getTargets(): List<PsiElement> {
3538
return listOf<PsiElement>(target)
@@ -40,7 +43,7 @@ class LuaHighlightExitPointsHandler internal constructor(editor: Editor, file: P
4043
}
4144

4245
override fun computeUsages(list: List<PsiElement>) {
43-
funcBody?.acceptChildren(object : LuaVisitor() {
46+
funcBody.acceptChildren(object : LuaVisitor() {
4447
override fun visitReturnStat(o: LuaReturnStat) {
4548
addOccurrence(o)
4649
}
@@ -57,5 +60,13 @@ class LuaHighlightExitPointsHandler internal constructor(editor: Editor, file: P
5760
o.acceptChildren(this)
5861
}
5962
})
63+
64+
val parent = funcBody.parent
65+
if (parent is LuaCommentOwner) {
66+
val comment = parent.comment
67+
val returnDef = PsiTreeUtil.findChildOfType(comment, LuaDocReturnDef::class.java)
68+
if (returnDef != null)
69+
addOccurrence(returnDef)
70+
}
6071
}
6172
}

0 commit comments

Comments
 (0)