diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-01-18 16:48:03 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-01-18 16:48:03 +0300 |
commit | 372e9c796cc77aaff788df56a13deeef64b6edd7 (patch) | |
tree | d43ce5275c5852f88ff8b466d34533504a50487a /core/src/main/kotlin/Samples | |
parent | f4f7642c90fef06f04cadc57835ed431ace69802 (diff) | |
download | dokka-372e9c796cc77aaff788df56a13deeef64b6edd7.tar.gz dokka-372e9c796cc77aaff788df56a13deeef64b6edd7.tar.bz2 dokka-372e9c796cc77aaff788df56a13deeef64b6edd7.zip |
KT-15497 Dokka: Using of not-FQ name in @sample should be allowed
Diffstat (limited to 'core/src/main/kotlin/Samples')
-rw-r--r-- | core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt | 12 | ||||
-rw-r--r-- | core/src/main/kotlin/Samples/SampleProcessingService.kt | 3 |
2 files changed, 8 insertions, 7 deletions
diff --git a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt index e6539135..6348c181 100644 --- a/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/DefaultSampleProcessingService.kt @@ -7,11 +7,13 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.PackageViewDescriptor import org.jetbrains.kotlin.idea.kdoc.getKDocLinkResolutionScope -import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink +import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.ResolutionScope @@ -23,15 +25,13 @@ open class DefaultSampleProcessingService val resolutionFacade: DokkaResolutionFacade) : SampleProcessingService { - override fun resolveSample(descriptor: DeclarationDescriptor, functionName: String?): ContentNode { + override fun resolveSample(descriptor: DeclarationDescriptor, functionName: String?, kdocTag: KDocTag): ContentNode { if (functionName == null) { logger.warn("Missing function name in @sample in ${descriptor.signature()}") return ContentBlockSampleCode().apply { append(ContentText("//Missing function name in @sample")) } } - val scope = getKDocLinkResolutionScope(resolutionFacade, descriptor) - val rootPackage = resolutionFacade.moduleDescriptor.getPackage(FqName.ROOT) - val rootScope = rootPackage.memberScope - val symbol = resolveInScope(functionName, scope) ?: resolveInScope(functionName, rootScope) + val bindingContext = BindingContext.EMPTY + val symbol = resolveKDocLink(bindingContext, resolutionFacade, descriptor, kdocTag, functionName.split(".")).firstOrNull() if (symbol == null) { logger.warn("Unresolved function $functionName in @sample in ${descriptor.signature()}") return ContentBlockSampleCode().apply { append(ContentText("//Unresolved: $functionName")) } diff --git a/core/src/main/kotlin/Samples/SampleProcessingService.kt b/core/src/main/kotlin/Samples/SampleProcessingService.kt index 7f46299f..86c917cf 100644 --- a/core/src/main/kotlin/Samples/SampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/SampleProcessingService.kt @@ -2,7 +2,8 @@ package org.jetbrains.dokka.Samples import org.jetbrains.dokka.ContentNode import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag interface SampleProcessingService { - fun resolveSample(descriptor: DeclarationDescriptor, functionName: String?): ContentNode + fun resolveSample(descriptor: DeclarationDescriptor, functionName: String?, kdocTag: KDocTag): ContentNode }
\ No newline at end of file |