Get rid of DeserializedNewPackageMemberScope.kt
This commit is contained in:
+8
-2
@@ -29,12 +29,12 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.serialization.PackageData
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedNewPackageMemberScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
@@ -124,7 +124,13 @@ public class IncrementalPackageFragmentProvider(
|
||||
}
|
||||
else {
|
||||
val scopes = dataOfPackageParts.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it)) }
|
||||
DecapitalizedAnnotationScope.wrapIfNeeded(DeserializedNewPackageMemberScope(this, scopes), fqName)
|
||||
DecapitalizedAnnotationScope.wrapIfNeeded(
|
||||
ChainedScope(this,
|
||||
"Member scope for incremental compilation: union of package parts data",
|
||||
*scopes.toTypedArray<JetScope>()
|
||||
),
|
||||
fqName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class LazyJavaPackageScope(
|
||||
if (kotlinBinaryClasses().isEmpty())
|
||||
JetScope.Empty
|
||||
else {
|
||||
c.components.deserializedDescriptorResolver.createKotlinNewPackageScope(packageFragment, kotlinBinaryClasses())
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, kotlinBinaryClasses())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -23,13 +23,13 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.serialization.ClassData;
|
||||
import org.jetbrains.kotlin.serialization.PackageData;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ClassDataProvider;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedNewPackageMemberScope;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope;
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil;
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
public JetScope createKotlinPackagePartScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
String[] data = readData(kotlinClass, KotlinClassHeader.Kind.FILE_FACADE);
|
||||
if (data != null) {
|
||||
//all classes are included in java scope
|
||||
@@ -87,10 +87,10 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope createKotlinNewPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
public JetScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
List<JetScope> list = new ArrayList<JetScope>();
|
||||
for (KotlinJvmBinaryClass callable : packageParts) {
|
||||
JetScope scope = createKotlinPackageScope(descriptor, callable);
|
||||
JetScope scope = createKotlinPackagePartScope(descriptor, callable);
|
||||
if (scope != null) {
|
||||
list.add(scope);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public final class DeserializedDescriptorResolver {
|
||||
if (list.isEmpty()) {
|
||||
return JetScope.Empty.INSTANCE$;
|
||||
}
|
||||
return new DeserializedNewPackageMemberScope(descriptor, list);
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new JetScope[list.size()]));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
-61
@@ -1,61 +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.serialization.deserialization.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public open class DeserializedNewPackageMemberScope(
|
||||
val packageDescriptor: PackageFragmentDescriptor,
|
||||
val membersList: List<JetScope>
|
||||
) : JetScopeImpl() {
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = membersList.flatMap { it.getFunctions(name, location) }
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = membersList.flatMap { it.getProperties(name, location) }
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation) = membersList.asSequence().map { it.getClassifier(name, location) }.filterNotNull().firstOrNull()
|
||||
|
||||
override fun getContainingDeclaration() = packageDescriptor
|
||||
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
||||
return listOf()
|
||||
}
|
||||
|
||||
override fun getOwnDeclaredDescriptors() = getAllDescriptors()
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.getSimpleName(), " {")
|
||||
p.pushIndent()
|
||||
|
||||
p.println("containingDeclaration = " + getContainingDeclaration())
|
||||
|
||||
p.popIndent()
|
||||
p.println("}")
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= membersList.flatMap { it.getDescriptors(kindFilter, nameFilter) }
|
||||
}
|
||||
Reference in New Issue
Block a user