diff --git a/CHANGELOG.md b/CHANGELOG.md index e341ca8..9650f39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ # collections-intellij Changelog ## [Unreleased] +### Fixed +- Ignore foreach to collection in blade files + +## [0.0.1-EAP.7] ### Added - Added closure to arrow function inside collection diff --git a/gradle.properties b/gradle.properties index 49cae89..4d2bb5b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = dev.nybroe.collector pluginName_ = Collector -pluginVersion = 0.0.1-EAP.7 +pluginVersion = 0.0.1-EAP.8 pluginSinceBuild = 193 pluginUntilBuild = @@ -11,7 +11,7 @@ platformType = IU platformVersion = 2020.2.3 platformDownloadSources = true # Get latest version from https://plugins.jetbrains.com/plugin/6610-php/versions -platformPlugins = com.jetbrains.php:202.7660.42 +platformPlugins = com.jetbrains.php:202.7660.42, com.jetbrains.php.blade:202.7319.5 # Opt-out flag for bundling Kotlin standard library. # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. diff --git a/src/main/kotlin/dev/nybroe/collector/blade/BladePhpInspectionSuppressor.kt b/src/main/kotlin/dev/nybroe/collector/blade/BladePhpInspectionSuppressor.kt new file mode 100644 index 0000000..9778962 --- /dev/null +++ b/src/main/kotlin/dev/nybroe/collector/blade/BladePhpInspectionSuppressor.kt @@ -0,0 +1,36 @@ +package dev.nybroe.collector.blade + +import com.intellij.codeInspection.InspectionSuppressor +import com.intellij.codeInspection.SuppressQuickFix +import com.intellij.psi.PsiElement +import com.jetbrains.php.blade.psi.BladePsiDirectiveParameter +import com.jetbrains.php.blade.psi.BladePsiLanguageInjectionHost +import com.jetbrains.php.blade.psi.BladePsiPhpBlock +import com.jetbrains.php.blade.psi.BladeTokenTypes +import dev.nybroe.collector.inspections.ForeachToCollectionInspection + +class BladePhpInspectionSuppressor : InspectionSuppressor { + companion object { + private val SUPPRESSED_PHP_INSPECTIONS = listOf(ForeachToCollectionInspection().id) + } + + override fun isSuppressedFor(element: PsiElement, toolId: String): Boolean { + if (element !is BladePsiLanguageInjectionHost) { + return false + } + + if (element is BladePsiPhpBlock) { + return false + } + + if (element is BladePsiDirectiveParameter && element.directiveElementType === BladeTokenTypes.PHP_DIRECTIVE) { + return false + } + + return SUPPRESSED_PHP_INSPECTIONS.contains(toolId) + } + + override fun getSuppressActions(element: PsiElement?, toolId: String): Array { + return SuppressQuickFix.EMPTY_ARRAY + } +} diff --git a/src/main/resources/META-INF/blade.xml b/src/main/resources/META-INF/blade.xml new file mode 100644 index 0000000..ee3e9a2 --- /dev/null +++ b/src/main/resources/META-INF/blade.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 11c3bff..73e8846 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -2,11 +2,11 @@ dev.nybroe.collector Collector Oliver Nybroe - com.intellij.modules.platform com.jetbrains.php + com.jetbrains.php.blade {{ $item }} +@endforeach \ No newline at end of file