Skip to content

Commit 2681387

Browse files
author
Vitaliy Boyko
committed
252: fixed null pointer exception, removed unused files, adjusted CHANGELOG.md
1 parent 93b5b83 commit 2681387

17 files changed

+183
-140
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
1.0.1
2+
=============
3+
* Features:
4+
* Create a CLI command action
5+
* Create a CRON group action
6+
* Module declaration inspections in the scope of`module.xml` and `registration.php`
7+
* Improvements:
8+
* Fixed the positioning of all dialog popups
9+
* Adjusted Magento root validation for consider `magento/framework` as a requirement
10+
* Adjusted Magento version validation RegExp to support patch versions
11+
* Fixed bugs:
12+
* The `create a plugin action` is accessible from the wrong context
13+
* Null pointer exception on the new module group
14+
115
1.0.0
216
=============
317
* Features:

src/com/magento/idea/magento2plugin/actions/generation/NewModuleAction.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModuleDialog;
1919
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
2020
import com.magento.idea.magento2plugin.project.Settings;
21-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
21+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
2222
import org.jetbrains.annotations.NotNull;
2323

2424
public class NewModuleAction extends com.intellij.openapi.actionSystem.AnAction {
@@ -86,9 +86,8 @@ public void update(final AnActionEvent event) {
8686
return;
8787
}
8888

89-
final GetModuleNameByDirectory getModuleName = GetModuleNameByDirectory
90-
.getInstance(project);
91-
final String moduleName = getModuleName.execute((PsiDirectory) psiElement);
89+
final String moduleName = GetModuleNameByDirectoryUtil
90+
.execute((PsiDirectory) psiElement, project);
9291
if (moduleName == null) {
9392
event.getPresentation().setVisible(true);
9493
return;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.magento.idea.magento2plugin.magento.files.BlockPhp;
1616
import com.magento.idea.magento2plugin.magento.packages.File;
1717
import com.magento.idea.magento2plugin.magento.packages.Package;
18-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
18+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
1919
import java.awt.event.ActionEvent;
2020
import java.awt.event.ActionListener;
2121
import java.awt.event.KeyEvent;
@@ -53,7 +53,7 @@ public NewBlockDialog(final Project project, final PsiDirectory directory) {
5353

5454
this.project = project;
5555
this.baseDir = directory;
56-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
56+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
5757
this.validator = NewBlockValidator.getInstance(this);
5858

5959
setContentPane(contentPanel);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.magento.idea.magento2plugin.actions.generation.generator.CLICommandDiXmlGenerator;
1616
import com.magento.idea.magento2plugin.actions.generation.generator.util.NamespaceBuilder;
1717
import com.magento.idea.magento2plugin.util.CamelCaseToSnakeCase;
18-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
18+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
1919
import java.awt.event.KeyEvent;
2020
import java.awt.event.WindowAdapter;
2121
import java.awt.event.WindowEvent;
@@ -52,7 +52,7 @@ public class NewCLICommandDialog extends AbstractDialog {
5252
public NewCLICommandDialog(final Project project, final PsiDirectory directory) {
5353
super();
5454
this.project = project;
55-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
55+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
5656
this.validator = new NewCLICommandValidator();
5757
this.toSnakeCase = CamelCaseToSnakeCase.getInstance();
5858

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.magento.idea.magento2plugin.magento.packages.HttpMethod;
2020
import com.magento.idea.magento2plugin.magento.packages.Package;
2121
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
22-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
22+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
2323
import java.awt.event.ActionEvent;
2424
import java.awt.event.ActionListener;
2525
import java.awt.event.KeyEvent;
@@ -64,7 +64,7 @@ public class NewControllerDialog extends AbstractDialog {
6464
public NewControllerDialog(final Project project, final PsiDirectory directory) {
6565
super();
6666
this.project = project;
67-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
67+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
6868
this.validator = NewControllerValidator.getInstance(this);
6969

7070
setContentPane(contentPane);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.NewCronGroupValidator;
1313
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleCronGroupXmlGenerator;
1414
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
15-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
15+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
1616
import java.awt.event.KeyEvent;
1717
import java.awt.event.WindowAdapter;
1818
import java.awt.event.WindowEvent;
@@ -68,7 +68,7 @@ public NewCronGroupDialog(final Project project, final PsiDirectory directory) {
6868
setModal(true);
6969
getRootPane().setDefaultButton(buttonOK);
7070
this.validator = NewCronGroupValidator.getInstance();
71-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
71+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
7272

7373
buttonOK.addActionListener(event -> onOK());
7474
buttonCancel.addActionListener(event -> onCancel());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.magento.idea.magento2plugin.indexes.CronGroupIndex;
1818
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
1919
import com.magento.idea.magento2plugin.util.CamelCaseToSnakeCase;
20-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
20+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
2121
import java.awt.event.ActionEvent;
2222
import java.awt.event.ActionListener;
2323
import java.awt.event.FocusEvent;
@@ -77,7 +77,7 @@ public class NewCronjobDialog extends AbstractDialog {
7777
public NewCronjobDialog(final Project project, final PsiDirectory directory) {
7878
super();
7979
this.project = project;
80-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
80+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
8181
this.validator = NewCronjobValidator.getInstance();
8282
this.camelCaseToSnakeCase = CamelCaseToSnakeCase.getInstance();
8383

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.magento.idea.magento2plugin.magento.files.GraphQlResolverPhp;
1616
import com.magento.idea.magento2plugin.magento.packages.File;
1717
import com.magento.idea.magento2plugin.magento.packages.Package;
18-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
18+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
1919
import java.awt.event.ActionEvent;
2020
import java.awt.event.ActionListener;
2121
import java.awt.event.KeyEvent;
@@ -49,7 +49,7 @@ public NewGraphQlResolverDialog(final Project project, final PsiDirectory direct
4949

5050
this.project = project;
5151
this.baseDir = directory;
52-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
52+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
5353
this.validator = NewGraphQlResolverValidator.getInstance(this);
5454

5555
setContentPane(contentPanel);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.magento.idea.magento2plugin.magento.files.ViewModelPhp;
1616
import com.magento.idea.magento2plugin.magento.packages.File;
1717
import com.magento.idea.magento2plugin.magento.packages.Package;
18-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
18+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
1919
import java.awt.event.ActionEvent;
2020
import java.awt.event.ActionListener;
2121
import java.awt.event.KeyEvent;
@@ -49,7 +49,7 @@ public NewViewModelDialog(final Project project, final PsiDirectory directory) {
4949

5050
this.project = project;
5151
this.baseDir = directory;
52-
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
52+
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
5353
this.validator = NewViewModelValidator.getInstance(this);
5454

5555
setContentPane(contentPanel);

src/com/magento/idea/magento2plugin/actions/groups/NewModuleFileGroup.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,57 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.groups;
67

78
import com.intellij.ide.actions.NonTrivialActionGroup;
89
import com.intellij.openapi.actionSystem.AnActionEvent;
910
import com.intellij.openapi.actionSystem.PlatformDataKeys;
1011
import com.intellij.openapi.project.Project;
1112
import com.intellij.openapi.util.IconLoader.LazyIcon;
12-
import javax.swing.Icon;
1313
import com.intellij.psi.PsiDirectory;
1414
import com.intellij.psi.PsiElement;
1515
import com.magento.idea.magento2plugin.MagentoIcons;
1616
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
1717
import com.magento.idea.magento2plugin.project.Settings;
18-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
18+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
19+
import javax.swing.Icon;
1920
import org.jetbrains.annotations.NotNull;
2021

2122
public class NewModuleFileGroup extends NonTrivialActionGroup {
23+
24+
/**
25+
* Group for generate module file actions.
26+
*/
2227
public NewModuleFileGroup() {
28+
super();
29+
2330
this.getTemplatePresentation().setIcon(new LazyIcon() {
2431
@NotNull
32+
@Override
2533
protected Icon compute() {
2634
return MagentoIcons.MODULE;
2735
}
2836
});
2937
}
3038

31-
public void update(AnActionEvent event) {
32-
Project project = event.getData(PlatformDataKeys.PROJECT);
33-
PsiElement psiElement = event.getData(PlatformDataKeys.PSI_ELEMENT);
39+
@Override
40+
public void update(final AnActionEvent event) {
41+
final PsiElement psiElement = event.getData(PlatformDataKeys.PSI_ELEMENT);
3442
if (!(psiElement instanceof PsiDirectory)) {
3543
event.getPresentation().setVisible(false);
3644
return;
3745
}
3846

39-
if(!IsClickedDirectoryInsideProject.getInstance().execute(project, (PsiDirectory) psiElement)) {
47+
final Project project = event.getData(PlatformDataKeys.PROJECT);
48+
if (!IsClickedDirectoryInsideProject.getInstance()
49+
.execute(project, (PsiDirectory) psiElement)) {
4050
event.getPresentation().setVisible(false);
4151
return;
4252
}
4353

44-
GetModuleNameByDirectory getModuleName = GetModuleNameByDirectory.getInstance(project);
45-
String moduleName = getModuleName.execute((PsiDirectory) psiElement);
54+
final String moduleName = GetModuleNameByDirectoryUtil
55+
.execute((PsiDirectory) psiElement, project);
4656
if (Settings.isEnabled(project) && moduleName != null) {
4757
event.getPresentation().setVisible(true);
4858
return;

0 commit comments

Comments
 (0)