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 a414907b5ec2..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,7 +58,8 @@ public class FileTypeUsagesCollector extends AbstractApplicationUsagesCollector if (project.isDisposed()) { throw new CollectUsagesException("Project is disposed"); } - final String ideaDirPath = project.getBaseDir().findChild(Project.DIRECTORY_STORE_FOLDER).getPath(); + 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() { @@ -70,7 +71,7 @@ public class FileTypeUsagesCollector extends AbstractApplicationUsagesCollector @Override public boolean process(VirtualFile file, Void value) { //skip files from .idea directory otherwise 99% of projects would have XML and PLAIN_TEXT file types - if (!file.getPath().startsWith(ideaDirPath)) { + if (ideaDirPath == null || !file.getPath().startsWith(ideaDirPath)) { usedFileTypes.add(fileType); return false; } 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)); } }