diff --git a/resources/META-INF/optional-lang-dependencies.xml b/resources/META-INF/optional-lang-dependencies.xml
index 068f5e492..8e243669e 100644
--- a/resources/META-INF/optional-lang-dependencies.xml
+++ b/resources/META-INF/optional-lang-dependencies.xml
@@ -33,7 +33,7 @@
-
+
@@ -51,7 +51,10 @@
+ implementationClass="com.intellij.idea.plugin.hybris.system.manifest.codeInsight.completion.ManifestJsonCompletionProvider"/>
+
+
+
diff --git a/resources/META-INF/plugin-inspections.xml b/resources/META-INF/plugin-inspections.xml
index e73666ab6..93da2dcd3 100644
--- a/resources/META-INF/plugin-inspections.xml
+++ b/resources/META-INF/plugin-inspections.xml
@@ -1,6 +1,12 @@
+
+
+
Feature: Added CCv2 DataHub manifest.json
schema support (#226)
Feature: Added CCv2 Javascript Storefront manifest.json
schema support (#227)
Feature: Added completion of the available extensions for CCv2 SAP Commerce manifest.json
file (#229)
+ Feature: Added extension name validation Inspection for CCv2 SAP Commerce manifest.json
file (#231)
Feature: Added possibility to group by Item parent for Type System preview (#211)
Feature: Added completion and navigation for Index attributes within items.xml
(#207)
Feature: Added completion for meta tags within extensioninfo.xml
(#230)
diff --git a/resources/i18n/HybrisBundle.properties b/resources/i18n/HybrisBundle.properties
index dfff84888..eba9bb02c 100644
--- a/resources/i18n/HybrisBundle.properties
+++ b/resources/i18n/HybrisBundle.properties
@@ -250,6 +250,9 @@ hybris.inspections.ei.EiDuplicateExtensionDefinition.key=[y] Dependency on exten
hybris.inspections.fix.ei.EiDuplicateExtensionDefinition.message=[y] Dependency on ''{0}'' extension is already declared
hybris.inspections.fix.ei.EiUnknownExtensionDefinition.message=[y] Unknown ''{0}'' extension
+hybris.inspections.manifest.ManifestUnknownExtensionInspection.key=[y] Unknown extension
+hybris.inspections.fix.manifest.ManifestUnknownExtensionInspection.message=[y] Unknown ''{0}'' extension
+
hybris.inspections.le.LeUnknownExtensionDefinition.key=[y] Unknown extension
hybris.inspections.fix.le.LeUnknownExtensionDefinition.message=[y] Unknown ''{0}'' extension
diff --git a/resources/inspectionDescriptions/ManifestUnknownExtensionInspection.html b/resources/inspectionDescriptions/ManifestUnknownExtensionInspection.html
new file mode 100644
index 000000000..cd347d67a
--- /dev/null
+++ b/resources/inspectionDescriptions/ManifestUnknownExtensionInspection.html
@@ -0,0 +1,23 @@
+
+
+
+
+This extension is not available. Refresh the project to re-scan available extensions.
+
+
\ No newline at end of file
diff --git a/resources/schemas/manifest-commerce.schema.json b/resources/schemas/manifest-commerce.schema.json
index ef5354708..67cf59fb9 100644
--- a/resources/schemas/manifest-commerce.schema.json
+++ b/resources/schemas/manifest-commerce.schema.json
@@ -160,6 +160,11 @@
"description": "The AddOns installed by the Platform during the build process.",
"items": {
"type": "object",
+ "required": [
+ "addon",
+ "storefront",
+ "template"
+ ],
"additionalProperties": false,
"properties": {
"addon": {
diff --git a/src/com/intellij/idea/plugin/hybris/codeInspection/rule/manifest/ManifestCommerceExtensionInspection.kt b/src/com/intellij/idea/plugin/hybris/codeInspection/rule/manifest/ManifestCommerceExtensionInspection.kt
new file mode 100644
index 000000000..7d02c39d4
--- /dev/null
+++ b/src/com/intellij/idea/plugin/hybris/codeInspection/rule/manifest/ManifestCommerceExtensionInspection.kt
@@ -0,0 +1,62 @@
+/*
+ * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA.
+ * Copyright (C) 2019 EPAM Systems
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.intellij.idea.plugin.hybris.codeInspection.rule.manifest
+
+import com.intellij.codeInspection.LocalInspectionTool
+import com.intellij.codeInspection.LocalInspectionToolSession
+import com.intellij.codeInspection.ProblemsHolder
+import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils
+import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettingsComponent
+import com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers.ManifestCommerceJsonSchemaFileProvider
+import com.intellij.json.psi.*
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiElementVisitor
+import com.intellij.psi.util.parentOfType
+
+class ManifestCommerceExtensionInspection : LocalInspectionTool() {
+
+ override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
+ val file = holder.file
+
+ if (!ManifestCommerceJsonSchemaFileProvider.instance(file.project).isAvailable(file.viewProvider.virtualFile)) return PsiElementVisitor.EMPTY_VISITOR
+
+ return ManifestCommerceVisitor(holder)
+ }
+
+ class ManifestCommerceVisitor(val holder: ProblemsHolder) : JsonElementVisitor() {
+
+ override fun visitStringLiteral(o: JsonStringLiteral) {
+ val parent = o.parent
+ if (isApplicable(parent, o) && !HybrisProjectSettingsComponent.getInstance(o.project).state.completeSetOfAvailableExtensionsInHybris.contains(o.value)) {
+ holder.registerProblem(
+ o,
+ HybrisI18NBundleUtils.message("hybris.inspections.fix.manifest.ManifestUnknownExtensionInspection.message", o.value)
+ )
+ }
+ }
+
+ private fun isApplicable(parent: PsiElement?, o: JsonStringLiteral) =
+ ((parent is JsonArray && o.parentOfType()?.name == "extensions")
+ || (parent is JsonProperty && JsonPsiUtil.isPropertyValue(o) && (parent.name == "addon" || parent.name == "storefront") && parent.parentOfType()?.name == "storefrontAddons")
+ || (parent is JsonProperty && JsonPsiUtil.isPropertyValue(o) && (parent.name == "name") && parent.parentOfType()?.name == "webapps"))
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/intellij/idea/plugin/hybris/system/ccv2/codeInsight/completion/ManifestJsonCompletionProvider.kt b/src/com/intellij/idea/plugin/hybris/system/manifest/codeInsight/completion/ManifestJsonCompletionProvider.kt
similarity index 89%
rename from src/com/intellij/idea/plugin/hybris/system/ccv2/codeInsight/completion/ManifestJsonCompletionProvider.kt
rename to src/com/intellij/idea/plugin/hybris/system/manifest/codeInsight/completion/ManifestJsonCompletionProvider.kt
index be8e8b7bf..75a2925cd 100644
--- a/src/com/intellij/idea/plugin/hybris/system/ccv2/codeInsight/completion/ManifestJsonCompletionProvider.kt
+++ b/src/com/intellij/idea/plugin/hybris/system/manifest/codeInsight/completion/ManifestJsonCompletionProvider.kt
@@ -16,12 +16,12 @@
* along with this program. If not, see .
*/
-package com.intellij.idea.plugin.hybris.system.ccv2.codeInsight.completion
+package com.intellij.idea.plugin.hybris.system.manifest.codeInsight.completion
import com.intellij.codeInsight.completion.CompletionContributor
import com.intellij.codeInsight.completion.CompletionType
import com.intellij.idea.plugin.hybris.codeInsight.completion.provider.ExtensionsNameCompletionProvider
-import com.intellij.idea.plugin.hybris.system.ccv2.psi.ManifestPatterns
+import com.intellij.idea.plugin.hybris.system.manifest.psi.ManifestPatterns
class ManifestJsonCompletionProvider : CompletionContributor() {
diff --git a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/ManifestJsonSchemaProviderFactory.kt b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/ManifestJsonSchemaProviderFactory.kt
similarity index 62%
rename from src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/ManifestJsonSchemaProviderFactory.kt
rename to src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/ManifestJsonSchemaProviderFactory.kt
index 41e6d5ddc..5ba1c25ab 100644
--- a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/ManifestJsonSchemaProviderFactory.kt
+++ b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/ManifestJsonSchemaProviderFactory.kt
@@ -15,20 +15,20 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
-package com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema
+package com.intellij.idea.plugin.hybris.system.manifest.jsonSchema
-import com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema.providers.ManifestCommerceJsonSchemaFileProvider
-import com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema.providers.ManifestDataHubJsonSchemaFileProvider
-import com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema.providers.ManifestJavascriptStorefrontJsonSchemaFileProvider
+import com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers.ManifestCommerceJsonSchemaFileProvider
+import com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers.ManifestDataHubJsonSchemaFileProvider
+import com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers.ManifestJavascriptStorefrontJsonSchemaFileProvider
import com.intellij.openapi.project.Project
import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory
class ManifestJsonSchemaProviderFactory : JsonSchemaProviderFactory {
override fun getProviders(project: Project) = listOf(
- ManifestCommerceJsonSchemaFileProvider(project),
- ManifestDataHubJsonSchemaFileProvider(project),
- ManifestJavascriptStorefrontJsonSchemaFileProvider(project)
+ ManifestCommerceJsonSchemaFileProvider.instance(project),
+ ManifestDataHubJsonSchemaFileProvider.instance(project),
+ ManifestJavascriptStorefrontJsonSchemaFileProvider.instance(project)
)
}
diff --git a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestCommerceJsonSchemaFileProvider.kt b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestCommerceJsonSchemaFileProvider.kt
similarity index 80%
rename from src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestCommerceJsonSchemaFileProvider.kt
rename to src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestCommerceJsonSchemaFileProvider.kt
index a86a5c87a..d08175de4 100644
--- a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestCommerceJsonSchemaFileProvider.kt
+++ b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestCommerceJsonSchemaFileProvider.kt
@@ -1,4 +1,4 @@
-package com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema.providers
+package com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers
import com.intellij.idea.plugin.hybris.common.HybrisConstants
import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettingsComponent
@@ -9,6 +9,7 @@ import com.jetbrains.jsonSchema.extension.JsonSchemaProviderFactory
import com.jetbrains.jsonSchema.extension.SchemaType
class ManifestCommerceJsonSchemaFileProvider(val project: Project) : JsonSchemaFileProvider {
+
override fun isAvailable(file: VirtualFile) = HybrisConstants.CCV2_MANIFEST_NAME == file.name
&& HybrisConstants.CCV2_CORE_CUSTOMIZE_NAME == file.parent.name
&& HybrisProjectSettingsComponent.getInstance(project).state.isHybrisProject
@@ -16,4 +17,8 @@ class ManifestCommerceJsonSchemaFileProvider(val project: Project) : JsonSchemaF
override fun getName() = "SAP Commerce Cloud Manifest"
override fun getSchemaFile() = JsonSchemaProviderFactory.getResourceFile(javaClass, "/schemas/manifest-commerce.schema.json")
override fun getSchemaType() = SchemaType.embeddedSchema
+
+ companion object {
+ fun instance(project: Project): JsonSchemaFileProvider = project.getService(ManifestCommerceJsonSchemaFileProvider::class.java)
+ }
}
\ No newline at end of file
diff --git a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestDataHubJsonSchemaFileProvider.kt b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestDataHubJsonSchemaFileProvider.kt
similarity index 80%
rename from src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestDataHubJsonSchemaFileProvider.kt
rename to src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestDataHubJsonSchemaFileProvider.kt
index db0ecd8b8..80e3e6885 100644
--- a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestDataHubJsonSchemaFileProvider.kt
+++ b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestDataHubJsonSchemaFileProvider.kt
@@ -1,4 +1,4 @@
-package com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema.providers
+package com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers
import com.intellij.idea.plugin.hybris.common.HybrisConstants
import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettingsComponent
@@ -16,4 +16,8 @@ class ManifestDataHubJsonSchemaFileProvider(val project: Project) : JsonSchemaFi
override fun getName() = "DataHub Manifest"
override fun getSchemaFile() = JsonSchemaProviderFactory.getResourceFile(javaClass, "/schemas/manifest-datahub.schema.json")
override fun getSchemaType() = SchemaType.embeddedSchema
+
+ companion object {
+ fun instance(project: Project): JsonSchemaFileProvider = project.getService(ManifestDataHubJsonSchemaFileProvider::class.java)
+ }
}
\ No newline at end of file
diff --git a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestJavascriptStorefrontJsonSchemaFileProvider.kt b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestJavascriptStorefrontJsonSchemaFileProvider.kt
similarity index 80%
rename from src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestJavascriptStorefrontJsonSchemaFileProvider.kt
rename to src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestJavascriptStorefrontJsonSchemaFileProvider.kt
index e491079bb..ff951ea73 100644
--- a/src/com/intellij/idea/plugin/hybris/system/ccv2/jsonSchema/providers/ManifestJavascriptStorefrontJsonSchemaFileProvider.kt
+++ b/src/com/intellij/idea/plugin/hybris/system/manifest/jsonSchema/providers/ManifestJavascriptStorefrontJsonSchemaFileProvider.kt
@@ -1,4 +1,4 @@
-package com.intellij.idea.plugin.hybris.system.ccv2.jsonSchema.providers
+package com.intellij.idea.plugin.hybris.system.manifest.jsonSchema.providers
import com.intellij.idea.plugin.hybris.common.HybrisConstants
import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettingsComponent
@@ -16,4 +16,8 @@ class ManifestJavascriptStorefrontJsonSchemaFileProvider(val project: Project) :
override fun getName() = "Javascript Storefront Manifest"
override fun getSchemaFile() = JsonSchemaProviderFactory.getResourceFile(javaClass, "/schemas/manifest-js-storefront.schema.json")
override fun getSchemaType() = SchemaType.embeddedSchema
+
+ companion object {
+ fun instance(project: Project): JsonSchemaFileProvider = project.getService(ManifestJavascriptStorefrontJsonSchemaFileProvider::class.java)
+ }
}
\ No newline at end of file
diff --git a/src/com/intellij/idea/plugin/hybris/system/ccv2/psi/ManifestPatterns.kt b/src/com/intellij/idea/plugin/hybris/system/manifest/psi/ManifestPatterns.kt
similarity index 94%
rename from src/com/intellij/idea/plugin/hybris/system/ccv2/psi/ManifestPatterns.kt
rename to src/com/intellij/idea/plugin/hybris/system/manifest/psi/ManifestPatterns.kt
index 9271d2f5b..e07c350ab 100644
--- a/src/com/intellij/idea/plugin/hybris/system/ccv2/psi/ManifestPatterns.kt
+++ b/src/com/intellij/idea/plugin/hybris/system/manifest/psi/ManifestPatterns.kt
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package com.intellij.idea.plugin.hybris.system.ccv2.psi
+package com.intellij.idea.plugin.hybris.system.manifest.psi
import com.intellij.json.JsonElementTypes
import com.intellij.json.psi.JsonArray
@@ -31,7 +31,6 @@ object ManifestPatterns {
private inline fun PsiElementPattern<*, *>.withParent() = this.withParent(T::class.java)
- private fun jsonPropertyName() = PlatformPatterns.psiElement(JsonElementTypes.IDENTIFIER)
private fun jsonStringValue() = PlatformPatterns.psiElement(JsonElementTypes.DOUBLE_QUOTED_STRING)
.withParent()