本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}