diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/KotlinParameterUTypeReference.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/KotlinParameterUTypeReference.kt new file mode 100644 index 00000000000..4eb03dbf7ea --- /dev/null +++ b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/KotlinParameterUTypeReference.kt @@ -0,0 +1,45 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.uast + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde +import org.jetbrains.kotlin.psi.KtTypeParameter +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode +import org.jetbrains.kotlin.uast.KotlinPsiElementStub +import org.jetbrains.kotlin.uast.orAnonymous +import org.jetbrains.uast.* +import org.jetbrains.uast.psi.PsiElementBacked + +class KotlinParameterUTypeReference( + override val psi: KtTypeParameter, + override val parent: UElement +) : UTypeReference, PsiElementBacked { + override fun resolve(context: UastContext): UClass? { + val descriptor = psi.analyze(BodyResolveMode.PARTIAL)[BindingContext.TYPE_PARAMETER, psi] + ?.typeConstructor?.declarationDescriptor as? ClassDescriptor ?: return null + return context.convert(DescriptorToSourceUtilsIde.getAnyDeclaration(psi.project, descriptor)) as? UClass + } + + override val nameElement: UElement? + get() = KotlinPsiElementStub(psi, this) + + override val name: String + get() = psi.name.orAnonymous() +} \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/kotlinUFunctions.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/kotlinUFunctions.kt index adbc4c6023d..5463d58bdff 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/kotlinUFunctions.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/declarations/kotlinUFunctions.kt @@ -83,7 +83,8 @@ class KotlinUFunction( KotlinConverter.convert(type, psi.project, this) } - //TODO - override val typeParameterCount = 0 - override val typeParameters = emptyList() + override val typeParameterCount: Int + get() = psi.typeParameters.size + + override val typeParameters by lz { psi.typeParameters.map { KotlinParameterUTypeReference(it, this) } } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinUArrayAccess.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinUArrayAccess.kt deleted file mode 100644 index 3a46461390f..00000000000 --- a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinUArrayAccess.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.uast - -import org.jetbrains.kotlin.psi.KtArrayAccessExpression -import org.jetbrains.uast.NoEvaluate -import org.jetbrains.uast.UArrayAccessExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class KotlinUArrayAccess( - override val psi: KtArrayAccessExpression, - override val parent: UElement -) : UArrayAccessExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate { - override val receiver by lz { KotlinConverter.convertOrEmpty(psi.arrayExpression, this) } - override val indices by lz { psi.indexExpressions.map { KotlinConverter.convert(it, this) } } -} \ No newline at end of file