generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refactor): add RenameLookupManagerListener to improve refactorin…
…g support by adding post-action support and code completion #132
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/cc/unitmesh/devti/practise/RenameLookupManagerListener.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,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 { | ||
|
||
} |