2020import org .jetbrains .annotations .NotNull ;
2121
2222public 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- }
3623
3724 /**
3825 * Fill text buffer with plugin methods.
@@ -43,27 +30,30 @@ public static FillTextBufferWithPluginMethods getInstance() {
4330 * @param textBuf StringBuffer
4431 * @param pluginMethods PluginMethodData
4532 */
33+ @ SuppressWarnings ("PMD.AvoidInstantiatingObjectsInLoops" )
4634 public void execute (
4735 final @ NotNull Key <Object > targetClassKey ,
4836 final Set <CharSequence > insertedMethodsNames ,
4937 final @ NotNull PhpClassReferenceResolver resolver ,
5038 final @ NotNull StringBuffer textBuf ,
51- final @ NotNull PluginMethodData [] pluginMethods
39+ final @ NotNull PluginMethodData ... pluginMethods
5240 ) {
53- for (PluginMethodData pluginMethod : pluginMethods ) {
41+ for (final PluginMethodData pluginMethod : pluginMethods ) {
5442 insertedMethodsNames .add (pluginMethod .getMethod ().getName ());
55- PhpDocComment comment = pluginMethod .getDocComment ();
43+ final PhpDocComment comment = pluginMethod .getDocComment ();
44+
5645 if (comment != null ) {
5746 textBuf .append (comment .getText ());
5847 }
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 ));
6252 resolver .processElements (processElements );
63- PsiElement targetClass = (PsiElement ) pluginMethod .getTargetMethod ()
53+ final PsiElement targetClass = (PsiElement ) pluginMethod .getTargetMethod ()
6454 .getUserData (targetClassKey );
6555 resolver .processElement (targetClass );
66- PhpReturnType returnType = targetMethod .getReturnType ();
56+ final PhpReturnType returnType = targetMethod .getReturnType ();
6757 if (returnType != null ) {
6858 resolver .processElement (returnType );
6959 }
0 commit comments