From 9970289efb199697190dc3e85bdf066366ed8e64 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 5 Sep 2016 17:36:23 +0300 Subject: [PATCH] j2k: right after convert (cherry picked from commit c0db343) --- .../KotlinTypeDeclarationProvider.kt | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinTypeDeclarationProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinTypeDeclarationProvider.kt index f6afe0b1d8b..86aa41679c3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinTypeDeclarationProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinTypeDeclarationProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,36 +14,35 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.codeInsight; +package org.jetbrains.kotlin.idea.codeInsight +import com.intellij.codeInsight.navigation.actions.TypeDeclarationProvider import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -public class KotlinTypeDeclarationProvider implements TypeDeclarationProvider { - @Override - public PsiElement[] getSymbolTypeDeclarations(@NotNull PsiElement symbol) { - if (symbol instanceof KtElement && symbol.getContainingFile() instanceof KtFile) { - BindingContext bindingContext = ResolutionUtils.analyze((KtElement)symbol); - DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, symbol); - if (descriptor instanceof CallableDescriptor) { - KotlinType type = ((CallableDescriptor) descriptor).getReturnType(); +class KotlinTypeDeclarationProvider : TypeDeclarationProvider { + override fun getSymbolTypeDeclarations(symbol: PsiElement): Array? { + if (symbol is KtElement && symbol.getContainingFile() is KtFile) { + val bindingContext = symbol.analyze() + val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, symbol) + if (descriptor is CallableDescriptor) { + val type = descriptor.returnType if (type != null) { - ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor(); + val classifierDescriptor = type.constructor.declarationDescriptor if (classifierDescriptor != null) { - PsiElement typeElement = DescriptorToSourceUtils.descriptorToDeclaration(classifierDescriptor); + val typeElement = DescriptorToSourceUtils.descriptorToDeclaration(classifierDescriptor) if (typeElement != null) { - return new PsiElement[] {typeElement}; + return arrayOf(typeElement) } } } } } - return new PsiElement[0]; + return arrayOfNulls(0) } }