diff --git a/java/java-tests/testData/psi/cls/mirror/$BuckClass.txt b/java/java-tests/testData/psi/cls/mirror/$BuckClass.txt new file mode 100644 index 000000000000..4e3899f22d42 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/$BuckClass.txt @@ -0,0 +1,12 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +class $BuckClass { + + $BuckClass() { /* compiled code */ } + + static pkg.$BuckClass getInstance() { /* compiled code */ } +} diff --git a/java/java-tests/testData/psi/cls/mirror/EmptyEnum.txt b/java/java-tests/testData/psi/cls/mirror/EmptyEnum.txt new file mode 100644 index 000000000000..30c4cd130a63 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/EmptyEnum.txt @@ -0,0 +1,14 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +final enum EmptyEnum { + ; + public static pkg.EmptyEnum[] values() { /* compiled code */ } + + public static pkg.EmptyEnum valueOf(java.lang.String s) { /* compiled code */ } + + private EmptyEnum() { /* compiled code */ } +} diff --git a/java/java-tests/testData/psi/cls/mirror/ExtMethods.txt b/java/java-tests/testData/psi/cls/mirror/ExtMethods.txt new file mode 100644 index 000000000000..5f4898ab4d87 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/ExtMethods.txt @@ -0,0 +1,12 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +interface ExtMethods { + + void m1(); + + void m2() { /* compiled code */ } +} diff --git a/java/java-tests/testData/psi/cls/mirror/MethodReceiver.txt b/java/java-tests/testData/psi/cls/mirror/MethodReceiver.txt new file mode 100644 index 000000000000..71213b8ead80 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/MethodReceiver.txt @@ -0,0 +1,15 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +class MethodReceiver { + + MethodReceiver() { /* compiled code */ } + + void m(int i) { /* compiled code */ } + + static @interface A { + } +} diff --git a/java/java-tests/testData/psi/cls/mirror/package-info.txt b/java/java-tests/testData/psi/cls/mirror/package-info.txt new file mode 100644 index 000000000000..48aa009cc146 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/package-info.txt @@ -0,0 +1,9 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +@pkg.PkgAnno +interface $$package-info /* Real name is 'package-info' */ { +} diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/$BuckClass.class b/java/java-tests/testData/psi/cls/mirror/pkg/$BuckClass.class new file mode 100644 index 000000000000..6ac4f3babd7f Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/$BuckClass.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/EmptyEnum.class b/java/java-tests/testData/psi/cls/mirror/pkg/EmptyEnum.class new file mode 100644 index 000000000000..2ffd189e8fce Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/EmptyEnum.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/ExtMethods.class b/java/java-tests/testData/psi/cls/mirror/pkg/ExtMethods.class new file mode 100644 index 000000000000..6404c7100249 Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/ExtMethods.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/MethodReceiver$A.class b/java/java-tests/testData/psi/cls/mirror/pkg/MethodReceiver$A.class new file mode 100644 index 000000000000..88ff02d2b73c Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/MethodReceiver$A.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/MethodReceiver.class b/java/java-tests/testData/psi/cls/mirror/pkg/MethodReceiver.class new file mode 100644 index 000000000000..b58fd8e185c2 Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/MethodReceiver.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/PkgAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/PkgAnno.class new file mode 100644 index 000000000000..50cbb5902df0 Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/PkgAnno.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/package-info.class b/java/java-tests/testData/psi/cls/mirror/pkg/package-info.class new file mode 100644 index 000000000000..0fbbecf68821 Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/package-info.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/$BuckClass.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/$BuckClass.java new file mode 100644 index 000000000000..a7736cc02eca --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/$BuckClass.java @@ -0,0 +1,5 @@ +package pkg; + +class $BuckClass { + static $BuckClass getInstance() { return null; } +} diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/EmptyEnum.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/EmptyEnum.java new file mode 100644 index 000000000000..3784ac812c3c --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/EmptyEnum.java @@ -0,0 +1,3 @@ +package pkg; + +enum EmptyEnum { } \ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/ExtMethods.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/ExtMethods.java new file mode 100644 index 000000000000..82c281b7a86c --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/ExtMethods.java @@ -0,0 +1,6 @@ +package pkg; + +interface ExtMethods { + void m1(); + void m2() default { System.out.println("Hello there."); } +} diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/MethodReceiver.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/MethodReceiver.java new file mode 100644 index 000000000000..9bdb2c657f79 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/MethodReceiver.java @@ -0,0 +1,6 @@ +package pkg; + +class MethodReceiver { + @interface A { } + void m(@A MethodReceiver this, int i) { System.out.println("i=" + i); } +} diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/PkgAnno.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/PkgAnno.java new file mode 100644 index 000000000000..d6091f63b848 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/PkgAnno.java @@ -0,0 +1,3 @@ +package pkg; + +@interface PkgAnno { } diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/package-info.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/package-info.java new file mode 100644 index 000000000000..a92068a893fd --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/package-info.java @@ -0,0 +1,2 @@ +@PkgAnno +package pkg; diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java new file mode 100644 index 000000000000..f4099893ff61 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2000-2012 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 com.intellij.psi; + +import com.intellij.JavaTestUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.testFramework.LightIdeaTestCase; +import com.intellij.testFramework.PlatformTestUtil; + +import java.io.IOException; + +public class ClsMirrorBuildingTest extends LightIdeaTestCase { + public void testEmptyEnum() { doTest(); } + public void test$BuckClass() { doTest(); } + public void testExtMethods() { doTest(); } + public void testMethodReceiver() { doTest(); } + public void testPackageInfo() { doTest("package-info"); } + + private void doTest() { + doTest(getTestName(false)); + } + + private static void doTest(String name) { + String testDir = JavaTestUtil.getJavaTestDataPath() + "/psi/cls/mirror/"; + + String clsPath = testDir + "pkg/" + name + ".class"; + VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(clsPath); + assertNotNull(clsPath, vFile); + PsiFile clsFile = getPsiManager().findFile(vFile); + assertNotNull(vFile.getPath(), clsFile); + + String expected; + try { + String txtPath = testDir + name + ".txt"; + expected = StringUtil.trimTrailing(PlatformTestUtil.loadFileText(txtPath)); + } + catch (IOException e) { + fail(e.getMessage()); + return; + } + assertEquals(expected, clsFile.getText()); + + /*String srcPath = testDir + "src/pkg/" + name + ".java"; + vFile = LocalFileSystem.getInstance().findFileByPath(srcPath); + assertNotNull(srcPath, vFile); + PsiFile srcFile = getPsiManager().findFile(vFile); + assertNotNull(vFile.getPath(), srcFile); + + ((ClsFileImpl)clsFile).setMirror((TreeElement)srcFile.getNode());*/ + } +}