constant for "namespace"

This commit is contained in:
Stepan Koltsov
2011-12-30 18:45:40 +04:00
parent c2dc189bec
commit 4b9e4b65b4
8 changed files with 21 additions and 14 deletions
@@ -7,6 +7,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.JavaClassDescriptor;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.types.JetStandardClasses;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeProjection;
@@ -206,12 +207,12 @@ public class NamespaceCodegen {
public static String getJVMClassName(String fqName) {
if (fqName.length() == 0) {
return "namespace";
return JvmAbi.PACKAGE_CLASS;
}
String name = fqName.replace('.', '/') + "/namespace";
String name = fqName.replace('.', '/') + "/" + JvmAbi.PACKAGE_CLASS;
if(name.startsWith("<java_root>")) {
name = name.substring("<java_root>".length() + 1, name.length() - ".namespace".length());
name = name.substring("<java_root>".length() + 1, name.length() - 1 - JvmAbi.PACKAGE_CLASS.length());
}
return name;
}
@@ -16,6 +16,7 @@ import org.jetbrains.jet.codegen.ClassFileFactory;
import org.jetbrains.jet.codegen.GeneratedClassLoader;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.plugin.JetMainDetector;
import java.io.*;
@@ -210,7 +211,7 @@ public class CompileEnvironment {
Class moduleSetBuilderClass = loader.loadClass("kotlin.modules.ModuleSetBuilder");
final IModuleSetBuilder moduleSetBuilder = (IModuleSetBuilder) moduleSetBuilderClass.newInstance();
Class namespaceClass = loader.loadClass("namespace");
Class namespaceClass = loader.loadClass(JvmAbi.PACKAGE_CLASS);
final Field[] fields = namespaceClass.getDeclaredFields();
boolean modulesDefined = false;
for (Field field : fields) {
@@ -343,7 +344,7 @@ public class CompileEnvironment {
String mainClass = null;
for (JetFile file : session.getSourceFileNamespaces()) {
if (JetMainDetector.hasMain(file.getDeclarations())) {
mainClass = JetPsiUtil.getFQName(file) + ".namespace";
mainClass = JetPsiUtil.getFQName(file) + "." + JvmAbi.PACKAGE_CLASS;
break;
}
}
@@ -48,7 +48,7 @@ public class JavaPackageScope extends JetScopeImpl {
}
// TODO: what is GlobalSearchScope
PsiClass psiClass = semanticServices.getDescriptorResolver().javaFacade.findClass(getQualifiedName("namespace"));
PsiClass psiClass = semanticServices.getDescriptorResolver().javaFacade.findClass(getQualifiedName(JvmAbi.PACKAGE_CLASS));
if (psiClass == null) {
return null;
}
@@ -116,7 +116,7 @@ public class JavaPackageScope extends JetScopeImpl {
}
for (PsiClass psiClass : javaPackage.getClasses()) {
if (isKotlinNamespace && "namespace".equals(psiClass.getName())) continue;
if (isKotlinNamespace && JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) continue;
// If this is a Kotlin class, we have already taken it through a containing namespace descriptor
ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(psiClass.getQualifiedName());
@@ -8,4 +8,5 @@ public class JvmAbi {
public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default";
public static final String GETTER_PREFIX = "get";
public static final String SETTER_PREFIX = "set";
public static final String PACKAGE_CLASS = "namespace";
}
@@ -7,6 +7,7 @@ import org.jetbrains.jet.lang.diagnostics.Renderer;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetStandardClasses;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.Collection;
import java.util.Collections;
@@ -268,7 +269,7 @@ public class DescriptorRenderer implements Renderer {
@Override
public Void visitNamespaceDescriptor(NamespaceDescriptor namespaceDescriptor, StringBuilder builder) {
builder.append(renderKeyword("namespace")).append(" ");
builder.append(renderKeyword(JetTokens.NAMESPACE_KEYWORD.getValue())).append(" ");
renderName(namespaceDescriptor, builder);
return super.visitNamespaceDescriptor(namespaceDescriptor, builder);
}