Skip to content

Commit 2ddeeb6

Browse files
1135: Minor code style fixes
1 parent f268ef6 commit 2ddeeb6

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
66

77
## 4.4.1
88

9+
### Fixed
10+
11+
- Fixed wrong director(y|ies) generation for GraphQL resolver class [#1192](https://github.com/magento/magento2-phpstorm-plugin/pull/1192)
12+
- Fixed IndexOutOfBoundsException: CreateResolverClassQuickFix.applyFix(CreateResolverClassQuickFix.java:43) [#1192](https://github.com/magento/magento2-phpstorm-plugin/pull/1192)
13+
914
## 4.4.0
1015

1116
### Added

resources/magento2/inspection.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inspection.plugin.duplicateInSameFile=The plugin name already used in this file.
1515
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.
1616
inspection.plugin.disabledPluginDoesNotExist=This plugin does not exist to be disabled.
1717
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
18-
inspection.graphql.resolver.notExist=Resolver class do not exist
18+
inspection.graphql.resolver.notExist=The GraphQL resolver class do not exist
1919
inspection.graphql.resolver.fix.family=Implement Resolver interface
2020
inspection.graphql.resolver.fix.title=Select one of the following interface
2121
inspection.graphql.schema.resolver.fix.family=Create GraphQL Resolver
@@ -40,5 +40,5 @@ inspection.warning.method.does.not.exist=The method "{0}" does not exist in the
4040
inspection.warning.method.should.have.public.access=The method "{0}" should have public access
4141
inspection.warning.method.should.have.public.access.fix=Change the method access
4242
inspection.warning.class.invalidFormat=The class "{0}" has invalid format
43-
inspection.error.class.tooShortFormat=The target resolver class format is incorrect.\nThe fully qualified name "{0}" should contain at least 3 parts.
44-
inspection.error.class.tooShortFormatTitle=Resolver class format is incorrect
43+
inspection.error.graphqlResolverClass.tooShortFormat=The target GraphQL resolver class format is incorrect.\nThe fully qualified name "{0}" should contain at least 3 parts.
44+
inspection.error.graphqlResolverClass.tooShortFormatTitle=The GraphQL resolver class format is incorrect

src/com/magento/idea/magento2plugin/actions/generation/generator/ModuleGraphQlResolverClassGenerator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.jetbrains.annotations.NotNull;
3434

3535
public class ModuleGraphQlResolverClassGenerator extends FileGenerator {
36+
3637
private final GraphQlResolverFileData graphQlResolverFileData;
3738
private final Project project;
3839
private final ValidatorBundle validatorBundle;
@@ -131,16 +132,15 @@ private PhpClass createGraphQlResolverClass(final String actionName) {
131132
if (parentDirectory == null) {
132133
return null;
133134
}
134-
135135
final String graphQlResolverDirectory = graphQlResolverFileData
136136
.getGraphQlResolverDirectory();
137+
137138
if (!graphQlResolverDirectory.isBlank()) {
138139
parentDirectory = directoryGenerator.findOrCreateSubdirectories(
139140
parentDirectory,
140141
graphQlResolverDirectory
141142
);
142143
}
143-
144144
final Properties attributes = getAttributes();
145145
final PsiFile graphQlResolverFile = fileFromTemplateGenerator.generate(
146146
GraphQlResolverPhp.getInstance(

src/com/magento/idea/magento2plugin/inspections/graphqls/SchemaResolverInspection.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@ public class SchemaResolverInspection extends LocalInspectionTool {
2525

2626
private final InspectionBundle inspectionBundle = new InspectionBundle();
2727

28-
@NotNull
2928
@Override
30-
public GraphQLVisitor buildVisitor(
31-
@NotNull final ProblemsHolder holder,
29+
public @NotNull GraphQLVisitor buildVisitor(
30+
final @NotNull ProblemsHolder holder,
3231
final boolean isOnTheFly
3332
) {
3433
return new GraphQLVisitor() {
3534
@Override
36-
public void visitValue(@NotNull final GraphQLValue element) {
35+
public void visitValue(final @NotNull GraphQLValue element) {
3736
final String getVisitedElementValue = element.getText();
3837
final PsiElement parentElementValue = element.getParent();
38+
3939
if (getVisitedElementValue == null
4040
|| !(parentElementValue instanceof GraphQLNamedElement)) {
4141
return;
4242
}
43-
4443
final String attributeName = ((GraphQLNamedElement) parentElementValue).getName();
44+
4545
if (!GraphQlResolver.CLASS_ARGUMENT.equals(attributeName)) {
4646
return;
4747
}
48-
4948
final String resolverFQN
5049
= GraphQlUtil.resolverStringToPhpFQN(getVisitedElementValue);
50+
5151
if (!resolverFQN.matches(RegExUtil.PhpRegex.FQN)) {
5252
holder.registerProblem(
5353
element,
@@ -57,10 +57,8 @@ public void visitValue(@NotNull final GraphQLValue element) {
5757
),
5858
ProblemHighlightType.WARNING
5959
);
60-
6160
return;
6261
}
63-
6462
final GetPhpClassByFQN getPhpClassByFQN
6563
= GetPhpClassByFQN.getInstance(holder.getProject());
6664
final PhpClass resolverClass = getPhpClassByFQN.execute(resolverFQN);

src/com/magento/idea/magento2plugin/inspections/graphqls/fix/CreateResolverClassQuickFix.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ public void applyFix(
4949
if (fqnPartsList.size() < CLASSPATH_MIN_DEPTH) {
5050
JOptionPane.showMessageDialog(
5151
null,
52-
inspectionBundle.message("inspection.error.class.tooShortFormat", resolverFqn),
53-
inspectionBundle.message("inspection.error.class.tooShortFormatTitle"),
52+
inspectionBundle.message(
53+
"inspection.error.graphqlResolverClass.tooShortFormat",
54+
resolverFqn
55+
),
56+
inspectionBundle.message(
57+
"inspection.error.graphqlResolverClass.tooShortFormatTitle"
58+
),
5459
JOptionPane.ERROR_MESSAGE
5560
);
56-
5761
return;
5862
}
5963

0 commit comments

Comments
 (0)