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


Java FileTypes.UNKNOWN属性代码示例

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


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

示例1: fileTypesAreOk

private boolean fileTypesAreOk(final List<Pair<VirtualFile, ApplyTextFilePatch>> textPatches) {
  for (Pair<VirtualFile, ApplyTextFilePatch> textPatch : textPatches) {
    final VirtualFile file = textPatch.getFirst();
    if (! file.isDirectory()) {
      FileType fileType = file.getFileType();
      if (fileType == FileTypes.UNKNOWN) {
        fileType = FileTypeChooser.associateFileType(file.getName());
        if (fileType == null) {
          showError(myProject, "Cannot apply patch. File " + file.getPresentableName() + " type not defined.", true);
          return false;
        }
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PatchApplier.java

示例2: compare

/**
 * {@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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GotoFileAction.java

示例3: update

@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  DataContext dataContext = e.getDataContext();
  VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  boolean haveSmthToDo;
  if (project == null || file == null || file.isDirectory()) {
    haveSmthToDo = false;
  }
  else {
    // the action should also be available for files which have been auto-detected as text or as a particular language (IDEA-79574)
    haveSmthToDo = FileTypeManager.getInstance().getFileTypeByFileName(file.getName()) == FileTypes.UNKNOWN &&
                   !ScratchRootType.getInstance().isScratchFile(file);
  }
  presentation.setVisible(haveSmthToDo || ActionPlaces.isMainMenuOrActionSearch(e.getPlace()));
  presentation.setEnabled(haveSmthToDo);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AssociateFileTypeAction.java

示例4: update

public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  DataContext dataContext = e.getDataContext();
  VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
  Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  boolean haveSmthToDo;
  if (project == null || file == null || file.isDirectory()) {
    haveSmthToDo = false;
  }
  else {
    // the action should also be available for files which have been auto-detected as text or as a particular language (IDEA-79574)
    haveSmthToDo = FileTypeManager.getInstance().getFileTypeByFileName(file.getName()) == FileTypes.UNKNOWN;
  }
  presentation.setVisible(haveSmthToDo || ActionPlaces.MAIN_MENU.equals(e.getPlace()));
  presentation.setEnabled(haveSmthToDo);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:AssociateFileType.java

示例5: copyOldIndentOptions

private void copyOldIndentOptions(@NonNls final String extension, final IndentOptions options) {
  final FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(extension);
  if (fileType != FileTypes.UNKNOWN && fileType != FileTypes.PLAIN_TEXT && !myAdditionalIndentOptions.containsKey(fileType) &&
      !fileType.getDefaultExtension().isEmpty()) {
    registerAdditionalIndentOptions(fileType, options);
    //
    // Upgrade to version 11
    //
    if (fileType instanceof LanguageFileType) {
      Language lang = ((LanguageFileType)fileType).getLanguage();
      CommonCodeStyleSettings langSettings = myCommonSettingsManager.getCommonSettings(lang);
      if (langSettings != this && langSettings.getIndentOptions() != null) {
        langSettings.importOldIndentOptions(this);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:CodeStyleSettings.java

示例6: fileTypesAreOk

private boolean fileTypesAreOk(final List<Pair<VirtualFile, ApplyTextFilePatch>> textPatches) {
  for (Pair<VirtualFile, ApplyTextFilePatch> textPatch : textPatches) {
    final VirtualFile file = textPatch.getFirst();
    if (! file.isDirectory()) {
      FileType fileType = file.getFileType();
      if (fileType == FileTypes.UNKNOWN) {
        fileType = FileTypeChooser.associateFileType(file.getPresentableName());
        if (fileType == null) {
          showError(myProject, "Cannot apply patch. File " + file.getPresentableName() + " type not defined.", true);
          return false;
        }
      }
    }
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:PatchApplier.java

示例7: updateFileTypeForEditorComponent

private void updateFileTypeForEditorComponent(@NotNull ComboBox inputComboBox) {
  final Component editorComponent = inputComboBox.getEditor().getEditorComponent();

  if (editorComponent instanceof EditorTextField) {
    boolean selected = myCbRegularExpressions.isSelectedWhenSelectable();
    @NonNls final String s = selected ? "*.regexp" : "*.txt";
    FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(s);

    if (selected && fileType == FileTypes.UNKNOWN) {
      fileType = FileTypeManager.getInstance().getFileTypeByFileName("*.txt"); // RegExp plugin is not installed
    }

    final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(s, fileType, ((EditorTextField)editorComponent).getText(), -1, true);

    ((EditorTextField)editorComponent).setNewDocumentAndFileType(fileType, PsiDocumentManager.getInstance(myProject).getDocument(file));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:FindDialog.java

示例8: isMyFileType

@Override
public boolean isMyFileType(@NotNull VirtualFile file) {
  VirtualFile parent = file.getParent();
  if (parent != null && Comparing.equal("services", parent.getNameSequence())) {
    final VirtualFile gParent = parent.getParent();
    if (gParent != null && Comparing.equal("META-INF", gParent.getNameSequence())) {
      final String fileName = file.getName();
      for (Object condition : Extensions.getExtensions("com.intellij.vetoSPICondition")) {
        if (((Condition<String>)condition).value(fileName)) return false;
      }
      return FileTypeRegistry.getInstance().getFileTypeByFileName(fileName) == FileTypes.UNKNOWN;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:SPIFileType.java

示例9: assertFilesEqual

public static void assertFilesEqual(VirtualFile fileAfter, VirtualFile fileBefore) throws IOException {
  try {
    assertJarFilesEqual(VfsUtilCore.virtualToIoFile(fileAfter), VfsUtilCore.virtualToIoFile(fileBefore));
  }
  catch (IOException e) {
    FileDocumentManager manager = FileDocumentManager.getInstance();

    Document docBefore = manager.getDocument(fileBefore);
    boolean canLoadBeforeText = !fileBefore.getFileType().isBinary() || fileBefore.getFileType() == FileTypes.UNKNOWN;
    String textB = docBefore != null
                   ? docBefore.getText()
                   : !canLoadBeforeText
                     ? null
                     : LoadTextUtil.getTextByBinaryPresentation(fileBefore.contentsToByteArray(false), fileBefore).toString();

    Document docAfter = manager.getDocument(fileAfter);
    boolean canLoadAfterText = !fileBefore.getFileType().isBinary() || fileBefore.getFileType() == FileTypes.UNKNOWN;
    String textA = docAfter != null
                   ? docAfter.getText()
                   : !canLoadAfterText
                     ? null
                     : LoadTextUtil.getTextByBinaryPresentation(fileAfter.contentsToByteArray(false), fileAfter).toString();

    if (textA != null && textB != null) {
      assertEquals(fileAfter.getPath(), textA, textB);
    }
    else {
      Assert.assertArrayEquals(fileAfter.getPath(), fileAfter.contentsToByteArray(), fileBefore.contentsToByteArray());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:PlatformTestUtil.java

示例10: findMatches

private boolean findMatches(MatchOptions options, CompiledPattern compiledPattern) {
  SearchScope searchScope = compiledPattern.getScope();
  final boolean ourOptimizedScope = searchScope != null;
  if (!ourOptimizedScope) searchScope = options.getScope();

  if (searchScope instanceof GlobalSearchScope) {
    final GlobalSearchScope scope = (GlobalSearchScope)searchScope;

    final ContentIterator ci = new ContentIterator() {
      public boolean processFile(final VirtualFile fileOrDir) {
        if (!fileOrDir.isDirectory() && scope.contains(fileOrDir) && fileOrDir.getFileType() != FileTypes.UNKNOWN) {
          ++totalFilesToScan;
          scheduler.addOneTask(new MatchOneVirtualFile(fileOrDir));
        }
        return true;
      }
    };

    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        FileBasedIndex.getInstance().iterateIndexableFiles(ci, project, progress);
      }
    });
    progress.setText2("");
  }
  else {
    final PsiElement[] elementsToScan = ((LocalSearchScope)searchScope).getScope();
    totalFilesToScan = elementsToScan.length;

    for (int i = 0; i < elementsToScan.length; ++i) {
      final PsiElement psiElement = elementsToScan[i];

      if (psiElement == null) continue;
      scheduler.addOneTask(new MatchOnePsiFile(psiElement));
      if (ourOptimizedScope) elementsToScan[i] = null; // to prevent long PsiElement reference
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:MatcherImpl.java

示例11: findFileType

@NotNull
private static FileType findFileType(final Language language) {
  FileType[] registeredFileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
  for (FileType fileType : registeredFileTypes) {
    if (fileType instanceof LanguageFileType && ((LanguageFileType)fileType).getLanguage() == language) {
      return fileType;
    }
  }
  return FileTypes.UNKNOWN;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TemplateLanguageStructureViewBuilder.java

示例12: canExternalizeAsFile

static boolean canExternalizeAsFile(VirtualFile file) {
  if (file == null || file.isDirectory()) return false;
  FileType fileType = file.getFileType();
  if (fileType.isBinary() && fileType != FileTypes.UNKNOWN) return false;
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:LocalFileExternalizer.java

示例13: readExternal

@Override
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  if (LAYOUT_STATIC_IMPORTS_SEPARATELY) {
    // add <all other static imports> entry if there is none
    boolean found = false;
    for (PackageEntry entry : IMPORT_LAYOUT_TABLE.getEntries()) {
      if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
        found = true;
        break;
      }
    }
    if (!found) {
      PackageEntry last = IMPORT_LAYOUT_TABLE.getEntryCount() == 0 ? null : IMPORT_LAYOUT_TABLE.getEntryAt(IMPORT_LAYOUT_TABLE.getEntryCount() - 1);
      if (last != PackageEntry.BLANK_LINE_ENTRY) {
        IMPORT_LAYOUT_TABLE.addEntry(PackageEntry.BLANK_LINE_ENTRY);
      }
      IMPORT_LAYOUT_TABLE.addEntry(PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY);
    }
  }
  for (final CustomCodeStyleSettings settings : getCustomSettingsValues()) {
    settings.readExternal(element);
    settings.importLegacySettings();
  }

  final List list = element.getChildren(ADDITIONAL_INDENT_OPTIONS);
  if (list != null) {
    for(Object o:list) {
      if (o instanceof Element) {
        final Element additionalIndentElement = (Element)o;
        final String fileTypeId = additionalIndentElement.getAttributeValue(FILETYPE);

        if (fileTypeId != null && !fileTypeId.isEmpty()) {
          FileType target = FileTypeManager.getInstance().getFileTypeByExtension(fileTypeId);
          if (FileTypes.UNKNOWN == target || FileTypes.PLAIN_TEXT == target || target.getDefaultExtension().isEmpty()) {
            target = new TempFileType(fileTypeId);
          }

          final IndentOptions options = getDefaultIndentOptions(target);
          options.readExternal(additionalIndentElement);
          registerAdditionalIndentOptions(target, options);
        }
      }
    }
  }

  myCommonSettingsManager.readExternal(element);

  if (USE_SAME_INDENTS) IGNORE_SAME_INDENTS_FOR_LANGUAGES = true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:CodeStyleSettings.java

示例14: getFileType

private static FileType getFileType(final String fileName) {
  FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName);
  if (fileType == FileTypes.UNKNOWN) fileType = FileTypes.PLAIN_TEXT;
  return fileType;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:EditVarConstraintsDialog.java

示例15: fetchOneFile

@Nullable
private String fetchOneFile(final ProgressIndicator indicator,
                                   final String resourceUrl,
                                   final Project project,
                                   String extResourcesPath,
                                   @Nullable String refname) throws IOException {
  SwingUtilities.invokeLater(
    new Runnable() {
      @Override
      public void run() {
        indicator.setText(XmlBundle.message("fetching.progress.indicator", resourceUrl));
      }
    }
  );

  FetchResult result = fetchData(project, resourceUrl, indicator);
  if (result == null) return null;

  if(!resultIsValid(project, indicator, resourceUrl, result)) {
    return null;
  }

  int slashIndex = resourceUrl.lastIndexOf('/');
  String resPath = extResourcesPath + File.separatorChar;

  if (refname != null) { // resource is known under ref.name so need to save it
    resPath += refname;
    int refNameSlashIndex = resPath.lastIndexOf('/');
    if (refNameSlashIndex != -1) {
      final File parent = new File(resPath.substring(0, refNameSlashIndex));
      if (!parent.mkdirs() || !parent.exists()) {
        LOG.warn("Unable to create: " + parent);
      }
    }
  }
  else {
    resPath += Integer.toHexString(resourceUrl.hashCode()) + "_" + resourceUrl.substring(slashIndex + 1);
  }

  final int lastDoPosInResourceUrl = resourceUrl.lastIndexOf('.', slashIndex);
  if (lastDoPosInResourceUrl == -1 ||
      FileTypeManager.getInstance().getFileTypeByExtension(resourceUrl.substring(lastDoPosInResourceUrl + 1)) == FileTypes.UNKNOWN) {
    // remote url does not contain file with extension
    final String extension =
      result.contentType != null &&
      result.contentType.contains(HTML_MIME) ? StdFileTypes.HTML.getDefaultExtension() : StdFileTypes.XML.getDefaultExtension();
    resPath += "." + extension;
  }

  File res = new File(resPath);

  FileOutputStream out = new FileOutputStream(res);
  try {
    out.write(result.bytes);
  }
  finally {
    out.close();
  }
  return resPath;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:FetchExtResourceAction.java


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