From 4dd3f30f2d368cb0c3432ec219bcc4f23d0986e4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 16 May 2017 17:52:08 +0200 Subject: [PATCH] Build stubs for local functions; show them in Goto Symbol #KT-14161 Fixed --- .../kotlin/psi/stubs/KotlinStubVersions.kt | 4 ++-- .../psi/stubs/elements/KtStubElementType.java | 5 +---- .../presentation/DeclarationPresenters.kt | 5 +++++ .../navigation/gotoSymbol/localFunction.kt | 8 ++++++++ .../resolve/referenceInLib/toLocalFun.kt | 2 +- .../stubs/AnnotationOnLocalFunction.expected | 8 ++++++++ .../stubs/LocalClassInLocalFunction.expected | 20 ++++++++++--------- .../navigation/KotlinGotoTestGenerated.java | 6 ++++++ 8 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 idea/testData/navigation/gotoSymbol/localFunction.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt index 74082c28fe2..a5d68a632b5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt @@ -23,12 +23,12 @@ object KotlinStubVersions { // Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version // if you are not 100% sure it can be avoided. // Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version. - const val SOURCE_STUB_VERSION = 122 + const val SOURCE_STUB_VERSION = 123 // Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed // or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder). // Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files). - private const val BINARY_STUB_VERSION = 59 + private const val BINARY_STUB_VERSION = 60 // Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile) // Increasing this version will lead to reindexing of all classfiles. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementType.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementType.java index 4b283bbd659..d157c5afa5b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementType.java @@ -87,12 +87,9 @@ public abstract class KtStubElementType() ?: return null + return "(in ${containingDeclaration.name})" + } val name = declaration.fqName ?: return null val qualifiedContainer = name.parent().toString() val parent = declaration.parent diff --git a/idea/testData/navigation/gotoSymbol/localFunction.kt b/idea/testData/navigation/gotoSymbol/localFunction.kt new file mode 100644 index 00000000000..ccb096a5419 --- /dev/null +++ b/idea/testData/navigation/gotoSymbol/localFunction.kt @@ -0,0 +1,8 @@ +fun main(args: Array) { + fun myFoo() { + + } +} + +// SEARCH_TEXT: myFoo +// REF: (in main).myFoo() diff --git a/idea/testData/resolve/referenceInLib/toLocalFun.kt b/idea/testData/resolve/referenceInLib/toLocalFun.kt index 2d3a085344a..57bcd2f2eb0 100644 --- a/idea/testData/resolve/referenceInLib/toLocalFun.kt +++ b/idea/testData/resolve/referenceInLib/toLocalFun.kt @@ -5,4 +5,4 @@ val tl = topLevel() // CONTEXT: return local() // WITH_LIBRARY: /resolve/referenceInLib/inLibrarySource -// REF: local() \ No newline at end of file +// REF: (in inlibrary.test.topLevel).local() \ No newline at end of file diff --git a/idea/testData/stubs/AnnotationOnLocalFunction.expected b/idea/testData/stubs/AnnotationOnLocalFunction.expected index 87cffe6fc09..f98483215dc 100644 --- a/idea/testData/stubs/AnnotationOnLocalFunction.expected +++ b/idea/testData/stubs/AnnotationOnLocalFunction.expected @@ -3,3 +3,11 @@ PsiJetFileStubImpl[package=] IMPORT_LIST FUN[fqName=foo, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=true, name=foo] VALUE_PARAMETER_LIST + FUN[fqName=null, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=innerFoo] + MODIFIER_LIST[] + ANNOTATION_ENTRY[hasValueArguments=false, shortName=Deprecated] + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION[referencedName=Deprecated] + VALUE_PARAMETER_LIST diff --git a/idea/testData/stubs/LocalClassInLocalFunction.expected b/idea/testData/stubs/LocalClassInLocalFunction.expected index 2b07ba76171..3c1546ef9cf 100644 --- a/idea/testData/stubs/LocalClassInLocalFunction.expected +++ b/idea/testData/stubs/LocalClassInLocalFunction.expected @@ -5,14 +5,16 @@ PsiJetFileStubImpl[package=] CLASS[fqName=T, isEnumEntry=false, isInterface=true, isLocal=false, isTopLevel=true, name=T, superNames=[]] FUN[fqName=foo, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=true, name=foo] VALUE_PARAMETER_LIST - CLASS[fqName=null, isEnumEntry=false, isInterface=false, isLocal=true, isTopLevel=false, name=Test, superNames=[A, T]] - SUPER_TYPE_LIST - SUPER_TYPE_CALL_ENTRY - CONSTRUCTOR_CALLEE + FUN[fqName=null, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=bar] + VALUE_PARAMETER_LIST + CLASS[fqName=null, isEnumEntry=false, isInterface=false, isLocal=true, isTopLevel=false, name=Test, superNames=[A, T]] + SUPER_TYPE_LIST + SUPER_TYPE_CALL_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION[referencedName=A] + SUPER_TYPE_ENTRY TYPE_REFERENCE USER_TYPE - REFERENCE_EXPRESSION[referencedName=A] - SUPER_TYPE_ENTRY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION[referencedName=T] + REFERENCE_EXPRESSION[referencedName=T] diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoTestGenerated.java index a22825932e5..2ad4657ea8c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/KotlinGotoTestGenerated.java @@ -143,6 +143,12 @@ public class KotlinGotoTestGenerated extends AbstractKotlinGotoTest { doSymbolTest(fileName); } + @TestMetadata("localFunction.kt") + public void testLocalFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoSymbol/localFunction.kt"); + doSymbolTest(fileName); + } + @TestMetadata("privateTopLevelDeclarations.kt") public void testPrivateTopLevelDeclarations() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoSymbol/privateTopLevelDeclarations.kt");