Skip to content

Commit b1adf1f

Browse files
author
Vitaliy
authored
Merge pull request #257 from magento/252-fixed-issue-with-new-module-group-prepare-release
252 fixed null pointer issue
2 parents 2bdc85c + 546490d commit b1adf1f

19 files changed

+189
-141
lines changed

CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
1.0.1
2+
=============
3+
* Features:
4+
* Create a CLI command action
5+
* Create a CRON group action
6+
* Create a CRON job action
7+
* Create a Controller action
8+
* Code Inspection: Module declaration inspections in the scope of `module.xml` and `registration.php`
9+
* Code Inspection: GraphQL resolver in the scope of a schema file
10+
* Improvements:
11+
* Fixed the positioning of all dialog popups
12+
* Adjusted Magento root validation for consider `magento/framework` as a requirement
13+
* Adjusted Magento version validation RegExp to support patch versions
14+
* Fixed bugs:
15+
* The `create a plugin action` is accessible from the wrong context
16+
* Null pointer exception on the new module group
17+
118
1.0.0
219
=============
320
* Features:
@@ -108,4 +125,4 @@
108125
0.0.5
109126
=============
110127
* Features:
111-
* Added reference support for classes/interfaces in DI configuration
128+
* Added reference support for classes/interfaces in DI configuration

resources/META-INF/pluginIcon.svg

+1
Loading
+1
Loading

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

+3-4
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+18-8
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;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.magento.idea.magento2plugin.magento.packages.Areas;
2727
import com.magento.idea.magento2plugin.magento.packages.File;
2828
import com.magento.idea.magento2plugin.magento.packages.Package;
29-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
29+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
3030
import java.util.ArrayList;
3131
import java.util.Collection;
3232
import java.util.HashMap;
@@ -235,9 +235,11 @@ private void addModuleNameWhereSamePluginUsed(
235235
final PsiFile indexedFile,
236236
final String scope
237237
) {
238-
final String moduleName = GetModuleNameByDirectory.getInstance(
239-
problemsHolder.getProject()
240-
).execute(indexedFile.getContainingDirectory());
238+
final String moduleName = GetModuleNameByDirectoryUtil
239+
.execute(
240+
indexedFile.getContainingDirectory(),
241+
problemsHolder.getProject()
242+
);
241243

242244
modulesName.add(Pair.create(scope, moduleName));
243245
}

src/com/magento/idea/magento2plugin/util/magento/GetModuleNameByDirectory.java

-110
This file was deleted.

0 commit comments

Comments
 (0)