当前位置: 首页>>代码示例>>Java>>正文


Java BinaryFileTypeDecompilers类代码示例

本文整理汇总了Java中com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers的典型用法代码示例。如果您正苦于以下问题:Java BinaryFileTypeDecompilers类的具体用法?Java BinaryFileTypeDecompilers怎么用?Java BinaryFileTypeDecompilers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BinaryFileTypeDecompilers类属于com.intellij.openapi.fileTypes包,在下文中一共展示了BinaryFileTypeDecompilers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBinaryImpl

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
@Nonnull
private DiffContent createBinaryImpl(@javax.annotation.Nullable Project project,
                                     @Nonnull byte[] content,
                                     @Nonnull FileType type,
                                     @Nonnull String fileName,
                                     @javax.annotation.Nullable VirtualFile highlightFile) throws IOException {
  // workaround - our JarFileSystem and decompilers can't process non-local files
  boolean useTemporalFile = type instanceof ArchiveFileType || BinaryFileTypeDecompilers.INSTANCE.forFileType(type) != null;

  VirtualFile file;
  if (useTemporalFile) {
    file = createTemporalFile(project, "tmp", fileName, content);
  }
  else {
    file = new BinaryLightVirtualFile(fileName, type, content);
    file.setWritable(false);
  }

  return new FileContentImpl(project, file, highlightFile);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:DiffContentFactoryImpl.java

示例2: loadText

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
@Nonnull
public static CharSequence loadText(@Nonnull final VirtualFile file) {
  FileType type = file.getFileType();
  if (type.isBinary()) {
    final BinaryFileDecompiler decompiler = BinaryFileTypeDecompilers.INSTANCE.forFileType(type);
    if (decompiler != null) {
      CharSequence text = decompiler.decompile(file);
      try {
        StringUtil.assertValidSeparators(text);
      }
      catch (AssertionError e) {
        LOG.error(e);
      }
      return text;
    }

    throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " +
                                       file.getPresentableUrl() + ". File type: " + type.getName());
  }
  return loadText(file, UNLIMITED);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:LoadTextUtil.java

示例3: isTextFile

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
public static boolean isTextFile(@NotNull VirtualFile file) {
  if (file.isDirectory() || !file.isValid()) {
    return false;
  }

  final FileType ft = file.getFileType();
  return !ft.isBinary() || BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:TextEditorProvider.java

示例4: accept

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
  if (file.isDirectory() || !file.isValid()) {
    return false;
  }
  if (SingleRootFileViewProvider.isTooLargeForContentLoading(file)) {
    return false;
  }

  final FileType ft = file.getFileType();
  return !ft.isBinary() || BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:TextEditorProvider.java

示例5: loadText

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
@NotNull
public static CharSequence loadText(@NotNull VirtualFile file) {
  if (file instanceof LightVirtualFile) {
    CharSequence content = ((LightVirtualFile)file).getContent();
    if (StringUtil.indexOf(content, '\r') == -1) return content;

    CharBuffer buffer = CharBuffer.allocate(content.length());
    buffer.append(content);
    buffer.rewind();
    return convertLineSeparators(buffer).first;
  }

  if (file.isDirectory()) {
    throw new AssertionError("'" + file.getPresentableUrl() + "' is directory");
  }
  final FileType fileType = file.getFileType();

  if (fileType.isBinary()) {
    final BinaryFileDecompiler decompiler = BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType);
    if (decompiler != null) {
      CharSequence text = decompiler.decompile(file);
      StringUtil.assertValidSeparators(text);
      return text;
    }

    throw new IllegalArgumentException("Attempt to load text for binary file, that doesn't have decompiler plugged in: "+file.getPresentableUrl());
  }

  try {
    byte[] bytes = file.contentsToByteArray();
    return getTextByBinaryPresentation(bytes, file);
  }
  catch (IOException e) {
    return ArrayUtil.EMPTY_CHAR_SEQUENCE;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:LoadTextUtil.java

示例6: getContent

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
public String getContent(final String fileUrl) {
  final VirtualFile fileByUrl = VirtualFileManager.getInstance().findFileByUrl(fileUrl);
  if (fileByUrl != null) {
    if (fileByUrl.isDirectory()) {
      return null;
    }
    BinaryFileDecompiler binaryFileDecompiler = null;
    FileType fileType = fileByUrl.getFileType();
    if (fileType.isBinary()) {
      binaryFileDecompiler = BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType);
      if (binaryFileDecompiler == null) {
        return null;
      }
    }

    if (binaryFileDecompiler != null) {
      return binaryFileDecompiler.decompile(fileByUrl).toString();
    }

    return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
      
      public String compute() {
        return getFileText(getProject(), fileByUrl).toString();
      }
    });
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:GwtTransportServiceImpl.java

示例7: isTextFile

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
public static boolean isTextFile(@Nonnull VirtualFile file) {
  if (file.isDirectory() || !file.isValid()) {
    return false;
  }

  final FileType ft = file.getFileType();
  return !ft.isBinary() || BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:TextEditorProvider.java

示例8: isBinaryWithDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private static boolean isBinaryWithDecompiler(@NotNull VirtualFile file) {
  final FileType ft = file.getFileType();
  return ft.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:FileDocumentManagerImpl.java

示例9: isBinaryWithoutDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private static boolean isBinaryWithoutDecompiler(@NotNull VirtualFile file) {
  final FileType fileType = file.getFileType();
  return fileType.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType) == null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:FileDocumentManagerImpl.java

示例10: isBinaryWithoutDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private static boolean isBinaryWithoutDecompiler(VirtualFile file) {
  final FileType ft = file.getFileType();
  return ft.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) == null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MockFileDocumentManagerImpl.java

示例11: loadText

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
@NotNull
public static CharSequence loadText(@NotNull final VirtualFile file) {
  if (file instanceof LightVirtualFile) {
    return ((LightVirtualFile)file).getContent();
  }

  if (file.isDirectory()) {
    throw new AssertionError("'" + file.getPresentableUrl() + "' is a directory");
  }

  FileType fileType = file.getFileType();
  if (fileType.isBinary()) {
    final BinaryFileDecompiler decompiler = BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType);
    if (decompiler != null) {
      CharSequence text;

      Application app = ApplicationManager.getApplication();
      if (app != null && app.isDispatchThread() && !app.isWriteAccessAllowed() && !GraphicsEnvironment.isHeadless()) {
        final Ref<CharSequence> result = Ref.create(ArrayUtil.EMPTY_CHAR_SEQUENCE);
        final Ref<Throwable> error = Ref.create();
        ProgressManager.getInstance().run(new Task.Modal(null, "Decompiling " + file.getName(), true) {
          @Override
          public void run(@NotNull ProgressIndicator indicator) {
            indicator.setIndeterminate(true);
            try {
              result.set(ApplicationUtil.runWithCheckCanceled(new Callable<CharSequence>() {
                @Override
                public CharSequence call() {
                  return decompiler.decompile(file);
                }
              }, indicator));
            }
            catch (Throwable t) {
              error.set(t);
            }
          }
        });
        ExceptionUtil.rethrowUnchecked(error.get());
        text = result.get();
      }
      else {
        text = decompiler.decompile(file);
      }

      StringUtil.assertValidSeparators(text);
      return text;
    }

    throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " + file.getPresentableUrl() + ". File type: " + fileType.getName());
  }

  try {
    byte[] bytes = file.contentsToByteArray();
    return getTextByBinaryPresentation(bytes, file);
  }
  catch (IOException e) {
    return ArrayUtil.EMPTY_CHAR_SEQUENCE;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:LoadTextUtil.java

示例12: isBinaryWithDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private static boolean isBinaryWithDecompiler(VirtualFile file) {
  final FileType ft = file.getFileType();
  return ft.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:FileDocumentManagerImpl.java

示例13: isBinaryWithoutDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private boolean isBinaryWithoutDecompiler(VirtualFile file) {
  final FileType ft = file.getFileType();
  return ft.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) == null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:MockFileDocumentManagerImpl.java

示例14: isBinaryWithDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private static boolean isBinaryWithDecompiler(@Nonnull VirtualFile file) {
  final FileType ft = file.getFileType();
  return ft.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:5,代码来源:FileDocumentManagerImpl.java

示例15: isBinaryWithoutDecompiler

import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; //导入依赖的package包/类
private static boolean isBinaryWithoutDecompiler(@Nonnull VirtualFile file) {
  final FileType fileType = file.getFileType();
  return fileType.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType) == null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:5,代码来源:FileDocumentManagerImpl.java


注:本文中的com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。