FileTypeUsagesCollector: uncoditional UnknownFileType.INSTANCE collection removed, test fixed

This commit is contained in:
Ivan Chirkov
2015-10-05 13:40:09 +02:00
parent 27968da496
commit c5d0d148e7
2 changed files with 6 additions and 5 deletions
@@ -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;
}
@@ -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));
}
}