constant for "namespace"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
import java.util.*;
|
||||
@@ -72,7 +73,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
for (JetFile file : filesInScope) {
|
||||
final String packageName = JetPsiUtil.getFQName(file);
|
||||
if (packageName != null && qualifiedName.startsWith(packageName)) {
|
||||
if (qualifiedName.equals(fqn(packageName, "namespace"))) {
|
||||
if (qualifiedName.equals(fqn(packageName, JvmAbi.PACKAGE_CLASS))) {
|
||||
answer.add(new JetLightClass(psiManager, file, qualifiedName));
|
||||
}
|
||||
else {
|
||||
@@ -122,7 +123,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
String packageFQN = psiPackage.getQualifiedName();
|
||||
for (JetFile psiFile : collectProjectJetFiles(project, GlobalSearchScope.allScope(project))) {
|
||||
if (packageFQN.equals(JetPsiUtil.getFQName(psiFile))) {
|
||||
answer.add("namespace");
|
||||
answer.add(JvmAbi.PACKAGE_CLASS);
|
||||
for (JetDeclaration declaration : psiFile.getDeclarations()) {
|
||||
if (declaration instanceof JetClassOrObject) {
|
||||
answer.add(getLocalName(declaration));
|
||||
@@ -160,7 +161,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
String packageFQN = psiPackage.getQualifiedName();
|
||||
for (JetFile file : filesInScope) {
|
||||
if (packageFQN.equals(JetPsiUtil.getFQName(file))) {
|
||||
answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, "namespace")));
|
||||
answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, JvmAbi.PACKAGE_CLASS)));
|
||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||
if (declaration instanceof JetClassOrObject) {
|
||||
answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, getLocalName(declaration))));
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.ClassBuilder;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
@@ -52,7 +53,7 @@ public class StubClassBuilder extends ClassBuilder {
|
||||
v = new StubBuildingVisitor<Object>(null, EMPTY_STRATEGY, parent, access);
|
||||
|
||||
super.defineClass(origin, version, access, name, signature, superName, interfaces);
|
||||
if (name.equals("namespace") || name.endsWith("/namespace")) {
|
||||
if (name.equals(JvmAbi.PACKAGE_CLASS) || name.endsWith("/" + JvmAbi.PACKAGE_CLASS)) {
|
||||
isNamespace = true;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
if (JetMainDetector.hasMain(jetFile.getDeclarations())) {
|
||||
mySourceElement = jetFile;
|
||||
String fqName = JetPsiUtil.getFQName(jetFile);
|
||||
String className = fqName.length() == 0 ? "namespace" : fqName + ".namespace";
|
||||
String className = fqName.length() == 0 ? JvmAbi.PACKAGE_CLASS : fqName + "." + JvmAbi.PACKAGE_CLASS;
|
||||
return createConfigurationByQName(module, configurationContext, className);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(module.getProject(), context);
|
||||
JetRunConfiguration configuration = (JetRunConfiguration) settings.getConfiguration();
|
||||
configuration.setModule(module);
|
||||
configuration.setName(StringUtil.trimEnd(fqName, ".namespace"));
|
||||
configuration.setName(StringUtil.trimEnd(fqName, "." + JvmAbi.PACKAGE_CLASS));
|
||||
configuration.MAIN_CLASS_NAME = fqName;
|
||||
return settings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user