blob: b832e65c7675a7784f7057fae3edb5fe1c904c7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* Copyright 2000-2014 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.ide.highlighter.JavaFileType;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.impl.compiled.ClsFileImpl;
import com.intellij.testFramework.LightIdeaTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import java.io.IOException;
public class ClsMirrorBuildingTest extends LightIdeaTestCase {
public void testSimpleEnum() { doTest(); }
public void testEnumWithFields() { doTest(); }
public void testNormalClass() { doTest(); }
public void testNested() { doTest(); }
public void testDeprecated() { doTest(); }
public void testAnnotations() { doTest(); }
public void testParameterNames() { doTest(); }
public void testEmptyEnum() { doTest(); }
public void test$BuckClass() { doTest(); }
public void testBuckClass$() { doTest(); }
public void testExtMethods() { doTest(); }
public void testMethodReceiver() { doTest(); }
public void testPackageInfo() { doTest("package-info"); }
public void testEA40568() { doTest(); }
public void testPrimitives() { doTest(); }
public void testClassRefs() { doTest(); }
public void testEA46236() { doTest("ValuedEnum"); }
public void testKotlinFunList() { doTest(); }
public void testMiddle$Buck() { doTest(); }
public void testDefaultPackage() { doTest(); }
public void testLocalClass() { doTest(); }
public void testBounds() { doTest(); }
public void testGrEnum() { doTest(); }
public void testTextPsiMismatch() {
CommonCodeStyleSettings.IndentOptions options =
CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getIndentOptions(JavaFileType.INSTANCE);
int indent = options.INDENT_SIZE;
options.INDENT_SIZE *= 2;
try {
doTest("Bounds");
}
finally {
options.INDENT_SIZE = indent;
}
}
public void testJdk8Class() {
String testDir = JavaTestUtil.getJavaTestDataPath();
String clsPath = testDir + "/../../mockJDK-1.8/jre/lib/rt.jar!/java/lang/Class.class";
String txtPath = testDir + "/psi/cls/mirror/Class.txt";
doTest(clsPath, txtPath);
}
private void doTest() {
doTest(getTestName(false));
}
private static void doTest(String name) {
String testDir = JavaTestUtil.getJavaTestDataPath() + "/psi/cls/mirror/";
doTest(testDir + "pkg/" + name + ".class", testDir + name + ".txt");
}
private static void doTest(String clsPath, String txtPath) {
VirtualFileSystem fs = clsPath.contains("!/") ? JarFileSystem.getInstance() : LocalFileSystem.getInstance();
VirtualFile vFile = fs.findFileByPath(clsPath);
assertNotNull(clsPath, vFile);
PsiFile clsFile = getPsiManager().findFile(vFile);
assertNotNull(vFile.getPath(), clsFile);
String expected;
try {
expected = StringUtil.trimTrailing(PlatformTestUtil.loadFileText(txtPath));
}
catch (IOException e) {
fail(e.getMessage());
return;
}
assertEquals(expected, ((ClsFileImpl)clsFile).getMirror().getText());
}
}
|