use of com.intellij.psi.impl.compiled.ClsFileImpl in project intellij-community by JetBrains.
the class ClsPsiTest method getFile.
private static PsiJavaFile getFile(String name) {
String path = PathManagerEx.getTestDataPath() + TEST_DATA_PATH + "/pack/" + name + ".class";
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
assertNotNull(path, file);
PsiFile clsFile = PsiManager.getInstance(getProject()).findFile(file);
assertTrue(String.valueOf(clsFile), clsFile instanceof ClsFileImpl);
return (PsiJavaFile) clsFile;
}
use of com.intellij.psi.impl.compiled.ClsFileImpl in project intellij-community by JetBrains.
the class CoreJavaDirectoryService method getPsiClasses.
@NotNull
public static PsiClass[] getPsiClasses(@NotNull PsiDirectory dir, PsiFile[] psiFiles) {
FileIndexFacade index = FileIndexFacade.getInstance(dir.getProject());
VirtualFile virtualDir = dir.getVirtualFile();
boolean onlyCompiled = index.isInLibraryClasses(virtualDir) && !index.isInSourceContent(virtualDir);
List<PsiClass> classes = null;
for (PsiFile file : psiFiles) {
if (onlyCompiled && !(file instanceof ClsFileImpl)) {
continue;
}
if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
PsiClass[] psiClasses = ((PsiClassOwner) file).getClasses();
if (psiClasses.length == 0)
continue;
if (classes == null)
classes = new ArrayList<>();
ContainerUtil.addAll(classes, psiClasses);
}
}
return classes == null ? PsiClass.EMPTY_ARRAY : classes.toArray(new PsiClass[classes.size()]);
}
use of com.intellij.psi.impl.compiled.ClsFileImpl in project intellij-community by JetBrains.
the class ClsMirrorBuildingTest method doTest.
private static void doTest(String clsPath, String txtPath) {
VirtualFile file = (clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local()).refreshAndFindFileByPath(clsPath);
assertNotNull(clsPath, file);
String expected;
try {
expected = StringUtil.trimTrailing(PlatformTestUtil.loadFileText(txtPath));
} catch (IOException e) {
throw new RuntimeException(e);
}
assertEquals(expected, ClsFileImpl.decompile(file).toString());
((ClsFileImpl) getPsiManager().findFile(file)).getMirror();
}
Aggregations