Skip to content

Commit

Permalink
Fixed CheckStyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
drpayyne committed Oct 30, 2020
1 parent 00305e5 commit b830fb7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

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

import com.intellij.openapi.actionSystem.AnActionEvent;
Expand All @@ -17,10 +18,10 @@
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.generation.dialog.CreateAPluginDialog;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.GetFirstClassOfFile;
import com.magento.idea.magento2plugin.util.magento.plugin.IsPluginAllowedForMethod;
import org.jetbrains.annotations.NotNull;
import com.magento.idea.magento2plugin.project.Settings;

public class CreateAPluginAction extends DumbAwareAction {
public static final String ACTION_NAME = "Create a new Plugin for this method";
Expand All @@ -30,12 +31,18 @@ public class CreateAPluginAction extends DumbAwareAction {
private Method targetMethod;
private PhpClass targetClass;

/**
* Constructor.
*/
public CreateAPluginAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
this.isPluginAllowed = IsPluginAllowedForMethod.getInstance();
this.getFirstClassOfFile = GetFirstClassOfFile.getInstance();
}

/**
* @inheritdoc
*/
@Override
public void update(final AnActionEvent event) {
targetClass = null;// NOPMD
Expand Down Expand Up @@ -88,7 +95,11 @@ private Pair<PsiFile, PhpClass> findPhpClass(@NotNull final AnActionEvent event)
return Pair.create(psiFile, phpClass);
}

private void fetchTargetMethod(@NotNull final AnActionEvent event, final PsiFile psiFile, final PhpClass phpClass) {
private void fetchTargetMethod(
@NotNull final AnActionEvent event,
final PsiFile psiFile,
final PhpClass phpClass
) {
final Caret caret = event.getData(PlatformDataKeys.CARET);
if (caret == null) {
return;
Expand All @@ -98,12 +109,14 @@ private void fetchTargetMethod(@NotNull final AnActionEvent event, final PsiFile
if (element == null) {
return;
}
if (element instanceof Method && element.getParent() == phpClass && isPluginAllowed.check((Method) element)) {
if (element instanceof Method && element.getParent()
== phpClass && isPluginAllowed.check((Method) element)) {
this.targetMethod = (Method) element;
return;
}
final PsiElement parent = element.getParent();
if (parent instanceof Method && parent.getParent() == phpClass && isPluginAllowed.check((Method) parent)) {
if (parent instanceof Method && parent.getParent()
== phpClass && isPluginAllowed.check((Method) parent)) {
this.targetMethod = (Method) parent;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

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

import com.intellij.lang.ASTNode;
Expand Down Expand Up @@ -35,6 +36,9 @@ public CreateAnObserverAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
}

/**
* @inheritdoc
*/
@Override
public void update(final AnActionEvent event) {
final Project project = event.getData(PlatformDataKeys.PROJECT);
Expand Down Expand Up @@ -78,10 +82,12 @@ private PsiElement getElement(@NotNull final AnActionEvent event) {
}

private boolean isObserverEventNameClicked(@NotNull final PsiElement element) {
return checkIsElementStringLiteral(element) &&
checkIsParametersList(element.getParent().getParent()) &&
checkIsMethodReference(element.getParent().getParent().getParent()) &&
checkIsEventDispatchMethod((MethodReference) element.getParent().getParent().getParent());
return checkIsElementStringLiteral(element)
&& checkIsParametersList(element.getParent().getParent())
&& checkIsMethodReference(element.getParent().getParent().getParent())
&& checkIsEventDispatchMethod(
(MethodReference) element.getParent().getParent().getParent()
);
}

private boolean checkIsParametersList(@NotNull final PsiElement element) {
Expand Down Expand Up @@ -119,7 +125,8 @@ private boolean checkIsElementStringLiteral(@NotNull final PsiElement element) {
}
final IElementType elementType = astNode.getElementType();

return elementType == PhpTokenTypes.STRING_LITERAL || elementType == PhpTokenTypes.STRING_LITERAL_SINGLE_QUOTE;
return elementType == PhpTokenTypes.STRING_LITERAL
|| elementType == PhpTokenTypes.STRING_LITERAL_SINGLE_QUOTE;
}

private void setStatus(final AnActionEvent event, final boolean status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

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

import com.intellij.ide.IdeView;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.magento.idea.magento2plugin.MagentoIcons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

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

import com.intellij.openapi.actionSystem.AnActionEvent;
Expand Down Expand Up @@ -29,6 +30,9 @@ public OverrideClassByAPreferenceAction() {
this.getFirstClassOfFile = GetFirstClassOfFile.getInstance();
}

/**
* @inheritdoc
*/
@Override
public void update(final AnActionEvent event) {
targetClass = null;// NOPMD
Expand Down

0 comments on commit b830fb7

Please sign in to comment.