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


Java FileTypeManager類代碼示例

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


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

示例1: projectOpened

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
@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) {

    }
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:20,代碼來源:TSPluginComponent.java

示例2: setupConfigurationFromContext

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
@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;
}
 
開發者ID:jiripudil,項目名稱:intellij-nette-tester,代碼行數:26,代碼來源:TesterTestMethodRunConfigurationProducer.java

示例3: jarModulesOutput

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:PrepareToDeployAction.java

示例4: testDoNotFilterButCopyBigFiles

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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"));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:ResourceFilteringTest.java

示例5: testModuleInIgnoredDir

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:DirectoryIndexTest.java

示例6: testClassUnderIgnoredFolder

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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());
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:FindClassTest.java

示例7: initTest

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
@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);
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:27,代碼來源:BlazeAndroidModelTest.java

示例8: init

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
@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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:ErrorDiffTool.java

示例9: isVersioned

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:IdeaGateway.java

示例10: testFoldingRegions

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:CodeInsightTestFixtureImpl.java

示例11: setUpProject

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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();
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:HeavyIdeaTestFixtureImpl.java

示例12: forIoFile

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
@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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:FileAppearanceServiceImpl.java

示例13: checkInput

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
@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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:NewFolderAction.java

示例14: createMockApplication

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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);
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:22,代碼來源:TestUtils.java

示例15: renderFileName

import com.intellij.openapi.fileTypes.FileTypeManager; //導入依賴的package包/類
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());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:ShelvedChangesViewManager.java


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