From 65aafa428e37a5f5a111199e44d4a186feb137e6 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 8 Jan 2021 00:19:45 +0100 Subject: [PATCH] [i18n] PsiElementTargetPopupPresentation GitOrigin-RevId: ba45521a335b13853631552c16b5a18132087e95 --- .../navigation/PsiElementTargetPopupPresentation.kt | 6 ++++-- .../src/com/intellij/codeInsight/navigation/util.kt | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) 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 6dd446767ed4..a9ab9b55c784 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/PsiElementTargetPopupPresentation.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/PsiElementTargetPopupPresentation.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.codeInsight.navigation import com.intellij.ide.util.PsiElementListCellRenderer @@ -17,6 +17,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiNamedElement import com.intellij.ui.JBColor import org.jetbrains.annotations.ApiStatus.Experimental +import org.jetbrains.annotations.Nls import java.awt.Color import java.awt.Font import javax.swing.Icon @@ -29,7 +30,7 @@ class PsiElementTargetPopupPresentation(private val myElement: PsiElement) : Tar private val myProject: Project = myElement.project private val myVirtualFile: VirtualFile? = myElement.containingFile?.virtualFile private val myItemPresentation: ItemPresentation? = (myElement as? NavigationItem)?.presentation - private val myModuleRendererData: Pair? = run { + private val myModuleRendererData: Pair<@Nls String, Icon?>? = run { val renderer = PsiElementListCellRenderer.getModuleRenderer(myElement) val component = renderer?.getListCellRendererComponent(JList(), myElement, -1, false, false) as? JLabel component?.let { @@ -77,6 +78,7 @@ class PsiElementTargetPopupPresentation(private val myElement: PsiElement) : Tar } } + @Suppress("HardCodedStringLiteral") // inspection doesn't support type annotations in Kotlin override fun getRightText(): String? = myModuleRendererData?.first override fun getRightIcon(): Icon? = myModuleRendererData?.second diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/util.kt b/platform/lang-impl/src/com/intellij/codeInsight/navigation/util.kt index 70a57c9e87b0..3fbe15d13377 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/util.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/util.kt @@ -1,10 +1,11 @@ -// 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.codeInsight.navigation import com.intellij.navigation.ColoredItemPresentation import com.intellij.navigation.ItemPresentation import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.editor.markup.TextAttributes +import org.jetbrains.annotations.Nls import java.util.regex.Pattern private val CONTAINER_PATTERN: Pattern = Pattern.compile("(\\(in |\\()?([^)]*)(\\))?") @@ -15,6 +16,7 @@ internal fun ItemPresentation.getColoredAttributes(): TextAttributes? { return EditorColorsManager.getInstance().schemeForCurrentUITheme.getAttributes(textAttributesKey) } +@Nls internal fun ItemPresentation.getLocationText(): String? { val locationString = locationString ?: return null val matcher = CONTAINER_PATTERN.matcher(locationString)