Add a temporary hack for migration "jet" -> "kotlin"
This commit is contained in:
@@ -44,6 +44,7 @@ import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
|||||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||||
import com.intellij.util.containers.ContainerUtil
|
import com.intellij.util.containers.ContainerUtil
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||||
|
import org.jetbrains.jet.lang.types.lang.BuiltInsPackageMigration
|
||||||
|
|
||||||
public class BuiltInsSerializer(val out: PrintStream?) {
|
public class BuiltInsSerializer(val out: PrintStream?) {
|
||||||
private var totalSize = 0
|
private var totalSize = 0
|
||||||
@@ -84,6 +85,24 @@ public class BuiltInsSerializer(val out: PrintStream?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (fqName in ContainerUtil.mapNotNull(files) { it?.getPackageName() }.toSet()) {
|
for (fqName in ContainerUtil.mapNotNull(files) { it?.getPackageName() }.toSet()) {
|
||||||
|
if (fqName == "kotlin") {
|
||||||
|
BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage = true
|
||||||
|
val provider = session.getDeclarationProviderFactory().getPackageMemberDeclarationProvider(FqName(fqName))!!
|
||||||
|
|
||||||
|
fun resolveClass(name: String): ClassDescriptor {
|
||||||
|
val classes = provider.getClassOrObjectDeclarations(Name.identifier(name))
|
||||||
|
assert(classes.size() == 1, "Class $name not found: " + classes)
|
||||||
|
return session.getClassDescriptor(classes.iterator().next())
|
||||||
|
}
|
||||||
|
BuiltInsPackageMigration.anyType = resolveClass("Any").getDefaultType()
|
||||||
|
BuiltInsPackageMigration.stringType = resolveClass("String").getDefaultType()
|
||||||
|
BuiltInsPackageMigration.annotationType = resolveClass("Annotation").getDefaultType()
|
||||||
|
BuiltInsPackageMigration.arrayClass = resolveClass("Array")
|
||||||
|
BuiltInsPackageMigration.enumClass = resolveClass("Enum")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage = false
|
||||||
|
}
|
||||||
serializePackage(module, FqName(fqName), destDir)
|
serializePackage(module, FqName(fqName), destDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.jet.lang.types.lang;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
|
|
||||||
|
// This is a temporary hack for migration of built-ins from package "jet" to "kotlin"
|
||||||
|
public class BuiltInsPackageMigration {
|
||||||
|
public static boolean isSerializingBuiltInsInKotlinPackage = false;
|
||||||
|
|
||||||
|
public static JetType anyType = null;
|
||||||
|
public static JetType stringType = null;
|
||||||
|
public static JetType annotationType = null;
|
||||||
|
public static ClassDescriptor arrayClass = null;
|
||||||
|
public static ClassDescriptor enumClass = null;
|
||||||
|
}
|
||||||
@@ -291,6 +291,9 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ClassDescriptor getArray() {
|
public ClassDescriptor getArray() {
|
||||||
|
if (BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage) {
|
||||||
|
return BuiltInsPackageMigration.arrayClass;
|
||||||
|
}
|
||||||
return getBuiltInClassByName("Array");
|
return getBuiltInClassByName("Array");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,6 +398,9 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ClassDescriptor getEnum() {
|
public ClassDescriptor getEnum() {
|
||||||
|
if (BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage) {
|
||||||
|
return BuiltInsPackageMigration.enumClass;
|
||||||
|
}
|
||||||
return getBuiltInClassByName("Enum");
|
return getBuiltInClassByName("Enum");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,6 +577,9 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetType getAnyType() {
|
public JetType getAnyType() {
|
||||||
|
if (BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage) {
|
||||||
|
return BuiltInsPackageMigration.anyType;
|
||||||
|
}
|
||||||
return getBuiltInTypeByClassName("Any");
|
return getBuiltInTypeByClassName("Any");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,6 +651,9 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetType getStringType() {
|
public JetType getStringType() {
|
||||||
|
if (BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage) {
|
||||||
|
return BuiltInsPackageMigration.stringType;
|
||||||
|
}
|
||||||
return getBuiltInTypeByClassName("String");
|
return getBuiltInTypeByClassName("String");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,6 +717,9 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetType getAnnotationType() {
|
public JetType getAnnotationType() {
|
||||||
|
if (BuiltInsPackageMigration.isSerializingBuiltInsInKotlinPackage) {
|
||||||
|
return BuiltInsPackageMigration.annotationType;
|
||||||
|
}
|
||||||
return getBuiltInTypeByClassName("Annotation");
|
return getBuiltInTypeByClassName("Annotation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user