diff --git a/src/main/java/com/intellij/aws/cloudformation/CloudFormationFileType.java b/src/main/java/com/intellij/aws/cloudformation/CloudFormationFileType.java index 3caa209..7a14e4c 100644 --- a/src/main/java/com/intellij/aws/cloudformation/CloudFormationFileType.java +++ b/src/main/java/com/intellij/aws/cloudformation/CloudFormationFileType.java @@ -2,16 +2,15 @@ import com.google.common.base.Charsets; import com.intellij.icons.AllIcons; +import com.intellij.json.JsonFileType; import com.intellij.json.JsonLanguage; +import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile; -import com.intellij.openapi.util.io.ByteSequence; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.openapi.vfs.newvfs.FileSystemInterface; import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile; -import com.intellij.util.Processor; import org.apache.commons.lang.ArrayUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,7 +57,12 @@ public Icon getIcon() { @Override public boolean isMyFileType(@NotNull VirtualFile file) { - return CloudFormationFileType.EXTENSION.equalsIgnoreCase(file.getExtension()) && detectFromContent(file); + String extension = file.getExtension(); + + return extension != null && + (FileTypeManager.getInstance().getFileTypeByExtension(extension) == JsonFileType.INSTANCE || + CloudFormationFileType.EXTENSION.equalsIgnoreCase(extension)) && + detectFromContent(file); } private boolean detectFromContent(@NotNull VirtualFile file) { diff --git a/testData/inspections/expected.xml b/testData/inspections/expected.xml index 4766ab7..9842881 100644 --- a/testData/inspections/expected.xml +++ b/testData/inspections/expected.xml @@ -10,6 +10,11 @@ 2 Unknown AWS CloudFormation template version "2010-09-09 + 1". Supported versions: 2010-09-09 + + wrongVersion.json + 2 + Unknown AWS CloudFormation template version "2010-09-09 + 1". Supported versions: 2010-09-09 + noResourceType.template 6 diff --git a/testData/inspections/src/wrongVersion.json b/testData/inspections/src/wrongVersion.json new file mode 100644 index 0000000..9c615db --- /dev/null +++ b/testData/inspections/src/wrongVersion.json @@ -0,0 +1,7 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09 + 1", + "Description": "desc", + + "Resources": { + } +}