Skip to content

Commit e51176c

Browse files
Merge branch '4.4.0-develop' of github.com:magento/magento2-phpstorm-plugin into pre-release-4.4.0
2 parents 574b638 + e6a4fbb commit e51176c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.codeInspection.ProblemHighlightType;
99
import com.intellij.codeInspection.ProblemsHolder;
1010
import com.intellij.ide.highlighter.XmlFileType;
11+
import com.intellij.openapi.externalSystem.service.execution.NotSupportedException;
1112
import com.intellij.openapi.vfs.VfsUtil;
1213
import com.intellij.openapi.vfs.VirtualFile;
1314
import com.intellij.psi.PsiElement;
@@ -71,6 +72,10 @@ public void visitFile(final @NotNull PsiFile file) {
7172
return;
7273
}
7374

75+
// This added to cover case if file exists only in memory.
76+
if (file.getContainingDirectory() == null) {
77+
return;
78+
}
7479
final EventIndex eventIndex = new EventIndex(file.getProject());
7580
final HashMap<String, XmlTag> targetObserversHash = new HashMap<>();
7681

@@ -108,7 +113,8 @@ public void visitFile(final @NotNull PsiFile file) {
108113
}
109114

110115
final String observerName = observerNameAttribute.getValue();
111-
if (observerName == null) {
116+
if (observerName == null
117+
|| observerNameAttribute.getValueElement() == null) {
112118
continue;
113119
}
114120

@@ -188,6 +194,11 @@ private List<HashMap<String, String>> fetchModuleNamesWhereSameObserverNameUsed(
188194
final EventIndex eventIndex,
189195
final PsiFile file
190196
) {
197+
if (file.getContainingDirectory() == null) {
198+
throw new NotSupportedException(
199+
"Operation is not supported for files in memory"
200+
);
201+
}
191202
final List<HashMap<String, String>> modulesName = new ArrayList<>();
192203
final String currentFileDirectory = file.getContainingDirectory().toString();
193204
final String currentFileFullPath = currentFileDirectory

0 commit comments

Comments
 (0)