22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5+
56package com .magento .idea .magento2plugin .linemarker .php ;
67
78import com .intellij .codeInsight .daemon .LineMarkerInfo ;
89import com .intellij .codeInsight .daemon .LineMarkerProvider ;
910import com .intellij .codeInsight .navigation .NavigationGutterIconBuilder ;
1011import com .intellij .icons .AllIcons ;
1112import com .intellij .psi .PsiElement ;
13+ import com .intellij .psi .util .PsiTreeUtil ;
1214import com .jetbrains .php .PhpIndex ;
1315import com .jetbrains .php .lang .psi .elements .Method ;
1416import com .jetbrains .php .lang .psi .elements .PhpClass ;
1517import com .magento .idea .magento2plugin .magento .files .Plugin ;
1618import com .magento .idea .magento2plugin .project .Settings ;
19+ import com .magento .idea .magento2plugin .util .magento .plugin .GetTargetClassNamesByPluginClassName ;
20+ import java .util .ArrayList ;
21+ import java .util .Collection ;
22+ import java .util .HashMap ;
23+ import java .util .List ;
1724import org .jetbrains .annotations .NotNull ;
1825import org .jetbrains .annotations .Nullable ;
19- import com .magento .idea .magento2plugin .util .magento .plugin .GetTargetClassNamesByPluginClassName ;
20- import com .intellij .psi .util .PsiTreeUtil ;
21-
22- import java .util .*;
2326
2427public 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