20
20
import org .jetbrains .annotations .NotNull ;
21
21
22
22
public class FillTextBufferWithPluginMethods {
23
- private static FillTextBufferWithPluginMethods INSTANCE = null ;
24
-
25
- /**
26
- * Get util instance.
27
- *
28
- * @return FillTextBufferWithPluginMethods
29
- */
30
- public static FillTextBufferWithPluginMethods getInstance () {
31
- if (null == INSTANCE ) {
32
- INSTANCE = new FillTextBufferWithPluginMethods ();
33
- }
34
- return INSTANCE ;
35
- }
36
23
37
24
/**
38
25
* Fill text buffer with plugin methods.
@@ -43,27 +30,30 @@ public static FillTextBufferWithPluginMethods getInstance() {
43
30
* @param textBuf StringBuffer
44
31
* @param pluginMethods PluginMethodData
45
32
*/
33
+ @ SuppressWarnings ("PMD.AvoidInstantiatingObjectsInLoops" )
46
34
public void execute (
47
35
final @ NotNull Key <Object > targetClassKey ,
48
36
final Set <CharSequence > insertedMethodsNames ,
49
37
final @ NotNull PhpClassReferenceResolver resolver ,
50
38
final @ NotNull StringBuffer textBuf ,
51
- final @ NotNull PluginMethodData [] pluginMethods
39
+ final @ NotNull PluginMethodData ... pluginMethods
52
40
) {
53
- for (PluginMethodData pluginMethod : pluginMethods ) {
41
+ for (final PluginMethodData pluginMethod : pluginMethods ) {
54
42
insertedMethodsNames .add (pluginMethod .getMethod ().getName ());
55
- PhpDocComment comment = pluginMethod .getDocComment ();
43
+ final PhpDocComment comment = pluginMethod .getDocComment ();
44
+
56
45
if (comment != null ) {
57
46
textBuf .append (comment .getText ());
58
47
}
59
- Method targetMethod = pluginMethod .getTargetMethod ();
60
- Parameter [] parameters = targetMethod .getParameters ();
61
- Collection <PsiElement > processElements = new ArrayList <>(Arrays .asList (parameters ));
48
+ final Method targetMethod = pluginMethod .getTargetMethod ();
49
+ final Parameter [] parameters = targetMethod .getParameters ();
50
+ final Collection <PsiElement > processElements =
51
+ new ArrayList <>(Arrays .asList (parameters ));
62
52
resolver .processElements (processElements );
63
- PsiElement targetClass = (PsiElement ) pluginMethod .getTargetMethod ()
53
+ final PsiElement targetClass = (PsiElement ) pluginMethod .getTargetMethod ()
64
54
.getUserData (targetClassKey );
65
55
resolver .processElement (targetClass );
66
- PhpReturnType returnType = targetMethod .getReturnType ();
56
+ final PhpReturnType returnType = targetMethod .getReturnType ();
67
57
if (returnType != null ) {
68
58
resolver .processElement (returnType );
69
59
}
0 commit comments