@@ -18,10 +18,7 @@ import com.tang.intellij.lua.project.LuaSettings
1818import com.tang.intellij.lua.psi.*
1919import com.tang.intellij.lua.reference.ReferencesSearch
2020import com.tang.intellij.lua.search.SearchContext
21- import com.tang.intellij.lua.ty.ITyFunction
22- import com.tang.intellij.lua.ty.findPerfectSignature
23- import com.tang.intellij.lua.ty.hasVarargs
24- import com.tang.intellij.lua.ty.process
21+ import com.tang.intellij.lua.ty.*
2522import com.tang.lsp.ILuaFile
2623import com.tang.lsp.getRangeInFile
2724import com.tang.lsp.nameRange
@@ -73,6 +70,7 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
7370 val notUse = mutableListOf<TextRange >()
7471 val paramHints = mutableListOf<RenderRange >()
7572 val localHints = mutableListOf<RenderRange >()
73+ val overrideHint = mutableListOf<RenderRange >()
7674
7775 // 认为所有local名称定义一开始都是未使用的
7876 val psiNotUse = mutableSetOf<PsiElement >()
@@ -130,6 +128,35 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
130128 o.acceptChildren(this )
131129 }
132130
131+ override fun visitClassMethodDef (o : LuaClassMethodDef ) {
132+ val context = SearchContext .get(o.project)
133+ val classType = o.guessClassType(context)
134+ if (classType != null ) {
135+ TyClass .processSuperClass(classType, context) { sup ->
136+ val id = o.classMethodName.id
137+ if (id != null ) {
138+ val member = sup.findMember(id.text, context)
139+ if (member != null ) {
140+ val funcBody = o.children.find { it is LuaFuncBody }
141+ if (funcBody is LuaFuncBody ) {
142+ var fchild = funcBody.firstChild
143+ while (fchild != funcBody.lastChild){
144+ if (fchild.text == " )" ){
145+ overrideHint.add(RenderRange (fchild.nameRange!! .toRange (file), null ))
146+ }
147+
148+ fchild = fchild.nextSibling
149+ }
150+ }
151+ }
152+ }
153+ true
154+ }
155+ }
156+
157+ o.acceptChildren(this )
158+ }
159+
133160 override fun visitNameDef (o : LuaNameDef ) {
134161 psiNotUse.add(o)
135162 }
@@ -308,6 +335,10 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
308335 if (localHints.isNotEmpty()) {
309336 all.add(Annotator (uri, localHints, AnnotatorType .LocalHint ))
310337 }
338+ if (overrideHint.isNotEmpty()){
339+ all.add(Annotator (uri, overrideHint, AnnotatorType .OverrideHint ))
340+ }
341+
311342 return all
312343 }
313344
@@ -921,25 +952,29 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
921952 val file = workspace.findFile(params.textDocument.uri)
922953 if (file is ILuaFile ) {
923954 file.didChange(params)
955+
956+ file.diagnose()
924957 val diagnosticsParams = PublishDiagnosticsParams (params.textDocument.uri, file.diagnostics)
925958 client?.publishDiagnostics(diagnosticsParams)
926959 }
927960 }
928961
929962 override fun references (params : ReferenceParams ): CompletableFuture <MutableList <out Location >> {
930- val list = mutableListOf<Location >()
931- withPsiFile(params.textDocument, params.position) { _, psiFile, pos ->
932- val element = TargetElementUtil .findTarget(psiFile, pos)
933- if (element != null ) {
934- val target = element.reference?.resolve() ? : element
935- val query = ReferencesSearch .search(target)
936- query.forEach { ref ->
937- val luaFile = ref.element.containingFile.virtualFile as LuaFile
938- list.add(Location (luaFile.uri.toString(), ref.getRangeInFile(luaFile)))
963+ return computeAsync {
964+ val list = mutableListOf<Location >()
965+ withPsiFile(params.textDocument, params.position) { _, psiFile, pos ->
966+ val element = TargetElementUtil .findTarget(psiFile, pos)
967+ if (element != null ) {
968+ val target = element.reference?.resolve() ? : element
969+ val query = ReferencesSearch .search(target)
970+ query.forEach { ref ->
971+ val luaFile = ref.element.containingFile.virtualFile as LuaFile
972+ list.add(Location (luaFile.uri.toString(), ref.getRangeInFile(luaFile)))
973+ }
939974 }
940975 }
976+ list
941977 }
942- return CompletableFuture .completedFuture(list)
943978 }
944979
945980 override fun foldingRange (params : FoldingRangeRequestParams ? ): CompletableFuture <MutableList <FoldingRange >> {
0 commit comments