Skip to content

Commit 674b10a

Browse files
Merge branch '1.0.0-develop' into test-covered-for-graphql-resolver--task-115
2 parents c67781d + 980b5ff commit 674b10a

File tree

200 files changed

+3188
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+3188
-549
lines changed

resources/META-INF/plugin.xml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@
8080
</actions>
8181

8282
<extensions defaultExtensionNs="com.intellij">
83-
<directoryProjectGenerator implementation="com.magento.idea.magento2plugin.generation.MagentoModuleGenerator"/>
84-
<projectTemplatesFactory implementation="com.magento.idea.magento2plugin.generation.MagentoTemplatesFactory"/>
83+
<directoryProjectGenerator implementation="com.magento.idea.magento2plugin.generation.php.MagentoModuleGenerator"/>
84+
<projectTemplatesFactory implementation="com.magento.idea.magento2plugin.generation.php.MagentoTemplatesFactory"/>
8585

8686
<projectService serviceImplementation="com.magento.idea.magento2plugin.project.Settings"/>
8787

88-
<completion.contributor language="XML" implementationClass="com.magento.idea.magento2plugin.completion.xml.XmlCompletionContributor" />
88+
<completion.contributor language="XML" implementationClass="com.magento.idea.magento2plugin.completion.xml.XmlCompletionContributor" id="xml" />
8989

9090
<psi.referenceContributor language="XML" implementation="com.magento.idea.magento2plugin.reference.xml.XmlReferenceContributor"/>
9191
<psi.referenceContributor language="PHP" implementation="com.magento.idea.magento2plugin.reference.php.PhpReferenceContributor"/>
@@ -109,10 +109,10 @@
109109
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.js.RequireJsIndex" />
110110
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.js.MagentoLibJsIndex" />
111111

112-
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.PluginLineMarkerProvider"/>
113-
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.PluginTargetLineMarkerProvider"/>
114-
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.ClassConfigurationLineMarkerProvider"/>
115-
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.WebApiLineMarkerProvider"/>
112+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.linemarker.php.PluginLineMarkerProvider"/>
113+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.linemarker.php.PluginTargetLineMarkerProvider"/>
114+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.linemarker.php.ClassConfigurationLineMarkerProvider"/>
115+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.linemarker.php.WebApiLineMarkerProvider"/>
116116

117117
<directoryProjectConfigurator implementation="com.magento.idea.magento2plugin.project.ProjectDetector"/>
118118

@@ -131,6 +131,14 @@
131131
level="WARNING"
132132
implementationClass="com.magento.idea.magento2plugin.inspections.xml.ObserverDeclarationInspection"/>
133133

134+
<localInspection language="XML" groupPath="XML"
135+
shortName="PluginDeclarationInspection"
136+
displayName="Duplicated Plugin Usage in di XML"
137+
groupName="Magento 2"
138+
enabledByDefault="true"
139+
level="WARNING"
140+
implementationClass="com.magento.idea.magento2plugin.inspections.xml.PluginDeclarationInspection"/>
141+
134142
<localInspection language="XML" groupPath="XML"
135143
shortName="CacheableFalseInDefaultLayoutInspection"
136144
displayName="Inspection for disabled cache site-wide"

resources/META-INF/withJsGraphQl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<idea-plugin>
22
<extensions defaultExtensionNs="com.intellij">
33
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.graphql.GraphQlResolverIndex" />
4-
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.GraphQlResolverUsageLineMarkerProvider"/>
5-
<codeInsight.lineMarkerProvider language="GraphQL" implementationClass="com.magento.idea.magento2plugin.graphql.linemarker.GraphQlResolverClassLineMarkerProvider"/>
4+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.linemarker.php.GraphQlResolverUsageLineMarkerProvider"/>
5+
<codeInsight.lineMarkerProvider language="GraphQL" implementationClass="com.magento.idea.magento2plugin.linemarker.graphql.GraphQlResolverClassLineMarkerProvider"/>
66
<localInspection language="PHP" groupPath="PHP"
77
shortName="GraphQlResolverInspection" displayName="Graphql must implements ResolverInterface"
88
groupName="Magento 2"

resources/fileTemplates/code/Magento Module Events Xml Observer.xml.html

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,46 @@
66
-->
77
<html>
88
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td><font face="verdana" size="-1">
12+
Observers are a certain type of Magento class that can influence general behavior, performance, or change business logic.
13+
Observers are executed whenever the event they are configured to watch is dispatched by the eobservent manager.
14+
</font><br>
15+
</td>
16+
</tr>
17+
<tr>
18+
<td><font face="verdana" size="-1">
19+
A observer is declared (registered) for a class in the di.xml file.
20+
</font><br>
21+
</td>
22+
</tr>
23+
<tr>
24+
<td><font face="verdana" size="-1">
25+
<a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/events-and-observers.html#observers">Read more</a> about Observer, including when those can be used.
26+
</font><br>
27+
</td>
28+
</tr>
29+
</table>
30+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
31+
<tr>
32+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
33+
</tr>
34+
<tr>
35+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${EVENT_NAME}</b></font></nobr></td>
36+
<td width="10">&nbsp;</td>
37+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of the observer for the event definition.</font></td>
38+
</tr>
39+
<tr>
40+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${OBSERVER_NAME}</b></font></nobr></td>
41+
<td width="10">&nbsp;</td>
42+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer name.</font></td>
43+
</tr>
44+
<tr>
45+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${OBSERVER_CLASS}</b></font></nobr></td>
46+
<td width="10">&nbsp;</td>
47+
<td width="100%" valign="top"><font face="verdana" size="-1">The fully qualified class name of the observer.</font></td>
48+
</tr>
49+
</table>
950
</body>
10-
</html>
51+
</html>

