Skip to content

Commit 961f8c9

Browse files
committed
fixed code after review
1 parent 9a5672a commit 961f8c9

File tree

9 files changed

+18
-21
lines changed

9 files changed

+18
-21
lines changed

resources/META-INF/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@
221221

222222
<localInspection language="XML" groupPath="XML"
223223
shortName="PreferenceXmlInspections"
224-
displayName="Inspection the existence of PHP classes for attributes in the preference"
225-
groupName="Magento 2"
224+
bundle="magento2.inspection" key="inspection.displayName.PreferenceXmlInspections"
225+
groupBundle="magento2.inspection" groupKey="inspection.group.name"
226226
enabledByDefault="true" level="WARNING"
227227
implementationClass="com.magento.idea.magento2plugin.inspections.xml.PreferenceDeclarationInspection"/>
228228

resources/inspectionDescriptions/PreferenceXmlInspections.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<html>
88
<body>
99
<p>
10-
Validates classes and interfaces for attributes "for" and the "type" for the "preference" tag
10+
Validation of attributes inside the "preference" tag
1111
</p>
1212
<p>This inspection checks the "for" and "type" attribute of the &ltpreference/&gt; tag for:</p>
1313
<ul>
1414
<li>the correct path to the class or interface</li>
1515
<li>existence of attribute values</li>
1616
</ul>
1717
</body>
18-
</html>
18+
</html>

resources/magento2/inspection.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ inspection.displayName.ModuleDeclarationInModuleXmlInspection=Inspection for the
88
inspection.displayName.AclResourceXmlInspection=Inspection for the Title XML required attribute in the `etc/acl.xml` file
99
inspection.displayName.WebApiServiceInspection=Inspection for the Web API XML service declaration
1010
inspection.displayName.InvalidDiTypeInspection=Invalid type configuration in the `etc/di.xml` file
11+
inspection.displayName.PreferenceXmlInspections=Inspection for the Preference declaration
1112
inspection.plugin.duplicateInSameFile=The plugin name already used in this file. For more details see Inspection Description.
1213
inspection.plugin.duplicateInOtherPlaces=The plugin name "{0}" for targeted "{1}" class is already used in the module "{2}" ({3} scope). For more details see Inspection Description.
1314
inspection.plugin.disabledPluginDoesNotExist=This plugin does not exist to be disabled.

src/com/magento/idea/magento2plugin/inspections/xml/PreferenceDeclarationInspection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public class PreferenceDeclarationInspection extends XmlSuppressableInspectionTo
3030
final boolean isOnTheFly
3131
) {
3232
return new XmlElementVisitor() {
33-
private final InspectionBundle inspectionBundle = new InspectionBundle();
3433

34+
private final InspectionBundle inspectionBundle = new InspectionBundle();
3535
private final InspectionValidator phpClassExistenceValidator =
3636
new PhpClassExistenceValidator(problemsHolder.getProject());
3737
private final InspectionValidator notEmptyValidator = new NotEmptyValidator();
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4-
<preference for="Foo\Bar\Model\Logger" type=""/>
4+
<preference for="" type="Foo\Bar\Model\Logger"/>
55
</config>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4-
<preference for="" type="Foo\Bar\Model\Logger"/>
4+
<preference for="Foo\Bar\Model\Logger" type=""/>
55
</config>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4-
<preference for="" type="Foo\Bar\Model\Logger"/>
4+
<preference for="Foo\Bar\Model\Logger" type=""/>
55
</config>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4-
<preference for="Foo\Bar\Model\Logger" type=""/>
4+
<preference for="" type="Foo\Bar\Model\Logger"/>
55
</config>

tests/com/magento/idea/magento2plugin/inspections/xml/PreferenceDeclarationInspectionTest.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ public class PreferenceDeclarationInspectionTest extends InspectionXmlFixtureTes
1111

1212
private static final String ARGUMENT_VALUE_IS_EMPTY =
1313
"inspection.error.idAttributeCanNotBeEmpty";
14-
1514
private static final String CLASS_DOES_NOT_EXIST =
1615
"inspection.warning.class.does.not.exist";
17-
1816
private static final String EXISTENT_CLASS_ONE =
1917
"Magento\\Catalog\\Api\\ProductRepositoryInterface";
20-
2118
private static final String EXISTENT_CLASS_TWO =
2219
"Foo\\Bar\\Model\\Logger";
23-
2420
private static final String NOT_EXISTENT_CLASS =
2521
"Not\\Existent\\Class";
2622

@@ -31,30 +27,30 @@ public void setUp() throws Exception {
3127
}
3228

3329
/**
34-
* Test for an error for the "type" attribute because it is empty.
30+
* Test for an error for the "for" attribute because it is empty.
3531
* <preference for="" type="Foo\Bar\Model\Logger"/>
3632
*/
37-
public void testAttrArgForValuesIsEmpty() {
33+
public void testAttrArgForValueIsEmpty() {
3834
configureFixture();
3935

4036
final String forAttrIsEmptyMessage = inspectionBundle.message(
4137
ARGUMENT_VALUE_IS_EMPTY,
42-
ModuleDiXml.TYPE_ATTR
38+
ModuleDiXml.PREFERENCE_ATTR_FOR
4339
);
4440

4541
assertHasHighlighting(forAttrIsEmptyMessage);
4642
}
4743

4844
/**
49-
* Test for an error for the "for" attribute because it is empty.
50-
* <preference for="Foo\Bar\Model\Logger" type=""/>
45+
* Test for an error for the "type" attribute because it is empty.
46+
* <preference for="Foo\Bar\Model\Logger" type="Foo\Bar\Model\Logger"/>
5147
*/
5248
public void testAttrArgTypeValueIsEmpty() {
5349
configureFixture();
5450

5551
final String forAttrIsEmptyMessage = inspectionBundle.message(
5652
ARGUMENT_VALUE_IS_EMPTY,
57-
ModuleDiXml.PREFERENCE_ATTR_FOR
53+
ModuleDiXml.TYPE_ATTR
5854
);
5955

6056
assertHasHighlighting(forAttrIsEmptyMessage);
@@ -69,7 +65,7 @@ public void testAttrForClassExists() {
6965

7066
final String typeAttrIsEmptyMessage = inspectionBundle.message(
7167
ARGUMENT_VALUE_IS_EMPTY,
72-
ModuleDiXml.TYPE_ATTR
68+
ModuleDiXml.PREFERENCE_ATTR_FOR
7369
);
7470

7571
assertHasNoHighlighting(typeAttrIsEmptyMessage);
@@ -84,7 +80,7 @@ public void testAttrTypeClassExists() {
8480

8581
final String typeAttrIsEmptyMessage = inspectionBundle.message(
8682
ARGUMENT_VALUE_IS_EMPTY,
87-
ModuleDiXml.PREFERENCE_ATTR_FOR
83+
ModuleDiXml.TYPE_ATTR
8884
);
8985

9086
assertHasNoHighlighting(typeAttrIsEmptyMessage);

0 commit comments

Comments
 (0)