Skip to content

Commit 94c85b9

Browse files
author
Vitaliy
authored
Merge branch '1.0.0-develop' into issue-93
2 parents 18b7370 + db51cd8 commit 94c85b9

34 files changed

+1285
-56
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Create a Plugin class for a class public method action
1414
* Code Inspection: Warning regarding Cacheable false attribute in default XML
1515
* Create a Preference for a class action
16+
* Create a Block action
17+
* Line markers for navigation from a plugin class to a target class
1618

1719
0.3.0
1820
=============

resources/META-INF/plugin.xml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
title="CHANGELOG.md"
2222
>here</a>
2323
]]>
24-
2524
</change-notes>
2625

2726
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
@@ -38,6 +37,7 @@
3837
<depends optional="true" config-file="withJsGraphQl.xml">com.intellij.lang.jsgraphql</depends>
3938

4039
<actions>
40+
<!-- In editor generators -->
4141
<group id="MagentoGenerateGroup">
4242
<action id="MagentoGenerateObserverMethodAction"
4343
class="com.magento.idea.magento2plugin.actions.generation.PluginGenerateBeforeMethodAction"
@@ -57,6 +57,14 @@
5757
description="Create Magento around plugin method."/>
5858
<add-to-group group-id="PhpGenerateGroup" anchor="last"/>
5959
</group>
60+
61+
<!-- Module file generators -->
62+
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
63+
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
64+
<add-to-group group-id="NewGroup" anchor="last"/>
65+
</group>
66+
67+
<!-- Complex generators -->
6068
<group id="MagentoNewGroup">
6169
<action id="Magento2NewModule" class="com.magento.idea.magento2plugin.actions.generation.NewModuleAction"/>
6270
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="NewDir"/>
@@ -70,6 +78,7 @@
7078
<action id="OverrideClassByAPreference.Menu" class="com.magento.idea.magento2plugin.actions.generation.OverrideClassByAPreferenceAction">
7179
<add-to-group group-id="EditorPopupMenu"/>
7280
</action>
81+
7382
</actions>
7483

7584
<extensions defaultExtensionNs="com.intellij">
@@ -107,6 +116,7 @@
107116
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.js.MagentoLibJsIndex" />
108117

109118
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.PluginLineMarkerProvider"/>
119+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.PluginTargetLineMarkerProvider"/>
110120
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.ClassConfigurationLineMarkerProvider"/>
111121
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.WebApiLineMarkerProvider"/>
112122

@@ -141,18 +151,7 @@
141151
<internalFileTemplate name="Magento Module Xml"/>
142152
<internalFileTemplate name="Magento Module DI Xml"/>
143153
<internalFileTemplate name="Magento Php Preference Class"/>
154+
<internalFileTemplate name="Magento Module Common Php Class"/>
144155
</extensions>
145156

146-
<application-components>
147-
<!-- Add your application components here -->
148-
</application-components>
149-
150-
<project-components>
151-
<!-- Add your project components here -->
152-
</project-components>
153-
154-
<actions>
155-
<!-- Add your actions here -->
156-
</actions>
157-
158157
</idea-plugin>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<preference for="${FOR}" type="${TYPE}" />
1+
<preference for="${FOR}" type="${TYPE}" />

resources/fileTemplates/code/Magento Module DI Xml Preference.xml.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,36 @@
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+
The object manager uses abstraction-implementation mappings when the constructor signature of a class requests
13+
an object by its interface. The object manager uses these mappings to determine what the default implementation
14+
is for that class for a particular scope.
15+
</font><br>
16+
</td>
17+
</tr>
18+
<tr>
19+
<td><font face="verdana" size="-1">
20+
If you want to override a public or protected method from a core class, utilize the preference node from di.xml to achieve it.
21+
</font><br>
22+
</td>
23+
</tr>
24+
</table>
25+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
26+
<tr>
27+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
28+
</tr>
29+
<tr>
30+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${FOR}</b></font></nobr></td>
31+
<td width="10">&nbsp;</td>
32+
<td width="100%" valign="top"><font face="verdana" size="-1">Target PHP Class to change its concrete implementation</font></td>
33+
</tr>
34+
<tr>
35+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${TYPE}</b></font></nobr></td>
36+
<td width="10">&nbsp;</td>
37+
<td width="100%" valign="top"><font face="verdana" size="-1">PHP Class that will be instantiated instead of specified in predefined ${FOR} variable</font></td>
38+
</tr>
39+
</table>
940
</body>
10-
</html>
41+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
#if (${USE})
8+
9+
use ${USE};
10+
#end
11+
12+
class ${NAME} #if (${EXTENDS})extends ${EXTENDS}#end #if (${IMPLEMENTS}) implements ${IMPLEMENTS}#end {
13+
14+
}

