mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MethodChainHintsAction: convert to AnAction
This commit is contained in:
@@ -1160,9 +1160,5 @@
|
||||
<className>com.intellij.codeInsight.intention.impl.SplitFilterAction</className>
|
||||
<category>Java/Streams</category>
|
||||
</intentionAction>
|
||||
<intentionAction>
|
||||
<className>com.intellij.codeInsight.hints.MethodChainHintTurningAction</className>
|
||||
<category>Other</category>
|
||||
</intentionAction>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -2,39 +2,17 @@
|
||||
package com.intellij.codeInsight.hints
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightSettings
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction
|
||||
import com.intellij.openapi.application.ApplicationBundle
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethodCallExpression
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.ToggleAction
|
||||
|
||||
class MethodChainHintTurningAction : PsiElementBaseIntentionAction() {
|
||||
override fun getFamilyName() = "Turn method chain hints"
|
||||
class MethodChainHintTurningAction : ToggleAction() {
|
||||
override fun isSelected(e: AnActionEvent?): Boolean {
|
||||
return CodeInsightSettings.getInstance().SHOW_METHOD_CHAIN_TYPES_INLINE
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
|
||||
CodeInsightSettings.getInstance().SHOW_METHOD_CHAIN_TYPES_INLINE = !CodeInsightSettings.getInstance().SHOW_METHOD_CHAIN_TYPES_INLINE
|
||||
override fun setSelected(e: AnActionEvent?, state: Boolean) {
|
||||
CodeInsightSettings.getInstance().SHOW_METHOD_CHAIN_TYPES_INLINE = state
|
||||
AnnotationHintsPassFactory.forceHintsUpdateOnNextPass()
|
||||
}
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement): Boolean {
|
||||
val origin = if (element is PsiWhiteSpace) {
|
||||
PsiTreeUtil.skipWhitespacesBackward(element) ?: return false
|
||||
} else {
|
||||
element
|
||||
}
|
||||
val parent = PsiTreeUtil.getParentOfType(origin, PsiMethodCallExpression::class.java)
|
||||
if (parent !is PsiMethodCallExpression) return false
|
||||
val available = (parent.nextSibling as? PsiWhiteSpace)?.textContains('\n') ?: false
|
||||
text = if (CodeInsightSettings.getInstance().SHOW_METHOD_CHAIN_TYPES_INLINE) {
|
||||
ApplicationBundle.message("editor.appearance.show.chain.call.type.hints.toggle.off")
|
||||
}
|
||||
else {
|
||||
ApplicationBundle.message("editor.appearance.show.chain.call.type.hints.toggle.on")
|
||||
}
|
||||
return available
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,5 +104,7 @@ class MethodChainHintsPass(private val rootElement: PsiElement, editor: Editor)
|
||||
private val METHOD_CHAIN_INLAY_KEY = Key.create<Boolean>("METHOD_CHAIN_INLAY_KEY")
|
||||
}
|
||||
|
||||
private class MethodChainHintRenderer(text: String) : HintRenderer(text)
|
||||
private class MethodChainHintRenderer(text: String) : HintRenderer(text) {
|
||||
override fun getContextMenuGroupId() = "MethodChainHintsContextMenu"
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
package com.intellij.codeInsight.hints
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Turns on/off method chain type hints
|
||||
</body>
|
||||
</html>
|
||||
@@ -493,6 +493,14 @@
|
||||
<reference ref="EditorPopupMenu"/>
|
||||
</group>
|
||||
|
||||
<group id="MethodChainHintsContextMenu" popup="true">
|
||||
<action id="MethodChainHintAction"
|
||||
class="com.intellij.codeInsight.hints.MethodChainHintTurningAction"
|
||||
text="Toggle method chain hints"/>
|
||||
<separator/>
|
||||
<reference ref="EditorPopupMenu"/>
|
||||
</group>
|
||||
|
||||
<action id="MethodOverloadSwitchUp" class="com.intellij.codeInsight.editorActions.JavaMethodOverloadSwitchUpAction"/>
|
||||
<action id="MethodOverloadSwitchDown" class="com.intellij.codeInsight.editorActions.JavaMethodOverloadSwitchDownAction" />
|
||||
</actions>
|
||||
|
||||
Reference in New Issue
Block a user