Skip to content

Commit bd7d510

Browse files
authored
Merge pull request magento#533 from magento/531-plugin/observer_name_is_not_set_error
Fixed error when plugin or observer name is not set
2 parents 178e05c + 0834895 commit bd7d510

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public void visitFile(final PsiFile file) {
100100
}
101101

102102
final String observerName = observerNameAttribute.getValue();
103+
if (observerName == null) {
104+
continue;
105+
}
106+
103107
final String observerKey = eventNameAttributeValue.concat("_")
104108
.concat(observerName);
105109
if (targetObserversHash.containsKey(observerKey)) {
@@ -124,10 +128,13 @@ public void visitFile(final PsiFile file) {
124128
if (observerDisabledAttribute != null
125129
&& observerDisabledAttribute.getValue() != null
126130
&& observerDisabledAttribute.getValue().equals("true")
131+
&& !observerName.isEmpty()
127132
) {
128-
if (modulesWithSameObserverName.isEmpty()) {
133+
@Nullable final XmlAttributeValue valueElement
134+
= observerNameAttribute.getValueElement();
135+
if (modulesWithSameObserverName.isEmpty() && valueElement != null) {
129136
problemsHolder.registerProblem(
130-
observerNameAttribute.getValueElement(),
137+
valueElement,
131138
inspectionBundle.message(
132139
"inspection.observer.disabledObserverDoesNotExist"
133140
),

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public void visitFile(final PsiFile file) {
9393
}
9494

9595
final String pluginTypeName = pluginTypeNameAttribute.getValue();
96+
if (pluginTypeName == null) {
97+
continue;
98+
}
99+
96100
final String pluginTypeKey = pluginNameAttributeValue.concat(
97101
Package.vendorModuleNameSeparator
98102
).concat(pluginTypeName);
@@ -118,14 +122,17 @@ public void visitFile(final PsiFile file) {
118122
if (pluginTypeDisabledAttribute != null
119123
&& pluginTypeDisabledAttribute.getValue() != null
120124
&& pluginTypeDisabledAttribute.getValue().equals("true")
125+
&& !pluginTypeName.isEmpty()
121126
) {
122-
if (modulesWithSamePluginName.isEmpty()) {
127+
@Nullable final XmlAttributeValue valueElement
128+
= pluginTypeNameAttribute.getValueElement();
129+
if (modulesWithSamePluginName.isEmpty() && valueElement != null) {
123130
problemsHolder.registerProblem(
124-
pluginTypeNameAttribute.getValueElement(),
125-
inspectionBundle.message(
126-
"inspection.plugin.disabledPluginDoesNotExist"
127-
),
128-
errorSeverity
131+
valueElement,
132+
inspectionBundle.message(
133+
"inspection.plugin.disabledPluginDoesNotExist"
134+
),
135+
errorSeverity
129136
);
130137
} else {
131138
continue;

0 commit comments

Comments
 (0)