當前位置: 首頁>>代碼示例>>Java>>正文


Java FileType.getDefaultExtension方法代碼示例

本文整理匯總了Java中com.intellij.openapi.fileTypes.FileType.getDefaultExtension方法的典型用法代碼示例。如果您正苦於以下問題:Java FileType.getDefaultExtension方法的具體用法?Java FileType.getDefaultExtension怎麽用?Java FileType.getDefaultExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.fileTypes.FileType的用法示例。


在下文中一共展示了FileType.getDefaultExtension方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureByText

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
public PsiFile configureByText(@NotNull final FileType fileType, @NotNull @NonNls final String text) {
  assertInitialized();
  final String extension = fileType.getDefaultExtension();
  final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
  if (fileTypeManager.getFileTypeByExtension(extension) != fileType) {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(@NotNull Result result) throws Exception {
        fileTypeManager.associateExtension(fileType, extension);
      }
    }.execute();
  }
  final String fileName = "aaa." + extension;
  return configureByText(fileName, text);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:CodeInsightTestFixtureImpl.java

示例2: createPatternTree

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@NotNull
@Override
public PsiElement[] createPatternTree(@NotNull String text,
                                      @NotNull PatternTreeContext context,
                                      @NotNull FileType fileType,
                                      @Nullable Language language,
                                      String contextName, @Nullable String extension,
                                      @NotNull Project project,
                                      boolean physical) {
  final String ext = extension != null ? extension : fileType.getDefaultExtension();
  String text1 = context == PatternTreeContext.File ? text : "<QQQ>" + text + "</QQQ>";
  final PsiFile fileFromText = PsiFileFactory.getInstance(project)
    .createFileFromText("dummy." + ext, fileType, text1, LocalTimeCounter.currentTime(), physical, true);

  final XmlDocument document = HtmlUtil.getRealXmlDocument(((XmlFile)fileFromText).getDocument());
  if (context == PatternTreeContext.File) {
    return new PsiElement[]{document};
  }

  return document.getRootTag().getValue().getChildren();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:XmlStructuralSearchProfile.java

示例3: createPatternTree

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@NotNull
public PsiElement[] createPatternTree(@NotNull String text,
                                      @NotNull PatternTreeContext context,
                                      @NotNull FileType fileType,
                                      @Nullable Language language,
                                      @Nullable String contextName,
                                      @Nullable String extension,
                                      @NotNull Project project,
                                      boolean physical) {
  final String ext = extension != null ? extension : fileType.getDefaultExtension();
  final String name = "__dummy." + ext;
  final PsiFileFactory factory = PsiFileFactory.getInstance(project);

  final PsiFile file = language == null
                       ? factory.createFileFromText(name, fileType, text, LocalTimeCounter.currentTime(), physical, true)
                       : factory.createFileFromText(name, language, text, physical, true);

  return file != null ? file.getChildren() : PsiElement.EMPTY_ARRAY;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:StructuralSearchProfile.java

示例4: remove

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Nonnull
@CheckReturnValue
public static String remove(@Nonnull String fileName, @Nonnull FileType fileType) {
    final String extension = fileType.getDefaultExtension();
    if (fileName.endsWith(DELIMITER + extension)) {
        return fileName.substring(0, fileName.length() - (extension.length() + 1));
    }
    return fileName;
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:10,代碼來源:Extensions.java

示例5: append

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Nonnull
@CheckReturnValue
public static String append(@Nonnull String fileName, @Nonnull FileType fileType) {
    final String extension = fileType.getDefaultExtension();
    if (fileName.endsWith(DELIMITER + extension)) {
        return fileName;
    }
    return fileName + DELIMITER + extension;
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:10,代碼來源:Extensions.java

示例6: getFileName

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@NotNull
public static String getFileName(@Nullable String title, @Nullable String windowTitle, @Nullable FileType fileType) {
  String prefix = "";
  if (title != null && windowTitle != null) {
    prefix = title + "_" + windowTitle;
  }
  else if (title != null || windowTitle != null) {
    prefix = title != null ? title : windowTitle;
  }
  // TODO: keep file name in DiffContent ?
  String ext = fileType != null ? fileType.getDefaultExtension() : "tmp";
  if (prefix.length() > 50) prefix = prefix.substring(0, 50);
  return PathUtil.suggestFileName(prefix + "." + ext, true, false);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:ExternalDiffToolUtil.java

示例7: getNewFileTemplateName

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Nullable
public
String getNewFileTemplateName() {
  FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(myText);
  if (fileType != UnknownFileType.INSTANCE) {
    return fileType.getName() + " File." + fileType.getDefaultExtension();
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:FileReference.java

示例8: chooseExtension

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
private String chooseExtension() {
  DiffContent content = getContent();
  VirtualFile contentFile = content.getFile();
  String extension;
  if (contentFile != null) {
    extension = "." + contentFile.getExtension();
  }
  else {
    FileType contentType = content.getContentType();
    if (contentType == null) contentType = DiffUtil.chooseContentTypes(myRequest.getContents())[myIndex];
    extension = contentType != null ?  "." + contentType.getDefaultExtension() : null;
  }
  return extension;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:ExternalToolContentExternalizer.java

示例9: createFileFragment

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
private static PsiFile createFileFragment(SearchContext searchContext, FileType fileType, Language dialect, String text) {
  final String name = "__dummy." + fileType.getDefaultExtension();
  final PsiFileFactory factory = PsiFileFactory.getInstance(searchContext.getProject());

  return dialect == null ?
         factory.createFileFromText(name, fileType, text, LocalTimeCounter.currentTime(), true, true) :
         factory.createFileFromText(name, dialect, text, true, true);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:StructuralSearchProfile.java

示例10: finished

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
public void finished(@Nullable final FileType fileType) {
  final File localIOFile;

  synchronized (myLock) {
    LOG.debug("Downloading finished, size = " + myLocalFile.length() + ", file type=" + (fileType != null ? fileType.getName() : "null"));
    if (fileType != null) {
      String fileName = myLocalFile.getName();
      int dot = fileName.lastIndexOf('.');
      String extension = fileType.getDefaultExtension();
      if (dot == -1 || !extension.regionMatches(true, 0, fileName, dot + 1, extension.length())) {
        File newFile = FileUtil.findSequentNonexistentFile(myLocalFile.getParentFile(), fileName, extension);
        try {
          FileUtil.rename(myLocalFile, newFile);
          myLocalFile = newFile;
        }
        catch (IOException e) {
          LOG.debug(e);
        }
      }
    }

    localIOFile = myLocalFile;
  }

  VirtualFile localFile = new WriteAction<VirtualFile>() {
    @Override
    protected void run(@NotNull final Result<VirtualFile> result) {
      final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(localIOFile);
      if (file != null) {
        file.refresh(false, false);
      }
      result.setResult(file);
    }
  }.execute().getResultObject();
  LOG.assertTrue(localFile != null, "Virtual local file not found for " + localIOFile.getAbsolutePath());
  LOG.debug("Virtual local file: " + localFile + ", size = " + localFile.getLength());
  synchronized (myLock) {
    myLocalVirtualFile = localFile;
    myPrevLocalFile = null;
    myState = RemoteFileState.DOWNLOADED;
    myErrorMessage = null;
  }
  for (FileDownloadingListener listener : myListeners) {
    listener.fileDownloaded(localFile);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:48,代碼來源:RemoteFileInfoImpl.java

示例11: parsePattern

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
public static PsiElement[] parsePattern(Project project,
                                        String context,
                                        String pattern,
                                        FileType fileType,
                                        Language language,
                                        String extension,
                                        boolean physical) {
  int offset = context.indexOf(PATTERN_PLACEHOLDER);

  final int patternLength = pattern.length();
  final String patternInContext = context.replace(PATTERN_PLACEHOLDER, pattern);

  final String ext = extension != null ? extension : fileType.getDefaultExtension();
  final String name = "__dummy." + ext;
  final PsiFileFactory factory = PsiFileFactory.getInstance(project);

  final PsiFile file = language == null
                       ? factory.createFileFromText(name, fileType, patternInContext, LocalTimeCounter.currentTime(), physical, true)
                       : factory.createFileFromText(name, language, patternInContext, physical, true);
  if (file == null) {
    return PsiElement.EMPTY_ARRAY;
  }

  final List<PsiElement> result = new ArrayList<PsiElement>();

  PsiElement element = file.findElementAt(offset);
  if (element == null) {
    return PsiElement.EMPTY_ARRAY;
  }

  PsiElement topElement = element;
  element = element.getParent();

  while (element != null) {
    if (element.getTextRange().getStartOffset() == offset && element.getTextLength() <= patternLength) {
      topElement = element;
    }
    element = element.getParent();
  }

  if (topElement instanceof PsiFile) {
    return topElement.getChildren();
  }

  final int endOffset = offset + patternLength;
  result.add(topElement);
  topElement = topElement.getNextSibling();

  while (topElement != null && topElement.getTextRange().getEndOffset() <= endOffset) {
    result.add(topElement);
    topElement = topElement.getNextSibling();
  }

  return result.toArray(new PsiElement[result.size()]);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:56,代碼來源:StructuralSearchProfileBase.java

示例12: getFileTypeExtension

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@NonNls
protected
String getFileTypeExtension(FileType fileType) {
  return fileType.getDefaultExtension();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:6,代碼來源:CodeStyleAbstractPanel.java

示例13: getExtractExtension

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@NonNls
protected String getExtractExtension(final FileType extractFileType, final T first) {
  return extractFileType.getDefaultExtension();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:ExtractIncludeFileBase.java

示例14: actionPerformed

import com.intellij.openapi.fileTypes.FileType; //導入方法依賴的package包/類
@Override
public void actionPerformed(final AnActionEvent e) {
  final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
  final Project project = e.getData(CommonDataKeys.PROJECT);

  if (view == null || project == null) {
    return;
  }
  final PsiDirectory taskDir = DirectoryChooserUtil.getOrChooseDirectory(view);
  if (taskDir == null) return;
  PsiDirectory lessonDir = taskDir.getParent();
  if (lessonDir == null) {
    return;
  }
  final CCProjectService service = CCProjectService.getInstance(project);
  final Course course = service.getCourse();
  final Lesson lesson = course.getLesson(lessonDir.getName());
  final Task task = lesson.getTask(taskDir.getName());

  final int index = task.getTaskFiles().size() + 1;
  String generatedName = "file" + index;
  CreateTaskFileDialog dialog = new CreateTaskFileDialog(project, generatedName, course);
  dialog.show();
  if (dialog.getExitCode() != OK_EXIT_CODE) {
    return;
  }
  final String taskFileName = dialog.getFileName();
  if (taskFileName == null) return;
  FileType type = dialog.getFileType();
  if (type == null) {
    return;
  }
  final CCLanguageManager CCLanguageManager = CCUtils.getStudyLanguageManager(course);
  if (CCLanguageManager == null) {
    return;
  }
  final String extension = type.getDefaultExtension();
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      final FileTemplate taskTemplate = CCLanguageManager.getTaskFileTemplateForExtension(project, extension);
      final String answerFileName = taskFileName + ".answer." + extension;
      try {
        if (taskTemplate == null) {
          VirtualFile file = taskDir.getVirtualFile().createChildData(this, answerFileName);
          ProjectView.getInstance(project).select(file, file, false);
          FileEditorManager.getInstance(project).openFile(file, true);
        }
        else {
          final PsiElement taskFile = FileTemplateUtil.createFromTemplate(taskTemplate, answerFileName, null, taskDir);
          ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
              EditorHelper.openInEditor(taskFile, false);
              view.selectElement(taskFile);
            }
          });
        }
        task.addTaskFile(taskFileName + "." + extension, index);
      }
      catch (Exception ignored) {
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:66,代碼來源:CCCreateTaskFile.java


注:本文中的com.intellij.openapi.fileTypes.FileType.getDefaultExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。