Java 类com.intellij.openapi.fileTypes.FileTypeManager 实例源码

项目:TS-IJ    文件:TSPluginComponent.java   
@Override
public void projectOpened() {
    try {
        WriteAction.run(new ThrowableRunnable<Throwable>() {
            @Override
            public void run() throws Throwable {
                String ignoredFiles = FileTypeManager.getInstance().getIgnoredFilesList();
                if (ignoredFiles.length() == 0) {
                    ignoredFiles = "*.dso";
                } else {
                    ignoredFiles = ignoredFiles + ";*.dso";
                }
                FileTypeManager.getInstance().setIgnoredFilesList(ignoredFiles);
            }
        });
    } catch (Throwable ignored) {

    }
}
项目:intellij-nette-tester    文件:TesterTestMethodRunConfigurationProducer.java   
@Override
protected boolean setupConfigurationFromContext(TesterTestMethodRunConfiguration runConfiguration, ConfigurationContext context, Ref<PsiElement> ref) {
    PsiElement element = context.getPsiLocation();
    Method method = PhpPsiUtil.getParentByCondition(element, parent -> parent instanceof Method);

    if (method != null && isValid(method)) {
        VirtualFile file = method.getContainingFile().getVirtualFile();
        ref.set(method);

        if (!FileTypeManager.getInstance().isFileOfType(file, ScratchFileType.INSTANCE)) {
            VirtualFile root = ProjectRootManager.getInstance(element.getProject()).getFileIndex().getContentRootForFile(file);
            if (root == null) {
                return false;
            }
        }

        PhpScriptRunConfiguration.Settings settings = runConfiguration.getSettings();
        settings.setPath(file.getPresentableUrl());
        runConfiguration.setMethod(method);
        runConfiguration.setName(runConfiguration.suggestedName());
        return true;
    }

    return false;
}
项目:intellij-ce-playground    文件:PrepareToDeployAction.java   
private static File jarModulesOutput(@NotNull Set<Module> modules, @Nullable Manifest manifest, final @Nullable String pluginXmlPath) throws IOException {
  File jarFile = FileUtil.createTempFile(TEMP_PREFIX, JAR_EXTENSION);
  jarFile.deleteOnExit();
  ZipOutputStream jarPlugin = null;
  try {
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(jarFile));
    jarPlugin = manifest != null ? new JarOutputStream(out, manifest) : new JarOutputStream(out);
    final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
    final Set<String> writtenItemRelativePaths = new HashSet<String>();
    for (Module module : modules) {
      final VirtualFile compilerOutputPath = CompilerModuleExtension.getInstance(module).getCompilerOutputPath();
      if (compilerOutputPath == null) continue; //pre-condition: output dirs for all modules are up-to-date
      ZipUtil.addDirToZipRecursively(jarPlugin, jarFile, new File(compilerOutputPath.getPath()), "",
                                     createFilter(progressIndicator, FileTypeManager.getInstance()), writtenItemRelativePaths);
    }
    if (pluginXmlPath != null) {
      ZipUtil.addFileToZip(jarPlugin, new File(pluginXmlPath), "/META-INF/plugin.xml", writtenItemRelativePaths,
                           createFilter(progressIndicator, null));
    }
  }
  finally {
    if (jarPlugin != null) jarPlugin.close();
  }
  return jarFile;
}
项目:intellij-ce-playground    文件:ResourceFilteringTest.java   
public void testDoNotFilterButCopyBigFiles() throws Exception {
  assertEquals(FileTypeManager.getInstance().getFileTypeByFileName("file.xyz"), FileTypes.UNKNOWN);

  new WriteAction() {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]);
    }
  }.execute().throwException();

  importProject("<groupId>test</groupId>" +
                "<artifactId>project</artifactId>" +
                "<version>1</version>" +

                "<build>" +
                "  <resources>" +
                "    <resource>" +
                "      <directory>resources</directory>" +
                "      <filtering>true</filtering>" +
                "    </resource>" +
                "  </resources>" +
                "</build>");
  compileModules("project");

  assertNotNull(myProjectPom.getParent().findFileByRelativePath("target/classes/file.xyz"));
}
项目:intellij-ce-playground    文件:DirectoryIndexTest.java   
public void testModuleInIgnoredDir() throws IOException {
  final VirtualFile ignored = createChildDirectory(myRootVFile, "RCS");
  assertTrue(FileTypeManager.getInstance().isFileIgnored(ignored));

  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      ModuleManager moduleManager = ModuleManager.getInstance(myProject);
      ModifiableModuleModel model = moduleManager.getModifiableModel();
      model.disposeModule(myModule);
      model.disposeModule(myModule2);
      model.disposeModule(myModule3);
      model.commit();
      Module module = moduleManager.newModule(myRootVFile.getPath() + "/newModule.iml", StdModuleTypes.JAVA.getId());
      PsiTestUtil.addContentRoot(module, ignored);
      checkInfo(ignored, module, false, false, null, null);
    }
  }.execute().throwException();
}
项目:intellij-ce-playground    文件:FindClassTest.java   
public void testClassUnderIgnoredFolder() {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      PsiClass psiClass = myJavaFacade.findClass("p.A", GlobalSearchScope.allScope(myProject));
      assertEquals("p.A", psiClass.getQualifiedName());

      assertTrue(psiClass.isValid());

      FileTypeManager fileTypeManager = FileTypeManager.getInstance();
      String ignoredFilesList = fileTypeManager.getIgnoredFilesList();
      fileTypeManager.setIgnoredFilesList(ignoredFilesList + ";p");
      try {
        assertFalse(psiClass.isValid());
      }
      finally {
        fileTypeManager.setIgnoredFilesList(ignoredFilesList);
      }

      psiClass = myJavaFacade.findClass("p.A");
      assertTrue(psiClass.isValid());
    }
  });
}
项目:intellij    文件:BlazeAndroidModelTest.java   
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  applicationServices.register(FileTypeManager.class, new MockFileTypeManager());
  applicationServices.register(
      FileDocumentManager.class, new MockFileDocumentManagerImpl(null, null));
  applicationServices.register(VirtualFileManager.class, mock(VirtualFileManager.class));
  applicationServices.register(BlazeBuildService.class, new BlazeBuildService());
  projectServices.register(ProjectScopeBuilder.class, new ProjectScopeBuilderImpl(project));
  projectServices.register(ProjectViewManager.class, new MockProjectViewManager());
  projectServices.register(
      BlazeProjectDataManager.class, new BlazeProjectDataManagerImpl(project));

  BlazeImportSettingsManager manager = new BlazeImportSettingsManager();
  manager.setImportSettings(new BlazeImportSettings("", "", "", "", BuildSystem.Blaze));
  projectServices.register(BlazeImportSettingsManager.class, manager);

  facade =
      new MockJavaPsiFacade(
          project,
          new MockPsiManager(project),
          ImmutableList.of("com.google.example.Modified", "com.google.example.NotModified"));

  projectServices.register(JavaPsiFacade.class, facade);
  module = new MockModule(() -> {});
  model = new BlazeAndroidModel(project, module, null, mock(SourceProvider.class), null, "", 0);
}
项目:intellij-ce-playground    文件:ErrorDiffTool.java   
@NotNull
@Override
public ToolbarComponents init() {
  if (myRequest instanceof UnknownFileTypeDiffRequest) {
    String fileName = ((UnknownFileTypeDiffRequest)myRequest).getFileName();
    if (fileName != null && FileTypeManager.getInstance().getFileTypeByFileName(fileName) != UnknownFileType.INSTANCE) {
      // FileType was assigned elsewhere (ex: by other UnknownFileTypeDiffRequest). We should reload request.
      if (myContext instanceof DiffContextEx) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            ((DiffContextEx)myContext).reloadDiffRequest();
          }
        }, ModalityState.current());
      }
    }
  }

  return new ToolbarComponents();
}
项目:intellij-ce-playground    文件:IdeaGateway.java   
public boolean isVersioned(@NotNull VirtualFile f, boolean shouldBeInContent) {
  if (!f.isInLocalFileSystem()) return false;

  if (!f.isDirectory() && StringUtil.endsWith(f.getNameSequence(), ".class")) return false;

  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
  boolean isInContent = false;
  for (Project each : openProjects) {
    if (each.isDefault()) continue;
    if (!each.isInitialized()) continue;
    if (Comparing.equal(each.getWorkspaceFile(), f)) return false;
    ProjectFileIndex index = ProjectRootManager.getInstance(each).getFileIndex();

    if (index.isExcluded(f)) return false;
    isInContent |= index.isInContent(f);
  }
  if (shouldBeInContent && !isInContent) return false;

  // optimisation: FileTypeManager.isFileIgnored(f) already checked inside ProjectFileIndex.isIgnored()
  return openProjects.length != 0 || !FileTypeManager.getInstance().isFileIgnored(f);
}
项目:intellij-ce-playground    文件:CodeInsightTestFixtureImpl.java   
private void testFoldingRegions(@NotNull String verificationFileName, boolean doCheckCollapseStatus) {
  String expectedContent;
  try {
    expectedContent = FileUtil.loadFile(new File(verificationFileName));
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
  Assert.assertNotNull(expectedContent);

  expectedContent = StringUtil.replace(expectedContent, "\r", "");
  final String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, "");

  configureByText(FileTypeManager.getInstance().getFileTypeByFileName(verificationFileName), cleanContent);
  final String actual = getFoldingDescription(doCheckCollapseStatus);

  Assert.assertEquals(expectedContent, actual);
}
项目:intellij-ce-playground    文件:HeavyIdeaTestFixtureImpl.java   
private void setUpProject() throws IOException {
  File tempDirectory = FileUtil.createTempDirectory(myName, "");
  PlatformTestCase.synchronizeTempDirVfs(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory));
  myFilesToDelete.add(tempDirectory);

  String projectPath = FileUtil.toSystemIndependentName(tempDirectory.getPath()) + "/" + myName + ProjectFileType.DOT_DEFAULT_EXTENSION;
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  new Throwable(projectPath).printStackTrace(new PrintStream(buffer));
  myProject = PlatformTestCase.createProject(projectPath, buffer.toString());

  EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
    @SuppressWarnings("TestOnlyProblems")
    @Override
    public void run() throws Throwable {
      ProjectManagerEx.getInstanceEx().openTestProject(myProject);

      for (ModuleFixtureBuilder moduleFixtureBuilder : myModuleFixtureBuilders) {
        moduleFixtureBuilder.getFixture().setUp();
      }

      LightPlatformTestCase.clearUncommittedDocuments(myProject);
      ((FileTypeManagerImpl)FileTypeManager.getInstance()).drainReDetectQueue();
    }
  });
}
项目:intellij-ce-playground    文件:FileAppearanceServiceImpl.java   
@NotNull
@Override
public CellAppearanceEx forIoFile(@NotNull final File file) {
  final String absolutePath = file.getAbsolutePath();
  if (!file.exists()) {
    return forInvalidUrl(absolutePath);
  }

  if (file.isDirectory()) {
    return SimpleTextCellAppearance.regular(absolutePath, PlatformIcons.FOLDER_ICON);
  }

  final String name = file.getName();
  final FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(name);
  final File parent = file.getParentFile();
  final CompositeAppearance appearance = CompositeAppearance.textComment(name, parent.getAbsolutePath());
  appearance.setIcon(fileType.getIcon());
  return appearance;
}
项目:intellij-ce-playground    文件:NewFolderAction.java   
@Override
public boolean checkInput(String inputString) {
  boolean firstToken = true;
  for (String token : StringUtil.tokenize(inputString, "\\/")) {
    if (firstToken) {
      final VirtualFile child = myDirectory.findChild(token);
      if (child != null) {
        myErrorText = "A " + (child.isDirectory() ? "folder" : "file") +
                      " with name '" + token + "' already exists";
        return false;
      }
    }
    firstToken = false;
    if (token.equals(".") || token.equals("..")) {
      myErrorText = "Can't create a folder with name '" + token + "'";
      return false;
    }
    if (FileTypeManager.getInstance().isFileIgnored(token)) {
      myErrorText = "Trying to create a folder with an ignored name, the result will not be visible";
      return true;
    }
  }
  myErrorText = null;
  return !inputString.isEmpty();
}
项目:intellij    文件:TestUtils.java   
public static void createMockApplication(Disposable parentDisposable) {
  final BlazeMockApplication instance = new BlazeMockApplication(parentDisposable);

  // If there was no previous application,
  // ApplicationManager leaves the MockApplication in place, which can break future tests.
  Application oldApplication = ApplicationManager.getApplication();
  if (oldApplication == null) {
    Disposer.register(
        parentDisposable,
        () -> {
          new ApplicationManager() {
            {
              ourApplication = null;
            }
          };
        });
  }

  ApplicationManager.setApplication(instance, FileTypeManager::getInstance, parentDisposable);
  instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
}
项目:intellij-ce-playground    文件:ShelvedChangesViewManager.java   
private void renderFileName(String path, final FileStatus fileStatus, final String movedMessage) {
  path = path.replace('/', File.separatorChar);
  int pos = path.lastIndexOf(File.separatorChar);
  String fileName;
  String directory;
  if (pos >= 0) {
    directory = path.substring(0, pos).replace(File.separatorChar, File.separatorChar);
    fileName = path.substring(pos+1);
  }
  else {
    directory = "<project root>";
    fileName = path;
  }
  append(fileName, new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, fileStatus.getColor()));
  if (movedMessage != null) {
    append(movedMessage, SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
  append(spaceAndThinSpace() + directory, SimpleTextAttributes.GRAYED_ATTRIBUTES);
  setIcon(FileTypeManager.getInstance().getFileTypeByFileName(fileName).getIcon());
}
项目:intellij    文件:ExternalFileProjectManagementHelper.java   
/** Whether the editor notification should be shown for this file type. */
private static boolean supportedFileType(File file) {
  LanguageClass languageClass =
      LanguageClass.fromExtension(FileUtilRt.getExtension(file.getName()).toLowerCase());
  if (languageClass != null && !supportedLanguage(languageClass)) {
    return false;
  }
  FileType type = FileTypeManager.getInstance().getFileTypeByFileName(file.getName());

  for (Class<? extends FileType> clazz : IGNORED_FILE_TYPES) {
    if (clazz.isInstance(type)) {
      return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:FilePathCompletionContributor.java   
private static boolean filenameMatchesPrefixOrType(final String fileName, final String prefix, final FileType[] suitableFileTypes, final int invocationCount) {
  final boolean prefixMatched = prefix.length() == 0 || StringUtil.startsWithIgnoreCase(fileName, prefix);
  if (prefixMatched && (suitableFileTypes.length == 0 || invocationCount > 2)) return true;

  if (prefixMatched) {
    final String extension = FileUtilRt.getExtension(fileName);
    if (extension.length() == 0) return false;

    for (final FileType fileType : suitableFileTypes) {
      for (final FileNameMatcher matcher : FileTypeManager.getInstance().getAssociations(fileType)) {
        if (FileNameMatcherEx.acceptsCharSequence(matcher, fileName)) return true;
      }
    }
  }

  return false;
}
项目:intellij-ce-playground    文件:PsiVFSListener.java   
public PsiVFSListener(Project project) {
  myProject = project;
  myFileTypeManager = FileTypeManager.getInstance();
  myProjectRootManager = ProjectRootManager.getInstance(project);
  myManager = (PsiManagerImpl) PsiManager.getInstance(project);
  myFileManager = (FileManagerImpl) myManager.getFileManager();

  myConnection = project.getMessageBus().connect(project);

  StartupManager.getInstance(project).registerPreStartupActivity(new Runnable() {
    @Override
    public void run() {
      myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
      myConnection.subscribe(FileTypeManager.TOPIC, new FileTypeListener.Adapter() {
        @Override
        public void fileTypesChanged(@NotNull FileTypeEvent e) {
          myFileManager.processFileTypesChanged();
        }
      });
      myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter());
      myFileManager.markInitialized();
    }
  });
}
项目:intellij-ce-playground    文件:AssociateFileTypeAction.java   
@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);
}
项目:intellij-ce-playground    文件:DefaultCreateFromTemplateHandler.java   
@NotNull
@Override
public PsiElement createFromTemplate(final Project project, final PsiDirectory directory, String fileName, final FileTemplate template,
                                     final String templateText,
                                     @NotNull final Map<String, Object> props) throws IncorrectOperationException {
  fileName = checkAppendExtension(fileName, template);

  if (FileTypeManager.getInstance().isFileIgnored(fileName)) {
    throw new IncorrectOperationException("This filename is ignored (Settings | Editor | File Types | Ignore files and folders)");
  }

  directory.checkCreateFile(fileName);
  FileType type = FileTypeRegistry.getInstance().getFileTypeByFileName(fileName);
  PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(fileName, type, templateText);

  if (template.isReformatCode()) {
    CodeStyleManager.getInstance(project).reformat(file);
  }

  file = (PsiFile)directory.add(file);
  return file;
}
项目:intellij-ce-playground    文件:RepositoryBrowserComponent.java   
@Nullable
public VirtualFile getSelectedVcsFile() {
  final RepositoryTreeNode node = getSelectedNode();
  if (node == null) return null;

  DirectoryEntry entry = node.getSVNDirEntry();
  if (entry == null || !entry.isFile()) {
    return null;
  }

  String name = entry.getName();
  FileTypeManager manager = FileTypeManager.getInstance();

  if (entry.getName().lastIndexOf('.') > 0 && !manager.getFileTypeByFileName(name).isBinary()) {
    SVNURL url = node.getURL();
    final SvnFileRevision revision = new SvnFileRevision(myVCS, SVNRevision.UNDEFINED, SVNRevision.HEAD, url.toString(),
            entry.getAuthor(), entry.getDate(), null, null);

    return new VcsVirtualFile(node.getSVNDirEntry().getName(), revision, VcsFileSystem.getInstance());
  } else {
    return null;
  }
}
项目:intellij-ce-playground    文件:CreateTaskFileDialog.java   
@SuppressWarnings("unchecked")
public CreateTaskFileDialog(@Nullable Project project, String generatedFileName, @NotNull final Course course) {
  super(project);
  myCourse = course;
  FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();

  DefaultListModel model = new DefaultListModel();
  for (FileType type : fileTypes) {
    if (!type.isReadOnly() && !type.getDefaultExtension().isEmpty()) {
      model.addElement(type);
    }
  }
  myList.setModel(model);
  myTextField.setText(generatedFileName);
  setTitle("Create New Task File");
  init();
}
项目:intellij-ce-playground    文件:CreateTaskFileDialog.java   
@Nullable
@Override
protected JComponent createCenterPanel() {
  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.setCellRenderer(new FileTypeRenderer());

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myList);

  CCLanguageManager manager = CCUtils.getStudyLanguageManager(myCourse);
  if (manager != null) {
    String extension = manager.getDefaultTaskFileExtension();
    ScrollingUtil.selectItem(myList, FileTypeManager.getInstance().getFileTypeByExtension(extension != null ? extension : "txt"));
  }
  return myPanel;
}
项目:intellij-ce-playground    文件:AbstractLanguageInjectionSupport.java   
public static AnAction createDefaultAddAction(final Project project,
                                              final Consumer<BaseInjection> consumer,
                                              final AbstractLanguageInjectionSupport support) {
  final String supportTitle = StringUtil.capitalize(support.getId());
  Icon icon = FileTypeManager.getInstance().getFileTypeByExtension(support.getId()).getIcon();
  return new AnAction("Generic "+ supportTitle, null, icon) {
    @Override
    public void actionPerformed(AnActionEvent e) {
      final BaseInjection injection = new BaseInjection(support.getId());
      injection.setDisplayName("New "+ supportTitle +" Injection");
      final BaseInjection newInjection = showDefaultInjectionUI(project, injection);
      if (newInjection != null) {
        consumer.consume(injection);
      }
    }
  };
}
项目:intellij-ce-playground    文件:ThumbnailViewUI.java   
private Set<VirtualFile> findFiles(VirtualFile file) {
    Set<VirtualFile> files = new HashSet<VirtualFile>(0);
    Project project = thumbnailView.getProject();
    if (!project.isDisposed()) {
        ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
        boolean projectIgnored = rootManager.getFileIndex().isExcluded(file);

        if (!projectIgnored && !FileTypeManager.getInstance().isFileIgnored(file)) {
            ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
            if (file.isDirectory()) {
                if (thumbnailView.isRecursive()) {
                    files.addAll(findFiles(file.getChildren()));
                } else if (isImagesInDirectory(file)) {
                    files.add(file);
                }
            } else if (typeManager.isImage(file)) {
                files.add(file);
            }
        }
    }
    return files;
}
项目:intellij-ce-playground    文件:PrepareToDeployAction.java   
private static void makeAndAddLibraryJar(final VirtualFile virtualFile,
                                         final File zipFile,
                                         final String pluginName,
                                         final ZipOutputStream zos,
                                         final Set<String> usedJarNames,
                                         final ProgressIndicator progressIndicator,
                                         final String preferredName) throws IOException {
  File libraryJar = FileUtil.createTempFile(TEMP_PREFIX, JAR_EXTENSION);
  libraryJar.deleteOnExit();
  ZipOutputStream jar = null;
  try {
    jar = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(libraryJar)));
    ZipUtil.addFileOrDirRecursively(jar, libraryJar, VfsUtilCore.virtualToIoFile(virtualFile), "",
                                    createFilter(progressIndicator, FileTypeManager.getInstance()), null);
  }
  finally {
    if (jar != null) jar.close();
  }
  final String jarName =
    getLibraryJarName(virtualFile.getName() + JAR_EXTENSION, usedJarNames, preferredName == null ? null : preferredName + JAR_EXTENSION);
  ZipUtil.addFileOrDirRecursively(zos, zipFile, libraryJar, getZipPath(pluginName, jarName), createFilter(progressIndicator, null), null);
}
项目:CodeGenerate    文件:TemplateEditPane.java   
private void addVmEditor(String template) {
    EditorFactory factory = EditorFactory.getInstance();
    Document velocityTemplate = factory.createDocument(template);
    editor = factory.createEditor(velocityTemplate, null, FileTypeManager.getInstance()
        .getFileTypeByExtension("vm"), false);
    GridConstraints constraints = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST,
        GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
        GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(300, 300), null, 0, true);
    editorPane.add(editor.getComponent(), constraints);
}
项目:SmartQQ4IntelliJ    文件:VFSUtils.java   
private static FileType getArchiveFileType() {
    FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(".zip");
    if (fileType == FileTypeManager.getInstance().getFileTypeByExtension(".kokoko")) {
        fileType = FileTypeManager.getInstance().getFileTypeByExtension("zip");
    }
    return fileType;
}
项目:idea-php-typo3-plugin    文件:TranslationIndexTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();

    WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
        FileTypeManager.getInstance().associateExtension(XmlFileType.INSTANCE, "xlf");
    });

    myFixture.addFileToProject("typo3conf/ext/foo/ext_emconf.php", "");

    myFixture.copyFileToProject("sample.xlf", "typo3conf/ext/foo/sample.xlf");
    myFixture.copyFileToProject("de.sample.xlf", "typo3conf/ext/foo/de.sample.xlf");
}
项目:idea-php-typo3-plugin    文件:TranslationReferenceProviderTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();

    WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
        FileTypeManager.getInstance().associateExtension(XmlFileType.INSTANCE, "xlf");
    });

    myFixture.addFileToProject("typo3conf/ext/foo/ext_emconf.php", "");

    myFixture.copyFileToProject("sample.xlf", "typo3conf/ext/foo/sample.xlf");
    myFixture.copyFileToProject("de.sample.xlf", "typo3conf/ext/foo/de.sample.xlf");
}
项目:idea-php-typo3-plugin    文件:TranslationReferenceTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();

    WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
        FileTypeManager.getInstance().associateExtension(XmlFileType.INSTANCE, "xlf");
    });

    myFixture.addFileToProject("typo3conf/ext/foo/ext_emconf.php", "");

    myFixture.copyFileToProject("sample.xlf", "typo3conf/ext/foo/sample.xlf");
    myFixture.copyFileToProject("de.sample.xlf", "typo3conf/ext/foo/de.sample.xlf");
}
项目:idea-php-typo3-plugin    文件:TranslationUtilTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();

    WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
        FileTypeManager.getInstance().associateExtension(XmlFileType.INSTANCE, "xlf");
    });

    myFixture.addFileToProject("typo3conf/ext/foo/ext_emconf.php", "");

    myFixture.copyFileToProject("sample.xlf", "typo3conf/ext/foo/sample.xlf");
    myFixture.copyFileToProject("de.sample.xlf", "typo3conf/ext/foo/de.sample.xlf");
}
项目:educational-plugin    文件:PyStudyInitialConfigurator.java   
/**
 * @noinspection UnusedParameters
 */