resources/fileTemplates/internal/Magento Module Xml.xml.ft

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
33
#if (${SEQUENCES})
44
<module name="${PACKAGE}_${MODULE_NAME}">
5-
${SEQUENCES}
5+
<sequence>
6+
${SEQUENCES}
7+
</sequence>
68
</module>
79
#else
810
<module name="${PACKAGE}_${MODULE_NAME}" />
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation;
6+
7+
import com.intellij.ide.IdeView;
8+
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.project.Project;
10+
import com.intellij.psi.PsiDirectory;
11+
import com.magento.idea.magento2plugin.MagentoIcons;
12+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewBlockDialog;
13+
import org.jetbrains.annotations.NotNull;
14+
15+
public class NewBlockAction extends AnAction {
16+
public static String ACTION_NAME = "Magento 2 Block";
17+
public static String ACTION_DESCRIPTION = "Create a new Magento 2 block";
18+
19+
NewBlockAction() {
20+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
21+
}
22+
23+
@Override
24+
public void actionPerformed(@NotNull AnActionEvent e) {
25+
DataContext dataContext = e.getDataContext();
26+
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
27+
if (view == null) {
28+
return;
29+
}
30+
31+
Project project = CommonDataKeys.PROJECT.getData(dataContext);
32+
if (project == null) {
33+
return;
34+
}
35+
36+
PsiDirectory directory = view.getOrChooseDirectory();
37+
if (directory == null) {
38+
return;
39+
}
40+
41+
NewBlockDialog.open(project, directory);
42+
}
43+
44+
@Override
45+
public boolean isDumbAware() {
46+
return false;
47+
}
48+
}
49+

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
import com.intellij.psi.PsiDirectory;
1515
import com.intellij.psi.PsiFile;
1616
import com.magento.idea.magento2plugin.MagentoIcons;
17-
import com.magento.idea.magento2plugin.actions.generation.dialog.NewMagentoModuleDialog;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModuleDialog;
1818
import org.jetbrains.annotations.NotNull;
1919
import org.jetbrains.annotations.Nullable;
2020

2121
public class NewModuleAction extends com.intellij.openapi.actionSystem.AnAction {
22-
public static String ACTION_NAME = "New Magento 2 Module";
22+
public static String ACTION_NAME = "Magento 2 Module";
2323
public static String ACTION_DESCRIPTION = "Create a new Magento 2 module";
2424

2525
NewModuleAction() {
@@ -41,7 +41,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
4141
}
4242

4343
public void invoke(@NotNull Project project, @NotNull PsiDirectory initialBaseDir, @Nullable PsiFile file, @Nullable IdeView view, @Nullable Editor editor) {
44-
NewMagentoModuleDialog.open(project, initialBaseDir, file, view, editor);
44+
NewModuleDialog.open(project, initialBaseDir, file, view, editor);
4545
}
4646

4747
@Override
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation.data;
6+
7+
public class BlockFileData {
8+
private String blockDirectory;
9+
private String blockClassName;
10+
private String blockModule;
11+
private String namespace;
12+
13+
public BlockFileData(
14+
String blockDirectory,
15+
String blockClassName,
16+
String blockModule,
17+
String namespace
18+
) {
19+
this.blockDirectory = blockDirectory;
20+
this.blockClassName = blockClassName;
21+
this.blockModule = blockModule;
22+
this.namespace = namespace;
23+
}
24+
25+
public String getBlockClassName() {
26+
return blockClassName;
27+
}
28+
29+
public String getBlockDirectory() {
30+
return blockDirectory;
31+
}
32+
33+
public String getBlockModule() {
34+
return blockModule;
35+
}
36+
37+
public String getNamespace() {
38+
return namespace;
39+
}
40+
}

src/com/magento/idea/magento2plugin/actions/generation/data/ModuleComposerJsonData.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class ModuleComposerJsonData {
1414
private final String moduleDescription;
1515
private final String composerPackageName;
1616
private final String moduleVersion;
17-
private final List moduleLicense;
17+
private final List<String> moduleLicense;
18+
private final List<String> moduleDependencies;
1819

1920
public ModuleComposerJsonData(
2021
String packageName,
@@ -23,7 +24,8 @@ public ModuleComposerJsonData(
2324
String moduleDescription,
2425
String composerPackageName,
2526
String moduleVersion,
26-
List moduleLicense
27+
List<String> moduleLicense,
28+
List<String> moduleDependencies
2729
) {
2830
this.packageName = packageName;
2931
this.moduleName = moduleName;
@@ -32,6 +34,7 @@ public ModuleComposerJsonData(
3234
this.composerPackageName = composerPackageName;
3335
this.moduleVersion = moduleVersion;
3436
this.moduleLicense = moduleLicense;
37+
this.moduleDependencies = moduleDependencies;
3538
}
3639

3740
public String getPackageName() {
@@ -58,7 +61,11 @@ public String getModuleVersion() {
5861
return this.moduleVersion;
5962
}
6063

61-
public List getModuleLicense() {
64+
public List<String> getModuleLicense() {
6265
return this.moduleLicense;
6366
}
67+
68+
public List<String> getModuleDependencies() {
69+
return moduleDependencies;
70+
}
6471
}

0 commit comments

Comments
 (0)