diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java index 8269d1d6e7e7..b2eac02b3541 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java @@ -58,6 +58,8 @@ public class FileTypeUsagesCollector extends AbstractApplicationUsagesCollector if (project.isDisposed()) { throw new CollectUsagesException("Project is disposed"); } + VirtualFile ideaDir = project.getBaseDir().findChild(Project.DIRECTORY_STORE_FOLDER); + final String ideaDirPath = ideaDir == null ? null : ideaDir.getPath(); ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { @@ -68,14 +70,17 @@ public class FileTypeUsagesCollector extends AbstractApplicationUsagesCollector new FileBasedIndex.ValueProcessor() { @Override public boolean process(VirtualFile file, Void value) { - usedFileTypes.add(fileType); - return false; + //skip files from .idea directory otherwise 99% of projects would have XML and PLAIN_TEXT file types + if (ideaDirPath == null || !file.getPath().startsWith(ideaDirPath)) { + usedFileTypes.add(fileType); + return false; + } + return true; } }, GlobalSearchScope.projectScope(project)); } }); } - usedFileTypes.add(UnknownFileType.INSTANCE); return ContainerUtil.map2Set(usedFileTypes, new NotNullFunction() { @NotNull @Override diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java index 48368840cc44..2f11676d7df7 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java @@ -55,17 +55,17 @@ public class FileTypeUsagesCollectorTest extends LightPlatformCodeInsightFixture } public void testEmptyProject() throws CollectUsagesException { - doTest(Arrays.asList(UnknownFileType.INSTANCE)); + doTest(Arrays.asList()); } public void testSingleFileProject() throws CollectUsagesException { myFixture.configureByText("a.txt", ""); - doTest(Arrays.asList(UnknownFileType.INSTANCE, PlainTextFileType.INSTANCE)); + doTest(Arrays.asList(PlainTextFileType.INSTANCE)); } public void testSeveralSameFilesProject() throws CollectUsagesException { myFixture.configureByText("a.txt", ""); myFixture.configureByText("b.txt", ""); - doTest(Arrays.asList(UnknownFileType.INSTANCE, PlainTextFileType.INSTANCE)); + doTest(Arrays.asList(PlainTextFileType.INSTANCE)); } }