@@ -435,6 +435,13 @@ public void addCompletions(@NotNull CompletionParameters parameters, ProcessingC
435
435
new IncompleteEmbedCompletionProvider ()
436
436
);
437
437
438
+ // {% bl => {% block '...'
439
+ extend (
440
+ CompletionType .BASIC ,
441
+ PlatformPatterns .psiElement (TwigTokenTypes .TAG_NAME ),
442
+ new IncompleteBlockCompletionProvider ()
443
+ );
444
+
438
445
// {{ in => {{ include('...')
439
446
extend (
440
447
CompletionType .BASIC ,
@@ -933,6 +940,41 @@ public boolean accepts(@NotNull String s, ProcessingContext processingContext) {
933
940
}
934
941
}
935
942
943
+ /**
944
+ * {% bl => {% block '...'
945
+ */
946
+ private class IncompleteBlockCompletionProvider extends CompletionProvider <CompletionParameters > {
947
+ @ Override
948
+ protected void addCompletions (@ NotNull CompletionParameters completionParameters , @ NotNull ProcessingContext processingContext , @ NotNull CompletionResultSet resultSet ) {
949
+ PsiElement position = completionParameters .getOriginalPosition ();
950
+ if (!Symfony2ProjectComponent .isEnabled (position )) {
951
+ return ;
952
+ }
953
+
954
+ resultSet .restartCompletionOnPrefixChange (StandardPatterns .string ().longerThan (1 ).with (new PatternCondition <>("embed startsWith" ) {
955
+ @ Override
956
+ public boolean accepts (@ NotNull String s , ProcessingContext processingContext ) {
957
+ return "block" .startsWith (s );
958
+ }
959
+ }));
960
+
961
+ if (!isCompletionStartingMatch ("block" , completionParameters , 2 )) {
962
+ return ;
963
+ }
964
+
965
+ Pair <Collection <PsiFile >, Boolean > scopedContext = TwigUtil .findScopedFile (position );
966
+
967
+ Collection <LookupElement > blockLookupElements = TwigUtil .getBlockLookupElements (
968
+ position .getProject (),
969
+ TwigFileUtil .collectParentFiles (scopedContext .getSecond (), scopedContext .getFirst ())
970
+ );
971
+
972
+ for (LookupElement blockLookupElement : blockLookupElements ) {
973
+ resultSet .addElement (LookupElementBuilder .create ("block " + blockLookupElement .getLookupString ()).withIcon (TwigIcons .TwigFileIcon ));
974
+ }
975
+ }
976
+ }
977
+
936
978
@ NotNull
937
979
private Collection <LookupElement > processVariables (@ NotNull PsiElement psiElement , @ NotNull Predicate <PhpType > filter , @ NotNull Function <Map .Entry <String , Pair <String , LookupElement >>, String > map ) {
938
980
Project project = psiElement .getProject ();
0 commit comments