Skip to content

Commit

Permalink
feat(refactor): add RenameLookupManagerListener to improve refactorin…
Browse files Browse the repository at this point in the history
…g support by adding post-action support and code completion #132
  • Loading branch information
phodal committed Apr 2, 2024
1 parent 2369148 commit 529b72d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/233/main/resources/META-INF/autodev-core.xml
Expand Up @@ -182,6 +182,11 @@
class="cc.unitmesh.devti.AutoDevUnloadListener"/>
</applicationListeners>

<!-- <projectListeners>-->
<!-- <listener class="cc.unitmesh.devti.practise.RenameLookupManagerListener"-->
<!-- topic="com.intellij.codeInsight.lookup.LookupManagerListener"/>-->
<!-- </projectListeners>-->

<extensions defaultExtensionNs="cc.unitmesh">
<autoDevIntention>
<className>cc.unitmesh.devti.intentions.action.CodeCompletionInlayIntention</className>
Expand Down
@@ -0,0 +1,27 @@
package cc.unitmesh.devti.practise

import com.intellij.codeInsight.lookup.Lookup
import com.intellij.codeInsight.lookup.LookupListener
import com.intellij.codeInsight.lookup.LookupManagerListener
import com.intellij.codeInsight.lookup.impl.LookupImpl
import com.intellij.openapi.project.Project

class RenameLookupManagerListener(val project: Project) : LookupManagerListener {
override fun activeLookupChanged(oldLookup: Lookup?, newLookup: Lookup?) {
val lookupImpl = newLookup as? LookupImpl ?: return

// val editor = lookupImpl.editor
// val activeTemplate = TemplateManager.getInstance(project).getActiveTemplate(editor) ?: return

val lookupOriginalStart = lookupImpl.lookupOriginalStart
val startOffset = if (lookupOriginalStart > -1) lookupOriginalStart else 0
val psiElement = lookupImpl.psiFile?.findElementAt(startOffset)
val element = psiElement ?: lookupImpl.psiElement

lookupImpl.addLookupListener(RenameLookupListener())
}
}

class RenameLookupListener : LookupListener {

}

0 comments on commit 529b72d

Please sign in to comment.