Infrastructure change: each header module now knows implementing modules list

This commit is contained in:
Mikhail Glukhikh
2016-12-09 18:18:23 +03:00
parent 57da92b862
commit 9ec1c5dc35
3 changed files with 19 additions and 2 deletions
@@ -49,6 +49,8 @@ interface ModuleDescriptor : DeclarationDescriptor {
*/
val allDependentModules: List<ModuleDescriptor>
val allImplementingModules: Set<ModuleDescriptor>
fun <T> getCapability(capability: Capability<T>): T?
class Capability<T>(val name: String) {
@@ -52,6 +52,8 @@ class ModuleDescriptorImpl @JvmOverloads constructor(
override val allDependentModules: List<ModuleDescriptor>
get() = this.dependencies.sure { "Dependencies of module $id were not set" }.allDependencies.filter { it != this }
override val allImplementingModules: MutableSet<ModuleDescriptor> = mutableSetOf()
override fun getPackage(fqName: FqName): PackageViewDescriptor = packages(fqName)
override fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection<FqName> {
@@ -79,6 +81,12 @@ class ModuleDescriptorImpl @JvmOverloads constructor(
fun setDependencies(dependencies: ModuleDependencies) {
assert(this.dependencies == null) { "Dependencies of $id were already set" }
this.dependencies = dependencies
if (platformKind == PlatformKind.DEFAULT) return
for (dependentModule in allDependentModules) {
if (dependentModule.platformKind != PlatformKind.DEFAULT) continue
if (dependentModule.sourceKind != sourceKind) continue
(dependentModule as? ModuleDescriptorImpl)?.allImplementingModules?.add(this)
}
}
fun setDependencies(vararg descriptors: ModuleDescriptorImpl) {
@@ -41,6 +41,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import static java.util.Collections.emptySet;
import static kotlin.collections.CollectionsKt.emptyList;
import static kotlin.collections.CollectionsKt.joinToString;
@@ -97,6 +98,12 @@ public class ErrorUtils {
return emptyList();
}
@NotNull
@Override
public Set<ModuleDescriptor> getAllImplementingModules() {
return emptySet();
}
@Override
public <R, D> R accept(@NotNull DeclarationDescriptorVisitor<R, D> visitor, D data) {
return null;
@@ -205,13 +212,13 @@ public class ErrorUtils {
@NotNull
@Override
public Set<Name> getFunctionNames() {
return Collections.emptySet();
return emptySet();
}
@NotNull
@Override
public Set<Name> getVariableNames() {
return Collections.emptySet();
return emptySet();
}
@NotNull