@Override @NotNull public CharSequence decompile(@NotNull VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if (decompiler instanceof ClassFileDecompilers.Full) { PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject()); return ((ClassFileDecompilers.Full)decompiler).createFileViewProvider(file, manager, true).getContents(); } if (decompiler instanceof ClassFileDecompilers.Light) { try { return ((ClassFileDecompilers.Light)decompiler).getText(file); } catch (ClassFileDecompilers.Light.CannotDecompileException e) { LOG.warn("decompiler: " + decompiler.getClass(), e); } } return ClsFileImpl.decompile(file); }
@Override public int getStubVersion() { int version = STUB_VERSION; List<ClassFileDecompilers.Decompiler> decompilers = ContainerUtil.newArrayList(ClassFileDecompilers.EP_NAME.getExtensions()); Collections.sort(decompilers, CLASS_NAME_COMPARATOR); for(ClassFileDecompilers.Decompiler decompiler : decompilers) { if(decompiler instanceof Full) { version = version * 31 + ((Full) decompiler).getStubBuilder().getStubVersion() + decompiler.getClass().getName().hashCode(); } } return version; }
@NotNull @Override public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean eventSystemEnabled) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if (decompiler instanceof Full) { return ((Full)decompiler).createFileViewProvider(file, manager, eventSystemEnabled); } return new ClassFileViewProvider(manager, file, eventSystemEnabled); }
private static Exception wrapException(InvalidMirrorException e, VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if (decompiler instanceof ClassFileDecompilers.Light) { PluginId pluginId = PluginManagerCore.getPluginByClassName(decompiler.getClass().getName()); if (pluginId != null) { return new PluginException(e, pluginId); } } return e; }
@Override public int getStubVersion() { int version = STUB_VERSION; List<ClassFileDecompilers.Decompiler> decompilers = ContainerUtil.newArrayList(ClassFileDecompilers.EP_NAME.getExtensions()); Collections.sort(decompilers, CLASS_NAME_COMPARATOR); for (ClassFileDecompilers.Decompiler decompiler : decompilers) { if (decompiler instanceof Full) { version = version * 31 + ((Full)decompiler).getStubBuilder().getStubVersion() + decompiler.getClass().getName().hashCode(); } } return version; }
public void testCancellation() { if (GraphicsEnvironment.isHeadless()) { System.err.println("** skipped in headless env."); return; } final VirtualFile file = getTestFile(PlatformTestUtil.getRtJarPath() + "!/javax/swing/JTable.class"); final IdeaDecompiler decompiler = (IdeaDecompiler)ClassFileDecompilers.find(file); assertNotNull(decompiler); final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, getProject()); alarm.addRequest(new Runnable() { @Override public void run() { ProgressIndicator progress = decompiler.getProgress(file); if (progress != null) { progress.cancel(); } else { alarm.addRequest(this, 200, ModalityState.any()); } } }, 750, ModalityState.any()); try { FileDocumentManager.getInstance().getDocument(file); fail("should have been cancelled"); } catch (ProcessCanceledException ignored) { } }
@NotNull @Override public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean eventSystemEnabled) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if(decompiler instanceof Full) { return ((Full) decompiler).createFileViewProvider(file, manager, eventSystemEnabled); } return new ClassFileViewProvider(manager, file, eventSystemEnabled); }
private static Exception wrapException(InvalidMirrorException e, VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if(decompiler instanceof ClassFileDecompilers.Light) { PluginId pluginId = PluginManagerCore.getPluginByClassName(decompiler.getClass().getName()); if(pluginId != null) { return new PluginException(e, pluginId); } } return e; }
@Override @NotNull public CharSequence decompile(@NotNull VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if(decompiler instanceof ClassFileDecompilers.Full) { PsiManager manager = PsiManager.getInstance(DefaultProjectFactory.getInstance().getDefaultProject()); return ((ClassFileDecompilers.Full) decompiler).createFileViewProvider(file, manager, true).getContents(); } return decompileText(file); }
@NotNull public static CharSequence decompileText(@NotNull VirtualFile file) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if(decompiler instanceof ClassFileDecompilers.Light) { return ((ClassFileDecompilers.Light) decompiler).getText(file); } return ClsFileImpl.decompile(file); }