resources/fileTemplates/code/Magento Observer Execute Method.php.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,23 @@
66
-->
77
<html>
88
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td><font face="verdana" size="-1">Your observer class should implement Magento\Framework\Event\ObserverInterface and define its execute function.
12+
One of the more powerful feature of observers is that they are able to use parameters passed into the event when it was dispatched
13+
</font><br>
14+
</td>
15+
</tr>
16+
</table>
17+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
18+
<tr>
19+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
20+
</tr>
21+
<tr>
22+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${EVENT_NAME}</b></font></nobr></td>
23+
<td width="10">&nbsp;</td>
24+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of the observer for the event definition.</font></td>
25+
</tr>
26+
</table>
927
</body>
1028
</html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
inspection.plugin.duplicateInSameFile=The plugin name already used in this file. For more details see Inspection Description.
2+
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.

resources/magento2/validation.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ validator.module.noSuchModule=No such module {0}
99
validator.file.alreadyExists={0} already exists
1010
validator.file.cantBeCreated={0} can't be created
1111
validator.class.alreadyDeclared={0} already declared in the target module
12+
validator.magentoVersionInvalid=Please specify valid Magento version or use 'any' keyword as default

src/com/magento/idea/magento2plugin/MagentoIcons.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
package com.magento.idea.magento2plugin;
66

77
import com.intellij.openapi.util.IconLoader;
8-
98
import javax.swing.*;
109

11-
/**
12-
* Created by dkvashnin on 11/14/15.
13-
*/
1410
public class MagentoIcons {
15-
public static final Icon WEB_API = IconLoader.getIcon("icons/webapi.png");
11+
public static final Icon WEB_API = IconLoader.getIcon("/icons/webapi.png");
1612
public static final Icon MODULE = IconLoader.getIcon("/icons/module.png");
1713
}

