Java 类com.intellij.psi.compiled.ClassFileDecompilers 实例源码

项目:intellij-ce-playground    文件:ClassFileDecompiler.java   
@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);
}
项目:consulo-java    文件:ClassFileStubBuilder.java   
@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;
}
项目:intellij-ce-playground    文件:ClassFileViewProviderFactory.java   
@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);
}
项目:intellij-ce-playground    文件:ClsFileImpl.java   
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;
}
项目:intellij-ce-playground    文件:ClassFileStubBuilder.java   
@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;
}
项目:intellij-ce-playground    文件:IdeaDecompilerTest.java   
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) { }
}
项目:consulo-java    文件:ClassFileViewProviderFactory.java   
@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);
}
项目:consulo-java    文件:ClsFileImpl.java   
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;
}
项目:consulo-java    文件:ClassFileDecompiler.java   
@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);
}
项目:consulo-java    文件:ClassFileDecompiler.java   
@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);
}