Convert Java model to Kotlin, put in several files
Also move JavaPropertyInitializerEvaluator to ../components/
This commit is contained in:
@@ -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.*
|
||||
|
||||
+3
-3
@@ -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
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class JavaMethodImpl extends JavaMemberImpl<PsiMethod> implements JavaMet
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnnotationParameterDefaultValue() {
|
||||
public boolean getHasAnnotationParameterDefaultValue() {
|
||||
PsiMethod psiMethod = getPsi();
|
||||
return psiMethod instanceof PsiAnnotationMethod && ((PsiAnnotationMethod) psiMethod).getDefaultValue() != null;
|
||||
}
|
||||
|
||||
+4
-2
@@ -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<JavaPackage>
|
||||
get() = packages(psi.getSubPackages(scope), scope)
|
||||
|
||||
override fun getFqName() = FqName(psi.qualifiedName)
|
||||
override val fqName: FqName
|
||||
get() = FqName(psi.qualifiedName)
|
||||
}
|
||||
|
||||
+2
-5
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user