package com.reason.bs;

import com.intellij.framework.detection.FileContentPattern;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.patterns.ElementPattern;
import com.intellij.util.indexing.FileContent;
import com.intellij.util.indexing.FileContentImpl;
import com.reason.ide.files.BsConfigJsonFileType;
import org.jetbrains.annotations.NotNull;

public class BsConfigJson {

    private BsConfigJson() {}

    public static boolean isBsConfigJson(@NotNull VirtualFile virtualFile) {
        FileContent fileContent = FileContentImpl.createByFile(virtualFile);
        return createFilePattern().accepts(fileContent);
    }

    public static FileType getFileType() {
        return BsConfigJsonFileType.INSTANCE;
    }

    private static ElementPattern<FileContent> createFilePattern() {
        return FileContentPattern.fileContent()
                .withName(BsConfigJsonFileType.getDefaultFilename());
    }
}

@@ -69,32 +69,71 @@
 ContentPattern;%0A
+import com.intellij.json.JsonFileType;%0A
 import com.intel
@@ -578,24 +578,93 @@
 tualFile) %7B%0A
+        if (virtualFile.getFileType() instanceof JsonFileType) %7B%0A    
         File
@@ -732,24 +732,28 @@
 e);%0A        
+    
 return creat
@@ -789,16 +789,48 @@
 ntent);%0A
+        %7D%0A        return false;%0A
     %7D%0A%0A 

fix exception in BSConfigJson when file is not readable (also in tests)