Skip to content

252 fixed null pointer issue #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
1.0.1
=============
* Features:
* Create a CLI command action
* Create a CRON group action
* Create a CRON job action
* Create a Controller action
* Code Inspection: Module declaration inspections in the scope of `module.xml` and `registration.php`
* Code Inspection: GraphQL resolver in the scope of a schema file
* Improvements:
* Fixed the positioning of all dialog popups
* Adjusted Magento root validation for consider `magento/framework` as a requirement
* Adjusted Magento version validation RegExp to support patch versions
* Fixed bugs:
* The `create a plugin action` is accessible from the wrong context
* Null pointer exception on the new module group

1.0.0
=============
* Features:
Expand Down Expand Up @@ -108,4 +125,4 @@
0.0.5
=============
* Features:
* Added reference support for classes/interfaces in DI configuration
* Added reference support for classes/interfaces in DI configuration
1 change: 1 addition & 0 deletions resources/META-INF/pluginIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/META-INF/pluginIcon_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModuleDialog;
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import org.jetbrains.annotations.NotNull;

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

final GetModuleNameByDirectory getModuleName = GetModuleNameByDirectory
.getInstance(project);
final String moduleName = getModuleName.execute((PsiDirectory) psiElement);
final String moduleName = GetModuleNameByDirectoryUtil
.execute((PsiDirectory) psiElement, project);
if (moduleName == null) {
event.getPresentation().setVisible(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.magento.idea.magento2plugin.magento.files.BlockPhp;
import com.magento.idea.magento2plugin.magento.packages.File;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -53,7 +53,7 @@ public NewBlockDialog(final Project project, final PsiDirectory directory) {

this.project = project;
this.baseDir = directory;
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
this.validator = NewBlockValidator.getInstance(this);

setContentPane(contentPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.magento.idea.magento2plugin.actions.generation.generator.CLICommandDiXmlGenerator;
import com.magento.idea.magento2plugin.actions.generation.generator.util.NamespaceBuilder;
import com.magento.idea.magento2plugin.util.CamelCaseToSnakeCase;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class NewCLICommandDialog extends AbstractDialog {
public NewCLICommandDialog(final Project project, final PsiDirectory directory) {
super();
this.project = project;
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
this.validator = new NewCLICommandValidator();
this.toSnakeCase = CamelCaseToSnakeCase.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.magento.idea.magento2plugin.magento.packages.HttpMethod;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -64,7 +64,7 @@ public class NewControllerDialog extends AbstractDialog {
public NewControllerDialog(final Project project, final PsiDirectory directory) {
super();
this.project = project;
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
this.validator = NewControllerValidator.getInstance(this);

setContentPane(contentPane);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.NewCronGroupValidator;
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleCronGroupXmlGenerator;
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
Expand Down Expand Up @@ -68,7 +68,7 @@ public NewCronGroupDialog(final Project project, final PsiDirectory directory) {
setModal(true);
getRootPane().setDefaultButton(buttonOK);
this.validator = NewCronGroupValidator.getInstance();
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);

buttonOK.addActionListener(event -> onOK());
buttonCancel.addActionListener(event -> onCancel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.magento.idea.magento2plugin.indexes.CronGroupIndex;
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
import com.magento.idea.magento2plugin.util.CamelCaseToSnakeCase;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
Expand Down Expand Up @@ -77,7 +77,7 @@ public class NewCronjobDialog extends AbstractDialog {
public NewCronjobDialog(final Project project, final PsiDirectory directory) {
super();
this.project = project;
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
this.validator = NewCronjobValidator.getInstance();
this.camelCaseToSnakeCase = CamelCaseToSnakeCase.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.magento.idea.magento2plugin.magento.files.GraphQlResolverPhp;
import com.magento.idea.magento2plugin.magento.packages.File;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -49,7 +49,7 @@ public NewGraphQlResolverDialog(final Project project, final PsiDirectory direct

this.project = project;
this.baseDir = directory;
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
this.validator = NewGraphQlResolverValidator.getInstance(this);

setContentPane(contentPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.magento.idea.magento2plugin.magento.files.ViewModelPhp;
import com.magento.idea.magento2plugin.magento.packages.File;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -49,7 +49,7 @@ public NewViewModelDialog(final Project project, final PsiDirectory directory) {

this.project = project;
this.baseDir = directory;
this.moduleName = GetModuleNameByDirectory.getInstance(project).execute(directory);
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
this.validator = NewViewModelValidator.getInstance(this);

setContentPane(contentPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,57 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.actions.groups;

import com.intellij.ide.actions.NonTrivialActionGroup;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader.LazyIcon;
import javax.swing.Icon;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import javax.swing.Icon;
import org.jetbrains.annotations.NotNull;

public class NewModuleFileGroup extends NonTrivialActionGroup {

/**
* Group for generate module file actions.
*/
public NewModuleFileGroup() {
super();

this.getTemplatePresentation().setIcon(new LazyIcon() {
@NotNull
@Override
protected Icon compute() {
return MagentoIcons.MODULE;
}
});
}

public void update(AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);
PsiElement psiElement = event.getData(PlatformDataKeys.PSI_ELEMENT);
@Override
public void update(final AnActionEvent event) {
final PsiElement psiElement = event.getData(PlatformDataKeys.PSI_ELEMENT);
if (!(psiElement instanceof PsiDirectory)) {
event.getPresentation().setVisible(false);
return;
}

if(!IsClickedDirectoryInsideProject.getInstance().execute(project, (PsiDirectory) psiElement)) {
final Project project = event.getData(PlatformDataKeys.PROJECT);
if (!IsClickedDirectoryInsideProject.getInstance()
.execute(project, (PsiDirectory) psiElement)) {
event.getPresentation().setVisible(false);
return;
}

GetModuleNameByDirectory getModuleName = GetModuleNameByDirectory.getInstance(project);
String moduleName = getModuleName.execute((PsiDirectory) psiElement);
final String moduleName = GetModuleNameByDirectoryUtil
.execute((PsiDirectory) psiElement, project);
if (Settings.isEnabled(project) && moduleName != null) {
event.getPresentation().setVisible(true);
return;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.magento.idea.magento2plugin.magento.packages.Areas;
import com.magento.idea.magento2plugin.magento.packages.File;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -235,9 +235,11 @@ private void addModuleNameWhereSamePluginUsed(
final PsiFile indexedFile,
final String scope
) {
final String moduleName = GetModuleNameByDirectory.getInstance(
problemsHolder.getProject()
).execute(indexedFile.getContainingDirectory());
final String moduleName = GetModuleNameByDirectoryUtil
.execute(
indexedFile.getContainingDirectory(),
problemsHolder.getProject()
);

modulesName.add(Pair.create(scope, moduleName));
}
Expand Down

This file was deleted.

Loading