Build stubs for local functions; show them in Goto Symbol
#KT-14161 Fixed
This commit is contained in:
@@ -23,12 +23,12 @@ object KotlinStubVersions {
|
|||||||
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
|
// 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.
|
// 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.
|
// 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
|
// 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).
|
// 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).
|
// 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)
|
// 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.
|
// Increasing this version will lead to reindexing of all classfiles.
|
||||||
|
|||||||
+1
-4
@@ -87,12 +87,9 @@ public abstract class KtStubElementType<StubT extends StubElement, PsiT extends
|
|||||||
@Override
|
@Override
|
||||||
public boolean shouldCreateStub(ASTNode node) {
|
public boolean shouldCreateStub(ASTNode node) {
|
||||||
PsiElement psi = node.getPsi();
|
PsiElement psi = node.getPsi();
|
||||||
if (psi instanceof KtClassOrObject) {
|
if (psi instanceof KtClassOrObject || psi instanceof KtFunction) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (psi instanceof KtFunction) {
|
|
||||||
return !((KtFunction) psi).isLocal();
|
|
||||||
}
|
|
||||||
if (psi instanceof KtProperty) {
|
if (psi instanceof KtProperty) {
|
||||||
return !((KtProperty) psi).isLocal();
|
return !((KtProperty) psi).isLocal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.Iconable
|
|||||||
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||||
|
|
||||||
open class KotlinDefaultNamedDeclarationPresentation(private val declaration: KtNamedDeclaration) : ColoredItemPresentation {
|
open class KotlinDefaultNamedDeclarationPresentation(private val declaration: KtNamedDeclaration) : ColoredItemPresentation {
|
||||||
|
|
||||||
@@ -38,6 +39,10 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
|
|||||||
override fun getPresentableText() = declaration.name
|
override fun getPresentableText() = declaration.name
|
||||||
|
|
||||||
override fun getLocationString(): String? {
|
override fun getLocationString(): String? {
|
||||||
|
if (declaration is KtFunction && declaration.isLocal) {
|
||||||
|
val containingDeclaration = declaration.getStrictParentOfType<KtDeclaration>() ?: return null
|
||||||
|
return "(in ${containingDeclaration.name})"
|
||||||
|
}
|
||||||
val name = declaration.fqName ?: return null
|
val name = declaration.fqName ?: return null
|
||||||
val qualifiedContainer = name.parent().toString()
|
val qualifiedContainer = name.parent().toString()
|
||||||
val parent = declaration.parent
|
val parent = declaration.parent
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
fun myFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SEARCH_TEXT: myFoo
|
||||||
|
// REF: (in main).myFoo()
|
||||||
+1
-1
@@ -5,4 +5,4 @@ val tl = <caret>topLevel()
|
|||||||
// CONTEXT: return <ref-caret>local()
|
// CONTEXT: return <ref-caret>local()
|
||||||
// WITH_LIBRARY: /resolve/referenceInLib/inLibrarySource
|
// WITH_LIBRARY: /resolve/referenceInLib/inLibrarySource
|
||||||
|
|
||||||
// REF: local()
|
// REF: (in inlibrary.test.topLevel).local()
|
||||||
@@ -3,3 +3,11 @@ PsiJetFileStubImpl[package=]
|
|||||||
IMPORT_LIST
|
IMPORT_LIST
|
||||||
FUN[fqName=foo, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=true, name=foo]
|
FUN[fqName=foo, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=true, name=foo]
|
||||||
VALUE_PARAMETER_LIST
|
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
|
||||||
|
|||||||
+11
-9
@@ -5,14 +5,16 @@ PsiJetFileStubImpl[package=]
|
|||||||
CLASS[fqName=T, isEnumEntry=false, isInterface=true, isLocal=false, isTopLevel=true, name=T, superNames=[]]
|
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]
|
FUN[fqName=foo, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=true, name=foo]
|
||||||
VALUE_PARAMETER_LIST
|
VALUE_PARAMETER_LIST
|
||||||
CLASS[fqName=null, isEnumEntry=false, isInterface=false, isLocal=true, isTopLevel=false, name=Test, superNames=[A, T]]
|
FUN[fqName=null, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=bar]
|
||||||
SUPER_TYPE_LIST
|
VALUE_PARAMETER_LIST
|
||||||
SUPER_TYPE_CALL_ENTRY
|
CLASS[fqName=null, isEnumEntry=false, isInterface=false, isLocal=true, isTopLevel=false, name=Test, superNames=[A, T]]
|
||||||
CONSTRUCTOR_CALLEE
|
SUPER_TYPE_LIST
|
||||||
|
SUPER_TYPE_CALL_ENTRY
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=A]
|
||||||
|
SUPER_TYPE_ENTRY
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION[referencedName=A]
|
REFERENCE_EXPRESSION[referencedName=T]
|
||||||
SUPER_TYPE_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION[referencedName=T]
|
|
||||||
|
|||||||
@@ -143,6 +143,12 @@ public class KotlinGotoTestGenerated extends AbstractKotlinGotoTest {
|
|||||||
doSymbolTest(fileName);
|
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")
|
@TestMetadata("privateTopLevelDeclarations.kt")
|
||||||
public void testPrivateTopLevelDeclarations() throws Exception {
|
public void testPrivateTopLevelDeclarations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoSymbol/privateTopLevelDeclarations.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoSymbol/privateTopLevelDeclarations.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user