Presentation: Add file name to the presentation of private top-level declaration
#KT-13838 Fixed
This commit is contained in:
@@ -106,6 +106,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
||||
- Re-highlight only single function after local modifications
|
||||
- [`KT-13474`](https://youtrack.jetbrains.com/issue/KT-13474) Fix performance of typing super call lambda
|
||||
- Show "Variables and values captured in a closure" highlighting only for usages
|
||||
- [`KT-13838`](https://youtrack.jetbrains.com/issue/KT-13838) Add file name to the presentation of private top-level declaration (Go to symbol, etc.)
|
||||
|
||||
#### Intention actions, inspections and quickfixes
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.colors.CodeInsightColors
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||
import com.intellij.openapi.util.Iconable
|
||||
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
open class KotlinDefaultNamedDeclarationPresentation(private val declaration: KtNamedDeclaration) : ColoredItemPresentation {
|
||||
@@ -38,15 +39,23 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
|
||||
|
||||
override fun getLocationString(): String? {
|
||||
val name = declaration.fqName ?: return null
|
||||
val receiverTypeRef = (declaration as? KtCallableDeclaration)?.receiverTypeReference
|
||||
if (receiverTypeRef != null) {
|
||||
return "(for " + receiverTypeRef.text + " in " + name.parent() + ")"
|
||||
}
|
||||
else if (declaration.parent is KtFile) {
|
||||
return "(" + name.parent() + ")"
|
||||
val qualifiedContainer = name.parent().toString()
|
||||
val parent = declaration.parent
|
||||
val containerText = if (parent is KtFile && declaration.hasModifier(KtTokens.PRIVATE_KEYWORD)) {
|
||||
"${parent.name} in $qualifiedContainer"
|
||||
}
|
||||
else {
|
||||
return "(in " + name.parent() + ")"
|
||||
qualifiedContainer
|
||||
}
|
||||
val receiverTypeRef = (declaration as? KtCallableDeclaration)?.receiverTypeReference
|
||||
if (receiverTypeRef != null) {
|
||||
return "(for " + receiverTypeRef.text + " in " + containerText + ")"
|
||||
}
|
||||
else if (parent is KtFile) {
|
||||
return "(" + containerText + ")"
|
||||
}
|
||||
else {
|
||||
return "(in " + containerText + ")"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package foo.bar
|
||||
|
||||
private class test
|
||||
|
||||
private fun Int.test() = 1
|
||||
|
||||
private fun test() = 2
|
||||
|
||||
private val Int.test: Int
|
||||
get() = 3
|
||||
|
||||
private val test = 4
|
||||
|
||||
// SEARCH_TEXT: test
|
||||
// REF: (for Int in privateTopLevelDeclarations.kt in foo.bar).test
|
||||
// REF: (for Int in privateTopLevelDeclarations.kt in foo.bar).test()
|
||||
// REF: (privateTopLevelDeclarations.kt in foo.bar).test
|
||||
// REF: (privateTopLevelDeclarations.kt in foo.bar).test
|
||||
// REF: (privateTopLevelDeclarations.kt in foo.bar).test()
|
||||
@@ -136,6 +136,12 @@ public class KotlinGotoTestGenerated extends AbstractKotlinGotoTest {
|
||||
doSymbolTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateTopLevelDeclarations.kt")
|
||||
public void testPrivateTopLevelDeclarations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoSymbol/privateTopLevelDeclarations.kt");
|
||||
doSymbolTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("properties.kt")
|
||||
public void testProperties() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoSymbol/properties.kt");
|
||||
|
||||
Reference in New Issue
Block a user