File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
src/com/magento/idea/magento2plugin/actions/generation/generator Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1818import org .jetbrains .annotations .NotNull ;
1919
2020public class LayoutXmlTemplateGenerator extends FileGenerator {
21+
2122 private final LayoutXmlData layoutXmlData ;
2223 private final Project project ;
2324 private final FindOrCreateLayoutXml findOrCreateLayoutXml ;
@@ -42,10 +43,11 @@ public LayoutXmlTemplateGenerator(
4243 * Creates a module layout file.
4344 *
4445 * @param actionName String
46+ *
4547 * @return PsiFile
4648 */
4749 @ Override
48- public PsiFile generate (final String actionName ) {
50+ public PsiFile generate (final @ NotNull String actionName ) {
4951 final XmlFile layoutXml = (XmlFile ) findOrCreateLayoutXml .execute (
5052 actionName ,
5153 layoutXmlData .getRoute (),
@@ -54,17 +56,26 @@ public PsiFile generate(final String actionName) {
5456 layoutXmlData .getModuleName (),
5557 layoutXmlData .getArea ()
5658 );
59+
60+ if (layoutXml == null ) {
61+ return null ;
62+ }
5763 final PsiDocumentManager psiDocumentManager =
5864 PsiDocumentManager .getInstance (project );
5965 final Document document = psiDocumentManager .getDocument (layoutXml );
66+
67+ if (document == null ) {
68+ return null ;
69+ }
6070 WriteCommandAction .runWriteCommandAction (project , () -> {
6171 final XmlTag rootTag = layoutXml .getRootTag ();
72+
6273 if (rootTag == null ) {
6374 return ;
6475 }
65-
6676 psiDocumentManager .commitDocument (document );
6777 });
78+
6879 return layoutXml ;
6980 }
7081
You can’t perform that action at this time.
0 commit comments