diff --git a/platform/core-api/src/com/intellij/navigation/TargetPopupPresentation.kt b/platform/core-api/src/com/intellij/navigation/TargetPopupPresentation.kt
index 86e01aedaa17..ed754be3eb50 100644
--- a/platform/core-api/src/com/intellij/navigation/TargetPopupPresentation.kt
+++ b/platform/core-api/src/com/intellij/navigation/TargetPopupPresentation.kt
@@ -1,56 +1,55 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-package com.intellij.navigation;
+package com.intellij.navigation
-import com.intellij.openapi.editor.markup.TextAttributes;
-import org.jetbrains.annotations.ApiStatus.Experimental;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-import java.awt.*;
+import com.intellij.openapi.editor.markup.TextAttributes
+import org.jetbrains.annotations.ApiStatus
+import org.jetbrains.annotations.Nls
+import java.awt.Color
+import javax.swing.Icon
/**
- * Represents presentation in target popup as follows:
- * | $icon $presentable_text (in $location_text) spacer $right_text $right_icon |
+ * Represents presentation in target popup as follows:
+ * ```
+ * | $icon $presentable_text (in $location_text) spacer $right_text $right_icon |
+ * ```
* Elements before spacer are aligned to the left, right text and right icon are aligned to the right.
*/
-@Experimental
-public interface TargetPopupPresentation {
+@ApiStatus.Experimental
+interface TargetPopupPresentation {
- default @Nullable Color getBackgroundColor() {
- return null;
- }
+ @JvmDefault
+ val backgroundColor: Color?
+ get() = null
- default @Nullable Icon getIcon() {
- return null;
- }
+ @JvmDefault
+ val icon: Icon?
+ get() = null
- @Nls @NotNull String getPresentableText();
+ val presentableText: @Nls String
/**
- * @return attributes to highlight {@link #getPresentableText()}
+ * Attributes to highlight [presentableText]
*/
- default @Nullable TextAttributes getPresentableAttributes() {
- return null;
- }
+ @JvmDefault
+ val presentableAttributes: TextAttributes?
+ get() = null
- default @Nls @Nullable String getLocationText() {
- return null;
- }
+ @JvmDefault
+ val locationText: @Nls String?
+ get() = null
/**
- * @return attributes to highlight {@link #getLocationText()}
+ * Attributes to highlight [locationText]
*/
- default @Nullable TextAttributes getLocationAttributes() {
- return null;
- }
+ @JvmDefault
+ val locationAttributes: TextAttributes?
+ get() = null
- default @Nls @Nullable String getRightText() {
- return null;
- }
+ @JvmDefault
+ val rightText: @Nls String?
+ get() = null
- default @Nullable Icon getRightIcon() {
- return null;
- }
+ @JvmDefault
+ val rightIcon: Icon?
+ get() = null
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/PsiElementTargetPopupPresentation.kt b/platform/lang-impl/src/com/intellij/codeInsight/navigation/PsiElementTargetPopupPresentation.kt
index a048e2a084a2..0c2e80857956 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/PsiElementTargetPopupPresentation.kt
+++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/PsiElementTargetPopupPresentation.kt
@@ -38,36 +38,39 @@ class PsiElementTargetPopupPresentation(private val myElement: PsiElement) : Tar
}
}
- override fun getBackgroundColor(): Color? {
- val virtualFile = myVirtualFile ?: return null
- return EditorTabPresentationUtil.getFileBackgroundColor(myProject, virtualFile)
- }
-
- override fun getIcon(): Icon? = myElement.getIcon(Iconable.ICON_FLAG_VISIBILITY or Iconable.ICON_FLAG_READ_STATUS)
-
- override fun getPresentableText(): String {
- return myItemPresentation?.presentableText
- ?: (myElement as? PsiNamedElement)?.name
- ?: myElement.text
- }
-
- override fun getPresentableAttributes(): TextAttributes? = myItemPresentation?.getColoredAttributes()
-
- override fun getLocationText(): String? = myItemPresentation?.getLocationText()
-
- override fun getLocationAttributes(): TextAttributes? {
- val virtualFile = myVirtualFile ?: return null
- val locationColor = FileStatusManager.getInstance(myProject).getStatus(virtualFile)?.color
- val hasProblem = WolfTheProblemSolver.getInstance(myProject).isProblemFile(virtualFile)
- return when {
- hasProblem -> TextAttributes(locationColor, null, JBColor.red, EffectType.WAVE_UNDERSCORE, Font.PLAIN)
- locationColor != null -> TextAttributes(locationColor, null, null, null, Font.PLAIN)
- else -> null
+ override val backgroundColor: Color?
+ get() {
+ val virtualFile = myVirtualFile ?: return null
+ return EditorTabPresentationUtil.getFileBackgroundColor(myProject, virtualFile)
}
- }
- @Suppress("HardCodedStringLiteral") // inspection doesn't support type annotations in Kotlin
- override fun getRightText(): String? = myModuleRendererData?.first
+ override val icon: Icon?
+ get() = myElement.getIcon(Iconable.ICON_FLAG_VISIBILITY or Iconable.ICON_FLAG_READ_STATUS)
- override fun getRightIcon(): Icon? = myModuleRendererData?.second
+ override val presentableText: String
+ get() = myItemPresentation?.presentableText
+ ?: (myElement as? PsiNamedElement)?.name
+ ?: myElement.text
+
+ override val presentableAttributes: TextAttributes?
+ get() = myItemPresentation?.getColoredAttributes()
+
+ override val locationText: String?
+ get() = myItemPresentation?.getLocationText()
+
+ override val locationAttributes: TextAttributes?
+ get() {
+ val virtualFile = myVirtualFile ?: return null
+ val locationColor = FileStatusManager.getInstance(myProject).getStatus(virtualFile)?.color
+ val hasProblem = WolfTheProblemSolver.getInstance(myProject).isProblemFile(virtualFile)
+ return when {
+ hasProblem -> TextAttributes(locationColor, null, JBColor.red, EffectType.WAVE_UNDERSCORE, Font.PLAIN)
+ locationColor != null -> TextAttributes(locationColor, null, null, null, Font.PLAIN)
+ else -> null
+ }
+ }
+
+ override val rightText: String? get() = myModuleRendererData?.first
+
+ override val rightIcon: Icon? get() = myModuleRendererData?.second
}
diff --git a/platform/lang-impl/src/com/intellij/find/actions/Item2TargetPresentation.kt b/platform/lang-impl/src/com/intellij/find/actions/Item2TargetPresentation.kt
index 4445d0fd4350..b8d360cc4936 100644
--- a/platform/lang-impl/src/com/intellij/find/actions/Item2TargetPresentation.kt
+++ b/platform/lang-impl/src/com/intellij/find/actions/Item2TargetPresentation.kt
@@ -1,4 +1,4 @@
-// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.find.actions
import com.intellij.codeInsight.navigation.getColoredAttributes
@@ -10,11 +10,11 @@ import javax.swing.Icon
internal class Item2TargetPresentation(private val itemPresentation: ItemPresentation) : TargetPopupPresentation {
- override fun getIcon(): Icon? = itemPresentation.getIcon(false)
+ override val icon: Icon? get() = itemPresentation.getIcon(false)
- override fun getPresentableText(): String = itemPresentation.presentableText ?: ""
+ override val presentableText: String get() = itemPresentation.presentableText ?: ""
- override fun getPresentableAttributes(): TextAttributes? = itemPresentation.getColoredAttributes()
+ override val presentableAttributes: TextAttributes? get() = itemPresentation.getColoredAttributes()
- override fun getLocationText(): String? = itemPresentation.getLocationText()
+ override val locationText: String? get() = itemPresentation.getLocationText()
}
diff --git a/plugins/gradle/java/src/service/resolve/GradleProjectSymbol.kt b/plugins/gradle/java/src/service/resolve/GradleProjectSymbol.kt
index f3006d242bef..c81b143dc450 100644
--- a/plugins/gradle/java/src/service/resolve/GradleProjectSymbol.kt
+++ b/plugins/gradle/java/src/service/resolve/GradleProjectSymbol.kt
@@ -1,4 +1,4 @@
-// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.gradle.service.resolve
import com.intellij.codeInsight.navigation.PsiElementNavigationTarget
@@ -57,8 +57,8 @@ abstract class GradleProjectSymbol(
get() {
val presentation = symbolPresentation
return object : TargetPopupPresentation {
- override fun getIcon(): Icon? = presentation.icon
- override fun getPresentableText(): String = presentation.longDescription
+ override val icon: Icon? get() = presentation.icon
+ override val presentableText: String get() = presentation.longDescription
}
}