Skip to content

Commit 4e42483

Browse files
dkvashninbaylenaorobei
authored andcommitted
Added more representative descriptions for "goto configuration"
(cherry picked from commit a0f7d63)
1 parent 54889a6 commit 4e42483

File tree

7 files changed

+68
-26
lines changed

7 files changed

+68
-26
lines changed

META-INF/plugin.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin version="2">
22
<id>com.magento.idea.magento2plugin</id>
33
<name>Magento2</name>
4-
<version>0.2.0</version>
4+
<version>0.2.1</version>
55
<vendor email="[email protected]" url="https://github.com/dkvashninbay/magento2plugin">Dmytro Kvashnin</vendor>
66

77
<description><![CDATA[
@@ -32,6 +32,10 @@
3232
]]></description>
3333

3434
<change-notes><![CDATA[
35+
<h3>0.2.1</h3>
36+
<ul>
37+
<li>added module name for "Goto configuration" labels</li>
38+
</ul>
3539
<h3>0.2.0</h3>
3640
<ul>
3741
<li>WebApi routes</li>

src/com/magento/idea/magento2plugin/php/module/MagentoComponentManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,18 @@ private void loadModules() {
138138
class MagentoModuleImpl extends MagentoComponentImp implements MagentoModule {
139139
private static final String DEFAULT_MODULE_NAME = "Undefined module";
140140
private static final String CONFIGURATION_PATH = "etc";
141+
private String moduleName;
141142

142143
public MagentoModuleImpl(@NotNull ComposerPackageModel composerPackageModel, @NotNull PsiDirectory directory) {
143144
super(composerPackageModel, directory);
144145
}
145146

146-
@Nullable
147147
@Override
148148
public String getMagentoName() {
149+
if (moduleName != null) {
150+
return moduleName;
151+
}
152+
149153
PsiDirectory configurationDir = directory.findSubdirectory(CONFIGURATION_PATH);
150154
if (configurationDir != null) {
151155
PsiFile configurationFile = configurationDir.findFile("module.xml");
@@ -155,7 +159,8 @@ public String getMagentoName() {
155159
if (rootTag != null) {
156160
XmlTag module = rootTag.findFirstSubTag("module");
157161
if (module != null && module.getAttributeValue("name") != null) {
158-
return module.getAttributeValue("name");
162+
moduleName = module.getAttributeValue("name");
163+
return moduleName;
159164
}
160165
}
161166
}

src/com/magento/idea/magento2plugin/php/module/MagentoModule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
* Created by dkvashnin on 12/5/15.
77
*/
88
public interface MagentoModule extends MagentoComponent {
9-
@Nullable
109
String getMagentoName();
1110
}

src/com/magento/idea/magento2plugin/xml/di/index/TypeConfigurationFileBasedIndex.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ public DiPreferenceLineMarkerXmlTagDecorator(XmlTag xmlTag) {
207207
super(xmlTag);
208208
}
209209

210+
@NotNull
211+
@Override
212+
public String getDescription() {
213+
String preference = xmlTag.getAttributeValue(XmlHelper.TYPE_ATTRIBUTE);
214+
if (preference != null) {
215+
return String.format("preference %s", preference);
216+
}
217+
return xmlTag.getName();
218+
}
219+
210220
@Override
211221
@NotNull
212222
@NonNls
@@ -228,11 +238,10 @@ public DiTypeLineMarkerXmlTagDecorator(XmlTag xmlTag) {
228238
super(xmlTag);
229239
}
230240

231-
@Override
232241
@NotNull
233-
@NonNls
234-
public String getName() {
235-
return String.format("[%s] type declaration", getAreaName());
242+
@Override
243+
public String getDescription() {
244+
return "type declaration";
236245
}
237246
}
238247

@@ -245,10 +254,9 @@ public DiPluginLineMarkerXmlTagDecorator(XmlTag xmlTag) {
245254
super(xmlTag);
246255
}
247256

248-
@Override
249257
@NotNull
250-
@NonNls
251-
public String getName() {
258+
@Override
259+
public String getDescription() {
252260
XmlTag typeTag = xmlTag.getParentTag();
253261
if (typeTag == null) {
254262
return xmlTag.getName();
@@ -257,7 +265,8 @@ public String getName() {
257265
if (type == null) {
258266
return xmlTag.getName();
259267
}
260-
return String.format("[%s] plugin for %s", getAreaName(), type);
268+
269+
return String.format("plugin for %s", type);
261270
}
262271
}
263272

@@ -270,13 +279,12 @@ public DiVirtualTypeLineMarkerXmlTagDecorator(XmlTag xmlTag) {
270279
super(xmlTag);
271280
}
272281

273-
@Override
274282
@NotNull
275-
@NonNls
276-
public String getName() {
283+
@Override
284+
public String getDescription() {
277285
String type = xmlTag.getAttributeValue(XmlHelper.NAME_ATTRIBUTE);
278286
if (type != null) {
279-
return String.format("[%s] virtual type %s", getAreaName(), type);
287+
return String.format("virtual type %s", type);
280288
}
281289
return xmlTag.getName();
282290
}

src/com/magento/idea/magento2plugin/xml/index/LineMarkerXmlTagDecorator.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.intellij.lang.ASTNode;
44
import com.intellij.lang.Language;
5+
import com.intellij.openapi.module.ModuleManager;
56
import com.intellij.openapi.project.Project;
67
import com.intellij.openapi.util.Key;
78
import com.intellij.openapi.util.TextRange;
@@ -19,6 +20,9 @@
1920
import com.intellij.util.IncorrectOperationException;
2021
import com.intellij.xml.XmlElementDescriptor;
2122
import com.intellij.xml.XmlNSDescriptor;
23+
import com.magento.idea.magento2plugin.php.module.MagentoComponent;
24+
import com.magento.idea.magento2plugin.php.module.MagentoComponentManager;
25+
import com.magento.idea.magento2plugin.php.module.MagentoModule;
2226
import org.jetbrains.annotations.Contract;
2327
import org.jetbrains.annotations.NonNls;
2428
import org.jetbrains.annotations.NotNull;
@@ -56,13 +60,30 @@ protected String getAreaName() {
5660
return configDirectory;
5761
}
5862

63+
@NotNull
64+
protected String getComponentName() {
65+
MagentoComponentManager moduleManager = MagentoComponentManager.getInstance(project);
66+
MagentoModule module = moduleManager.getComponentOfTypeForFile(xmlTag.getContainingFile(), MagentoModule.class);
67+
68+
if (module == null) {
69+
return "";
70+
}
71+
72+
return module.getMagentoName();
73+
}
74+
75+
@NotNull
76+
abstract public String getDescription();
77+
5978
/**
6079
* Get line marker text. This method should be overridden to generate user-friendly XmlTag presentation.
6180
*/
6281
@Override
6382
@NotNull
6483
@NonNls
65-
abstract public String getName();
84+
public String getName() {
85+
return String.format("%s [%s] - %s", getComponentName(), getAreaName(), getDescription());
86+
}
6687

6788
@Override
6889
@NotNull

src/com/magento/idea/magento2plugin/xml/layout/index/util/LayoutIndexUtility.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,19 @@ public LayoutBlockLineMarkerXmlTagDecorator(XmlTag xmlTag) {
111111
super(xmlTag);
112112
}
113113

114+
@NotNull
114115
@Override
116+
protected String getAreaName() {
117+
return xmlTag.getContainingFile().getVirtualFile().getParent().getParent().getName();
118+
}
119+
115120
@NotNull
116-
@NonNls
117-
public String getName() {
121+
@Override
122+
public String getDescription() {
118123
String name = xmlTag.getAttributeValue("name");
119124
if (name != null) {
120-
return String.format("[%s] block %s", getAreaName(), name);
125+
return String.format("block %s", name);
121126
}
122127
return xmlTag.getName();
123128
}
124-
125-
@NotNull
126-
@Override
127-
protected String getAreaName() {
128-
return xmlTag.getContainingFile().getVirtualFile().getParent().getParent().getName();
129-
}
130129
}

src/com/magento/idea/magento2plugin/xml/webapi/index/WebApiTypesFileBasedIndex.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ public WebApiLineMarkerXmlTagDecorator(XmlTag xmlTag) {
173173
super(xmlTag);
174174
}
175175

176+
@NotNull
177+
@Override
178+
public String getDescription() {
179+
return "";
180+
}
181+
176182
@Override
177183
@NotNull
178184
@NonNls

0 commit comments

Comments
 (0)