本文整理匯總了Java中com.intellij.openapi.fileTypes.FileType.isBinary方法的典型用法代碼示例。如果您正苦於以下問題:Java FileType.isBinary方法的具體用法?Java FileType.isBinary怎麽用?Java FileType.isBinary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.fileTypes.FileType
的用法示例。
在下文中一共展示了FileType.isBinary方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getData
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
public Object getData(DataProvider dataProvider) {
final VirtualFile virtualFile = (VirtualFile)dataProvider.getData(CommonDataKeys.VIRTUAL_FILE.getName());
if (virtualFile == null) {
return null;
}
final FileType fileType = virtualFile.getFileType();
if (fileType.isBinary() || fileType.isReadOnly()) {
return null;
}
final Project project = (Project)dataProvider.getData(CommonDataKeys.PROJECT.getName());
if (project == null) {
return null;
}
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document == null) {
return null;
}
return document.getText();
}
示例2: canHaveStub
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
public boolean canHaveStub(VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
Language l = ((LanguageFileType)fileType).getLanguage();
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null) return false;
final IFileElementType elementType = parserDefinition.getFileNodeType();
return elementType instanceof IStubFileElementType && ((IStubFileElementType)elementType).shouldBuildStubFor(file);
}
else if (fileType.isBinary()) {
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
return false;
}
示例3: calcBaseLanguage
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
private static Language calcBaseLanguage(@NotNull VirtualFile file, @NotNull Project project, @NotNull final FileType fileType) {
if (file instanceof LightVirtualFile) {
final Language language = ((LightVirtualFile)file).getLanguage();
if (language != null) {
return language;
}
}
if (fileType.isBinary()) return Language.ANY;
if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;
if (fileType instanceof LanguageFileType) {
return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project);
}
return PlainTextLanguage.INSTANCE;
}
示例4: compare
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public int compare(final FileType o1, final FileType o2) {
if (o1 == o2) {
return 0;
}
if (o1 == FileTypes.UNKNOWN) {
return 1;
}
if (o2 == FileTypes.UNKNOWN) {
return -1;
}
if (o1.isBinary() && !o2.isBinary()) {
return 1;
}
if (!o1.isBinary() && o2.isBinary()) {
return -1;
}
return o1.getName().compareToIgnoreCase(o2.getName());
}
示例5: setName
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
public static PsiFile setName(@NotNull PsiFile file, @NotNull String newName) throws IncorrectOperationException {
VirtualFile vFile = file.getViewProvider().getVirtualFile();
PsiManagerImpl manager = (PsiManagerImpl)file.getManager();
try{
final FileType newFileType = FileTypeRegistry.getInstance().getFileTypeByFileName(newName);
if (UnknownFileType.INSTANCE.equals(newFileType) || newFileType.isBinary()) {
// before the file becomes unknown or a binary (thus, not openable in the editor), save it to prevent data loss
final FileDocumentManager fdm = FileDocumentManager.getInstance();
final Document doc = fdm.getCachedDocument(vFile);
if (doc != null) {
fdm.saveDocumentAsIs(doc);
}
}
vFile.rename(manager, newName);
}
catch(IOException e){
throw new IncorrectOperationException(e);
}
return file.getViewProvider().isPhysical() ? manager.findFile(vFile) : file;
}
示例6: getFile
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
VcsFileRevision revision = getFileRevision(e);
if (revision == null) return null;
final FileType currentFileType = myAnnotation.getFile().getFileType();
FilePath filePath =
(revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx)revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
@NotNull
@Override
public FileType getFileType() {
FileType type = super.getFileType();
if (!type.isBinary()) return type;
if (!currentFileType.isBinary()) return currentFileType;
return PlainTextFileType.INSTANCE;
}
};
}
示例7: checkAssociate
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
public static boolean checkAssociate(final Project project, String fileName, DiffChainContext context) {
final String pattern = FileUtilRt.getExtension(fileName).toLowerCase();
if (context.contains(pattern)) return false;
int rc = Messages.showOkCancelDialog(project,
VcsBundle.message("diff.unknown.file.type.prompt", fileName),
VcsBundle.message("diff.unknown.file.type.title"),
VcsBundle.message("diff.unknown.file.type.associate"),
CommonBundle.getCancelButtonText(),
Messages.getQuestionIcon());
if (rc == Messages.OK) {
FileType fileType = FileTypeChooser.associateFileType(fileName);
return fileType != null && !fileType.isBinary();
} else {
context.add(pattern);
}
return false;
}
示例8: isBPMN
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
public static boolean isBPMN(@NotNull VirtualFile virtualFile) {
if (BPMN_EXTENSION.equals(virtualFile.getExtension())) {
final FileType fileType = virtualFile.getFileType();
if (fileType == getFileType() && !fileType.isBinary()) {
return virtualFile.getName().endsWith(DOT_BPMN_EXTENSION);
}
}
return false;
}
示例9: isTextFile
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的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;
}
示例10: isValueEditableForFile
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
protected boolean isValueEditableForFile(final VirtualFile virtualFile) {
boolean enabled = true;
if (virtualFile != null) {
if (!virtualFile.isDirectory()) {
final FileType fileType = virtualFile.getFileType();
if (fileType.isBinary()) {
enabled = false;
}
}
}
return enabled;
}
示例11: isFxml
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
public static boolean isFxml(@NotNull VirtualFile virtualFile) {
if (FXML_EXTENSION.equals(virtualFile.getExtension())) {
final FileType fileType = virtualFile.getFileType();
if (fileType == FileTypeManager.getInstance().getFileTypeByExtension(FXML_EXTENSION) && !fileType.isBinary()) return true;
}
return false;
}
示例12: createFileFromText
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
@NotNull
public PsiFile createFileFromText(@NotNull String name, @NotNull String text){
FileType type = FileTypeRegistry.getInstance().getFileTypeByFileName(name);
if (type.isBinary()) {
throw new RuntimeException("Cannot create binary files from text: name " + name + ", file type " + type);
}
return createFileFromText(name, type, text);
}
示例13: checkContentRevision
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
private boolean checkContentRevision(ContentRevision rev, final DiffChainContext context, final List<String> errSb) {
if (rev == null) return true;
if (rev.getFile().isDirectory()) return false;
if (! hasContents(rev, errSb)) {
return false;
}
final FileType type = rev.getFile().getFileType();
if (! type.isBinary()) return true;
if (FileTypes.UNKNOWN.equals(type)) {
final boolean associatedToText = checkAssociate(myProject, rev.getFile().getName(), context);
}
return true;
}
示例14: isHighlightingAvailable
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
public boolean isHighlightingAvailable(@Nullable PsiFile file) {
if (file == null || !file.isPhysical()) return false;
if (myDisabledHighlightingFiles.contains(PsiUtilCore.getVirtualFile(file))) return false;
if (file instanceof PsiCompiledElement) return false;
final FileType fileType = file.getFileType();
// To enable T.O.D.O. highlighting
return !fileType.isBinary();
}
示例15: getDaemonCodeAnalyzerStatus
import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@NotNull
protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@NotNull SeverityRegistrar severityRegistrar) {
DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
if (myFile == null) {
status.reasonWhyDisabled = "No file";
status.errorAnalyzingFinished = true;
return status;
}
if (myProject != null && myProject.isDisposed()) {
status.reasonWhyDisabled = "Project is disposed";
status.errorAnalyzingFinished = true;
return status;
}
if (!myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) {
if (!myFile.isPhysical()) {
status.reasonWhyDisabled = "File is generated";
status.errorAnalyzingFinished = true;
return status;
}
else if (myFile instanceof PsiCompiledElement) {
status.reasonWhyDisabled = "File is decompiled";
status.errorAnalyzingFinished = true;
return status;
}
final FileType fileType = myFile.getFileType();
if (fileType.isBinary()) {
status.reasonWhyDisabled = "File is binary";
status.errorAnalyzingFinished = true;
return status;
}
status.reasonWhyDisabled = "Highlighting is disabled for this file";
status.errorAnalyzingFinished = true;
return status;
}
FileViewProvider provider = myFile.getViewProvider();
Set<Language> languages = provider.getLanguages();
HighlightingSettingsPerFile levelSettings = HighlightingSettingsPerFile.getInstance(myProject);
boolean shouldHighlight = languages.isEmpty();
for (Language language : languages) {
PsiFile root = provider.getPsi(language);
FileHighlightingSetting level = levelSettings.getHighlightingSettingForRoot(root);
shouldHighlight |= level != FileHighlightingSetting.SKIP_HIGHLIGHTING;
}
if (!shouldHighlight) {
status.reasonWhyDisabled = "Highlighting level is None";
status.errorAnalyzingFinished = true;
return status;
}
if (HeavyProcessLatch.INSTANCE.isRunning()) {
status.reasonWhySuspended = StringUtil.defaultIfEmpty(HeavyProcessLatch.INSTANCE.getRunningOperationName(), "Heavy operation is running");
status.errorAnalyzingFinished = true;
return status;
}
status.errorCount = errorCount.clone();
fillDaemonCodeAnalyzerErrorsStatus(status, severityRegistrar);
List<TextEditorHighlightingPass> passes = myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument);
status.passStati = passes.isEmpty() ? Collections.<ProgressableTextEditorHighlightingPass>emptyList() :
new ArrayList<ProgressableTextEditorHighlightingPass>(passes.size());
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < passes.size(); i++) {
TextEditorHighlightingPass tepass = passes.get(i);
if (!(tepass instanceof ProgressableTextEditorHighlightingPass)) continue;
ProgressableTextEditorHighlightingPass pass = (ProgressableTextEditorHighlightingPass)tepass;
if (pass.getProgress() < 0) continue;
status.passStati.add(pass);
}
status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(myFile);
status.reasonWhySuspended = myDaemonCodeAnalyzer.isUpdateByTimerEnabled() ? null : "Highlighting is paused temporarily";
return status;
}