TEST_MODULE_NAME extraction

This commit is contained in:
Michael Bogdanov
2015-09-04 16:05:07 +03:00
parent 49ee4169f3
commit b58479a169
5 changed files with 6 additions and 5 deletions
@@ -479,7 +479,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
@NotNull GenerationState state, @NotNull GenerationState state,
@NotNull ClassBuilder classBuilder @NotNull ClassBuilder classBuilder
) { ) {
classBuilder.newField(NO_ORIGIN, ACC_PUBLIC | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.KOTLIN_MODULE_FIELD_NAME, classBuilder.newField(NO_ORIGIN, ACC_PUBLIC | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.MODULE_NAME_FIELD,
AsmTypes.JAVA_STRING_TYPE.getDescriptor(), null, state.getModuleName()); AsmTypes.JAVA_STRING_TYPE.getDescriptor(), null, state.getModuleName());
} }
@@ -58,7 +58,7 @@ public class LazyResolveTestUtil {
@NotNull List<JetFile> sourceFiles, @NotNull List<JetFile> sourceFiles,
@NotNull KotlinCoreEnvironment environment @NotNull KotlinCoreEnvironment environment
) { ) {
ModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, "test"); ModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, JvmResolveUtil.TEST_MODULE_NAME);
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationNoIncremental( TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationNoIncremental(
moduleContext, sourceFiles, trace, TopDownAnalysisMode.TopLevelDeclarations, moduleContext, sourceFiles, trace, TopDownAnalysisMode.TopLevelDeclarations,
@@ -44,7 +44,7 @@ public final class JvmAbi {
public static final String KOTLIN_CLASS_FIELD_NAME = "$kotlinClass"; public static final String KOTLIN_CLASS_FIELD_NAME = "$kotlinClass";
public static final String KOTLIN_PACKAGE_FIELD_NAME = "$kotlinPackage"; public static final String KOTLIN_PACKAGE_FIELD_NAME = "$kotlinPackage";
public static final String KOTLIN_MODULE_FIELD_NAME = "$moduleName"; public static final String MODULE_NAME_FIELD = "$moduleName";
public static final ClassId REFLECTION_FACTORY_IMPL = ClassId.topLevel(new FqName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl")); public static final ClassId REFLECTION_FACTORY_IMPL = ClassId.topLevel(new FqName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl"));
@NotNull @NotNull
@@ -98,7 +98,7 @@ public val Class<*>.kotlinPackage: KPackage?
get() = if (getSimpleName().endsWith("Package") && get() = if (getSimpleName().endsWith("Package") &&
getAnnotation(javaClass<kotlin.jvm.internal.KotlinPackage>()) != null) { getAnnotation(javaClass<kotlin.jvm.internal.KotlinPackage>()) != null) {
try { try {
val field = this.getField(JvmAbi.KOTLIN_MODULE_FIELD_NAME) val field = this.getField(JvmAbi.MODULE_NAME_FIELD)
if (field != null) { if (field != null) {
KPackageImpl(this, field.get(null) as String) KPackageImpl(this, field.get(null) as String)
} }
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.BindingTraceContext import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
@@ -48,7 +49,7 @@ public class DecompiledTextConsistencyTest : TextConsistencyBaseTest() {
override fun getModuleDescriptor(): ModuleDescriptor = override fun getModuleDescriptor(): ModuleDescriptor =
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationWithCustomContext( TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationWithCustomContext(
TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, "test"), TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, JvmResolveUtil.TEST_MODULE_NAME),
listOf(), BindingTraceContext(), null, null, listOf(), BindingTraceContext(), null, null,
IDEPackagePartProvider(GlobalSearchScope.allScope(project)) IDEPackagePartProvider(GlobalSearchScope.allScope(project))
).moduleDescriptor ).moduleDescriptor