public PyStudyInitialConfigurator(MessageBus bus,
                                  CodeInsightSettings codeInsightSettings,
                                  final PropertiesComponent propertiesComponent,
                                  FileTypeManager fileTypeManager,
                                  final ProjectManagerEx projectManager) {
  if (!propertiesComponent.getBoolean(CONFIGURED_V40)) {
    final File courses = new File(PathManager.getConfigPath(), "courses");
    FileUtil.delete(courses);
    propertiesComponent.setValue(CONFIGURED_V40, "true");
  }
}
项目:CodeGen    文件:TemplateEditorUI.java   
/**
 * 创建编辑器
 *
 * @param template
 * @param extension
 * @return
 */
private Editor createEditor(String template, String extension) {
    template = StringUtils.isEmpty(template) ? "" : template;
    extension = StringUtils.isEmpty(extension) ? "vm" : extension;

    Document velocityTemplate = factory.createDocument(template);
    Editor editor = factory.createEditor(velocityTemplate, null, FileTypeManager.getInstance()
            .getFileTypeByExtension(extension), false);

    EditorSettings editorSettings = editor.getSettings();
    editorSettings.setLineNumbersShown(true);
    return editor;
}
项目:GravSupport    文件:FileCreateUtil.java   
public static List<VirtualFile> findFileByRelativePath(@NotNull Project project, @NotNull String fileRelativePath) {
    String relativePath = fileRelativePath.startsWith("/") ? fileRelativePath : "/" + fileRelativePath;
    Set<FileType> fileTypes = Collections.singleton(FileTypeManager.getInstance().getFileTypeByFileName(relativePath));
    final List<VirtualFile> fileList = new ArrayList<>();
    FileBasedIndex.getInstance().processFilesContainingAllKeys(FileTypeIndex.NAME, fileTypes, GlobalSearchScope.projectScope(project), null, virtualFile -> {
        if (virtualFile.getPath().endsWith(relativePath)) {
            fileList.add(virtualFile);
        }
        return true;
    });
    return fileList;
}
项目:lua-for-idea    文件:LuaCodeFragment.java   
public LuaCodeFragment(Project project,
                           IElementType contentElementType,
                           boolean isPhysical,
                           @NonNls String name,
                           CharSequence text,
                           @Nullable PsiElement context) {
    super(TokenType.CODE_FRAGMENT,
            contentElementType,
            PsiManagerEx.getInstanceEx(project).getFileManager().createFileViewProvider(
                    new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical)
    );
    setContext(context);
    ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this);
}
项目:lua-for-idea    文件:TestUtils.java   
public static PsiFile createPseudoPhysicalFile(final Project project,
                                               final String fileName,
                                               final String text) throws IncorrectOperationException {
  return PsiFileFactory.getInstance(project)
      .createFileFromText(fileName, FileTypeManager.getInstance().getFileTypeByFileName(fileName), text,
          LocalTimeCounter.currentTime(), true);
}
项目:intellij-ce-playground    文件:FileIndexUtil.java   
public static boolean isJavaSourceFile(@NotNull Project project, @NotNull VirtualFile file) {
  FileTypeManager fileTypeManager = FileTypeManager.getInstance();
  if (file.isDirectory() || file.getFileType() != StdFileTypes.JAVA || fileTypeManager.isFileIgnored(file)) {
    return false;
  }
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  return fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || fileIndex.isInLibrarySource(file);
}
项目:intellij-ce-playground    文件:PsiCodeFragmentImpl.java   
public PsiCodeFragmentImpl(Project project,
                           IElementType contentElementType,
                           boolean isPhysical,
                           @NonNls String name,
                           CharSequence text,
                           @Nullable PsiElement context) {
  super(TokenType.CODE_FRAGMENT,
        contentElementType,
        ((PsiManagerEx)PsiManager.getInstance(project)).getFileManager().createFileViewProvider(
          new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical)
  );
  myContext = context;
  ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this);
  myPhysical = isPhysical;
}
项目:intellij-ce-playground    文件:PsiJavaDirectoryImpl.java   
@Override
public void checkCreateFile(@NotNull final String name) throws IncorrectOperationException {
  final FileType type = FileTypeManager.getInstance().getFileTypeByFileName(name);
  if (type == StdFileTypes.CLASS) {
    throw new IncorrectOperationException("Cannot create class-file");
  }

  super.checkCreateFile(name);
}