@@ -716,21 +716,43 @@ public static ElementPattern<PsiElement> getTaggedServicePattern() {
716716 * _defaults:
717717 * bind:
718718 * $<caret>: ''
719+ *
720+ * _defaults:
721+ * bind:
722+ * $<caret>
719723 */
720- static PsiElementPattern .Capture <PsiElement > getNamedDefaultBindPattern () {
721- return PlatformPatterns .psiElement (YAMLTokenTypes .SCALAR_KEY ).withText (PlatformPatterns .string ().startsWith ("$" )).withParent (
722- PlatformPatterns .psiElement (YAMLKeyValue .class ).withParent (PlatformPatterns .psiElement (YAMLMapping .class ).withParent (PlatformPatterns .psiElement (YAMLKeyValue .class ).with (new PatternCondition <YAMLKeyValue >("KeyText" ) {
723- @ Override
724- public boolean accepts (@ NotNull YAMLKeyValue yamlKeyValue , ProcessingContext context ) {
725- return "bind" .equals (yamlKeyValue .getKeyText ());
726- }
727- }).withParent (PlatformPatterns .psiElement (YAMLMapping .class ).withParent (PlatformPatterns .psiElement (YAMLKeyValue .class ).with (new PatternCondition <YAMLKeyValue >("KeyText" ) {
728- @ Override
729- public boolean accepts (@ NotNull YAMLKeyValue yamlKeyValue , ProcessingContext context ) {
730- return "_defaults" .equals (yamlKeyValue .getKeyText ());
731- }
732- })))))
724+ static ElementPattern <PsiElement > getNamedDefaultBindPattern () {
725+ // "__defaults" key
726+ PsiElementPattern .Capture <YAMLMapping > defaultsKey = PlatformPatterns .psiElement (YAMLMapping .class ).withParent (PlatformPatterns .psiElement (YAMLKeyValue .class ).with (new PatternCondition <YAMLKeyValue >("KeyText" ) {
727+ @ Override
728+ public boolean accepts (@ NotNull YAMLKeyValue yamlKeyValue , ProcessingContext context ) {
729+ return "_defaults" .equals (yamlKeyValue .getKeyText ());
730+ }
731+ }));
732+
733+ // "bind" bind
734+ PsiElementPattern .Capture <YAMLMapping > bindKey = PlatformPatterns .psiElement (YAMLMapping .class ).withParent (PlatformPatterns .psiElement (YAMLKeyValue .class ).with (new PatternCondition <YAMLKeyValue >("KeyText" ) {
735+ @ Override
736+ public boolean accepts (@ NotNull YAMLKeyValue yamlKeyValue , ProcessingContext context ) {
737+ return "bind" .equals (yamlKeyValue .getKeyText ());
738+ }
739+ }).withParent (defaultsKey ));
740+
741+ // complete code
742+ // bind:
743+ // $<caret>: ''
744+ PsiElementPattern .Capture <PsiElement > argumentPattern = PlatformPatterns .psiElement (YAMLTokenTypes .SCALAR_KEY ).withText (PlatformPatterns .string ().startsWith ("$" )).withParent (
745+ PlatformPatterns .psiElement (YAMLKeyValue .class ).withParent (bindKey )
733746 );
747+
748+ // incomplete code
749+ // bind:
750+ // $<caret>
751+ PsiElementPattern .Capture <PsiElement > incompleteCodePattern = PlatformPatterns .psiElement (YAMLTokenTypes .TEXT ).withText (PlatformPatterns .string ().startsWith ("$" )).withParent (
752+ PlatformPatterns .psiElement (YAMLScalar .class ).withParent (bindKey )
753+ );
754+
755+ return PlatformPatterns .or (argumentPattern , incompleteCodePattern );
734756 }
735757
736758 /**
0 commit comments