Skip to content

Commit 7ea4822

Browse files
Merge branch '4.0.0-develop' of github.com:magento/magento2-phpstorm-plugin into entity-web-api-generation
2 parents 4a2fcd2 + d33256d commit 7ea4822

32 files changed

+498
-272
lines changed

resources/META-INF/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@
229229
enabledByDefault="true" level="WARNING"
230230
implementationClass="com.magento.idea.magento2plugin.inspections.xml.PreferenceDeclarationInspection"/>
231231

232+
<localInspection language="XML" groupPath="XML"
233+
shortName="PluginAttrTypeInspection"
234+
bundle="magento2.inspection" key="inspection.displayName.PluginAttrTypeInspection"
235+
groupBundle="magento2.inspection" groupKey="inspection.group.name"
236+
enabledByDefault="true" level="WARNING"
237+
implementationClass="com.magento.idea.magento2plugin.inspections.xml.PluginAttributeTypeInspection"/>
238+
232239
<internalFileTemplate name="Magento Composer JSON"/>
233240
<internalFileTemplate name="Magento Registration PHP"/>
234241
<internalFileTemplate name="Magento Module XML"/>

resources/fileTemplates/code/GitHub New Bug Issue Body Template.txt.ft

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ If applicable, add screenshots to help explain your problem.
2424

2525
**Please complete the following information:** (*)
2626

27-
- OS: [e.g. MacOS or Ubuntu Linux 20.04]
28-
- PhpStorm/Intellij version: [e.g. 2019.3.3]
29-
- Plugin Version: [e.g. 1.0.0]
27+
#set($os = "#if(${OS_VERSION})${OS_VERSION}#else[e.g. MacOS or Ubuntu Linux 20.04]#end")
28+
#set($intellijVersion = "#if(${INTELLIJ_VERSION})${INTELLIJ_VERSION}#else[e.g. 2019.3.3]#end")
29+
#set($pluginVersion = "#if(${PLUGIN_VERSION})${PLUGIN_VERSION}#else[e.g. 1.0.0]#end")
30+
- OS: $os
31+
- PhpStorm/Intellij version: $intellijVersion
32+
- Plugin Version: $pluginVersion
3033

3134
**Additional context**
3235

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<p>
10+
Validates if attribute `type` in the &lt;plugin/&gt; tag of di.xml files contains valid classes or interfaces
11+
and that it cannot be empty.
12+
</p>
13+
<p>This inspection inspects:
14+
<ul>
15+
<li>The existence of the class on the specified path</li>
16+
<li>Tag `type` is not empty</li>
17+
</ul>
18+
</body>
19+
</html>

