Skip to content

Commit 3f8c4fd

Browse files
committed
Fixed static test failures
1 parent a17b6a3 commit 3f8c4fd

File tree

1 file changed

+34
-19
lines changed

1 file changed

+34
-19
lines changed

src/com/magento/idea/magento2plugin/linemarker/php/PluginTargetLineMarkerProvider.java

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker.php;
67

78
import com.intellij.codeInsight.daemon.LineMarkerInfo;
89
import com.intellij.codeInsight.daemon.LineMarkerProvider;
910
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
1011
import com.intellij.icons.AllIcons;
1112
import com.intellij.psi.PsiElement;
13+
import com.intellij.psi.util.PsiTreeUtil;
14+
import java.util.ArrayList;
15+
import java.util.Collection;
16+
import java.util.HashMap;
17+
import java.util.List;
18+
import org.jetbrains.annotations.NotNull;
19+
import org.jetbrains.annotations.Nullable;
1220
import com.jetbrains.php.PhpIndex;
1321
import com.jetbrains.php.lang.psi.elements.Method;
1422
import com.jetbrains.php.lang.psi.elements.PhpClass;
1523
import com.magento.idea.magento2plugin.magento.files.Plugin;
1624
import com.magento.idea.magento2plugin.project.Settings;
17-
import org.jetbrains.annotations.NotNull;
18-
import org.jetbrains.annotations.Nullable;
1925
import com.magento.idea.magento2plugin.util.magento.plugin.GetTargetClassNamesByPluginClassName;
20-
import com.intellij.psi.util.PsiTreeUtil;
21-
22-
import java.util.*;
2326

2427
public class PluginTargetLineMarkerProvider implements LineMarkerProvider {
2528
@Nullable
@@ -29,23 +32,28 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) {
2932
}
3033

3134
@Override
32-
public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNull Collection<LineMarkerInfo> collection) {
35+
public void collectSlowLineMarkers(
36+
@NotNull List<PsiElement> psiElements,
37+
@NotNull Collection<LineMarkerInfo> collection
38+
) {
3339
if (psiElements.size() > 0) {
3440
if (!Settings.isEnabled(psiElements.get(0).getProject())) {
3541
return;
3642
}
3743
}
3844
PluginClassCache pluginClassCache = new PluginClassCache();
39-
TargetClassesCollector TargetClassesCollector = new TargetClassesCollector(pluginClassCache);
40-
TargetMethodsCollector TargetMethodsCollector = new TargetMethodsCollector(pluginClassCache);
45+
TargetClassesCollector targetClassesCollector =
46+
new TargetClassesCollector(pluginClassCache);
47+
TargetMethodsCollector targetMethodsCollector =
48+
new TargetMethodsCollector(pluginClassCache);
4149

4250
for (PsiElement psiElement : psiElements) {
4351
if (psiElement instanceof PhpClass || psiElement instanceof Method) {
4452
List<? extends PsiElement> results;
4553

4654
if (psiElement instanceof PhpClass) {
47-
results = TargetClassesCollector.collect((PhpClass) psiElement);
48-
if (results.size() > 0 ) {
55+
results = targetClassesCollector.collect((PhpClass) psiElement);
56+
if (results.size() > 0) {
4957
collection.add(NavigationGutterIconBuilder
5058
.create(AllIcons.Nodes.Class)
5159
.setTargets(results)
@@ -54,8 +62,8 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNu
5462
);
5563
}
5664
} else {
57-
results = TargetMethodsCollector.collect((Method) psiElement);
58-
if (results.size() > 0 ) {
65+
results = targetMethodsCollector.collect((Method) psiElement);
66+
if (results.size() > 0) {
5967
collection.add(NavigationGutterIconBuilder
6068
.create(AllIcons.Nodes.Method)
6169
.setTargets(results)
@@ -70,16 +78,21 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNu
7078
}
7179

7280
private static class PluginClassCache {
73-
private HashMap<String, List<PhpClass>> pluginClassesMap = new HashMap<String, List<PhpClass>>();
81+
private HashMap<String, List<PhpClass>> pluginClassesMap =
82+
new HashMap<String, List<PhpClass>>();
7483

75-
List<PhpClass> getTargetClassesForPlugin(@NotNull PhpClass phpClass, @NotNull String classFQN) {
84+
List<PhpClass> getTargetClassesForPlugin(
85+
@NotNull PhpClass phpClass,
86+
@NotNull String classFQN
87+
) {
7688
List<PhpClass> results = new ArrayList<>();
7789

7890
if (pluginClassesMap.containsKey(classFQN)) {
7991
return pluginClassesMap.get(classFQN);
8092
}
8193

82-
GetTargetClassNamesByPluginClassName targetClassesService = GetTargetClassNamesByPluginClassName.getInstance(phpClass.getProject());
94+
GetTargetClassNamesByPluginClassName targetClassesService =
95+
GetTargetClassNamesByPluginClassName.getInstance(phpClass.getProject());
8396
ArrayList<String> targetClassNames = targetClassesService.execute(classFQN);
8497

8598
if (targetClassNames.size() == 0) {
@@ -103,7 +116,9 @@ List<PhpClass> getTargetClassesForPlugin(@NotNull PhpClass phpClass, @NotNull St
103116
}
104117

105118
List<PhpClass> getTargetClassesForPlugin(@NotNull PhpClass phpClass) {
106-
List<PhpClass> classesForPlugin = getTargetClassesForPlugin(phpClass, phpClass.getPresentableFQN());
119+
List<PhpClass> classesForPlugin = getTargetClassesForPlugin(
120+
phpClass, phpClass.getPresentableFQN()
121+
);
107122
for (PhpClass parent: phpClass.getSupers()) {
108123
classesForPlugin.addAll(getTargetClassesForPlugin(parent));
109124
}
@@ -171,8 +186,7 @@ public List<Method> collect(@NotNull Method pluginMethod) {
171186

172187
private String getTargetMethodName(Method pluginMethod, String pluginPrefix) {
173188
String pluginMethodName = pluginMethod.getName();
174-
String targetClassMethodName = pluginMethodName.
175-
replace(pluginPrefix, "");
189+
String targetClassMethodName = pluginMethodName.replace(pluginPrefix, "");
176190
if (targetClassMethodName.isEmpty()) {
177191
return null;
178192
}
@@ -181,7 +195,8 @@ private String getTargetMethodName(Method pluginMethod, String pluginPrefix) {
181195
if (charType == Character.LOWERCASE_LETTER) {
182196
return null;
183197
}
184-
return Character.toLowerCase(firstCharOfTargetName) + targetClassMethodName.substring(1);
198+
return Character.toLowerCase(firstCharOfTargetName)
199+
+ targetClassMethodName.substring(1);
185200
}
186201

187202
private String getPluginPrefix(Method pluginMethod) {

0 commit comments

Comments
 (0)