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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user