resources/magento2/inspection.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ inspection.displayName.ModuleDeclarationInModuleXmlInspection=Inspection for the
88
inspection.displayName.AclResourceXmlInspection=Inspection for the Title XML required attribute in the `etc/acl.xml` file
99
inspection.displayName.WebApiServiceInspection=Inspection for the Web API XML service declaration
1010
inspection.displayName.InvalidDiTypeInspection=Invalid type configuration in the `etc/di.xml` file
11+
inspection.displayName.PluginAttrTypeInspection=Inspection for the attribute `type` in the `plugin` tag
1112
inspection.displayName.PreferenceXmlInspections=Inspection for the Preference declaration
1213
inspection.plugin.duplicateInSameFile=The plugin name already used in this file. For more details see Inspection Description.
1314
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.

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.magento.idea.magento2plugin.actions.generation.data.DataModelData;
10-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
11-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
1210
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
1311
import com.magento.idea.magento2plugin.magento.files.DataModelFile;
1412
import com.magento.idea.magento2plugin.magento.files.DataModelInterfaceFile;
@@ -60,29 +58,20 @@ protected AbstractPhpFile initFile() {
6058
*/
6159
@Override
6260
protected void fillAttributes(final @NotNull Properties attributes) {
63-
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
64-
65-
phpClassTypesBuilder
66-
.appendProperty("NAMESPACE", file.getNamespace())
67-
.appendProperty("NAME", data.getName())
68-
.appendProperty("PROPERTIES", data.getProperties())
69-
.appendProperty("HASINTERFACE", Boolean.toString(data.hasInterface()))
61+
typesBuilder
62+
.append("NAMESPACE", file.getNamespace(), false)
63+
.append("NAME", data.getName(), false)
64+
.append("PROPERTIES", data.getProperties(), false)
65+
.append("HASINTERFACE", Boolean.toString(data.hasInterface()), false)
7066
.append("EXTENDS", DataModelFile.DATA_OBJECT);
7167

7268
if (data.hasInterface()) {
73-
phpClassTypesBuilder.append(
69+
typesBuilder.append(
7470
"IMPLEMENTS",
7571
new DataModelInterfaceFile(
7672
data.getModuleName(),
7773
data.getInterfaceName()
7874
).getClassFqn());
7975
}
80-
81-
phpClassTypesBuilder.mergeProperties(attributes);
82-
83-
attributes.setProperty(
84-
"USES",
85-
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses())
86-
);
8776
}
8877
}

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.magento.idea.magento2plugin.actions.generation.data.DeleteEntityByIdCommandData;
10-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
11-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
1210
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
1311
import com.magento.idea.magento2plugin.magento.files.ModelFile;
1412
import com.magento.idea.magento2plugin.magento.files.ResourceModelFile;
@@ -63,29 +61,24 @@ protected AbstractPhpFile initFile() {
6361
*/
6462
@Override
6563
protected void fillAttributes(final @NotNull Properties attributes) {
66-
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
6764
final ModelFile modelFile = new ModelFile(data.getModuleName(), data.getModelName());
6865
final String modelType = modelFile.getClassFqn();
6966
final String modelFactoryType = modelType.concat("Factory");
7067
final ResourceModelFile resourceFile =
7168
new ResourceModelFile(data.getModuleName(), data.getResourceModelName());
7269

73-
phpClassTypesBuilder
74-
.appendProperty("ENTITY_NAME", data.getEntityName())
75-
.appendProperty("NAMESPACE", file.getNamespace())
76-
.appendProperty("CLASS_NAME", DeleteEntityByIdCommandFile.CLASS_NAME)
77-
.appendProperty("ENTITY_ID", data.getEntityId())
70+
typesBuilder
71+
.append("ENTITY_NAME", data.getEntityName(), false)
72+
.append("NAMESPACE", file.getNamespace(), false)
73+
.append("CLASS_NAME", DeleteEntityByIdCommandFile.CLASS_NAME, false)
74+
.append("ENTITY_ID", data.getEntityId(), false)
7875
.append("Exception", "Exception")
7976
.append("COULD_NOT_DELETE", ExceptionType.COULD_NOT_DELETE.getType())
8077
.append("NO_SUCH_ENTITY_EXCEPTION",
8178
ExceptionType.NO_SUCH_ENTITY_EXCEPTION.getType())
8279
.append("LOGGER", FrameworkLibraryType.LOGGER.getType())
8380
.append("MODEL", modelType)
8481
.append("MODEL_FACTORY", modelFactoryType)
85-
.append("RESOURCE", resourceFile.getClassFqn())
86-
.mergeProperties(attributes);
87-
88-
attributes.setProperty("USES",
89-
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
82+
.append("RESOURCE", resourceFile.getClassFqn());
9083
}
9184
}

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.magento.idea.magento2plugin.actions.generation.data.DeleteEntityControllerFileData;
10-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
11-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
1210
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
1311
import com.magento.idea.magento2plugin.magento.files.actions.DeleteActionFile;
1412
import com.magento.idea.magento2plugin.magento.files.commands.DeleteEntityByIdCommandFile;
@@ -64,14 +62,12 @@ protected AbstractPhpFile initFile() {
6462
*/
6563
@Override
6664
protected void fillAttributes(final @NotNull Properties attributes) {
67-
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
68-
69-
phpClassTypesBuilder
70-
.appendProperty("NAMESPACE", file.getNamespace())
71-
.appendProperty("ENTITY_NAME", data.getEntityName())
72-
.appendProperty("CLASS_NAME", DeleteActionFile.CLASS_NAME)
73-
.appendProperty("ADMIN_RESOURCE", data.getAcl())
74-
.appendProperty("ENTITY_ID", data.getEntityId())
65+
typesBuilder
66+
.append("NAMESPACE", file.getNamespace(), false)
67+
.append("ENTITY_NAME", data.getEntityName(), false)
68+
.append("CLASS_NAME", DeleteActionFile.CLASS_NAME, false)
69+
.append("ADMIN_RESOURCE", data.getAcl(), false)
70+
.append("ENTITY_ID", data.getEntityId(), false)
7571
.append("DELETE_COMMAND",
7672
new DeleteEntityByIdCommandFile(
7773
data.getModuleName(),
@@ -87,10 +83,6 @@ protected void fillAttributes(final @NotNull Properties attributes) {
8783
.append("IMPLEMENTS_GET", HttpMethod.GET.getInterfaceFqn())
8884
.append("NO_SUCH_ENTITY_EXCEPTION",
8985
ExceptionType.NO_SUCH_ENTITY_EXCEPTION.getType())
90-
.append("COULD_NOT_DELETE", ExceptionType.COULD_NOT_DELETE.getType())
91-
.mergeProperties(attributes);
92-
93-
attributes.setProperty("USES",
94-
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
86+
.append("COULD_NOT_DELETE", ExceptionType.COULD_NOT_DELETE.getType());
9587
}
9688
}

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.magento.idea.magento2plugin.actions.generation.data.EditEntityActionData;
10-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
11-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
1210
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
1311
import com.magento.idea.magento2plugin.magento.files.actions.EditActionFile;
1412
import com.magento.idea.magento2plugin.magento.packages.HttpMethod;
@@ -62,22 +60,16 @@ protected AbstractPhpFile initFile() {
6260
*/
6361
@Override
6462
protected void fillAttributes(final @NotNull Properties attributes) {
65-
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
66-
67-
phpClassTypesBuilder
68-
.appendProperty("NAMESPACE", file.getNamespace())
69-
.appendProperty("ENTITY_NAME", data.getEntityName())
70-
.appendProperty("CLASS_NAME", file.getClassName())
71-
.appendProperty("ADMIN_RESOURCE", data.getAcl())
72-
.appendProperty("MENU_IDENTIFIER", data.getMenu())
63+
typesBuilder
64+
.append("NAMESPACE", file.getNamespace(), false)
65+
.append("ENTITY_NAME", data.getEntityName(), false)
66+
.append("CLASS_NAME", file.getClassName(), false)
67+
.append("ADMIN_RESOURCE", data.getAcl(), false)
68+
.append("MENU_IDENTIFIER", data.getMenu(), false)
7369
.append("EXTENDS", BackendModuleType.EXTENDS.getType())
7470
.append("IMPLEMENTS", HttpMethod.GET.getInterfaceFqn())
7571
.append("RESULT_INTERFACE", FrameworkLibraryType.RESULT_INTERFACE.getType())
7672
.append("RESULT_FACTORY", FrameworkLibraryType.RESULT_FACTORY.getType())
77-
.append("RESULT_PAGE", BackendModuleType.RESULT_PAGE.getType())
78-
.mergeProperties(attributes);
79-
80-
attributes.setProperty("USES",
81-
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
73+
.append("RESULT_PAGE", BackendModuleType.RESULT_PAGE.getType());
8274
}
8375
}

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

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.magento.idea.magento2plugin.actions.generation.data.EntityDataMapperData;
10-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
11-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
1210
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
1311
import com.magento.idea.magento2plugin.magento.files.DataModelFile;
1412
import com.magento.idea.magento2plugin.magento.files.DataModelInterfaceFile;
@@ -63,8 +61,6 @@ protected AbstractPhpFile initFile() {
6361
*/
6462
@Override
6563
protected void fillAttributes(final @NotNull Properties attributes) {
66-
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
67-
6864
final ModelFile modelFile = new ModelFile(data.getModuleName(), data.getModelName());
6965
final DataModelFile dtoFile = new DataModelFile(data.getDtoName(), data.getModuleName());
7066
final DataModelInterfaceFile dtoInterfaceFile =
@@ -77,20 +73,14 @@ protected void fillAttributes(final @NotNull Properties attributes) {
7773
dtoType = dtoFile.getClassFqn();
7874
}
7975

80-
phpClassTypesBuilder
81-
.appendProperty("NAMESPACE", file.getNamespace())
82-
.appendProperty("ENTITY_NAME", data.getEntityName())
83-
.appendProperty("CLASS_NAME", file.getClassName())
76+
typesBuilder
77+
.append("NAMESPACE", file.getNamespace(), false)
78+
.append("ENTITY_NAME", data.getEntityName(), false)
79+
.append("CLASS_NAME", file.getClassName(), false)
8480
.append("DATA_OBJECT", FrameworkLibraryType.DATA_OBJECT.getType())
8581
.append("DTO_TYPE", dtoType)
8682
.append("MAGENTO_MODEL_TYPE", modelFile.getClassFqn())
8783
.append("DTO_FACTORY", dtoType.concat("Factory"))
88-
.append("ABSTRACT_COLLECTION", FrameworkLibraryType.ABSTRACT_COLLECTION.getType())
89-
.mergeProperties(attributes);
90-
91-
attributes.setProperty(
92-
"USES",
93-
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses())
94-
);
84+
.append("ABSTRACT_COLLECTION", FrameworkLibraryType.ABSTRACT_COLLECTION.getType());
9585
}
9686
}

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.magento.idea.magento2plugin.actions.generation.data.FormGenericButtonBlockData;
10-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil;
11-
import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassTypesBuilder;
1210
import com.magento.idea.magento2plugin.magento.files.AbstractPhpFile;
1311
import com.magento.idea.magento2plugin.magento.files.FormGenericButtonBlockFile;
1412
import com.magento.idea.magento2plugin.magento.packages.code.FrameworkLibraryType;
@@ -63,22 +61,17 @@ protected AbstractPhpFile initFile() {
6361
*/
6462
@Override
6563
protected void fillAttributes(final @NotNull Properties attributes) {
66-
final PhpClassTypesBuilder phpClassTypesBuilder = new PhpClassTypesBuilder();
6764
final String entityIdGetter = "get" + Arrays.stream(data.getEntityId().split("_"))
6865
.map(s -> s.substring(0, 1).toUpperCase(Locale.getDefault()) + s.substring(1))
6966
.collect(Collectors.joining());
7067

71-
phpClassTypesBuilder
72-
.appendProperty("NAMESPACE", file.getNamespace())
73-
.appendProperty("ENTITY_NAME", data.getEntityName())
74-
.appendProperty("CLASS_NAME", FormGenericButtonBlockFile.CLASS_NAME)
75-
.appendProperty("ENTITY_ID", data.getEntityId())
76-
.appendProperty("ENTITY_ID_GETTER", entityIdGetter)
68+
typesBuilder
69+
.append("NAMESPACE", file.getNamespace(), false)
70+
.append("ENTITY_NAME", data.getEntityName(), false)
71+
.append("CLASS_NAME", FormGenericButtonBlockFile.CLASS_NAME, false)
72+
.append("ENTITY_ID", data.getEntityId(), false)
73+
.append("ENTITY_ID_GETTER", entityIdGetter, false)
7774
.append("CONTEXT", FormGenericButtonBlockFile.CONTEXT)
78-
.append("URL", FrameworkLibraryType.URL.getType())
79-
.mergeProperties(attributes);
80-
81-
attributes.setProperty("USES",
82-
PhpClassGeneratorUtil.formatUses(phpClassTypesBuilder.getUses()));
75+
.append("URL", FrameworkLibraryType.URL.getType());
8376
}
8477
}

0 commit comments

Comments
 (0)