Skip to content

Commit a6265a1

Browse files
authored
Merge branch '4.4.0-develop' into 1131-bug-fix-null-data-in-ModuleIndex-class
2 parents dd65c30 + 9bdd689 commit a6265a1

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<action id="MagentoCreateWebapiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWebapiXmlAction"/>
7878
<action id="MagentoCreateWidgetFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWidgetXmlAction"/>
7979
<action id="MagentoCreateLayoutFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewLayoutXmlAction"/>
80+
<action id="MagentoCreateReadmeFile" class="com.magento.idea.magento2plugin.actions.context.md.NewReadmeMdAction"/>
8081
<!-- Context dependent actions -->
8182
<separator/>
8283
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewXml"/>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.context.md;
7+
8+
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
9+
import com.intellij.psi.PsiDirectory;
10+
import com.intellij.psi.PsiFile;
11+
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
12+
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
13+
import com.magento.idea.magento2plugin.magento.files.ModuleReadmeMdFile;
14+
import com.magento.idea.magento2plugin.magento.packages.ComponentType;
15+
import com.magento.idea.magento2plugin.magento.packages.Package;
16+
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
17+
import org.jetbrains.annotations.NotNull;
18+
19+
public class NewReadmeMdAction extends AbstractContextAction {
20+
21+
public static final String ACTION_NAME = "Magento 2 README File";
22+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 README file";
23+
24+
public NewReadmeMdAction() {
25+
super(ACTION_NAME, ACTION_DESCRIPTION, new ModuleReadmeMdFile());
26+
}
27+
28+
@Override
29+
protected boolean isVisible(
30+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
31+
final PsiDirectory targetDirectory,
32+
final PsiFile targetFile
33+
) {
34+
if (!moduleData.getType().equals(ComponentType.module)) {
35+
return false;
36+
}
37+
final PsiDirectory moduleDirectory = new ModuleIndex(targetDirectory.getProject())
38+
.getModuleDirectoryByModuleName(moduleData.getName());
39+
final String magentoModuleName = moduleData
40+
.getName()
41+
.split(Package.vendorModuleNameSeparator)[1];
42+
43+
return targetDirectory.getName().equals(magentoModuleName)
44+
&& targetDirectory.equals(moduleDirectory);
45+
}
46+
47+
@Override
48+
protected AttributesDefaults getProperties(
49+
final @NotNull AttributesDefaults defaults,
50+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
51+
final PsiDirectory targetDirectory,
52+
final PsiFile targetFile
53+
) {
54+
final String[] templateData = moduleData.getName().split(Package.vendorModuleNameSeparator);
55+
defaults.addPredefined("PACKAGE", templateData[0]);
56+
defaults.addPredefined("MODULE_NAME", templateData[1]);
57+
58+
return defaults;
59+
}
60+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private void suggestPreferenceDirectory(final PhpClass targetClass) {
146146
if (fqnParts.length != 0) {
147147
fqnParts = ArrayUtil.remove(fqnParts, fqnParts.length - 1);
148148
}
149-
if (fqnParts[1] != null) {
149+
if (fqnParts.length > 1 && fqnParts[1] != null) {
150150
fqnParts = ArrayUtil.remove(fqnParts, 1);
151151
}
152152
if (fqnParts[0] != null) {

src/com/magento/idea/magento2plugin/project/diagnostic/github/GitHubNewIssueBodyBuilderUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static String buildNewBugReportBody(
4242
final @NotNull String stackTrace,
4343
final int maxAllowedBodyLength
4444
) {
45-
final int maxAllowedStackTraceLength = getMaxAllowedStackTraceLength(
45+
int maxAllowedStackTraceLength = getMaxAllowedStackTraceLength(
4646
project,
4747
bugDescription,
4848
maxAllowedBodyLength
@@ -56,6 +56,9 @@ public static String buildNewBugReportBody(
5656
String encodedCutStackTrace = "";
5757

5858
while (!isFound) {
59+
if (stackTrace.length() < maxAllowedStackTraceLength) {
60+
maxAllowedStackTraceLength = stackTrace.length();
61+
}
5962
final String cutStackTrace = stackTrace.substring(0, maxAllowedStackTraceLength - step);
6063
encodedCutStackTrace = encode(cutStackTrace);
6164

0 commit comments

Comments
 (0)