Skip to content

Commit 0d5fcc1

Browse files
I added conditional logic to test if the given variable is null, if null we will return and avoid execution of the code that could through a NPE. If the code is fine then it will continue as normal.
1 parent 6ea5de7 commit 0d5fcc1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/com/magento/idea/magento2plugin/actions/generation/dialog/InjectAViewModelDialog.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,15 @@ protected void onOK() {
141141
exit();
142142
return;
143143
}
144-
final String moduleName = GetModuleNameByDirectoryUtil.execute(
145-
targetBlockTag.getContainingFile().getParent(),
146-
project
147-
);
144+
if(targetBlockTag.getContainingFile() != null &&
145+
targetBlockTag.getContainingFile().getParent() != null) {
146+
final String moduleName = GetModuleNameByDirectoryUtil.execute(
147+
targetBlockTag.getContainingFile().getParent(),
148+
project
149+
);
150+
} else {
151+
return;
152+
}
148153
final NamespaceBuilder namespaceBuilder = new NamespaceBuilder(
149154
moduleName,
150155
getViewModelClassName(),

0 commit comments

Comments
 (0)