mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method chain inlays: don't repeat same types to reduce visual noise
GitOrigin-RevId: da0a4065ec33f4c2b2530c640c7d945dba5cefd7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2f1abbd6a0
commit
ace2a64535
@@ -13,9 +13,6 @@ import com.intellij.util.ui.JBUI
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils
|
||||
import org.intellij.lang.annotations.Language
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.event.ChangeEvent
|
||||
import javax.swing.event.DocumentEvent
|
||||
import javax.swing.event.DocumentListener
|
||||
|
||||
class MethodChainsInlayProvider : InlayHintsProvider<MethodChainsInlayProvider.Settings> {
|
||||
override fun getCollectorFor(file: PsiFile, editor: Editor, settings: Settings, sink: InlayHintsSink) =
|
||||
@@ -41,8 +38,11 @@ class MethodChainsInlayProvider : InlayHintsProvider<MethodChainsInlayProvider.S
|
||||
}
|
||||
if (uniqueTypes.size < settings.uniqueTypeCount) return true // to hide hints for builders, where type is obvious
|
||||
val javaFactory = JavaTypeHintsPresentationFactory(factory, 3)
|
||||
var lastType : PsiType? = null
|
||||
for ((index, currentCall) in chain.withIndex()) {
|
||||
val type = types[index]
|
||||
if (lastType == type) continue
|
||||
lastType = type
|
||||
val presentation = javaFactory.typeHint(type)
|
||||
val project = file.project
|
||||
val finalPresentation = InsetPresentation(MenuOnClickPresentation(presentation, project) {
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class Chains {
|
||||
public static void main(String[] args) {
|
||||
new A()
|
||||
.b()<hint text="[Chains . B]"/>
|
||||
.c().b()<hint text="[Chains . B]"/>
|
||||
.c().b()
|
||||
.a()<hint text="[Chains . A]"/>
|
||||
.c()<hint text="[Chains . C]"/>
|
||||
.b()<hint text="[Chains . B]"/>
|
||||
|
||||
Reference in New Issue
Block a user