|
8 | 8 | import com.intellij.codeInspection.ProblemHighlightType;
|
9 | 9 | import com.intellij.codeInspection.ProblemsHolder;
|
10 | 10 | import com.intellij.codeInspection.XmlSuppressableInspectionTool;
|
| 11 | +import com.intellij.patterns.XmlAttributeValuePattern; |
11 | 12 | import com.intellij.psi.PsiDirectory;
|
12 | 13 | import com.intellij.psi.PsiElementVisitor;
|
13 | 14 | import com.intellij.psi.PsiFile;
|
|
27 | 28 |
|
28 | 29 | public class ModuleDeclarationInModuleXmlInspection extends XmlSuppressableInspectionTool {
|
29 | 30 |
|
| 31 | + private static final String MODULE_NAME = "name"; |
| 32 | + |
30 | 33 | @NotNull
|
31 | 34 | @Override
|
32 | 35 | public PsiElementVisitor buildVisitor(
|
@@ -54,24 +57,26 @@ public void visitXmlAttributeValue(final XmlAttributeValue value) {
|
54 | 57 | return;
|
55 | 58 | }
|
56 | 59 |
|
57 |
| - final String expectedName |
58 |
| - = GetEditableModuleNameByRootFileUtil.execute(etcDirectory); |
59 |
| - final String actualName = value.getValue(); |
60 |
| - if (actualName.equals(expectedName)) { |
61 |
| - return; |
| 60 | + final String attributeName = XmlAttributeValuePattern.getLocalName(value); |
| 61 | + if (attributeName != null && attributeName.equals(MODULE_NAME)) { |
| 62 | + final String expectedName |
| 63 | + = GetEditableModuleNameByRootFileUtil.execute(etcDirectory); |
| 64 | + final String actualName = value.getValue(); |
| 65 | + if (actualName.equals(expectedName)) { |
| 66 | + return; |
| 67 | + } |
| 68 | + final InspectionBundle inspectionBundle = new InspectionBundle(); |
| 69 | + problemsHolder.registerProblem( |
| 70 | + value, |
| 71 | + inspectionBundle.message( |
| 72 | + "inspection.moduleDeclaration.warning.wrongModuleName", |
| 73 | + actualName, |
| 74 | + expectedName |
| 75 | + ), |
| 76 | + ProblemHighlightType.ERROR, |
| 77 | + new XmlModuleNameQuickFix(expectedName) |
| 78 | + ); |
62 | 79 | }
|
63 |
| - |
64 |
| - final InspectionBundle inspectionBundle = new InspectionBundle(); |
65 |
| - problemsHolder.registerProblem( |
66 |
| - value, |
67 |
| - inspectionBundle.message( |
68 |
| - "inspection.moduleDeclaration.warning.wrongModuleName", |
69 |
| - actualName, |
70 |
| - expectedName |
71 |
| - ), |
72 |
| - ProblemHighlightType.ERROR, |
73 |
| - new XmlModuleNameQuickFix(expectedName) |
74 |
| - ); |
75 | 80 | }
|
76 | 81 | };
|
77 | 82 | }
|
|
0 commit comments