Rename namespace class to {package.name}Package
Conflicts: compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java
This commit is contained in:
+6
-1
@@ -27,7 +27,8 @@ public class AbstractCodegenTestCaseOnAndroid extends TestCase {
|
||||
protected void invokeBoxMethod(String filePath, String expectedResult) throws Exception {
|
||||
try {
|
||||
Class clazz;
|
||||
clazz = Class.forName(filePath.replaceAll("\\\\|-|\\.|/", "_") + ".namespace");
|
||||
String packageName = filePath.replaceAll("\\\\|-|\\.|/", "_");
|
||||
clazz = Class.forName(packageName + "." + getPackageClassName(packageName));
|
||||
Method method;
|
||||
method = clazz.getMethod("box");
|
||||
assertEquals(expectedResult, method.invoke(null));
|
||||
@@ -36,4 +37,8 @@ public class AbstractCodegenTestCaseOnAndroid extends TestCase {
|
||||
throw new RuntimeException("File: " + filePath, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPackageClassName(String packageName) {
|
||||
return Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1, packageName.length()) + "Package";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -142,7 +142,8 @@ public class NamespaceCodegen extends MemberCodegen {
|
||||
}
|
||||
|
||||
if (k > 0) {
|
||||
String namespaceInternalName = JvmClassName.byFqNameWithoutInnerClasses(name.child(Name.identifier(JvmAbi.PACKAGE_CLASS))).getInternalName();
|
||||
String namespaceInternalName = JvmClassName.byFqNameWithoutInnerClasses(
|
||||
PackageClassUtils.getPackageClassFqName(name)).getInternalName();
|
||||
String className = getMultiFileNamespaceInternalName(namespaceInternalName, file);
|
||||
ClassBuilder builder = state.getFactory().forNamespacepart(className, file);
|
||||
|
||||
@@ -271,11 +272,12 @@ public class NamespaceCodegen extends MemberCodegen {
|
||||
|
||||
@NotNull
|
||||
public static JvmClassName getJVMClassNameForKotlinNs(@NotNull FqName fqName) {
|
||||
String packageClassName = PackageClassUtils.getPackageClassName(fqName);
|
||||
if (fqName.isRoot()) {
|
||||
return JvmClassName.byInternalName(JvmAbi.PACKAGE_CLASS);
|
||||
return JvmClassName.byInternalName(packageClassName);
|
||||
}
|
||||
|
||||
return JvmClassName.byFqNameWithoutInnerClasses(fqName.child(Name.identifier(JvmAbi.PACKAGE_CLASS)));
|
||||
return JvmClassName.byFqNameWithoutInnerClasses(fqName.child(Name.identifier(packageClassName)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+6
-2
@@ -24,6 +24,8 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
@@ -255,11 +257,13 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
}
|
||||
else if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
String peek = peekFromStack(nameStack);
|
||||
FqName qualifiedName = ((NamespaceDescriptor) containingDeclaration).getQualifiedName();
|
||||
String packageClassName = PackageClassUtils.getPackageClassName(qualifiedName);
|
||||
if (peek.isEmpty()) {
|
||||
peek = JvmAbi.PACKAGE_CLASS;
|
||||
peek = packageClassName;
|
||||
}
|
||||
else {
|
||||
peek += "/" + JvmAbi.PACKAGE_CLASS;
|
||||
peek += "/" + packageClassName;
|
||||
}
|
||||
nameStack.push(peek + '$' + function.getName());
|
||||
super.visitNamedFunction(function);
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
@@ -144,9 +145,10 @@ public final class PsiCodegenPredictor {
|
||||
|
||||
private static JvmClassName addPackageClass(JvmClassName packageName) {
|
||||
FqName name = packageName.getFqName();
|
||||
String packageClassName = PackageClassUtils.getPackageClassName(name);
|
||||
return name.isRoot() ?
|
||||
JvmClassName.byFqNameWithoutInnerClasses(JvmAbi.PACKAGE_CLASS) :
|
||||
JvmClassName.byInternalName(packageName.getInternalName() + "/" + JvmAbi.PACKAGE_CLASS);
|
||||
JvmClassName.byFqNameWithoutInnerClasses(packageClassName) :
|
||||
JvmClassName.byInternalName(packageName.getInternalName() + "/" + packageClassName);
|
||||
}
|
||||
|
||||
public static boolean checkPredictedClassNameForFun(
|
||||
|
||||
@@ -145,7 +145,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (r.length() > 0) {
|
||||
r.append("/");
|
||||
}
|
||||
r.append("namespace");
|
||||
r.append(PackageClassUtils.getPackageClassName(namespace.getQualifiedName()));
|
||||
}
|
||||
|
||||
if (r.length() == 0) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
@@ -137,7 +137,7 @@ public class CompileEnvironmentUtil {
|
||||
loader = new GeneratedClassLoader(factory, KotlinToJVMBytecodeCompiler.class.getClassLoader());
|
||||
}
|
||||
try {
|
||||
Class namespaceClass = loader.loadClass(JvmAbi.PACKAGE_CLASS);
|
||||
Class namespaceClass = loader.loadClass(PackageClassUtils.getPackageClassName(FqName.ROOT));
|
||||
final Method method = namespaceClass.getDeclaredMethod("project");
|
||||
if (method == null) {
|
||||
throw new CompileEnvironmentException("Module script " + moduleFile + " must define project() function");
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptNameUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
@@ -166,7 +166,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
return null;
|
||||
}
|
||||
FqName fqName = JetPsiUtil.getFQName(file);
|
||||
mainClass = fqName.child(Name.identifier(JvmAbi.PACKAGE_CLASS));
|
||||
mainClass = PackageClassUtils.getPackageClassFqName(fqName);
|
||||
}
|
||||
}
|
||||
return mainClass;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class DescriptorResolverUtils {
|
||||
}
|
||||
|
||||
public static boolean isKotlinClass(@NotNull PsiClass psiClass) {
|
||||
return new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS);
|
||||
return new PsiClassWrapper(psiClass).getJetClass().isDefined() || PackageClassUtils.isPackageClass(psiClass);
|
||||
}
|
||||
|
||||
public static boolean isInnerEnum(@NotNull PsiClass innerClass, @Nullable DeclarationDescriptor owner) {
|
||||
|
||||
@@ -23,7 +23,6 @@ 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";
|
||||
|
||||
public static final String CLASS_OBJECT_CLASS_NAME = "object";
|
||||
public static final String CLASS_OBJECT_SUFFIX = "$" + CLASS_OBJECT_CLASS_NAME;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.resolve.java;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public class PackageClassUtils {
|
||||
|
||||
private static final String DEFAULT_PACKAGE = "_DefaultPackage";
|
||||
|
||||
// ex. <root> -> _DefaultPackage, a -> APackage, a.b -> BPackage
|
||||
public static String getPackageClassName(@NotNull FqName packageFQN) {
|
||||
if (packageFQN.isRoot()) {
|
||||
return DEFAULT_PACKAGE;
|
||||
}
|
||||
return StringUtil.capitalize(packageFQN.shortName().getName()) + "Package";
|
||||
}
|
||||
|
||||
public static FqName getPackageClassFqName(@NotNull FqName packageFQN) {
|
||||
return packageFQN.child(Name.identifier(getPackageClassName(packageFQN)));
|
||||
}
|
||||
|
||||
public static boolean isPackageClass(@NotNull FqName fqName) {
|
||||
if (fqName.isRoot()) {
|
||||
return true;
|
||||
}
|
||||
return getPackageClassName(fqName.parent()).equals(fqName.shortName().getName());
|
||||
}
|
||||
|
||||
public static boolean isPackageClass(@NotNull PsiClass psiClass) {
|
||||
String qualifiedName = psiClass.getQualifiedName();
|
||||
if (qualifiedName == null) {
|
||||
return false;
|
||||
}
|
||||
if (DEFAULT_PACKAGE.equals(qualifiedName)) {
|
||||
return true;
|
||||
}
|
||||
return getPackageClassName(new FqName(qualifiedName).parent()).equals(psiClass.getName());
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -203,7 +203,6 @@ public final class JavaNamespaceResolver {
|
||||
|
||||
@Nullable
|
||||
private PsiClass getPsiClassForJavaPackageScope(@NotNull FqName packageFQN) {
|
||||
return psiClassFinder.findPsiClass(packageFQN.child(Name.identifier(JvmAbi.PACKAGE_CLASS)),
|
||||
PsiClassFinder.RuntimeClassesHandleMode.IGNORE);
|
||||
return psiClassFinder.findPsiClass(PackageClassUtils.getPackageClassFqName(packageFQN), PsiClassFinder.RuntimeClassesHandleMode.IGNORE);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -53,7 +53,7 @@ public final class ScopeUtils {
|
||||
}
|
||||
|
||||
for (PsiClass psiClass : javaSemanticServices.getPsiClassFinder().findPsiClasses(psiPackage)) {
|
||||
if (isKotlinNamespace && JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) {
|
||||
if (isKotlinNamespace && PackageClassUtils.isPackageClass(psiClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class ScopeUtils {
|
||||
}
|
||||
|
||||
// TODO: Temp hack for collection function descriptors from java
|
||||
if (JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) {
|
||||
if (PackageClassUtils.isPackageClass(psiClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
|
||||
String runtime = new File("dist/kotlinc/lib/kotlin-runtime.jar").getAbsolutePath();
|
||||
|
||||
assertEquals("compilation failed", 0, runAnt("build.log", "build.xml"));
|
||||
runJava("hello.run", "-cp", jar + File.pathSeparator + runtime, "Hello.namespace");
|
||||
runJava("hello.run", "-cp", jar + File.pathSeparator + runtime, "Hello.HelloPackage");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
||||
final String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
||||
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
|
||||
runJava("hello.run", "-cp", jar, "Hello.namespace");
|
||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -37,7 +37,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
||||
final String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
|
||||
|
||||
assertEquals("compilation failed", 0, runCompiler("Smoke.compile", "-module", "Smoke.kts", "-jar", jar));
|
||||
runJava("Smoke.run", "-cp", jar + File.pathSeparator + getKotlinRuntimePath(), "Smoke.namespace", "1", "2", "3");
|
||||
runJava("Smoke.run", "-cp", jar + File.pathSeparator + getKotlinRuntimePath(), "Smoke.SmokePackage", "1", "2", "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.NamespaceCodegen;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPsiFacadeKotlinHacks;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -87,8 +87,9 @@ public class JavaElementFinder extends PsiElementFinder implements JavaPsiFacade
|
||||
|
||||
findClassesAndObjects(qualifiedName, scope, answer);
|
||||
|
||||
if (JvmAbi.PACKAGE_CLASS.equals(qualifiedName.shortName().getName())) {
|
||||
findPackageClass(qualifiedName.parent(), scope, answer);
|
||||
FqName packageFQN = qualifiedName.parent();
|
||||
if (PackageClassUtils.getPackageClassFqName(packageFQN).equals(qualifiedName)) {
|
||||
findPackageClass(packageFQN, scope, answer);
|
||||
}
|
||||
|
||||
return answer.toArray(new PsiClass[answer.size()]);
|
||||
@@ -141,7 +142,7 @@ public class JavaElementFinder extends PsiElementFinder implements JavaPsiFacade
|
||||
Collection<JetClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
|
||||
|
||||
Set<String> answer = Sets.newHashSet();
|
||||
answer.add(JvmAbi.PACKAGE_CLASS);
|
||||
answer.add(PackageClassUtils.getPackageClassName(packageFQN));
|
||||
|
||||
for (JetClassOrObject declaration : declarations) {
|
||||
String name = declaration.getName();
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
* Copyright 2010-2013 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.
|
||||
@@ -30,9 +30,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetJavaMirrorMarker;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
@@ -55,7 +54,7 @@ public class KotlinLightClassForPackage extends KotlinLightClassForPackageBase i
|
||||
private KotlinLightClassForPackage(@NotNull PsiManager manager, @NotNull FqName packageFqName, @NotNull Collection<JetFile> files) {
|
||||
super(manager);
|
||||
this.packageFqName = packageFqName;
|
||||
this.packageClassFqName = packageFqName.child(Name.identifier(JvmAbi.PACKAGE_CLASS));
|
||||
this.packageClassFqName = PackageClassUtils.getPackageClassFqName(packageFqName);
|
||||
assert !files.isEmpty() : "No files for package " + packageFqName;
|
||||
this.files = Sets.newHashSet(files); // needed for hashCode
|
||||
this.hashCode = computeHashCode();
|
||||
|
||||
@@ -28,7 +28,11 @@ import org.jetbrains.asm4.ClassVisitor;
|
||||
import org.jetbrains.asm4.FieldVisitor;
|
||||
import org.jetbrains.asm4.MethodVisitor;
|
||||
import org.jetbrains.jet.codegen.ClassBuilder;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -66,13 +70,20 @@ 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(JvmAbi.PACKAGE_CLASS) || name.endsWith("/" + JvmAbi.PACKAGE_CLASS)) {
|
||||
isNamespace = true;
|
||||
|
||||
if (origin instanceof JetFile) {
|
||||
FqName packageName = JetPsiUtil.getFQName((JetFile) origin);
|
||||
String packageClassName = PackageClassUtils.getPackageClassName(packageName);
|
||||
|
||||
if (name.equals(packageClassName) || name.endsWith("/" + packageClassName)) {
|
||||
isNamespace = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (!isNamespace) {
|
||||
parentStack.push(v.getResult());
|
||||
}
|
||||
|
||||
|
||||
((StubBase) v.getResult()).putUserData(ClsWrapperStubPsiFactory.ORIGIN_ELEMENT, origin);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,5 +7,5 @@ fun foo() {
|
||||
}
|
||||
|
||||
// METHOD : invoke(I)V
|
||||
// VARIABLE : NAME=this TYPE=Lnamespace$foo$1$1; INDEX=0
|
||||
// VARIABLE : NAME=this TYPE=L_DefaultPackage$foo$1$1; INDEX=0
|
||||
// VARIABLE : NAME=it TYPE=I INDEX=1
|
||||
@@ -0,0 +1,7 @@
|
||||
fun foo() {
|
||||
fun bar() {
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD : invoke()V
|
||||
// VARIABLE : NAME=this TYPE=L_DefaultPackage$foo$1; INDEX=0
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo() {
|
||||
var a = {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD : invoke()V
|
||||
// VARIABLE : NAME=this TYPE=L_DefaultPackage$foo$a$1; INDEX=0
|
||||
@@ -0,0 +1,9 @@
|
||||
fun foo1() {
|
||||
(1..5).forEach {
|
||||
println(it)
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD : invoke(I)V
|
||||
// VARIABLE : NAME=this TYPE=L_DefaultPackage$foo1$1; INDEX=0
|
||||
// VARIABLE : NAME=it TYPE=I INDEX=1
|
||||
@@ -1,7 +0,0 @@
|
||||
fun foo() {
|
||||
fun bar() {
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD : invoke()V
|
||||
// VARIABLE : NAME=this TYPE=Lnamespace$foo$1; INDEX=0
|
||||
@@ -1,8 +0,0 @@
|
||||
fun foo() {
|
||||
var a = {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD : invoke()V
|
||||
// VARIABLE : NAME=this TYPE=Lnamespace$foo$a$1; INDEX=0
|
||||
@@ -1,9 +0,0 @@
|
||||
fun foo1() {
|
||||
(1..5).forEach {
|
||||
println(it)
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD : invoke(I)V
|
||||
// VARIABLE : NAME=this TYPE=Lnamespace$foo1$1; INDEX=0
|
||||
// VARIABLE : NAME=it TYPE=I INDEX=1
|
||||
@@ -9,7 +9,7 @@ World""");
|
||||
|
||||
fun box() : String {
|
||||
// TODO compiler error
|
||||
// both these expressions causes java.lang.NoClassDefFoundError: collections/namespace
|
||||
// both these expressions causes java.lang.NoClassDefFoundError: collections/CollectionPackage
|
||||
val list1 = sample().useLines{it.toArrayList()}
|
||||
val list2 = sample().useLines<ArrayList<String>>{it.toArrayList()}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
class Any {
|
||||
{
|
||||
Object r = namespace.anyany(new Object(), null);
|
||||
Object r = _DefaultPackage.anyany(new Object(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
class ArrayOfIntArray {
|
||||
{
|
||||
int[][] a = new int[0][];
|
||||
int[][] r = namespace.ohMy(a);
|
||||
int[][] r = _DefaultPackage.ohMy(a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
class ArrayOfIntArray {
|
||||
{
|
||||
Integer[][] a = new Integer[0][];
|
||||
Integer[][] r = namespace.ohMy(a, null);
|
||||
Integer[][] r = _DefaultPackage.ohMy(a, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class GenericArray {
|
||||
public static void ggff() {
|
||||
String[] s = namespace.ffgg(new String[0]);
|
||||
String[] s = _DefaultPackage.ffgg(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
class Hello {
|
||||
public static void xx() {
|
||||
String s = namespace.f();
|
||||
String s = _DefaultPackage.f();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
class Int {
|
||||
{
|
||||
int r = namespace.lll(1);
|
||||
int r = _DefaultPackage.lll(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
class IntArray {
|
||||
{
|
||||
int[] r = namespace.doNothing(new int[0], null);
|
||||
int[] r = _DefaultPackage.doNothing(new int[0], null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
class IntWithDefault {
|
||||
{
|
||||
int r = namespace.www(1);
|
||||
int r = _DefaultPackage.www(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
class IntArray {
|
||||
{
|
||||
Integer[] r = namespace.doNothing(new Integer[0], null);
|
||||
Integer[] r = _DefaultPackage.doNothing(new Integer[0], null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class ListOfInt {
|
||||
|
||||
public static void hhh() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
List<Integer> r = namespace.ggg(list);
|
||||
List<Integer> r = _DefaultPackage.ggg(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ import java.util.ArrayList;
|
||||
class ListString {
|
||||
public static void gg() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
namespace.ff(list);
|
||||
_DefaultPackage.ff(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class ListOfT {
|
||||
|
||||
public static void check() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> r = namespace.listOfT(list);
|
||||
List<String> r = _DefaultPackage.listOfT(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ class MapOfKString {
|
||||
public static void gfgdgfg() {
|
||||
Map<BigDecimal, String> map = new HashMap<BigDecimal, String>();
|
||||
|
||||
Map<BigDecimal, String> r = namespace.fff(map);
|
||||
Map<BigDecimal, String> r = _DefaultPackage.fff(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ class MapOfKString {
|
||||
public static void gfgdgfg() {
|
||||
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
|
||||
Map<String, Integer> r = namespace.fff(map);
|
||||
Map<String, Integer> r = _DefaultPackage.fff(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ class Question {
|
||||
// id2 is to prevent java type parameter type inference
|
||||
static <T> T id2(T p) { return p; }
|
||||
{
|
||||
java.util.List<? extends String> s = id2(namespace.id(null));
|
||||
java.util.List<? extends String> s = id2(_DefaultPackage.id(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ class Question {
|
||||
// id2 is to prevent java type parameter type inference
|
||||
static <T> T id2(T p) { return p; }
|
||||
{
|
||||
String s = id2(namespace.id(null));
|
||||
String s = id2(_DefaultPackage.id(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ import java.util.ArrayList;
|
||||
class Vararg {
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> r = namespace.gg(list, 3, 4, 5, 6);
|
||||
List<String> r = _DefaultPackage.gg(list, 3, 4, 5, 6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Void {
|
||||
{
|
||||
namespace.f();
|
||||
_DefaultPackage.f();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ class MyClass() { }
|
||||
deprecated("") fun MyClass.test() {}
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: namespace, test
|
||||
// TESTED_OBJECTS: _DefaultPackage, test
|
||||
// FLAGS: ACC_DEPRECATED, ACC_PUBLIC, ACC_FINAL, ACC_STATIC
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
deprecated("") fun test() {}
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: namespace, test
|
||||
// TESTED_OBJECTS: _DefaultPackage, test
|
||||
// FLAGS: ACC_DEPRECATED, ACC_PUBLIC, ACC_FINAL, ACC_STATIC
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
deprecated("") val test: Int = 0
|
||||
|
||||
// TESTED_OBJECT_KIND: property
|
||||
// TESTED_OBJECTS: namespace, test
|
||||
// TESTED_OBJECTS: _DefaultPackage, test
|
||||
// FLAGS: ACC_DEPRECATED, ACC_FINAL, ACC_STATIC
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun never(): Array<java.lang.CharSequence> = throw Exception()
|
||||
|
||||
// method: namespace::never
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[Ljava/lang/CharSequence;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[Mjava/lang/CharSequence; // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun never(): Array<Int> = throw Exception()
|
||||
|
||||
// method: namespace::never
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[Ljava/lang/Integer;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[Ljava/lang/Integer; // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun cc(): Comparable<java.lang.CharSequence>? = null
|
||||
|
||||
// method: namespace::cc
|
||||
// method: _DefaultPackage::cc
|
||||
// jvm signature: ()Ljava/lang/Comparable;
|
||||
// generic signature: ()Ljava/lang/Comparable<Ljava/lang/CharSequence;>;
|
||||
// kotlin signature: ()?Ljava/lang/Comparable<Mjava/lang/CharSequence;>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun key(): Int = throw Exception()
|
||||
|
||||
// method: namespace::key
|
||||
// method: _DefaultPackage::key
|
||||
// jvm signature: ()I
|
||||
// generic signature: null
|
||||
// kotlin signature: ()I // TODO: make null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun never(): IntArray = throw Exception()
|
||||
|
||||
// method: namespace::never
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[I
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[I // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun sometimes(): Int? = null
|
||||
|
||||
// method: namespace::sometimes
|
||||
// method: _DefaultPackage::sometimes
|
||||
// jvm signature: ()Ljava/lang/Integer;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()?Ljava/lang/Integer; // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
fun foo(p: List<CharSequence>) = 1
|
||||
|
||||
// method: namespace::foo
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: (Ljava/util/List;)I
|
||||
// generic signature: (Ljava/util/List<+Ljava/lang/CharSequence;>;)I
|
||||
// kotlin signature: (Ljet/List<Ljava/lang/CharSequence;>;)I // TODO: skip Kotlin signature
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
fun listOfStar(): List<*> = throw Exception()
|
||||
|
||||
|
||||
// method: namespace::listOfStar
|
||||
// method: _DefaultPackage::listOfStar
|
||||
// jvm signature: ()Ljava/util/List;
|
||||
// generic signature: ()Ljava/util/List<Ljava/lang/Object;>;
|
||||
// kotlin signature: ()Ljet/List<?Ljava/lang/Object;>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun getEntry(): jet.Map.Entry<Int, String>? = null
|
||||
|
||||
// method: namespace::getEntry
|
||||
// method: _DefaultPackage::getEntry
|
||||
// jvm signature: ()Ljava/util/Map$Entry;
|
||||
// generic signature: ()Ljava/util/Map$Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
// kotlin signature: ()?Ljet/Map.Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun getEntry(): jet.MutableMap.MutableEntry<Int, String>? = null
|
||||
|
||||
// method: namespace::getEntry
|
||||
// method: _DefaultPackage::getEntry
|
||||
// jvm signature: ()Ljava/util/Map$Entry;
|
||||
// generic signature: ()Ljava/util/Map$Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
// kotlin signature: ()?Ljet/MutableMap.MutableEntry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun foo() = 1
|
||||
|
||||
// method: namespace::foo
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: ()I
|
||||
// generic signature: null
|
||||
// kotlin signature: ()I // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun nothing(): Nothing = throw Exception()
|
||||
|
||||
// method: namespace::nothing
|
||||
// method: _DefaultPackage::nothing
|
||||
// jvm signature: ()V
|
||||
// generic signature: null
|
||||
// kotlin signature: ()Ljet/Nothing;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun nothingq(): Nothing? = null
|
||||
|
||||
// method: namespace::nothingq
|
||||
// method: _DefaultPackage::nothingq
|
||||
// jvm signature: ()Ljava/lang/Object;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()?Ljet/Nothing;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun foo(vararg tail: java.lang.CharSequence) = 1
|
||||
|
||||
// method: namespace::foo
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: ([Ljava/lang/CharSequence;)I
|
||||
// generic signature: null
|
||||
// kotlin signature: ([Mjava/lang/CharSequence;)I // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun <P> foo(vararg tail: P) = 1
|
||||
|
||||
// method: namespace::foo
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: ([Ljava/lang/Object;)I
|
||||
// generic signature: <P:Ljava/lang/Object;>([TP;)I
|
||||
// kotlin signature: <erased P:?Ljava/lang/Object;>([TP;)I
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ class X
|
||||
|
||||
fun f(m: M<X, X>): M<X, X> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LM;)LM;
|
||||
// generic signature: (LM<-LX;+LX;>;)LM<LX;LX;>;
|
||||
// kotlin signature: (LM<LX;LX;>;)LM<LX;LX;>;
|
||||
|
||||
@@ -2,7 +2,7 @@ class In<in T>
|
||||
|
||||
fun f(p: In<String>) {}
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LIn;)V
|
||||
// generic signature: (LIn<-Ljava/lang/String;>;)V
|
||||
// kotlin signature: (LIn<Ljava/lang/String;>;)V
|
||||
|
||||
@@ -2,7 +2,7 @@ class In<in T>
|
||||
|
||||
fun f(): In<String> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LIn;
|
||||
// generic signature: ()LIn<Ljava/lang/String;>;
|
||||
// kotlin signature: ()LIn<Ljava/lang/String;>;
|
||||
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
fun f(p: In<In<X>>) {}
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LIn;)V
|
||||
// generic signature: (LIn<-LIn<-LX;>;>;)V
|
||||
// kotlin signature: (LIn<LIn<LX;>;>;)V
|
||||
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
fun f(): In<In<X>> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LIn;
|
||||
// generic signature: ()LIn<LIn<-LX;>;>;
|
||||
// kotlin signature: ()LIn<LIn<LX;>;>;
|
||||
|
||||
@@ -4,7 +4,7 @@ class X
|
||||
|
||||
fun f(p: In<Out<X>>) {}
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LIn;)V
|
||||
// generic signature: (LIn<-LOut<+LX;>;>;)V
|
||||
// kotlin signature: (LIn<LOut<LX;>;>;)V
|
||||
|
||||
@@ -4,7 +4,7 @@ class X
|
||||
|
||||
fun f(): In<Out<X>> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LIn;
|
||||
// generic signature: ()LIn<LOut<+LX;>;>;
|
||||
// kotlin signature: ()LIn<LOut<LX;>;>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun f(p: List<String>) {}
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (Ljava/util/List;)V
|
||||
// generic signature: (Ljava/util/List<+Ljava/lang/String;>;)V
|
||||
// kotlin signature: (Ljet/List<Ljava/lang/String;>;)V
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun f(): List<String> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()Ljava/util/List;
|
||||
// generic signature: ()Ljava/util/List<Ljava/lang/String;>;
|
||||
// kotlin signature: ()Ljet/List<Ljava/lang/String;>;
|
||||
|
||||
@@ -4,7 +4,7 @@ class X
|
||||
|
||||
fun f(p: Out<In<X>>) {}
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LOut;)V
|
||||
// generic signature: (LOut<+LIn<-LX;>;>;)V
|
||||
// kotlin signature: (LOut<LIn<LX;>;>;)V
|
||||
|
||||
@@ -4,7 +4,7 @@ class X
|
||||
|
||||
fun f(): Out<In<X>> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LOut;
|
||||
// generic signature: ()LOut<LIn<-LX;>;>;
|
||||
// kotlin signature: ()LOut<LIn<LX;>;>;
|
||||
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
fun f(p: Out<Out<X>>) {}
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LOut;)V
|
||||
// generic signature: (LOut<+LOut<+LX;>;>;)V
|
||||
// kotlin signature: (LOut<LOut<LX;>;>;)V
|
||||
|
||||
@@ -13,7 +13,7 @@ class X
|
||||
// thus removing the wildcard would be restricting the use of the return value of the method, and we don't want do this.
|
||||
fun f(): Out<Out<X>> = throw Exception()
|
||||
|
||||
// method: namespace::f
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LOut;
|
||||
// generic signature: ()LOut<LOut<+LX;>;>;
|
||||
// kotlin signature: ()LOut<LOut<LX;>;>;
|
||||
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
val p: M<X> = throw Exception()
|
||||
|
||||
// method: namespace::getP
|
||||
// method: _DefaultPackage::getP
|
||||
// jvm signature: ()LM;
|
||||
// generic signature: ()LM<LX;>;
|
||||
// kotlin signature: null
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
val p: M<X> = throw Exception()
|
||||
|
||||
// method: namespace::getP
|
||||
// method: _DefaultPackage::getP
|
||||
// jvm signature: ()LM;
|
||||
// generic signature: ()LM<LX;>;
|
||||
// kotlin signature: null
|
||||
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
val p: M<X, X> = throw Exception()
|
||||
|
||||
// method: namespace::getP
|
||||
// method: _DefaultPackage::getP
|
||||
// jvm signature: ()LM;
|
||||
// generic signature: ()LM<LX;LX;>;
|
||||
// kotlin signature: null
|
||||
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
var p: M<X> = throw Exception()
|
||||
|
||||
// method: namespace::setP
|
||||
// method: _DefaultPackage::setP
|
||||
// jvm signature: (LM;)V
|
||||
// generic signature: (LM<-LX;>;)V
|
||||
// kotlin signature: null
|
||||
@@ -3,7 +3,7 @@ class X
|
||||
|
||||
var p: M<X> = throw Exception()
|
||||
|
||||
// method: namespace::setP
|
||||
// method: _DefaultPackage::setP
|
||||
// jvm signature: (LM;)V
|
||||
// generic signature: (LM<+LX;>;)V
|
||||
// kotlin signature: null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun string(): java.lang.String = throw Exception()
|
||||
|
||||
// method: namespace::string
|
||||
// method: _DefaultPackage::string
|
||||
// jvm signature: ()Ljava/lang/String;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()Mjava/lang/String;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.jetbrains.jet.lang.resolve.java.PackageClassUtils.*;
|
||||
|
||||
public class PackageClassNameTest {
|
||||
|
||||
@Test
|
||||
public void testPackageName1() {
|
||||
doTest("kotlin", "KotlinPackage", "_DefaultPackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageName2() {
|
||||
doTest("kotlin.io", "IoPackage", "KotlinPackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageName3() {
|
||||
doTest("kotlin.io.foo", "FooPackage", "IoPackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageName4() {
|
||||
doTest("kotlinTest.ioTest", "IoTestPackage", "KotlinTestPackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageName5() {
|
||||
doTest(FqName.ROOT, "_DefaultPackage", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageName6() {
|
||||
doTest(FqName.ROOT.child(Name.identifier("kotlin")), "KotlinPackage", "_DefaultPackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPackageClass1() {
|
||||
doTestIsPackageClass("", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPackageClass2() {
|
||||
doTestIsPackageClass("kotlin", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPackageClass3() {
|
||||
doTestIsPackageClass("kotlin.KotlinPackage", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPackageClass4() {
|
||||
doTestIsPackageClass("kotlin.test.SomeClass", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPackageClass5() {
|
||||
doTestIsPackageClass("kotlin.io.IoPackage", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerIsPackage() {
|
||||
doTestIsPackageClass("kotlin.io.IoPackage$Foo", false);
|
||||
}
|
||||
|
||||
private void doTest(@NotNull String name, @NotNull String expectedForChild, @Nullable String expectedForParent) {
|
||||
doTest(new FqName(name), expectedForChild, expectedForParent);
|
||||
}
|
||||
|
||||
private void doTest(@NotNull FqName name, @NotNull String expectedForChild, @Nullable String expectedForParent) {
|
||||
assertEquals("Wrong result for child [" + name + "].", expectedForChild, getPackageClassName(name));
|
||||
if (expectedForParent != null) {
|
||||
assertEquals("Wrong result for parent [" + name + "].", expectedForParent, getPackageClassName(name.parent()));
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestIsPackageClass(String testedName, boolean expected) {
|
||||
assertEquals("Wrong result for [" + testedName + "].", expected, isPackageClass(new FqName(testedName)));
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,10 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinTestWithEnvironment;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.LazyResolveTestUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -126,7 +128,7 @@ public abstract class KotlinLightClassTest extends KotlinTestWithEnvironment {
|
||||
}
|
||||
|
||||
public void testPackage() throws Exception {
|
||||
checkModifiers("test.namespace", PUBLIC, FINAL);
|
||||
checkModifiers("test." + PackageClassUtils.getPackageClassName(new FqName("test")), PUBLIC, FINAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import org.jetbrains.jet.cli.common.ExitCode;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
||||
import org.jetbrains.jet.lang.parsing.JetScriptDefinition;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ref.JetTypeName;
|
||||
import org.jetbrains.jet.test.Tmpdir;
|
||||
@@ -101,7 +103,7 @@ public class CliTest {
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutput(args);
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), "namespace.class").isFile());
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), PackageClassUtils.getPackageClassName(FqName.ROOT) + ".class").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+20
-20
@@ -33,29 +33,29 @@ public class CheckLocalVariablesTableTestGenerated extends AbstractCheckLocalVar
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/checkLocalVariablesTable"), "kt", true);
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo$1.kt")
|
||||
public void testNamespace$foo$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo$1$1.kt")
|
||||
public void testNamespace$foo$1$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo$1$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo$a$1.kt")
|
||||
public void testNamespace$foo$a$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo$a$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo1$1.kt")
|
||||
public void testNamespace$foo1$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo1$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("someClass.kt")
|
||||
public void testSomeClass() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/someClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("_DefaultPackage$foo$1.kt")
|
||||
public void test_DefaultPackage$foo$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/_DefaultPackage$foo$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("_DefaultPackage$foo$1$1.kt")
|
||||
public void test_DefaultPackage$foo$1$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/_DefaultPackage$foo$1$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("_DefaultPackage$foo$a$1.kt")
|
||||
public void test_DefaultPackage$foo$a$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/_DefaultPackage$foo$a$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("_DefaultPackage$foo1$1.kt")
|
||||
public void test_DefaultPackage$foo1$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/_DefaultPackage$foo1$1.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -60,7 +62,7 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
// System.out.println(generateToText());
|
||||
final ClassFileFactory state = generateClassesInFile();
|
||||
final GeneratedClassLoader loader = createClassLoader(state);
|
||||
final Class aClass = loader.loadClass("namespace");
|
||||
final Class aClass = loader.loadClass(PackageClassUtils.getPackageClassName(FqName.ROOT));
|
||||
assertEquals("OK", aClass.getMethod("box").invoke(null));
|
||||
|
||||
final Class test = loader.loadClass("Test");
|
||||
|
||||
@@ -29,6 +29,8 @@ import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -69,7 +71,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
|
||||
loadFiles("notNullAssertions/noAssertionsForKotlin.kt", "notNullAssertions/noAssertionsForKotlinMain.kt");
|
||||
|
||||
assertNoIntrinsicsMethodIsCalled("namespace");
|
||||
assertNoIntrinsicsMethodIsCalled(PackageClassUtils.getPackageClassName(FqName.ROOT));
|
||||
}
|
||||
|
||||
public void testNoAssertionsForKotlinFromBinary() throws Exception {
|
||||
@@ -85,7 +87,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
|
||||
loadFile("notNullAssertions/noAssertionsForKotlinMain.kt");
|
||||
|
||||
assertNoIntrinsicsMethodIsCalled("namespace");
|
||||
assertNoIntrinsicsMethodIsCalled(PackageClassUtils.getPackageClassName(FqName.ROOT));
|
||||
}
|
||||
|
||||
public void testGenerateParamAssertions() throws Exception {
|
||||
|
||||
@@ -30,7 +30,8 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
@@ -326,7 +327,7 @@ public class LineNumberTest extends TestCaseWithTmpdir {
|
||||
JetFile foo = createPsiFile("staticDelegate/foo.kt");
|
||||
JetFile bar = createPsiFile("staticDelegate/bar.kt");
|
||||
GenerationState state = GenerationUtils.compileManyFilesGetGenerationStateForTest(foo.getProject(), Arrays.asList(foo, bar));
|
||||
ClassReader reader = new ClassReader(state.getFactory().asBytes(JvmAbi.PACKAGE_CLASS + ".class"));
|
||||
ClassReader reader = new ClassReader(state.getFactory().asBytes(PackageClassUtils.getPackageClassName(FqName.ROOT) + ".class"));
|
||||
|
||||
// There must be exactly one line number attribute for each static delegate in namespace.class, and it should point to the first
|
||||
// line. There are two static delegates in this test, hence the [1, 1]
|
||||
|
||||
+3
-1
@@ -30,6 +30,8 @@ import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
import org.jetbrains.jet.codegen.GenerationUtils;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
|
||||
import java.io.File;
|
||||
@@ -62,7 +64,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends TestCaseWit
|
||||
new URL[]{ aDir.toURI().toURL(), bDir.toURI().toURL() },
|
||||
AbstractCompileKotlinAgainstKotlinTest.class.getClassLoader()
|
||||
);
|
||||
Class<?> clazz = classLoader.loadClass("namespace");
|
||||
Class<?> clazz = classLoader.loadClass(PackageClassUtils.getPackageClassName(FqName.ROOT));
|
||||
Method main = clazz.getMethod("main", new Class[] {String[].class});
|
||||
main.invoke(null, new Object[] {ArrayUtil.EMPTY_STRING_ARRAY});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.jetbrains.jet.cli.common.ExitCode;
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
import org.junit.Assert;
|
||||
|
||||
@@ -55,7 +57,7 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
JarInputStream is = new JarInputStream(fileInputStream);
|
||||
try {
|
||||
final List<String> entries = listEntries(is);
|
||||
assertTrue(entries.contains("Smoke/namespace.class"));
|
||||
assertTrue(entries.contains("Smoke/" + PackageClassUtils.getPackageClassName(new FqName("Smoke")) + ".class"));
|
||||
assertEquals(1, entries.size());
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -29,8 +29,8 @@ import jet.runtime.typeinfo.JetClass;
|
||||
import jet.runtime.typeinfo.JetValueParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetValueParameterAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -57,7 +57,8 @@ class JetFromJavaDescriptorHelper {
|
||||
/* Will iterate through short name caches
|
||||
Kotlin namespaces from jar a class files will be collected from java cache
|
||||
Kotlin namespaces classes from sources will be collected with JetShortNamesCache.getClassesByName */
|
||||
return PsiShortNamesCache.getInstance(project).getClassesByName(JvmAbi.PACKAGE_CLASS, scope);
|
||||
// TODO Collect all package classes
|
||||
return PsiShortNamesCache.getInstance(project).getClassesByName("namespace", scope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +161,7 @@ class JetFromJavaDescriptorHelper {
|
||||
|
||||
FqName classFQN = new FqName(qualifiedName);
|
||||
|
||||
if (classFQN.shortName().toString().equals(JvmAbi.PACKAGE_CLASS)) {
|
||||
if (PackageClassUtils.isPackageClass(classFQN)) {
|
||||
FqName classParentFQN = QualifiedNamesUtil.withoutLastSegment(classFQN);
|
||||
return QualifiedNamesUtil.combine(classParentFQN, Name.identifier(method.getName()));
|
||||
}
|
||||
@@ -183,7 +184,7 @@ class JetFromJavaDescriptorHelper {
|
||||
|
||||
// Check this is top level function
|
||||
PsiClass containingClass = psiMethod.getContainingClass();
|
||||
if (containingClass == null || !JvmAbi.PACKAGE_CLASS.equals(containingClass.getName())) {
|
||||
if (containingClass == null || !PackageClassUtils.isPackageClass(containingClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -46,6 +47,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.IDELightClassGenerationSupport;
|
||||
import org.jetbrains.jet.plugin.stubindex.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -81,8 +83,12 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
@Override
|
||||
public String[] getAllClassNames() {
|
||||
Collection<String> classNames = JetShortClassNameIndex.getInstance().getAllKeys(project);
|
||||
|
||||
// .namespace classes can not be indexed, since they have no explicit declarations
|
||||
classNames.add(JvmAbi.PACKAGE_CLASS);
|
||||
IDELightClassGenerationSupport lightClassGenerationSupport = IDELightClassGenerationSupport.getInstanceForIDE(project);
|
||||
Set<String> packageClassShortNames = lightClassGenerationSupport.getAllPackageClasses(GlobalSearchScope.allScope(project)).keySet();
|
||||
classNames.addAll(packageClassShortNames);
|
||||
|
||||
return ArrayUtil.toStringArray(classNames);
|
||||
}
|
||||
|
||||
@@ -94,11 +100,14 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
public PsiClass[] getClassesByName(@NotNull @NonNls String name, @NotNull GlobalSearchScope scope) {
|
||||
List<PsiClass> result = new ArrayList<PsiClass>();
|
||||
|
||||
if (JvmAbi.PACKAGE_CLASS.equals(name)) {
|
||||
// .namespace classes can not be indexed, since they have no explicit declarations
|
||||
Collection<String> allPackageFqNames = JetPackageDeclarationIndex.getInstance().getAllKeys(project);
|
||||
for (String fqName : allPackageFqNames) {
|
||||
PsiClass psiClass = JavaElementFinder.getInstance(project).findClass(fqName + "." + JvmAbi.PACKAGE_CLASS, scope);
|
||||
IDELightClassGenerationSupport lightClassGenerationSupport = IDELightClassGenerationSupport.getInstanceForIDE(project);
|
||||
MultiMap<String, FqName> packageClasses = lightClassGenerationSupport.getAllPackageClasses(scope);
|
||||
|
||||
// .namespace classes can not be indexed, since they have no explicit declarations
|
||||
Collection<FqName> fqNames = packageClasses.get(name);
|
||||
if (!fqNames.isEmpty()) {
|
||||
for (FqName fqName : fqNames) {
|
||||
PsiClass psiClass = JavaElementFinder.getInstance(project).findClass(fqName.getFqName(), scope);
|
||||
if (psiClass != null) {
|
||||
result.add(psiClass);
|
||||
}
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
package org.jetbrains.jet.plugin.caches.resolve;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.asJava.LightClassConstructionContext;
|
||||
import org.jetbrains.jet.asJava.LightClassGenerationSupport;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.plugin.stubindex.*;
|
||||
import org.jetbrains.jet.util.QualifiedNamesUtil;
|
||||
@@ -36,6 +39,10 @@ import static org.jetbrains.jet.plugin.stubindex.JetSourceFilterScope.kotlinSour
|
||||
|
||||
public class IDELightClassGenerationSupport extends LightClassGenerationSupport {
|
||||
|
||||
public static IDELightClassGenerationSupport getInstanceForIDE(@NotNull Project project) {
|
||||
return (IDELightClassGenerationSupport) ServiceManager.getService(project, LightClassGenerationSupport.class);
|
||||
}
|
||||
|
||||
private final Project project;
|
||||
|
||||
public IDELightClassGenerationSupport(@NotNull Project project) {
|
||||
@@ -96,4 +103,20 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MultiMap<String, FqName> getAllPackageClasses(@NotNull final GlobalSearchScope scope) {
|
||||
Collection<String> packageFqNames = JetPackageDeclarationIndex.getInstance().getAllKeys(project);
|
||||
|
||||
MultiMap<String, FqName> result = new MultiMap<String, FqName>();
|
||||
for (String packageFqName : packageFqNames) {
|
||||
Collection<JetFile> files = JetPackageDeclarationIndex.getInstance().get(packageFqName, project, kotlinSources(scope));
|
||||
if (!files.isEmpty()) {
|
||||
FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(new FqName(packageFqName));
|
||||
result.putValue(packageClassFqName.shortName().getName(), packageClassFqName);
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.plugin.quickfix.ImportInsertHelper;
|
||||
@@ -190,7 +190,7 @@ public class JetImportOptimizer implements ImportOptimizer {
|
||||
if (element instanceof JetFile) {
|
||||
return JetPsiUtil.getFQName((JetFile) element);
|
||||
}
|
||||
|
||||
|
||||
if (element instanceof JetSimpleNameExpression) {
|
||||
JetNamespaceHeader namespaceHeader = PsiTreeUtil.getParentOfType(element, JetNamespaceHeader.class);
|
||||
if (namespaceHeader != null) {
|
||||
@@ -221,7 +221,7 @@ public class JetImportOptimizer implements ImportOptimizer {
|
||||
return new FqName(qualifiedName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (element instanceof PsiField) {
|
||||
PsiField field = (PsiField) element;
|
||||
|
||||
@@ -260,7 +260,7 @@ public class JetImportOptimizer implements ImportOptimizer {
|
||||
if (memberName == null) {
|
||||
return null;
|
||||
}
|
||||
if (classFQN.shortName().getName().equals(JvmAbi.PACKAGE_CLASS)) {
|
||||
if (PackageClassUtils.isPackageClass(classFQN)) {
|
||||
return QualifiedNamesUtil.combine(classFQN.parent(), Name.identifier(memberName));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -26,8 +26,10 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.IDELightClassGenerationSupport;
|
||||
import org.jetbrains.jet.plugin.util.DebuggerUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -55,10 +57,8 @@ public class JetExceptionFilter implements Filter {
|
||||
// fullyQualifiedName is of format "package.Class$Inner"
|
||||
String fullyQualifiedName = element.getClassName();
|
||||
|
||||
int lastDot = fullyQualifiedName.lastIndexOf('.');
|
||||
String classNameWithInners = fullyQualifiedName.substring(lastDot + 1);
|
||||
// All classes except 'namespace' and its inner classes are handled correctly in the default ExceptionFilter
|
||||
if (!classNameWithInners.equals(JvmAbi.PACKAGE_CLASS) && !classNameWithInners.startsWith(JvmAbi.PACKAGE_CLASS + "$")) {
|
||||
if (!isPackageClassOrSubClass(fullyQualifiedName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,20 @@ public class JetExceptionFilter implements Filter {
|
||||
return new OpenFileHyperlinkInfo(project, virtualFile, element.getLineNumber() - 1);
|
||||
}
|
||||
|
||||
private boolean isPackageClassOrSubClass(String fqName) {
|
||||
if (fqName.equals(PackageClassUtils.getPackageClassName(FqName.ROOT))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int lastDot = fqName.lastIndexOf('.');
|
||||
String classNameWithInners = fqName.substring(lastDot + 1);
|
||||
int firstDollar = classNameWithInners.indexOf('$');
|
||||
String className = firstDollar >= 0 ? classNameWithInners.substring(0, firstDollar) : classNameWithInners;
|
||||
|
||||
String packageClassName = PackageClassUtils.getPackageClassName(new FqName(fqName).parent());
|
||||
return packageClassName.equals(className);
|
||||
}
|
||||
|
||||
// Matches strings like "\tat test.namespace$foo$f$1.invoke(a.kt:3)\n"
|
||||
private static final Pattern STACK_TRACE_ELEMENT_PATTERN = Pattern.compile("^\\s*at\\s+(.+)\\.(.+)\\((.+):(\\d+)\\)\\s*$");
|
||||
|
||||
|
||||
@@ -33,10 +33,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.MemberComparator;
|
||||
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
@@ -236,7 +233,7 @@ public class DecompiledDataFactory {
|
||||
}
|
||||
|
||||
public static boolean isKotlinNamespaceClass(@NotNull PsiClass psiClass) {
|
||||
if (JvmAbi.PACKAGE_CLASS.equals(psiClass.getName()) && !isKotlinClass(psiClass)) {
|
||||
if (PackageClassUtils.isPackageClass(psiClass) && !isKotlinClass(psiClass)) {
|
||||
for (PsiMethod method : psiClass.getMethods()) {
|
||||
if (hasAnnotation(method, JET_METHOD)) {
|
||||
return true;
|
||||
|
||||
@@ -29,7 +29,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.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
@@ -76,7 +76,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
if (JetMainDetector.hasMain(jetFile.getDeclarations())) {
|
||||
mySourceElement = jetFile;
|
||||
FqName fqName = JetPsiUtil.getFQName(jetFile);
|
||||
return fqName.child(Name.identifier(JvmAbi.PACKAGE_CLASS));
|
||||
return PackageClassUtils.getPackageClassFqName(fqName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,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.getFqName(), "." + JvmAbi.PACKAGE_CLASS));
|
||||
configuration.setName(StringUtil.trimEnd(fqName.getFqName(), "." + PackageClassUtils.getPackageClassName(fqName)));
|
||||
configuration.setRunClass(fqName.getFqName());
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ public class Testing {
|
||||
}
|
||||
|
||||
// EXIST: ClassFromJet
|
||||
// EXIST: namespace
|
||||
// EXIST: SomePackage
|
||||
// NUMBER: 2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
public class Testing {
|
||||
public static void main(String[] args) {
|
||||
kotlin.testing.namespace.<caret>
|
||||
kotlin.testing.TestingPackage.<caret>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
"" // _DefaultPackage
|
||||
}
|
||||
@@ -4,5 +4,5 @@ class A {
|
||||
}
|
||||
|
||||
fun A.foo() {
|
||||
"" // a/namespace
|
||||
"" // a/APackage
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user