stubs for new components
This commit is contained in:
+3
-2
@@ -30,7 +30,8 @@ import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
public class LazyJavaPackageFragmentProvider(
|
||||
components: JavaResolverComponents,
|
||||
module: ModuleDescriptor,
|
||||
reflectionTypes: ReflectionTypes
|
||||
reflectionTypes: ReflectionTypes,
|
||||
packageMapper: PackageMappingProvider
|
||||
) : PackageFragmentProvider {
|
||||
|
||||
private val c =
|
||||
@@ -41,7 +42,7 @@ public class LazyJavaPackageFragmentProvider(
|
||||
fqName ->
|
||||
val jPackage = c.components.finder.findPackage(fqName)
|
||||
if (jPackage != null) {
|
||||
LazyJavaPackageFragment(c, jPackage)
|
||||
LazyJavaPackageFragment(c, jPackage, packageMapper)
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.lazy
|
||||
|
||||
//interface PackageMappingProvider {
|
||||
//
|
||||
// fun findPackageMembers(packageName: String): List<String>
|
||||
//
|
||||
// companion object {
|
||||
// val EMPTY = object : PackageMappingProvider {
|
||||
// override fun findPackageMembers(packageName: String): List<String> {
|
||||
// return emptyList()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
+4
-1
@@ -19,7 +19,9 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.lazy.PackageMappingProvider
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
@@ -27,7 +29,8 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
|
||||
class LazyJavaPackageFragment(
|
||||
private val c: LazyJavaResolverContext,
|
||||
private val jPackage: JavaPackage
|
||||
private val jPackage: JavaPackage,
|
||||
val packageMapper: PackageMappingProvider
|
||||
) : PackageFragmentDescriptorImpl(c.module, jPackage.getFqName()) {
|
||||
val scope: LazyJavaPackageScope by lazy { LazyJavaPackageScope(c, jPackage, this) }
|
||||
// Just a temporary hack to inject deprecated decapitalized annotation
|
||||
|
||||
+8
-2
@@ -52,8 +52,14 @@ public class LazyJavaPackageScope(
|
||||
val kotlinBinaryClass = kotlinBinaryClass
|
||||
if (kotlinBinaryClass == null)
|
||||
JetScope.Empty
|
||||
else
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, kotlinBinaryClass) ?: JetScope.Empty
|
||||
else {
|
||||
val pakage = jPackage.getFqName().asString()
|
||||
val files = containingDeclaration.packageMapper.findPackageMembers(pakage.replace("\\.", "/"))
|
||||
// println("package:" + pakage)
|
||||
// println(files.join())
|
||||
val jetScope = c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, kotlinBinaryClass) ?: JetScope.Empty
|
||||
jetScope
|
||||
}
|
||||
}
|
||||
|
||||
private val packageFragment: LazyJavaPackageFragment get() = getContainingDeclaration() as LazyJavaPackageFragment
|
||||
|
||||
@@ -30,15 +30,49 @@ public class ModuleMapping(val moduleMapping: String) {
|
||||
miniFacades.parts.add(facade)
|
||||
}
|
||||
}
|
||||
|
||||
fun findPackageParts(internalPackageName: String): PackageFacades? {
|
||||
return package2MiniFacades[internalPackageName]
|
||||
}
|
||||
|
||||
companion object {
|
||||
public val MAPPING_FILE_EXT: String = "kotlin_module";
|
||||
}
|
||||
}
|
||||
|
||||
public class PackageFacades(val internalName: String) {
|
||||
|
||||
val parts = hashSetOf<String>()
|
||||
val parts = linkedSetOf<String>()
|
||||
|
||||
fun serialize(out: Writer) {
|
||||
for (i in parts) {
|
||||
out.write("$internalName->$i\n")
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is PackageFacades) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.internalName != internalName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.parts.size() != parts.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (part in other.parts) {
|
||||
if (!parts.contains(part)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return internalName.hashCode() / 3 + parts.size() / 3+ (parts.firstOrNull()?.hashCode() ?: 0) /3
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user