diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt index 5a3736b7c81..18132f8bd25 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt @@ -30,7 +30,6 @@ import org.jetbrains.kotlin.load.java.components.* import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolver import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver import org.jetbrains.kotlin.load.java.sam.SamConversionResolverImpl -import org.jetbrains.kotlin.load.java.structure.impl.JavaPropertyInitializerEvaluatorImpl import org.jetbrains.kotlin.load.kotlin.DeserializationComponentsForJava import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory import org.jetbrains.kotlin.resolve.* diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaPropertyInitializerEvaluatorImpl.kt similarity index 92% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt rename to compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaPropertyInitializerEvaluatorImpl.kt index bb99bd3e739..53710d7d884 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaPropertyInitializerEvaluatorImpl.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,13 +14,13 @@ * limitations under the License. */ -package org.jetbrains.kotlin.load.java.structure.impl +package org.jetbrains.kotlin.load.java.components import com.intellij.psi.impl.JavaConstantExpressionEvaluator import com.intellij.psi.util.PsiUtil import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.load.java.structure.JavaField -import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator +import org.jetbrains.kotlin.load.java.structure.impl.JavaFieldImpl import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java index ce0398471fb..a60495f143d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java @@ -57,7 +57,7 @@ public class JavaMethodImpl extends JavaMemberImpl implements JavaMet } @Override - public boolean hasAnnotationParameterDefaultValue() { + public boolean getHasAnnotationParameterDefaultValue() { PsiMethod psiMethod = getPsi(); return psiMethod instanceof PsiAnnotationMethod && ((PsiAnnotationMethod) psiMethod).getDefaultValue() != null; } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt index 79acff38300..83edbeb7d7a 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt @@ -35,7 +35,9 @@ class JavaPackageImpl(psiPackage: PsiPackage, private val scope: GlobalSearchSco return classes(psiClasses) } - override fun getSubPackages() = packages(psi.getSubPackages(scope), scope) + override val subPackages: Collection + get() = packages(psi.getSubPackages(scope), scope) - override fun getFqName() = FqName(psi.qualifiedName) + override val fqName: FqName + get() = FqName(psi.qualifiedName) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt index e1b0f4bea53..4cc61b1dded 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt @@ -29,7 +29,7 @@ abstract class VirtualFileKotlinClassFinder : JvmVirtualFileFinder { override fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass? { var file = (javaClass as JavaClassImpl).psi.containingFile!!.virtualFile ?: return null - if (javaClass.getOuterClass() != null) { + if (javaClass.outerClass != null) { // For nested classes we get a file of the containing class, to get the actual class file for A.B.C, // we take the file for A, take its parent directory, then in this directory we look for A$B$C.class file = file.parent!!.findChild(classFileName(javaClass) + ".class").sure { "Virtual file not found for $javaClass" } @@ -39,10 +39,7 @@ abstract class VirtualFileKotlinClassFinder : JvmVirtualFileFinder { } private fun classFileName(jClass: JavaClass): String { - val outerClass = jClass.outerClass - if (outerClass == null) { - return jClass.name.asString() - } + val outerClass = jClass.outerClass ?: return jClass.name.asString() return classFileName(outerClass) + "$" + jClass.name.asString() } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaPropertyInitializerEvaluator.kt similarity index 88% rename from core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt rename to core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaPropertyInitializerEvaluator.kt index f660f787587..8c3511db002 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaPropertyInitializerEvaluator.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,9 +14,10 @@ * limitations under the License. */ -package org.jetbrains.kotlin.load.java.structure +package org.jetbrains.kotlin.load.java.components import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.load.java.structure.JavaField import org.jetbrains.kotlin.resolve.constants.ConstantValue interface JavaPropertyInitializerEvaluator { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt index 96e35b28742..339bd4cb8e6 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt @@ -23,13 +23,9 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.load.java.JavaClassFinder -import org.jetbrains.kotlin.load.java.components.ExternalAnnotationResolver -import org.jetbrains.kotlin.load.java.components.SignaturePropagator -import org.jetbrains.kotlin.load.java.components.JavaResolverCache -import org.jetbrains.kotlin.load.java.components.SamConversionResolver +import org.jetbrains.kotlin.load.java.components.* import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver import org.jetbrains.kotlin.load.java.sources.JavaSourceElementFactory -import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator import org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index e62c424589a..405b9d52a66 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -44,7 +44,7 @@ class LazyJavaAnnotationDescriptor( ) : AnnotationDescriptor { private val fqName = c.storageManager.createNullableLazyValue { - javaAnnotation.getClassId()?.asSingleFqName() + javaAnnotation.classId?.asSingleFqName() } private val type = c.storageManager.createLazyValue { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 3906954513d..04b5491bbcc 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -75,7 +75,7 @@ class LazyJavaClassMemberScope( } internal val constructors = c.storageManager.createLazyValue { - val constructors = jClass.getConstructors() + val constructors = jClass.constructors val result = ArrayList(constructors.size) for (constructor in constructors) { val descriptor = resolveConstructor(constructor) @@ -599,7 +599,7 @@ class LazyJavaClassMemberScope( method.name, // Parameters of annotation constructors in Java are never nullable TypeUtils.makeNotNullable(returnType), - method.hasAnnotationParameterDefaultValue(), + method.hasAnnotationParameterDefaultValue, /* isCrossinline = */ false, /* isNoinline = */ false, // Nulls are not allowed in annotation arguments in Java @@ -649,7 +649,7 @@ class LazyJavaClassMemberScope( = nestedClassIndex().keys + enumEntryIndex().keys override fun getPropertyNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { - if (jClass.isAnnotationType()) return memberIndex().getMethodNames(nameFilter) + if (jClass.isAnnotationType) return memberIndex().getMethodNames(nameFilter) return memberIndex().getAllFieldNames() + ownerDescriptor.getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet()) { supertype -> diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt index 411b8023d21..51abc9a0671 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.storage.getValue class LazyJavaPackageFragment( private val c: LazyJavaResolverContext, private val jPackage: JavaPackage -) : PackageFragmentDescriptorImpl(c.module, jPackage.getFqName()) { +) : PackageFragmentDescriptorImpl(c.module, jPackage.fqName) { private val scope by c.storageManager.createLazyValue { LazyJavaPackageScope(c, jPackage, this) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt index 7c32e04e765..35e4ce70d6d 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt @@ -172,7 +172,7 @@ class LazyJavaPackageScope( private val subPackages = c.storageManager.createRecursionTolerantLazyValue( { - jPackage.getSubPackages().map { sp -> sp.getFqName() } + jPackage.subPackages.map { sp -> sp.fqName } }, // This breaks infinite recursion between loading Java descriptors and building light classes onRecursiveCall = listOf() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index 9004728d838..8946e244ee0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -231,7 +231,7 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS val properties = ArrayList() val field = memberIndex().findFieldByName(name) - if (field != null && !field.isEnumEntry()) { + if (field != null && !field.isEnumEntry) { properties.add(resolveProperty(field)) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt index f3ae19014a6..0e7a33b2649 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt @@ -62,10 +62,10 @@ open class ClassMemberIndex(val jClass: JavaClass, val memberFilter: (JavaMember override fun findMethodsByName(name: Name): Collection = methods[name] ?: listOf() override fun getMethodNames(nameFilter: (Name) -> Boolean): Collection = - jClass.getAllMemberNames(methodFilter) { getMethods() } + jClass.getAllMemberNames(methodFilter) { methods } override fun findFieldByName(name: Name): JavaField? = fields[name] - override fun getAllFieldNames(): Collection = jClass.getAllMemberNames(memberFilter) { getFields() } + override fun getAllFieldNames(): Collection = jClass.getAllMemberNames(memberFilter) { fields } } private fun JavaClass.getNonDeclaredMethodNames(): List { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt index 44cc77ed13b..ce7d8ab8401 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt @@ -100,7 +100,7 @@ class LazyJavaTypeResolver( ) : AbstractLazyType(c.storageManager) { private val annotations = CompositeAnnotations(listOf(LazyJavaAnnotations(c, javaType), attr.typeAnnotations)) - private val classifier = c.storageManager.createNullableLazyValue { javaType.getClassifier() } + private val classifier = c.storageManager.createNullableLazyValue { javaType.classifier } override fun computeTypeConstructor(): TypeConstructor { val classifier = classifier() @@ -109,7 +109,7 @@ class LazyJavaTypeResolver( } return when (classifier) { is JavaClass -> { - val fqName = classifier.getFqName().sure { "Class type should have a FQ name: $classifier" } + val fqName = classifier.fqName.sure { "Class type should have a FQ name: $classifier" } val classData = mapKotlinClass(fqName) ?: c.components.moduleClassResolver.resolveClass(classifier) @@ -222,7 +222,7 @@ class LazyJavaTypeResolver( else { createProjection( type = transformJavaType(bound, UPPER_BOUND.toAttributes()), - projectionKind = if (javaType.isExtends()) OUT_VARIANCE else IN_VARIANCE, + projectionKind = if (javaType.isExtends) OUT_VARIANCE else IN_VARIANCE, typeParameterDescriptor = typeParameter ) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaAnnotation.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaAnnotation.java deleted file mode 100644 index 72379e66ef2..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaAnnotation.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.name.ClassId; - -import java.util.Collection; - -public interface JavaAnnotation extends JavaElement { - @NotNull - Collection getArguments(); - - @Nullable - ClassId getClassId(); - - @Nullable - JavaClass resolve(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaAnnotationOwner.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaAnnotationOwner.java deleted file mode 100644 index 1aced051933..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaAnnotationOwner.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.name.FqName; - -import java.util.Collection; - -public interface JavaAnnotationOwner extends JavaElement { - @NotNull - Collection getAnnotations(); - - @Nullable - JavaAnnotation findAnnotation(@NotNull FqName fqName); - - boolean isDeprecatedInJavaDoc(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaArrayType.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaArrayType.java deleted file mode 100644 index 81cbde92815..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaArrayType.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; - -public interface JavaArrayType extends JavaType { - @NotNull - JavaType getComponentType(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClass.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClass.java deleted file mode 100644 index 32bb37372bb..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClass.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.name.FqName; - -import java.util.Collection; - -public interface JavaClass extends JavaClassifier, JavaTypeParameterListOwner, JavaModifierListOwner { - @NotNull - Collection getInnerClasses(); - - @Nullable - FqName getFqName(); - - boolean isInterface(); - - boolean isAnnotationType(); - - boolean isEnum(); - - boolean isKotlinLightClass(); - - @Nullable - JavaClass getOuterClass(); - - @NotNull - Collection getSupertypes(); - - @NotNull - Collection getMethods(); - - @NotNull - Collection getFields(); - - @NotNull - Collection getConstructors(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifier.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifier.java deleted file mode 100644 index ef1a7239365..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifier.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -public interface JavaClassifier extends JavaNamedElement, JavaAnnotationOwner { -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java deleted file mode 100644 index 391cd77dc38..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.ReadOnly; - -import java.util.List; - -public interface JavaClassifierType extends JavaType, JavaAnnotationOwner { - @Nullable - JavaClassifier getClassifier(); - - @NotNull - String getPresentableText(); - - boolean isRaw(); - - @NotNull - @ReadOnly - List getTypeArguments(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaConstructor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaConstructor.java deleted file mode 100644 index 7fab8785043..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaConstructor.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public interface JavaConstructor extends JavaMember, JavaTypeParameterListOwner { - @NotNull - List getValueParameters(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaElement.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaElement.java deleted file mode 100644 index 484fca10c48..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaElement.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -public interface JavaElement { -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaField.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaField.java deleted file mode 100644 index 1f2dde98e7b..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaField.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; - -public interface JavaField extends JavaMember { - boolean isEnumEntry(); - - @NotNull - JavaType getType(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMember.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMember.java deleted file mode 100644 index a124c00d02f..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMember.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; - -public interface JavaMember extends JavaModifierListOwner, JavaAnnotationOwner, JavaNamedElement { - @NotNull - JavaClass getContainingClass(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java deleted file mode 100644 index def254fe374..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.ReadOnly; - -import java.util.List; - -public interface JavaMethod extends JavaMember, JavaTypeParameterListOwner { - @NotNull - @ReadOnly - List getValueParameters(); - - boolean hasAnnotationParameterDefaultValue(); - - @NotNull - JavaType getReturnType(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaModifierListOwner.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaModifierListOwner.java deleted file mode 100644 index 79f9e69ff8f..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaModifierListOwner.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.descriptors.Visibility; - -public interface JavaModifierListOwner extends JavaElement { - boolean isAbstract(); - - boolean isStatic(); - - boolean isFinal(); - - @NotNull - Visibility getVisibility(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaNamedElement.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaNamedElement.java deleted file mode 100644 index dfbf49de4ab..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaNamedElement.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.name.Name; - -public interface JavaNamedElement extends JavaElement { - @NotNull - Name getName(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPrimitiveType.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPrimitiveType.java deleted file mode 100644 index 21a500f4430..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPrimitiveType.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.PrimitiveType; - -public interface JavaPrimitiveType extends JavaType { - /** {@code null} means the {@code void} type. */ - @Nullable - PrimitiveType getType(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaType.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaType.java deleted file mode 100644 index af9d3821175..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaType.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -public interface JavaType { -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaTypeParameter.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaTypeParameter.java deleted file mode 100644 index bc1b8796b71..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaTypeParameter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.ReadOnly; - -import java.util.Collection; - -public interface JavaTypeParameter extends JavaClassifier { - @NotNull - @ReadOnly - Collection getUpperBounds(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaTypeParameterListOwner.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaTypeParameterListOwner.java deleted file mode 100644 index f7f011423bd..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaTypeParameterListOwner.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.ReadOnly; - -import java.util.List; - -public interface JavaTypeParameterListOwner extends JavaElement { - @NotNull - @ReadOnly - List getTypeParameters(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaValueParameter.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaValueParameter.java deleted file mode 100644 index 144563dff30..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaValueParameter.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.name.Name; - -public interface JavaValueParameter extends JavaAnnotationOwner { - @Nullable - Name getName(); - - @NotNull - JavaType getType(); - - boolean isVararg(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaWildcardType.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaWildcardType.java deleted file mode 100644 index 6aabb2ec314..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaWildcardType.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 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.load.java.structure; - -import org.jetbrains.annotations.Nullable; - -public interface JavaWildcardType extends JavaType { - @Nullable - JavaType getBound(); - - boolean isExtends(); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt new file mode 100644 index 00000000000..a357b9ce868 --- /dev/null +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt @@ -0,0 +1,109 @@ +/* + * 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.load.java.structure + +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +interface JavaElement + +interface JavaNamedElement : JavaElement { + val name: Name +} + +interface JavaAnnotationOwner : JavaElement { + val annotations: Collection + fun findAnnotation(fqName: FqName): JavaAnnotation? + + val isDeprecatedInJavaDoc: Boolean +} + +interface JavaModifierListOwner : JavaElement { + val isAbstract: Boolean + val isStatic: Boolean + val isFinal: Boolean + val visibility: Visibility +} + +interface JavaTypeParameterListOwner : JavaElement { + val typeParameters: List +} + +interface JavaAnnotation : JavaElement { + val arguments: Collection + val classId: ClassId? + + fun resolve(): JavaClass? +} + +interface JavaPackage : JavaElement { + val fqName: FqName + val subPackages: Collection + + fun getClasses(nameFilter: (Name) -> Boolean): Collection +} + +interface JavaClassifier : JavaNamedElement, JavaAnnotationOwner + +interface JavaClass : JavaClassifier, JavaTypeParameterListOwner, JavaModifierListOwner { + val fqName: FqName? + + val supertypes: Collection + val innerClasses: Collection + val outerClass: JavaClass? + + val isInterface: Boolean + val isAnnotationType: Boolean + val isEnum: Boolean + val isKotlinLightClass: Boolean + + val methods: Collection + val fields: Collection + val constructors: Collection +} + +interface JavaMember : JavaModifierListOwner, JavaAnnotationOwner, JavaNamedElement { + val containingClass: JavaClass +} + +interface JavaMethod : JavaMember, JavaTypeParameterListOwner { + val valueParameters: List + val returnType: JavaType + + val hasAnnotationParameterDefaultValue: Boolean +} + +interface JavaField : JavaMember { + val isEnumEntry: Boolean + val type: JavaType +} + +interface JavaConstructor : JavaMember, JavaTypeParameterListOwner { + val valueParameters: List +} + +interface JavaValueParameter : JavaAnnotationOwner { + val name: Name? + val type: JavaType + val isVararg: Boolean +} + +interface JavaTypeParameter : JavaClassifier { + val upperBounds: Collection +} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/javaTypes.kt similarity index 51% rename from core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt rename to core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/javaTypes.kt index 9d70ffd61cb..1c2b038f023 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/javaTypes.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. @@ -16,13 +16,29 @@ package org.jetbrains.kotlin.load.java.structure -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.builtins.PrimitiveType -interface JavaPackage : JavaElement { - fun getClasses(nameFilter: (Name) -> Boolean): Collection +interface JavaType - fun getSubPackages(): Collection - - fun getFqName(): FqName +interface JavaArrayType : JavaType { + val componentType: JavaType +} + +interface JavaClassifierType : JavaType, JavaAnnotationOwner { + val classifier: JavaClassifier? + val typeArguments: List + + val isRaw: Boolean + + val presentableText: String +} + +interface JavaPrimitiveType : JavaType { + /** `null` means the `void` type. */ + val type: PrimitiveType? +} + +interface JavaWildcardType : JavaType { + val bound: JavaType? + val isExtends: Boolean } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt index ab92bb1c32f..77e428de5bb 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt @@ -34,7 +34,7 @@ class KotlinJvmBinaryPackageSourceElement( result } - override fun toString(): String = "Binary package ${jPackage.getFqName()}: ${implClassNameToBinaryClass.keys}" + override fun toString(): String = "Binary package ${jPackage.fqName}: ${implClassNameToBinaryClass.keys}" override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE fun getRepresentativeBinaryClass(): KotlinJvmBinaryClass { diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt index c77b92a2e41..e14201627a8 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt @@ -18,19 +18,20 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaAnnotation import org.jetbrains.kotlin.load.java.structure.JavaAnnotationArgument +import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name class ReflectJavaAnnotation(val annotation: Annotation) : ReflectJavaElement(), JavaAnnotation { - override fun getArguments(): Collection { - return annotation.annotationClass.java.declaredMethods.map { method -> + override val arguments: Collection + get() = annotation.annotationClass.java.declaredMethods.map { method -> ReflectJavaAnnotationArgument.create(method.invoke(annotation), Name.identifier(method.name)) } - } + + override val classId: ClassId + get() = annotation.annotationClass.java.classId override fun resolve() = ReflectJavaClass(annotation.annotationClass.java) - override fun getClassId() = annotation.annotationClass.java.classId - override fun equals(other: Any?) = other is ReflectJavaAnnotation && annotation == other.annotation override fun hashCode() = annotation.hashCode() diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt index e45f59c96e9..3da10318aef 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt @@ -23,11 +23,14 @@ import java.lang.reflect.AnnotatedElement interface ReflectJavaAnnotationOwner : JavaAnnotationOwner { val element: AnnotatedElement? - override fun getAnnotations() = element?.declaredAnnotations?.getAnnotations() ?: emptyList() + override val annotations: List + get() = element?.declaredAnnotations?.getAnnotations() ?: emptyList() - override fun findAnnotation(fqName: FqName) = element?.declaredAnnotations?.findAnnotation(fqName) + override fun findAnnotation(fqName: FqName) = + element?.declaredAnnotations?.findAnnotation(fqName) - override fun isDeprecatedInJavaDoc() = false + override val isDeprecatedInJavaDoc: Boolean + get() = false } fun Array.getAnnotations(): List { diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt index 47bb86e1647..9babd0bb640 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt @@ -20,14 +20,12 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType import java.lang.reflect.GenericArrayType import java.lang.reflect.Type -class ReflectJavaArrayType(override val type: Type) : ReflectJavaType(), JavaArrayType { - private val componentType: ReflectJavaType = with (type) { +class ReflectJavaArrayType(override val reflectType: Type) : ReflectJavaType(), JavaArrayType { + override val componentType: ReflectJavaType = with (reflectType) { when { this is GenericArrayType -> ReflectJavaType.create(genericComponentType) this is Class<*> && isArray() -> ReflectJavaType.create(getComponentType()) - else -> throw IllegalArgumentException("Not an array type (${type.javaClass}): $type") + else -> throw IllegalArgumentException("Not an array type (${reflectType.javaClass}): $reflectType") } } - - override fun getComponentType() = componentType } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt index 803cea99f44..65480efaa95 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.java.structure.JavaClassifierType +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import java.lang.reflect.Method import java.util.* @@ -29,37 +30,42 @@ class ReflectJavaClass( override val modifiers: Int get() = klass.modifiers - override fun getInnerClasses() = klass.declaredClasses - .asSequence() - .filterNot { - // getDeclaredClasses() returns anonymous classes sometimes, for example enums with specialized entries (which are in fact - // anonymous classes) or in case of a special anonymous class created for the synthetic accessor to a private nested class - // constructor accessed from the outer class - it.simpleName.isEmpty() - } - .map(::ReflectJavaClass) - .toList() - - override fun getFqName() = klass.classId.asSingleFqName() - - override fun getOuterClass() = klass.declaringClass?.let(::ReflectJavaClass) - - override fun getSupertypes(): Collection { - if (klass == Any::class.java) return emptyList() - return listOf(klass.genericSuperclass ?: Any::class.java, *klass.genericInterfaces).map(::ReflectJavaClassifierType) - } - - override fun getMethods() = klass.declaredMethods - .asSequence() - .filter { method -> - when { - method.isSynthetic -> false - isEnum -> !isEnumValuesOrValueOf(method) - else -> true + override val innerClasses: List + get() = klass.declaredClasses + .asSequence() + .filterNot { + // getDeclaredClasses() returns anonymous classes sometimes, for example enums with specialized entries (which are + // in fact anonymous classes) or in case of a special anonymous class created for the synthetic accessor to a private + // nested class constructor accessed from the outer class + it.simpleName.isEmpty() } - } - .map(::ReflectJavaMethod) - .toList() + .map(::ReflectJavaClass) + .toList() + + override val fqName: FqName + get() = klass.classId.asSingleFqName() + + override val outerClass: ReflectJavaClass? + get() = klass.declaringClass?.let(::ReflectJavaClass) + + override val supertypes: Collection + get() { + if (klass == Any::class.java) return emptyList() + return listOf(klass.genericSuperclass ?: Any::class.java, *klass.genericInterfaces).map(::ReflectJavaClassifierType) + } + + override val methods: List + get() = klass.declaredMethods + .asSequence() + .filter { method -> + when { + method.isSynthetic -> false + isEnum -> !isEnumValuesOrValueOf(method) + else -> true + } + } + .map(::ReflectJavaMethod) + .toList() private fun isEnumValuesOrValueOf(method: Method): Boolean { return when (method.name) { @@ -69,27 +75,35 @@ class ReflectJavaClass( } } - override fun getFields() = klass.declaredFields - .asSequence() - .filter { field -> !field.isSynthetic } - .map(::ReflectJavaField) - .toList() + override val fields: List + get() = klass.declaredFields + .asSequence() + .filter { field -> !field.isSynthetic } + .map(::ReflectJavaField) + .toList() - override fun getConstructors() = klass.declaredConstructors - .asSequence() - .filter { constructor -> !constructor.isSynthetic } - .map(::ReflectJavaConstructor) - .toList() + override val constructors: List + get() = klass.declaredConstructors + .asSequence() + .filter { constructor -> !constructor.isSynthetic } + .map(::ReflectJavaConstructor) + .toList() - override fun isKotlinLightClass() = false + override val isKotlinLightClass: Boolean + get() = false - override fun getName() = Name.identifier(klass.simpleName) + override val name: Name + get() = Name.identifier(klass.simpleName) - override fun getTypeParameters() = klass.typeParameters.map { ReflectJavaTypeParameter(it) } + override val typeParameters: List + get() = klass.typeParameters.map { ReflectJavaTypeParameter(it) } - override fun isInterface() = klass.isInterface - override fun isAnnotationType() = klass.isAnnotation - override fun isEnum() = klass.isEnum + override val isInterface: Boolean + get() = klass.isInterface + override val isAnnotationType: Boolean + get() = klass.isAnnotation + override val isEnum: Boolean + get() = klass.isEnum override fun equals(other: Any?) = other is ReflectJavaClass && klass == other.klass diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt index d0b9ac0bbe8..116cd91cc9f 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt @@ -25,9 +25,9 @@ import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.lang.reflect.TypeVariable -class ReflectJavaClassifierType(public override val type: Type) : ReflectJavaType(), JavaClassifierType { - private val classifier: JavaClassifier = run { - val type = type +class ReflectJavaClassifierType(public override val reflectType: Type) : ReflectJavaType(), JavaClassifierType { + override val classifier: JavaClassifier = run { + val type = reflectType val classifier: JavaClassifier = when (type) { is Class<*> -> ReflectJavaClass(type) is TypeVariable<*> -> ReflectJavaTypeParameter(type) @@ -37,25 +37,26 @@ class ReflectJavaClassifierType(public override val type: Type) : ReflectJavaTyp classifier } - override fun getClassifier(): JavaClassifier = classifier + override val presentableText: String + get() = reflectType.toString() - override fun getPresentableText(): String = type.toString() + override val isRaw: Boolean + get() = with(reflectType) { this is Class<*> && getTypeParameters().isNotEmpty() } - override fun isRaw(): Boolean = with(type) { this is Class<*> && getTypeParameters().isNotEmpty() } - - override fun getTypeArguments(): List { - return generateSequence({type as? ParameterizedType}, { it.ownerType as? ParameterizedType }).flatMap { + override val typeArguments: List + get() = generateSequence({ reflectType as? ParameterizedType }, { it.ownerType as? ParameterizedType }).flatMap { it.actualTypeArguments.asSequence().map { ReflectJavaType.create(it) } }.toList() - } - override fun getAnnotations(): Collection { - return emptyList() // TODO - } + override val annotations: Collection + get() { + return emptyList() // TODO + } override fun findAnnotation(fqName: FqName): JavaAnnotation? { return null // TODO } - override fun isDeprecatedInJavaDoc() = false + override val isDeprecatedInJavaDoc: Boolean + get() = false } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt index 5dccf3005cd..8628c7567e9 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt @@ -17,33 +17,34 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaConstructor -import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter import org.jetbrains.kotlin.load.java.structure.JavaValueParameter import java.lang.reflect.Constructor import java.lang.reflect.Modifier class ReflectJavaConstructor(override val member: Constructor<*>) : ReflectJavaMember(), JavaConstructor { // TODO: test local/anonymous classes - override fun getValueParameters(): List { - val types = member.genericParameterTypes - if (types.isEmpty()) return emptyList() + override val valueParameters: List + get() { + val types = member.genericParameterTypes + if (types.isEmpty()) return emptyList() - val klass = member.declaringClass + val klass = member.declaringClass - val realTypes = when { - klass.declaringClass != null && !Modifier.isStatic(klass.modifiers) -> types.copyOfRange(1, types.size) - else -> types + val realTypes = when { + klass.declaringClass != null && !Modifier.isStatic(klass.modifiers) -> types.copyOfRange(1, types.size) + else -> types + } + + val annotations = member.parameterAnnotations + val realAnnotations = when { + annotations.size < realTypes.size -> throw IllegalStateException("Illegal generic signature: $member") + annotations.size > realTypes.size -> annotations.copyOfRange(annotations.size - realTypes.size, annotations.size) + else -> annotations + } + + return getValueParameters(realTypes, realAnnotations, member.isVarArgs) } - val annotations = member.parameterAnnotations - val realAnnotations = when { - annotations.size < realTypes.size -> throw IllegalStateException("Illegal generic signature: $member") - annotations.size > realTypes.size -> annotations.copyOfRange(annotations.size - realTypes.size, annotations.size) - else -> annotations - } - - return getValueParameters(realTypes, realAnnotations, member.isVarArgs) - } - - override fun getTypeParameters() = member.typeParameters.map { ReflectJavaTypeParameter(it) } + override val typeParameters: List + get() = member.typeParameters.map { ReflectJavaTypeParameter(it) } } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt index 3eb3214861e..4bdcf4f139b 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt @@ -20,7 +20,9 @@ import org.jetbrains.kotlin.load.java.structure.JavaField import java.lang.reflect.Field class ReflectJavaField(override val member: Field) : ReflectJavaMember(), JavaField { - override fun isEnumEntry() = member.isEnumConstant + override val isEnumEntry: Boolean + get() = member.isEnumConstant - override fun getType() = ReflectJavaType.create(member.genericType) + override val type: ReflectJavaType + get() = ReflectJavaType.create(member.genericType) } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt index 0d90aadeea4..bf2a20de76e 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt @@ -33,9 +33,11 @@ abstract class ReflectJavaMember : ReflectJavaElement(), ReflectJavaAnnotationOw override val modifiers: Int get() = member.modifiers - override fun getName() = member.name?.let { Name.identifier(it) } ?: SpecialNames.NO_NAME_PROVIDED + override val name: Name + get() = member.name?.let { Name.identifier(it) } ?: SpecialNames.NO_NAME_PROVIDED - override fun getContainingClass() = ReflectJavaClass(member.declaringClass) + override val containingClass: ReflectJavaClass + get() = ReflectJavaClass(member.declaringClass) protected fun getValueParameters( parameterTypes: Array, diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt index df2c9973ad7..c1aaeabe043 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt @@ -21,12 +21,15 @@ import org.jetbrains.kotlin.load.java.structure.JavaValueParameter import java.lang.reflect.Method class ReflectJavaMethod(override val member: Method) : ReflectJavaMember(), JavaMethod { - override fun getValueParameters(): List = - getValueParameters(member.genericParameterTypes, member.parameterAnnotations, member.isVarArgs) + override val valueParameters: List + get() = getValueParameters(member.genericParameterTypes, member.parameterAnnotations, member.isVarArgs) - override fun getReturnType() = ReflectJavaType.create(member.genericReturnType) + override val returnType: ReflectJavaType + get() = ReflectJavaType.create(member.genericReturnType) - override fun hasAnnotationParameterDefaultValue() = member.defaultValue != null + override val hasAnnotationParameterDefaultValue: Boolean + get() = member.defaultValue != null - override fun getTypeParameters() = member.typeParameters.map { ReflectJavaTypeParameter(it) } + override val typeParameters: List + get() = member.typeParameters.map { ReflectJavaTypeParameter(it) } } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt index 172b90f191b..d70a9da0ee0 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt @@ -25,18 +25,24 @@ import java.lang.reflect.Modifier interface ReflectJavaModifierListOwner : JavaModifierListOwner { /* protected // KT-3029 */ val modifiers: Int - override fun isAbstract() = Modifier.isAbstract(modifiers) - override fun isStatic() = Modifier.isStatic(modifiers) - override fun isFinal() = Modifier.isFinal(modifiers) + override val isAbstract: Boolean + get() = Modifier.isAbstract(modifiers) - override fun getVisibility(): Visibility = modifiers.let { modifiers -> - when { - Modifier.isPublic(modifiers) -> Visibilities.PUBLIC - Modifier.isPrivate(modifiers) -> Visibilities.PRIVATE - Modifier.isProtected(modifiers) -> - if (Modifier.isStatic(modifiers)) JavaVisibilities.PROTECTED_STATIC_VISIBILITY - else JavaVisibilities.PROTECTED_AND_PACKAGE - else -> JavaVisibilities.PACKAGE_VISIBILITY + override val isStatic: Boolean + get() = Modifier.isStatic(modifiers) + + override val isFinal: Boolean + get() = Modifier.isFinal(modifiers) + + override val visibility: Visibility + get() = modifiers.let { modifiers -> + when { + Modifier.isPublic(modifiers) -> Visibilities.PUBLIC + Modifier.isPrivate(modifiers) -> Visibilities.PRIVATE + Modifier.isProtected(modifiers) -> + if (Modifier.isStatic(modifiers)) JavaVisibilities.PROTECTED_STATIC_VISIBILITY + else JavaVisibilities.PROTECTED_AND_PACKAGE + else -> JavaVisibilities.PACKAGE_VISIBILITY + } } - } } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt index 46e278dbab6..6da7fcbe066 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt @@ -21,18 +21,17 @@ import org.jetbrains.kotlin.load.java.structure.JavaPackage import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -class ReflectJavaPackage(private val fqName: FqName) : ReflectJavaElement(), JavaPackage { - override fun getFqName() = fqName - +class ReflectJavaPackage(override val fqName: FqName) : ReflectJavaElement(), JavaPackage { override fun getClasses(nameFilter: (Name) -> Boolean): Collection { // A package at runtime can't know what classes it has and has not return listOf() } - override fun getSubPackages(): Collection { - // A package at runtime can't know what sub packages it has and has not - return listOf() - } + override val subPackages: Collection + get() { + // A package at runtime can't know what sub packages it has and has not + return listOf() + } override fun equals(other: Any?) = other is ReflectJavaPackage && fqName == other.fqName diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt index b33c3f12449..894753e9960 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt @@ -16,11 +16,14 @@ package org.jetbrains.kotlin.load.java.structure.reflect +import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType -class ReflectJavaPrimitiveType(override val type: Class<*>) : ReflectJavaType(), JavaPrimitiveType { - override fun getType() = - if (type == Void.TYPE) null - else JvmPrimitiveType.get(type.name).primitiveType +class ReflectJavaPrimitiveType(override val reflectType: Class<*>) : ReflectJavaType(), JavaPrimitiveType { + override val type: PrimitiveType? + get() = if (reflectType == Void.TYPE) + null + else + JvmPrimitiveType.get(reflectType.name).primitiveType } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt index 8afcca8e67a..771a5d7ac71 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt @@ -22,7 +22,7 @@ import java.lang.reflect.Type import java.lang.reflect.WildcardType abstract class ReflectJavaType : JavaType { - protected abstract val type: Type + protected abstract val reflectType: Type companion object Factory { fun create(type: Type): ReflectJavaType { @@ -35,9 +35,9 @@ abstract class ReflectJavaType : JavaType { } } - override fun equals(other: Any?) = other is ReflectJavaType && type == other.type + override fun equals(other: Any?) = other is ReflectJavaType && reflectType == other.reflectType - override fun hashCode() = type.hashCode() + override fun hashCode() = reflectType.hashCode() - override fun toString() = javaClass.name + ": " + type + override fun toString() = javaClass.name + ": " + reflectType } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt index f6dcd48e8a8..2004bfd206e 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt @@ -24,17 +24,19 @@ import java.lang.reflect.TypeVariable class ReflectJavaTypeParameter( val typeVariable: TypeVariable<*> ) : ReflectJavaElement(), JavaTypeParameter, ReflectJavaAnnotationOwner { - override fun getUpperBounds(): List { - val bounds = typeVariable.bounds.map { bound -> ReflectJavaClassifierType(bound) } - if (bounds.singleOrNull()?.type == Any::class.java) return emptyList() - return bounds - } + override val upperBounds: List + get() { + val bounds = typeVariable.bounds.map { bound -> ReflectJavaClassifierType(bound) } + if (bounds.singleOrNull()?.reflectType == Any::class.java) return emptyList() + return bounds + } override val element: AnnotatedElement? // TypeVariable is AnnotatedElement only in JDK8 get() = typeVariable as? AnnotatedElement - override fun getName() = Name.identifier(typeVariable.name) + override val name: Name + get() = Name.identifier(typeVariable.name) override fun equals(other: Any?) = other is ReflectJavaTypeParameter && typeVariable == other.typeVariable diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt index a0b19517b16..f46651d3d29 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt @@ -21,20 +21,22 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name class ReflectJavaValueParameter( - private val returnType: ReflectJavaType, - private val annotations: Array, - private val name: String?, - private val isVararg: Boolean + override val type: ReflectJavaType, + private val reflectAnnotations: Array, + private val reflectName: String?, + override val isVararg: Boolean ) : ReflectJavaElement(), JavaValueParameter { - override fun getAnnotations() = annotations.getAnnotations() + override val annotations: List + get() = reflectAnnotations.getAnnotations() - override fun findAnnotation(fqName: FqName) = annotations.findAnnotation(fqName) + override fun findAnnotation(fqName: FqName) = + reflectAnnotations.findAnnotation(fqName) - override fun isDeprecatedInJavaDoc() = false + override val isDeprecatedInJavaDoc: Boolean + get() = false - override fun getName() = name?.let(Name::guessByFirstCharacter) - override fun getType() = returnType - override fun isVararg() = isVararg + override val name: Name? + get() = reflectName?.let(Name::guessByFirstCharacter) - override fun toString() = javaClass.name + ": " + (if (isVararg) "vararg " else "") + getName() + ": " + returnType + override fun toString() = javaClass.name + ": " + (if (isVararg) "vararg " else "") + name + ": " + type } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt index 3bf2360e9b9..23a66af53f8 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt @@ -19,19 +19,21 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaWildcardType import java.lang.reflect.WildcardType -class ReflectJavaWildcardType(override val type: WildcardType): ReflectJavaType(), JavaWildcardType { - override fun getBound(): ReflectJavaType? { - val upperBounds = type.upperBounds - val lowerBounds = type.lowerBounds - if (upperBounds.size > 1 || lowerBounds.size > 1) { - throw UnsupportedOperationException("Wildcard types with many bounds are not yet supported: $type") +class ReflectJavaWildcardType(override val reflectType: WildcardType): ReflectJavaType(), JavaWildcardType { + override val bound: ReflectJavaType? + get() { + val upperBounds = reflectType.upperBounds + val lowerBounds = reflectType.lowerBounds + if (upperBounds.size > 1 || lowerBounds.size > 1) { + throw UnsupportedOperationException("Wildcard types with many bounds are not yet supported: $reflectType") + } + return when { + lowerBounds.size == 1 -> ReflectJavaType.create(lowerBounds.single()) + upperBounds.size == 1 -> upperBounds.single().let { ub -> if (ub != Any::class.java) ReflectJavaType.create(ub) else null } + else -> null + } } - return when { - lowerBounds.size == 1 -> ReflectJavaType.create(lowerBounds.single()) - upperBounds.size == 1 -> upperBounds.single().let { ub -> if (ub != Any::class.java) ReflectJavaType.create(ub) else null } - else -> null - } - } - override fun isExtends() = type.upperBounds.firstOrNull() != Any::class.java + override val isExtends: Boolean + get() = reflectType.upperBounds.firstOrNull() != Any::class.java } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt index 3fa5bf8934f..5d82c45c2d2 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt @@ -27,7 +27,6 @@ import org.jetbrains.kotlin.load.java.lazy.JavaResolverComponents import org.jetbrains.kotlin.load.java.lazy.LazyJavaPackageFragmentProvider import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver import org.jetbrains.kotlin.load.java.reflect.ReflectJavaClassFinder -import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator import org.jetbrains.kotlin.load.kotlin.BinaryClassAnnotationAndConstantLoaderImpl import org.jetbrains.kotlin.load.kotlin.DeserializationComponentsForJava import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver