@@ -175,11 +175,8 @@ public static ElementPattern<PsiElement> getPrintBlockOrTagFunctionPattern(Strin
175175
176176 /**
177177 * Check for {{ include('|') }}, {% include('|') %}
178- *
179- * @param functionName twig function name
180178 */
181179 public static ElementPattern <PsiElement > getPrintBlockOrTagFunctionPattern () {
182- //noinspection unchecked
183180 return PlatformPatterns
184181 .psiElement (TwigTokenTypes .STRING_TEXT )
185182 .withParent (
@@ -579,17 +576,19 @@ static ElementPattern<PsiElement> getPrintBlockFunctionPattern() {
579576 .withLanguage (TwigLanguage .INSTANCE );
580577 }
581578
582- public static ElementPattern <PsiElement > getFunctionPattern (@ NotNull String ...functionName ) {
583- return PlatformPatterns .psiElement (TwigElementTypes .FUNCTION_CALL ).withText (PlatformPatterns .string ().with (new PatternCondition <String >("Twig: Function call" ) {
584- @ Override
585- public boolean accepts (@ NotNull String function , ProcessingContext processingContext ) {
586- String funcWithoutSpace = function .replaceAll (" +" , "" );
587-
588- return Arrays .stream (functionName ).anyMatch (wantFunction ->
589- funcWithoutSpace .startsWith (wantFunction + "(" ) || funcWithoutSpace .equals (wantFunction )
590- );
591- }
592- }));
579+ public static ElementPattern <PsiElement > getLeafFunctionPattern (@ NotNull String ...functionName ) {
580+ return PlatformPatterns .psiElement (TwigTokenTypes .IDENTIFIER )
581+ .withParent (PlatformPatterns .psiElement (TwigElementTypes .FUNCTION_CALL ))
582+ .withText (PlatformPatterns .string ().with (new PatternCondition <>("Twig: Leaf function call" ) {
583+ @ Override
584+ public boolean accepts (@ NotNull String function , ProcessingContext processingContext ) {
585+ String funcWithoutSpace = function .replaceAll (" +" , "" );
586+
587+ return Arrays .stream (functionName ).anyMatch (wantFunction ->
588+ funcWithoutSpace .startsWith (wantFunction + "(" ) || funcWithoutSpace .equals (wantFunction )
589+ );
590+ }
591+ }));
593592 }
594593
595594 /**
0 commit comments