Skip to content

Commit b089766

Browse files
Merge branch '4.4.0-develop' into 1144-error-magento-installation-path
2 parents 4e81303 + e6a4fbb commit b089766

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 12 additions & 1 deletion
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

src/com/magento/idea/magento2plugin/lang/php/MagentoProxyDeclarationFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private <E extends PhpNamedElement> boolean isValidFqn(final E candidate) {
5858
PhpClass targetClass = null;
5959

6060
if (candidate instanceof Method) {
61-
targetClass = (PhpClass) candidate.getParent();
61+
targetClass = ((Method) candidate).getContainingClass();
6262
} else if (candidate instanceof PhpClass) {
6363
targetClass = (PhpClass) candidate;
6464
}

0 commit comments

Comments
 (0)