From 843298883f5b40ff9ecef6f790b80bf9aba52d27 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 24 Mar 2015 18:57:18 +0100 Subject: [PATCH] shuffle some code around to avoid JVM crash in tests --- .../jetbrains/kotlin/idea/kdoc/KDocReference.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt index 81bb80ba68a..228a876153c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt @@ -75,10 +75,7 @@ public fun resolveKDocLink(session: KotlinCodeAnalyzer, // Try to find a matching local descriptor (parameter or type parameter) first. if (qualifiedName.size() == 1) { - val scope = getResolutionScope(session, fromDescriptor) - val localResult = scope.getDescriptors().filter { - it.getName().asString() == qualifiedName.single() && it.getContainingDeclaration() == fromDescriptor - } + val localResult = resolveInLocalScope(fromDescriptor, qualifiedName.single(), session) if (!localResult.isEmpty()) { return localResult } @@ -87,9 +84,6 @@ public fun resolveKDocLink(session: KotlinCodeAnalyzer, var result: Collection = listOf(fromDescriptor) qualifiedName.forEach { nameComponent -> if (result.size() != 1) return listOf() - if (!Name.isValidIdentifier(nameComponent)) { - return listOf() - } val scope = getResolutionScope(session, result.first()) result = scope.getDescriptors().filter { it.getName().asString() == nameComponent } } @@ -97,6 +91,15 @@ public fun resolveKDocLink(session: KotlinCodeAnalyzer, return result } +private fun resolveInLocalScope(fromDescriptor: DeclarationDescriptor, + name: String, + session: KotlinCodeAnalyzer): List { + val scope = getResolutionScope(session, fromDescriptor) + return scope.getDescriptors().filter { + it.getName().asString() == name && it.getContainingDeclaration() == fromDescriptor + } +} + public fun getParamDescriptors(fromDescriptor: DeclarationDescriptor): List { // TODO resolve parameters of functions passed as parameters when (fromDescriptor) {