Skip to content

Commit 6b793fc

Browse files
committed
codacy check & comments added
1 parent d5edcfb commit 6b793fc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.intellij.lang.*;
44
import com.intellij.lexer.Lexer;
55
import com.intellij.openapi.fileTypes.FileType;
6-
import com.intellij.openapi.fileTypes.FileTypeManager;
76
import com.intellij.openapi.fileTypes.FileTypeRegistry;
87
import com.intellij.openapi.project.Project;
98
import com.intellij.openapi.vfs.VirtualFile;
@@ -51,17 +50,23 @@ public static PsiElement createEmptyCsvField(PsiFile psiFile) {
5150
}
5251

5352
public static boolean isCsvFile(String extension) {
53+
if (extension == null) {
54+
return false;
55+
}
56+
// simple check to always in include the defaults even if association was removed
5457
switch(extension.toLowerCase()) {
5558
case "csv":
5659
case "tsv":
5760
case "tab":
5861
case "psv":
5962
return true;
63+
default:
64+
// but also consider other extensions that are associated manually
65+
FileType fileType = FileTypeRegistry.getInstance().getFileTypeByExtension(extension);
66+
return fileType == CsvFileType.INSTANCE ||
67+
fileType == TsvFileType.INSTANCE ||
68+
fileType == PsvFileType.INSTANCE;
6069
}
61-
FileType fileType = FileTypeRegistry.getInstance().getFileTypeByExtension(extension);
62-
return fileType == CsvFileType.INSTANCE ||
63-
fileType == TsvFileType.INSTANCE ||
64-
fileType == PsvFileType.INSTANCE;
6570
}
6671

6772
public static boolean isCsvFile(Project project, VirtualFile file) {

0 commit comments

Comments
 (0)