generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from olivernybroe/fix-blade
Fix foreach inspection running on blade files
- Loading branch information
Showing
7 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/dev/nybroe/collector/blade/BladePhpInspectionSuppressor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SuppressQuickFix> { | ||
return SuppressQuickFix.EMPTY_ARRAY | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<lang.inspectionSuppressor | ||
language="Blade" | ||
implementationClass="dev.nybroe.collector.blade.BladePhpInspectionSuppressor" | ||
/> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ | |
<id>dev.nybroe.collector</id> | ||
<name>Collector</name> | ||
<vendor email="[email protected]" url="https://nybroe.dev">Oliver Nybroe</vendor> | ||
|
||
<!-- Product and plugin compatibility requirements --> | ||
<!-- https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html --> | ||
<depends>com.intellij.modules.platform</depends> | ||
<depends>com.jetbrains.php</depends> | ||
<depends optional="true" config-file="blade.xml">com.jetbrains.php.blade</depends> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<localInspection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...es/inspections/ForeachToCollectionInspection/nonMatches/foreach-blade-directive.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@foreach ($items as $item) | ||
<li>{{ $item }}</li> | ||
@endforeach |