コード例 #1
0
 public static ElementPattern<PsiElement> getDocBlockTag() {
   return PlatformPatterns.or(
       PlatformPatterns.psiElement()
           .withSuperParent(1, PhpDocPsiElement.class)
           .withParent(PhpDocComment.class)
           .withLanguage(PhpLanguage.INSTANCE),
       // eap:
       // * @<completion>
       //
       // "@" char is not detected on lexer, so provider additional asterisk check for more secured
       // pattern filter
       PlatformPatterns.psiElement()
           .afterLeafSkipping(
               PlatformPatterns.or(PlatformPatterns.psiElement(PsiWhiteSpace.class)),
               PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_LEADING_ASTERISK))
           .withSuperParent(1, PhpDocPsiElement.class)
           .withLanguage(PhpLanguage.INSTANCE));
 }
 /** foo: b<caret>ar foo: [ b<caret>ar ] foo: { b<caret>ar } foo: - b<caret>ar */
 private PsiElementPattern.Capture<PsiElement> getGlobalServiceStringPattern() {
   return PlatformPatterns.psiElement()
       .withParent(
           PlatformPatterns.or(
               PlatformPatterns.psiElement(YAMLKeyValue.class),
               PlatformPatterns.psiElement(YAMLSequence.class),
               PlatformPatterns.psiElement(YAMLArray.class),
               PlatformPatterns.psiElement(YAMLHash.class)));
 }
コード例 #3
0
 /** return 'value' inside class method */
 public static ElementPattern<PhpExpression> getMethodReturnPattern() {
   return PlatformPatterns.or(
       PlatformPatterns.psiElement(StringLiteralExpression.class)
           .withParent(PlatformPatterns.psiElement(PhpReturn.class).inside(Method.class))
           .withLanguage(PhpLanguage.INSTANCE),
       PlatformPatterns.psiElement(ClassConstantReference.class)
           .withParent(PlatformPatterns.psiElement(PhpReturn.class).inside(Method.class))
           .withLanguage(PhpLanguage.INSTANCE));
 }
コード例 #4
0
 /** matches "@Callback(propertyName="<value>")" */
 public static PsiElementPattern.Capture<StringLiteralExpression> getPropertyIdentifierValue(
     String propertyName) {
   return PlatformPatterns.psiElement(StringLiteralExpression.class)
       .afterLeafSkipping(
           PlatformPatterns.or(
               PlatformPatterns.psiElement(PsiWhiteSpace.class),
               PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText("=")),
           PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText(propertyName))
       .withParent(PlatformPatterns.psiElement(PhpDocElementTypes.phpDocAttributeList));
 }
コード例 #5
0
 /**
  * fire on: @Callback(<completion>), @Callback("", <completion>) * @ORM\Column( <completion>, )
  */
 public static ElementPattern<PsiElement> getDocAttribute() {
   return PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER)
       .afterLeafSkipping(
           PlatformPatterns.psiElement(PsiWhiteSpace.class),
           PlatformPatterns.or(
               PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_COMMA),
               PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_LPAREN),
               PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_LEADING_ASTERISK)))
       .inside(PlatformPatterns.psiElement(PhpDocElementTypes.phpDocTag))
       .withLanguage(PhpLanguage.INSTANCE);
 }
コード例 #6
0
  /**
   * $this->methodName('service_name') $this->methodName(SERVICE::NAME)
   * $this->methodName($this->name)
   */
  public static boolean isMethodWithFirstStringOrFieldReference(
      PsiElement psiElement, String... methodName) {

    if (!PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE)
        .withChild(
            PlatformPatterns.psiElement(PhpElementTypes.PARAMETER_LIST)
                .withFirstChild(
                    PlatformPatterns.or(
                        PlatformPatterns.psiElement(PhpElementTypes.STRING),
                        PlatformPatterns.psiElement(PhpElementTypes.FIELD_REFERENCE),
                        PlatformPatterns.psiElement(PhpElementTypes.CLASS_CONSTANT_REFERENCE))))
        .accepts(psiElement)) {

      return false;
    }

    // cant we move it up to PlatformPatterns? withName condition dont looks working
    String methodRefName = ((MethodReference) psiElement).getName();

    return null != methodRefName && Arrays.asList(methodName).contains(methodRefName);
  }