Skip to content

Commit 43c7a5c

Browse files
author
Mykola Silin
authored
Merge branch '4.4.0-develop' into 1143-fix-nullPointerException-at-ObserverDeclarationInspection-class
2 parents 72a6a6a + 84ee9aa commit 43c7a5c

File tree

8 files changed

+179
-18
lines changed

8 files changed

+179
-18
lines changed

resources/META-INF/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@
293293
enabledByDefault="true" level="WARNING"
294294
implementationClass="com.magento.idea.magento2plugin.inspections.xml.InvalidDependencyInjectionTypeInspection"/>
295295

296+
<localInspection language="XML" groupPath="XML"
297+
shortName="InvalidVirtualTypeSourceClassInspection"
298+
bundle="magento2.inspection" key="inspection.displayName.InvalidVirtualTypeSourceClassInspection"
299+
groupBundle="magento2.inspection" groupKey="inspection.group.name"
300+
enabledByDefault="true" level="WARNING"
301+
implementationClass="com.magento.idea.magento2plugin.inspections.xml.InvalidVirtualTypeSourceClassInspection"/>
302+
296303
<localInspection language="XML" groupPath="XML"
297304
shortName="PreferenceXmlInspections"
298305
bundle="magento2.inspection" key="inspection.displayName.PreferenceXmlInspections"
Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
1-
<!---
2-
You can describe your module here.
3-
We recommend that you add the following information:
4-
- implementation details: why and how to use the module, preferably with some example scenarios
5-
- any dependencies (usually other modules but could be any important dependencies, libraries, etc)
6-
- extension points, APIs, plug-ins, etc
7-
- any introduced events
8-
-->
1+
<font color='red'>**The following example is a complete README for a module Magento_Default:** </font>
2+
# Magento_Default module
3+
The Magento_Default module enables you to add the Configurable Product updates to the existing store campaigns.
4+
5+
The Magento_Default module is a part of the staging functionality in Magento EE. The module adds the “Configurations” tab and the configuration wizard to the Schedule Update form of a product. You can change the Configurable Product attributes in campaigns. These updates are shown on the campaign dashboard.
6+
7+
## Installation details
8+
9+
The Magento_Default module makes irreversible changes in a database during installation. You cannot disable or uninstall this module.
10+
11+
For information about a module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-subcommands-enable.html).
12+
13+
## Extensibility
14+
15+
Extension developers can interact with the Magento_Default module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/plugins.html).
16+
17+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_Default module.
18+
19+
### Layouts
20+
21+
The module introduces layout handles in the `view/adminhtml/layout` directory.
22+
23+
For more information about a layout in Magento 2, see the [Layout documentation](https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-overview.html).
24+
25+
### UI components
26+
27+
You can extend product and category updates using the UI components located in the `view/adminhtml/ui_component` directory.
28+
29+
For information about a UI component in Magento 2, see [Overview of UI components](https://devdocs.magento.com/guides/v2.4/ui_comp_guide/bk-ui_comps.html).
30+
31+
## Additional information
32+
33+
For information about significant changes in patch releases, see [Release information](https://devdocs.magento.com/guides/v2.4/release-notes/bk-release-notes.html).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# ${PACKAGE}_${MODULE_NAME} module
22

3-
#parse("MD File Description.md")
3+
#include("MD File Description.md")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 value in the type attribute inside the &lt;virtualType/&gt; tag of di.xml files contains valid class,
11+
interface, factory or proxy name.
12+
</p>
13+
<p>This inspection checks type attribute of the &lt;virtualType/&gt; tag.</p>
14+
<p>This inspection supports next types:</p>
15+
<ul>
16+
<li>PHP classes</li>
17+
<li>PHP interfaces</li>
18+
<li>PHP classes or interfaces with added Factory or \Proxy suffixes</li>
19+
</ul>
20+
</body>
21+
</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.InvalidVirtualTypeSourceClassInspection=Invalid source type specified for virtual type in the `di.xml` file
1112
inspection.displayName.PluginAttrTypeInspection=Inspection for the attribute `type` in the `plugin` tag
1213
inspection.displayName.PreferenceXmlInspections=Inspection for the Preference declaration
1314
inspection.plugin.duplicateInSameFile=The plugin name already used in this file. For more details see Inspection Description.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.inspections.xml;
7+
8+
import com.intellij.codeInspection.ProblemHighlightType;
9+
import com.intellij.codeInspection.ProblemsHolder;
10+
import com.intellij.codeInspection.XmlSuppressableInspectionTool;
11+
import com.intellij.psi.PsiElementVisitor;
12+
import com.intellij.psi.PsiFile;
13+
import com.intellij.psi.XmlElementVisitor;
14+
import com.intellij.psi.xml.XmlAttribute;
15+
import com.intellij.psi.xml.XmlTag;
16+
import com.magento.idea.magento2plugin.bundles.InspectionBundle;
17+
import com.magento.idea.magento2plugin.inspections.validator.InspectionValidator;
18+
import com.magento.idea.magento2plugin.inspections.validator.NotEmptyValidator;
19+
import com.magento.idea.magento2plugin.inspections.validator.PhpClassExistenceValidator;
20+
import com.magento.idea.magento2plugin.magento.files.ModuleDiXml;
21+
import org.jetbrains.annotations.NotNull;
22+
23+
public class InvalidVirtualTypeSourceClassInspection extends XmlSuppressableInspectionTool {
24+
25+
@Override
26+
public @NotNull PsiElementVisitor buildVisitor(
27+
final @NotNull ProblemsHolder problemsHolder,
28+
final boolean isOnTheFly
29+
) {
30+
return new XmlElementVisitor() {
31+
32+
private final InspectionBundle inspectionBundle = new InspectionBundle();
33+
private final InspectionValidator phpClassExistenceValidator =
34+
new PhpClassExistenceValidator(problemsHolder.getProject());
35+
private final InspectionValidator notEmptyValidator = new NotEmptyValidator();
36+
37+
@Override
38+
public void visitXmlAttribute(final XmlAttribute attribute) {
39+
final PsiFile file = attribute.getContainingFile();
40+
final XmlTag tag = attribute.getParent();
41+
42+
if (file == null
43+
|| tag == null
44+
|| !file.getName().equals(ModuleDiXml.FILE_NAME)
45+
|| !attribute.getName().equals(ModuleDiXml.TYPE_ATTR)
46+
|| !tag.getName().equals(ModuleDiXml.VIRTUAL_TYPE_TAG)
47+
) {
48+
return;
49+
}
50+
51+
if (attribute.getValue() == null
52+
|| attribute.getValueElement() == null
53+
|| attribute.getValueElement().getText().isEmpty()
54+
) {
55+
return;
56+
}
57+
58+
if (!notEmptyValidator.validate(attribute.getValue())) {
59+
problemsHolder.registerProblem(
60+
attribute.getValueElement(),
61+
inspectionBundle.message(
62+
"inspection.error.idAttributeCanNotBeEmpty",
63+
attribute.getName()
64+
),
65+
ProblemHighlightType.ERROR
66+
);
67+
}
68+
69+
if (!phpClassExistenceValidator.validate(attribute.getValue())) {
70+
problemsHolder.registerProblem(
71+
attribute.getValueElement(),
72+
inspectionBundle.message(
73+
"inspection.warning.class.does.not.exist",
74+
attribute.getValue()
75+
),
76+
ProblemHighlightType.WARNING
77+
);
78+
}
79+
}
80+
};
81+
}
82+
}

src/com/magento/idea/magento2plugin/lang/php/MagentoProxyDeclarationFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private <E extends PhpNamedElement> boolean isValidFqn(final E candidate) {
5858
PhpClass targetClass = null;
5959

6060
if (candidate instanceof Method) {
61-
targetClass = (PhpClass) candidate.getParent();
61+
targetClass = ((Method) candidate).getContainingClass();
6262
} else if (candidate instanceof PhpClass) {
6363
targetClass = (PhpClass) candidate;
6464
}
Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
# Foo_Bar module
22

3-
<!---
4-
You can describe your module here.
5-
We recommend that you add the following information:
6-
- implementation details: why and how to use the module, preferably with some example scenarios
7-
- any dependencies (usually other modules but could be any important dependencies, libraries, etc)
8-
- extension points, APIs, plug-ins, etc
9-
- any introduced events
10-
-->
3+
<font color='red'>**The following example is a complete README for a module Magento_Default:** </font>
4+
# Magento_Default module
5+
The Magento_Default module enables you to add the Configurable Product updates to the existing store campaigns.
6+
7+
The Magento_Default module is a part of the staging functionality in Magento EE. The module adds the “Configurations” tab and the configuration wizard to the Schedule Update form of a product. You can change the Configurable Product attributes in campaigns. These updates are shown on the campaign dashboard.
8+
9+
## Installation details
10+
11+
The Magento_Default module makes irreversible changes in a database during installation. You cannot disable or uninstall this module.
12+
13+
For information about a module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-subcommands-enable.html).
14+
15+
## Extensibility
16+
17+
Extension developers can interact with the Magento_Default module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/plugins.html).
18+
19+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_Default module.
20+
21+
### Layouts
22+
23+
The module introduces layout handles in the `view/adminhtml/layout` directory.
24+
25+
For more information about a layout in Magento 2, see the [Layout documentation](https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-overview.html).
26+
27+
### UI components
28+
29+
You can extend product and category updates using the UI components located in the `view/adminhtml/ui_component` directory.
30+
31+
For information about a UI component in Magento 2, see [Overview of UI components](https://devdocs.magento.com/guides/v2.4/ui_comp_guide/bk-ui_comps.html).
32+
33+
## Additional information
34+
35+
For information about significant changes in patch releases, see [Release information](https://devdocs.magento.com/guides/v2.4/release-notes/bk-release-notes.html).

0 commit comments

Comments
 (0)