Skip to content

Commit

Permalink
Merge pull request #1262 from vitaliyboykocontributor/5.0.0-pre-release
Browse files Browse the repository at this point in the history
5.0.0 pre release
  • Loading branch information
VitaliyBoyko authored Dec 13, 2022
2 parents 1a39e01 + 817dea7 commit f338e39
Show file tree
Hide file tree
Showing 19 changed files with 234 additions and 74 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).

## 5.0.0

### Added

- Code generation of a Data Patch Boilerplate file [#1188](https://github.com/magento/magento2-phpstorm-plugin/pull/1188)
- Code generation of an Observer from the context menu [#1200](https://github.com/magento/magento2-phpstorm-plugin/pull/1200)
- Code generation of events.xml file [#1189](https://github.com/magento/magento2-phpstorm-plugin/pull/1189)
- Config Scope directory inspection [#1261](https://github.com/magento/magento2-phpstorm-plugin/pull/1261)

### Changed

- EAV attributes code generators: Added default values of the group property [#1259](https://github.com/magento/magento2-phpstorm-plugin/pull/1259)
- All code generators: Added constants visibility and class property types [#1260](https://github.com/magento/magento2-phpstorm-plugin/pull/1260)
- UCT custom coming versions [#1251](https://github.com/magento/magento2-phpstorm-plugin/pull/1251)

### Fixed

- Fixed wrong director(y|ies) generation for GraphQL resolver class [#1192](https://github.com/magento/magento2-phpstorm-plugin/pull/1192)
- Fixed IndexOutOfBoundsException: CreateResolverClassQuickFix.applyFix(CreateResolverClassQuickFix.java:43) [#1192](https://github.com/magento/magento2-phpstorm-plugin/pull/1192)
- Index out of range [#1239](https://github.com/magento/magento2-phpstorm-plugin/pull/1239)

## 4.4.0

### Added
Expand Down
11 changes: 11 additions & 0 deletions resources/icons/graphql.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion resources/magento2/inspection.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inspection.plugin.duplicateInSameFile=The plugin name already used in this file.
inspection.plugin.duplicateInOtherPlaces=The plugin name "{0}" for targeted "{1}" class is already used in the module "{2}" ({3} scope). For more details see Inspection Description.
inspection.plugin.disabledPluginDoesNotExist=This plugin does not exist to be disabled.
inspection.graphql.resolver.mustImplement=Class must implements any of the following interfaces: \\Magento\\Framework\\GraphQl\\Query\\ResolverInterface, \\Magento\\Framework\\GraphQl\\Query\\Resolver\\BatchResolverInterface, \\Magento\\Framework\\GraphQl\\Query\\Resolver\\BatchServiceContractResolverInterface
inspection.graphql.resolver.notExist=Resolver class do not exist
inspection.graphql.resolver.notExist=The GraphQL resolver class do not exist
inspection.graphql.resolver.fix.family=Implement Resolver interface
inspection.graphql.resolver.fix.title=Select one of the following interface
inspection.graphql.schema.resolver.fix.family=Create GraphQL Resolver
Expand All @@ -41,3 +41,6 @@ inspection.warning.method.should.have.public.access=The method "{0}" should have
inspection.warning.method.should.have.public.access.fix=Change the method access
inspection.displayName.ModuleScopeInspection=Module Configuration Scope Inspection
inspection.config.wrong.area = The area of this config file is wrong. Please check the spelling of the parent directory, it should be equal to one of the following: adminhtml, frontend, crontab, webapi_rest, webapi_soap, graphql.
inspection.warning.class.invalidFormat=The class "{0}" has invalid format
inspection.error.graphqlResolverClass.tooShortFormat=The target GraphQL resolver class format is incorrect.\nThe fully qualified name "{0}" should contain at least 3 parts.
inspection.error.graphqlResolverClass.tooShortFormatTitle=The GraphQL resolver class format is incorrect
1 change: 1 addition & 0 deletions src/com/magento/idea/magento2plugin/MagentoIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class MagentoIcons {
IconLoader.getIcon("/icons/pluginIcon16x16.svg", MagentoIcons.class);
public static final Icon PLUGIN_ICON_MEDIUM =
IconLoader.getIcon("/icons/pluginIcon64x64.svg", MagentoIcons.class);
public static final Icon GRAPHQL = IconLoader.getIcon("/icons/graphql.svg", MagentoIcons.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
import javax.swing.Icon;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -51,6 +52,24 @@ public AbstractContextAction(
this.moduleFile = moduleFile;
}

/**
* Abstract context action constructor.
*
* @param title String
* @param description String
* @param moduleFile ModuleFileInterface
* @param icon Icon
*/
public AbstractContextAction(
final @NotNull String title,
final @NotNull String description,
final @NotNull ModuleFileInterface moduleFile,
final @Nullable Icon icon
) {
super(title, description, icon);
this.moduleFile = moduleFile;
}

@Override
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
public void update(final @NotNull AnActionEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
import com.magento.idea.magento2plugin.magento.files.SchemaGraphQLsFile;
import com.magento.idea.magento2plugin.magento.packages.ComponentType;
Expand All @@ -25,7 +26,12 @@ public class NewGraphQLSchemaAction extends AbstractContextAction {
* New schema.graphqls file action constructor.
*/
public NewGraphQLSchemaAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, SchemaGraphQLsFile.getInstance());
super(
ACTION_NAME,
ACTION_DESCRIPTION,
SchemaGraphQLsFile.getInstance(),
MagentoIcons.GRAPHQL
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class NewGraphQlResolverAction extends AnAction {
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 GraphQL Resolver";

public NewGraphQlResolverAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.GRAPHQL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
import com.magento.idea.magento2plugin.magento.files.GraphQlResolverPhp;
import com.magento.idea.magento2plugin.magento.packages.File;
import com.magento.idea.magento2plugin.magento.packages.MagentoPhpClass;
import com.magento.idea.magento2plugin.util.GetFirstClassOfFile;
import com.magento.idea.magento2plugin.util.GetPhpClassByFQN;
Expand All @@ -34,6 +33,7 @@
import org.jetbrains.annotations.NotNull;

public class ModuleGraphQlResolverClassGenerator extends FileGenerator {

private final GraphQlResolverFileData graphQlResolverFileData;
private final Project project;
private final ValidatorBundle validatorBundle;
Expand Down Expand Up @@ -132,15 +132,15 @@ private PhpClass createGraphQlResolverClass(final String actionName) {
if (parentDirectory == null) {
return null;
}
final String[] graphQlResolverDirectories = graphQlResolverFileData
.getGraphQlResolverDirectory().split(File.separator);
for (final String graphQlResolverDirectory: graphQlResolverDirectories) {
parentDirectory = directoryGenerator.findOrCreateSubdirectory(
final String graphQlResolverDirectory = graphQlResolverFileData
.getGraphQlResolverDirectory();

if (!graphQlResolverDirectory.isBlank()) {
parentDirectory = directoryGenerator.findOrCreateSubdirectories(
parentDirectory,
graphQlResolverDirectory
);
}

final Properties attributes = getAttributes();
final PsiFile graphQlResolverFile = fileFromTemplateGenerator.generate(
GraphQlResolverPhp.getInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.completion.provider;

import com.intellij.codeInsight.completion.CompletionParameters;
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.icons.AllIcons;
import com.intellij.psi.PsiElement;
import com.intellij.util.ProcessingContext;
import com.jetbrains.php.PhpIcons;
import com.magento.idea.magento2plugin.indexes.LayoutIndex;
import com.magento.idea.magento2plugin.stubs.indexes.BlockNameIndex;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import org.jetbrains.annotations.NotNull;

public class LayoutBlockCompletionContributor extends CompletionProvider<CompletionParameters> {

@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
protected void addCompletions(final @NotNull CompletionParameters parameters,
final ProcessingContext context,
final @NotNull CompletionResultSet result) {
final PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}

Collection<String> keys = LayoutIndex.getAllKeys(BlockNameIndex.KEY, position.getProject());
for (String key: keys) {
final Collection<String> keys
= LayoutIndex.getAllKeys(BlockNameIndex.KEY, position.getProject());
for (final String key: keys) {
result.addElement(
LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
LookupElementBuilder.create(key).withIcon(AllIcons.Nodes.Tag)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.completion.provider;

import com.intellij.codeInsight.completion.CompletionParameters;
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.icons.AllIcons;
import com.intellij.psi.PsiElement;
import com.intellij.util.ProcessingContext;
import com.jetbrains.php.PhpIcons;
import com.magento.idea.magento2plugin.indexes.LayoutIndex;
import com.magento.idea.magento2plugin.stubs.indexes.ContainerNameIndex;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import org.jetbrains.annotations.NotNull;

public class LayoutContainerCompletionContributor extends CompletionProvider<CompletionParameters> {

@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
protected void addCompletions(final @NotNull CompletionParameters parameters,
final ProcessingContext context,
final @NotNull CompletionResultSet result) {
final PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}

Collection<String> keys = LayoutIndex.getAllKeys(ContainerNameIndex.KEY, position.getProject());
for (String key: keys) {
final Collection<String> keys
= LayoutIndex.getAllKeys(ContainerNameIndex.KEY, position.getProject());
for (final String key: keys) {
result.addElement(
LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
LookupElementBuilder.create(key).withIcon(AllIcons.Nodes.Tag)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.completion.provider;

import com.intellij.codeInsight.completion.CompletionParameters;
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.icons.AllIcons;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.ProcessingContext;
import com.jetbrains.php.PhpIcons;
import com.magento.idea.magento2plugin.indexes.LayoutIndex;
import java.util.List;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class LayoutUpdateCompletionContributor extends CompletionProvider<CompletionParameters> {

@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
protected void addCompletions(final @NotNull CompletionParameters parameters,
final ProcessingContext context,
final @NotNull CompletionResultSet result) {
final PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}

List<XmlFile> targets = LayoutIndex.getLayoutFiles(position.getProject());
if (targets.size() > 0) {
for (XmlFile file : targets) {
final List<XmlFile> targets = LayoutIndex.getLayoutFiles(position.getProject());
if (!targets.isEmpty()) {
for (final XmlFile file : targets) {
result.addElement(
LookupElementBuilder
LookupElementBuilder
.create(file.getVirtualFile().getNameWithoutExtension())
.withIcon(PhpIcons.XML_TAG_ICON)
.withIcon(AllIcons.Nodes.Tag)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.icons.AllIcons;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.ProcessingContext;
import com.jetbrains.php.PhpIcons;
import com.magento.idea.magento2plugin.indexes.UIComponentIndex;
import java.util.List;
import org.jetbrains.annotations.NotNull;
Expand All @@ -34,7 +34,7 @@ protected void addCompletions(@NotNull final CompletionParameters parameters,
for (final XmlFile file : targets) {
result.addElement(LookupElementBuilder
.create(file.getVirtualFile().getNameWithoutExtension())
.withIcon(PhpIcons.XML_TAG_ICON)
.withIcon(AllIcons.Nodes.Tag)
);
}
}
Expand Down
Loading

0 comments on commit f338e39

Please sign in to comment.