Infrastructure change: module descriptor now knows its platform kind & its sources kind

This commit is contained in:
Mikhail Glukhikh
2016-12-09 16:47:27 +03:00
parent d32ab9d4d6
commit 57da92b862
11 changed files with 108 additions and 17 deletions
@@ -26,6 +26,10 @@ interface ModuleDescriptor : DeclarationDescriptor {
val builtIns: KotlinBuiltIns
val platformKind: PlatformKind
val sourceKind: SourceKind
fun shouldSeeInternalsOf(targetModule: ModuleDescriptor): Boolean
override fun substitute(substitutor: TypeSubstitutor): ModuleDescriptor {
@@ -0,0 +1,23 @@
/*
* 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.descriptors
enum class PlatformKind {
DEFAULT,
JVM,
JS
}
@@ -0,0 +1,23 @@
/*
* 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.descriptors
enum class SourceKind {
NONE,
PRODUCTION,
TEST
}
@@ -17,9 +17,7 @@
package org.jetbrains.kotlin.descriptors.impl
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -31,6 +29,8 @@ class ModuleDescriptorImpl @JvmOverloads constructor(
moduleName: Name,
private val storageManager: StorageManager,
override val builtIns: KotlinBuiltIns,
override val platformKind: PlatformKind = PlatformKind.DEFAULT,
override val sourceKind: SourceKind = SourceKind.NONE,
private val capabilities: Map<ModuleDescriptor.Capability<*>, Any?> = emptyMap()
) : DeclarationDescriptorImpl(Annotations.EMPTY, moduleName), ModuleDescriptor {
init {
@@ -49,6 +49,18 @@ public class ErrorUtils {
private static final ModuleDescriptor ERROR_MODULE;
static {
ERROR_MODULE = new ModuleDescriptor() {
@NotNull
@Override
public PlatformKind getPlatformKind() {
return PlatformKind.DEFAULT;
}
@NotNull
@Override
public SourceKind getSourceKind() {
return SourceKind.NONE;
}
@Nullable
@Override
public <T> T getCapability(@NotNull Capability<T> capability) {