Skip to content

Commit e82609b

Browse files
authored
Merge pull request #330 from cedricziel/ns-suppressor
2 parents 8ae6d94 + 99a9321 commit e82609b

File tree

5 files changed

+73
-2
lines changed

5 files changed

+73
-2
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ buildscript {
1212
}
1313

1414
plugins {
15-
id "org.jetbrains.intellij" version "0.4.21"
15+
id "org.jetbrains.intellij" version "0.4.26"
1616
id "org.jetbrains.grammarkit" version "${grammarKitPluginVersion}"
17-
id 'com.palantir.git-version' version "0.11.0"
17+
id 'com.palantir.git-version' version "0.12.3"
1818
}
1919

2020
def details = versionDetails()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.cedricziel.idea.typo3.codeInspection;
2+
3+
import com.intellij.codeInspection.InspectionSuppressor;
4+
import com.intellij.codeInspection.SuppressQuickFix;
5+
import com.intellij.lang.xml.XMLLanguage;
6+
import com.intellij.psi.PsiElement;
7+
import com.intellij.psi.xml.XmlAttribute;
8+
import org.jetbrains.annotations.NotNull;
9+
import org.jetbrains.annotations.Nullable;
10+
11+
public class XmlUnusedNamespaceDeclarationSuppressor implements InspectionSuppressor {
12+
@Override
13+
public boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String toolId) {
14+
if (!(element.getLanguage() instanceof XMLLanguage)) {
15+
return false;
16+
}
17+
18+
if (!toolId.equals("XmlUnusedNamespaceDeclaration")) {
19+
return false;
20+
}
21+
22+
if (!(element instanceof XmlAttribute)) {
23+
return false;
24+
}
25+
26+
String namespace = ((XmlAttribute) element).getValue();
27+
28+
return namespace != null && namespace.contains("typo3.org/ns");
29+
}
30+
31+
@NotNull
32+
@Override
33+
public SuppressQuickFix[] getSuppressActions(@Nullable PsiElement element, @NotNull String toolId) {
34+
return SuppressQuickFix.EMPTY_ARRAY;
35+
}
36+
}

typo3-cms/src/main/resources/META-INF/plugin.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@
186186
<!-- FlexForms -->
187187
<completion.contributor language="XML"
188188
implementationClass="com.cedricziel.idea.typo3.flexform.FlexFormCompletionContributionProvider"/>
189+
190+
<!-- Fluid -->
191+
<lang.inspectionSuppressor language="XML"
192+
implementationClass="com.cedricziel.idea.typo3.codeInspection.XmlUnusedNamespaceDeclarationSuppressor"/>
193+
<lang.inspectionSuppressor language="HTML"
194+
implementationClass="com.cedricziel.idea.typo3.codeInspection.XmlUnusedNamespaceDeclarationSuppressor"/>
195+
<lang.inspectionSuppressor language="XHTML"
196+
implementationClass="com.cedricziel.idea.typo3.codeInspection.XmlUnusedNamespaceDeclarationSuppressor"/>
189197
</extensions>
190198

191199
<actions>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.cedricziel.idea.typo3.codeInspection;
2+
3+
import com.cedricziel.idea.typo3.AbstractTestCase;
4+
import com.intellij.codeInsight.daemon.impl.analysis.XmlUnusedNamespaceInspection;
5+
6+
public class XmlUnusedNamespaceDeclarationSuppressorTest extends AbstractTestCase {
7+
@Override
8+
protected String getTestDataPath() {
9+
return super.getTestDataPath() + "/codeInspection";
10+
}
11+
12+
public void testUnusedNamespacesInspectionIsSuppressed() {
13+
myFixture.enableInspections(new XmlUnusedNamespaceInspection());
14+
15+
myFixture.testHighlighting("unused_namespace.html");
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:v="<warning descr="URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)">http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers</warning>"
3+
xmlns:f="<warning descr="URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)">http://typo3.org/ns/TYPO3/Fluid/ViewHelpers</warning>"
4+
xmlns:flux="<warning descr="URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)">http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers</warning>"
5+
xmlns:yp="<warning descr="URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)">http://typo3.org/ns/Vendor/YourPlugin/ViewHelpers</warning>"
6+
7+
flux:schemaLocation="http://fluidtypo3.org/schemas/flux-7.0.0.xsd"
8+
v:schemaLocation="http://fluidtypo3.org/schemas/vhs-1.8.5.xsd">
9+
<!-- Fluid goes here -->
10+
</div>

0 commit comments

Comments
 (0)