mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FileTypeUsagesCollector: uncoditional UnknownFileType.INSTANCE collection removed, test fixed
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
+3
-3
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user