src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public void update(AnActionEvent event) {
4444
Pair<PsiFile, PhpClass> pair = this.findPhpClass(event);
4545
PsiFile psiFile = pair.getFirst();
4646
PhpClass phpClass = pair.getSecond();
47+
if (phpClass == null || psiFile == null) {
48+
return;
49+
}
4750
targetClass = phpClass;
4851
if (!(psiFile instanceof PhpFile) || phpClass.isFinal() || this.targetMethod == null) {
4952
this.setStatus(event, false);

src/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideClassByAPreferenceDialog.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
1818
import com.magento.idea.magento2plugin.magento.packages.Package;
1919
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
20-
import com.magento.idea.magento2plugin.validators.ValidatorBundle;
20+
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
2121
import org.jetbrains.annotations.NotNull;
2222
import javax.swing.*;
2323
import java.awt.event.*;
@@ -43,11 +43,13 @@ public class OverrideClassByAPreferenceDialog extends AbstractDialog {
4343
private JCheckBox inheritClass;
4444
private JLabel inheritClassLabel;
4545
private JLabel preferenceDirectoryLabel;
46+
private ValidatorBundle validatorBundle;
4647

4748
public OverrideClassByAPreferenceDialog(@NotNull Project project, PhpClass targetClass) {
4849
this.project = project;
4950
this.targetClass = targetClass;
5051
this.validator = OverrideClassByAPreferenceDialogValidator.getInstance(this);
52+
this.validatorBundle = new ValidatorBundle();
5153

5254
setContentPane(contentPane);
5355
setModal(true);
@@ -124,7 +126,7 @@ private void onOK() {
124126
getPreferenceArea()
125127
), project).generate(OverrideClassByAPreferenceAction.ACTION_NAME);
126128
if (diXml == null) {
127-
String errorMessage = ValidatorBundle.message("validator.class.alreadyDeclared", "Preference");
129+
String errorMessage = validatorBundle.message("validator.class.alreadyDeclared", "Preference");
128130
JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
129131

130132
return;

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/CreateAPluginDialogValidator.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
import com.intellij.openapi.project.Project;
88
import com.magento.idea.magento2plugin.actions.generation.dialog.CreateAPluginDialog;
99
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
10-
import com.magento.idea.magento2plugin.util.Regex;
11-
import com.magento.idea.magento2plugin.validators.ValidatorBundle;
10+
import com.magento.idea.magento2plugin.util.RegExUtil;
11+
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
1212
import javax.swing.*;
1313
import java.util.List;
1414

1515
public class CreateAPluginDialogValidator {
1616
private static CreateAPluginDialogValidator INSTANCE = null;
17+
private ValidatorBundle validatorBundle;
1718
private CreateAPluginDialog dialog;
1819

1920
public static CreateAPluginDialogValidator getInstance(CreateAPluginDialog dialog) {
@@ -25,88 +26,92 @@ public static CreateAPluginDialogValidator getInstance(CreateAPluginDialog dialo
2526
return INSTANCE;
2627
}
2728

29+
public CreateAPluginDialogValidator() {
30+
this.validatorBundle = new ValidatorBundle();
31+
}
32+
2833
public boolean validate(Project project)
2934
{
3035
String errorTitle = "Error";
3136
String pluginClassName = dialog.getPluginClassName();
3237

3338
if (pluginClassName.length() == 0) {
34-
String errorMessage = ValidatorBundle.message("validator.notEmpty", "Plugin Class Name");
39+
String errorMessage = validatorBundle.message("validator.notEmpty", "Plugin Class Name");
3540
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
3641

3742
return false;
3843
}
3944

40-
if (!pluginClassName.matches(Regex.ALPHANUMERIC)) {
41-
String errorMessage = ValidatorBundle.message("validator.alphaNumericCharacters", "Plugin Class Name");
45+
if (!pluginClassName.matches(RegExUtil.ALPHANUMERIC)) {
46+
String errorMessage = validatorBundle.message("validator.alphaNumericCharacters", "Plugin Class Name");
4247
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
4348

4449
return false;
4550
}
4651

4752
if (!Character.isUpperCase(pluginClassName.charAt(0)) && !Character.isDigit(pluginClassName.charAt(0))) {
48-
String errorMessage = ValidatorBundle.message("validator.startWithNumberOrCapitalLetter", "Plugin Class Name");
53+
String errorMessage = validatorBundle.message("validator.startWithNumberOrCapitalLetter", "Plugin Class Name");
4954
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
5055

5156
return false;
5257
}
5358

5459
String pluginDirectory = dialog.getPluginDirectory();
5560
if (pluginDirectory.length() == 0) {
56-
String errorMessage = ValidatorBundle.message("validator.notEmpty", "Plugin Directory");
61+
String errorMessage = validatorBundle.message("validator.notEmpty", "Plugin Directory");
5762
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
5863

5964
return false;
6065
}
6166

62-
if (!pluginDirectory.matches(Regex.DIRECTORY)) {
63-
String errorMessage = ValidatorBundle.message("validator.directory.isNotValid", "Plugin Directory");
67+
if (!pluginDirectory.matches(RegExUtil.DIRECTORY)) {
68+
String errorMessage = validatorBundle.message("validator.directory.isNotValid", "Plugin Directory");
6469
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
6570

6671
return false;
6772
}
6873

6974
String pluginName = dialog.getPluginName();
7075
if (pluginName.length() == 0) {
71-
String errorMessage = ValidatorBundle.message("validator.notEmpty", "Plugin Name");
76+
String errorMessage = validatorBundle.message("validator.notEmpty", "Plugin Name");
7277
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
7378

7479
return false;
7580
}
7681

77-
if (!pluginName.matches(Regex.IDENTIFIER)) {
78-
String errorMessage = ValidatorBundle.message("validator.identifier", "Plugin Name");
82+
if (!pluginName.matches(RegExUtil.IDENTIFIER)) {
83+
String errorMessage = validatorBundle.message("validator.identifier", "Plugin Name");
7984
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
8085

8186
return false;
8287
}
8388

8489
String sortOrder = dialog.getPluginSortOrder();
8590
if (sortOrder.length() == 0) {
86-
String errorMessage = ValidatorBundle.message("validator.notEmpty", "Sort Order");
91+
String errorMessage = validatorBundle.message("validator.notEmpty", "Sort Order");
8792
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
8893

8994
return false;
9095
}
9196

92-
if (!sortOrder.matches(Regex.NUMERIC)) {
93-
String errorMessage = ValidatorBundle.message("validator.onlyNumbers", "Sort Order");
97+
if (!sortOrder.matches(RegExUtil.NUMERIC)) {
98+
String errorMessage = validatorBundle.message("validator.onlyNumbers", "Sort Order");
9499
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
95100

96101
return false;
97102
}
98103

99104
String pluginModule = dialog.getPluginModule();
100105
if (pluginModule.length() == 0) {
101-
String errorMessage = ValidatorBundle.message("validator.notEmpty", "Plugin Module");
106+
String errorMessage = validatorBundle.message("validator.notEmpty", "Plugin Module");
102107
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
103108

104109
return false;
105110
}
106111

107112
List<String> allModulesList = ModuleIndex.getInstance(project).getEditableModuleNames();
108113
if (!allModulesList.contains(pluginModule)) {
109-
String errorMessage = ValidatorBundle.message("validator.module.noSuchModule", pluginModule);
114+
String errorMessage = validatorBundle.message("validator.module.noSuchModule", pluginModule);
110115
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
111116

112117
return false;

0 commit comments

Comments
 (0)