File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/main/java/net/seesharpsoft/intellij/plugins/csv Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 33import com .intellij .lang .*;
44import com .intellij .lexer .Lexer ;
55import com .intellij .openapi .fileTypes .FileType ;
6- import com .intellij .openapi .fileTypes .FileTypeManager ;
76import com .intellij .openapi .fileTypes .FileTypeRegistry ;
87import com .intellij .openapi .project .Project ;
98import 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 ) {
You can’t perform that action at this time.
0 commit comments