org.eclipse.jdt.internal.compiler.ast.Annotation.memberValuePairs()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(17.1k)|赞(0)|评价(0)|浏览(189)

本文整理了Java中org.eclipse.jdt.internal.compiler.ast.Annotation.memberValuePairs()方法的一些代码示例,展示了Annotation.memberValuePairs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.memberValuePairs()方法的具体详情如下:
包路径:org.eclipse.jdt.internal.compiler.ast.Annotation
类名称:Annotation
方法名:memberValuePairs

Annotation.memberValuePairs介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public int match(Annotation node, MatchingNodeSet nodeSet) {
  if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
  MemberValuePair[] pairs = node.memberValuePairs();
  if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH;

  int length = pairs.length;
  MemberValuePair pair = null;
  for (int i=0; i<length; i++) {
    pair = node.memberValuePairs()[i];
    if (matchesName(this.pattern.selector, pair.name)) {
      ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair;
      return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
    }
  }
  return IMPOSSIBLE_MATCH;
}
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

public int match(Annotation node, MatchingNodeSet nodeSet) {
  if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
  MemberValuePair[] pairs = node.memberValuePairs();
  if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH;

  int length = pairs.length;
  MemberValuePair pair = null;
  for (int i=0; i<length; i++) {
    pair = node.memberValuePairs()[i];
    if (matchesName(this.pattern.selector, pair.name)) {
      ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair;
      return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
    }
  }
  return IMPOSSIBLE_MATCH;
}
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public int match(Annotation node, MatchingNodeSet nodeSet) {
  if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
  MemberValuePair[] pairs = node.memberValuePairs();
  if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH;

  int length = pairs.length;
  MemberValuePair pair = null;
  for (int i=0; i<length; i++) {
    pair = node.memberValuePairs()[i];
    if (matchesName(this.pattern.selector, pair.name)) {
      ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair;
      return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
    }
  }
  return IMPOSSIBLE_MATCH;
}
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public int match(Annotation node, MatchingNodeSet nodeSet) {
  if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
  MemberValuePair[] pairs = node.memberValuePairs();
  if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH;

  int length = pairs.length;
  MemberValuePair pair = null;
  for (int i=0; i<length; i++) {
    pair = node.memberValuePairs()[i];
    if (matchesName(this.pattern.selector, pair.name)) {
      ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair;
      return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
    }
  }
  return IMPOSSIBLE_MATCH;
}
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

@Override
public int match(Annotation node, MatchingNodeSet nodeSet) {
  if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
  MemberValuePair[] pairs = node.memberValuePairs();
  if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH;

  int length = pairs.length;
  MemberValuePair pair = null;
  for (int i=0; i<length; i++) {
    pair = node.memberValuePairs()[i];
    if (matchesName(this.pattern.selector, pair.name)) {
      ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair;
      return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
    }
  }
  return IMPOSSIBLE_MATCH;
}
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public int match(Annotation node, MatchingNodeSet nodeSet) {
  if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
  MemberValuePair[] pairs = node.memberValuePairs();
  if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH;

  int length = pairs.length;
  MemberValuePair pair = null;
  for (int i=0; i<length; i++) {
    pair = node.memberValuePairs()[i];
    if (matchesName(this.pattern.selector, pair.name)) {
      ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair;
      return nodeSet.addMatch(possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
    }
  }
  return IMPOSSIBLE_MATCH;
}
//public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

boolean isValueProvidedUsingAnnotation(FieldDeclaration fieldDecl) {
  // a member field annotated with @Inject is considered to be initialized by the injector 
  if (fieldDecl.annotations != null) {
    int length = fieldDecl.annotations.length;
    for (int i = 0; i < length; i++) {
      Annotation annotation = fieldDecl.annotations[i];
      if (annotation.resolvedType.id == TypeIds.T_JavaxInjectInject) {
        return true; // no concept of "optional"
      } else if (annotation.resolvedType.id == TypeIds.T_ComGoogleInjectInject) {
        MemberValuePair[] memberValuePairs = annotation.memberValuePairs();
        if (memberValuePairs == Annotation.NoValuePairs)
          return true;
        for (int j = 0; j < memberValuePairs.length; j++) {
          // if "optional=false" is specified, don't rely on initialization by the injector:
          if (CharOperation.equals(memberValuePairs[j].name, TypeConstants.OPTIONAL))
            return memberValuePairs[j].value instanceof FalseLiteral;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

boolean isValueProvidedUsingAnnotation(FieldDeclaration fieldDecl) {
  // a member field annotated with @Inject is considered to be initialized by the injector 
  if (fieldDecl.annotations != null) {
    int length = fieldDecl.annotations.length;
    for (int i = 0; i < length; i++) {
      Annotation annotation = fieldDecl.annotations[i];
      if (annotation.resolvedType.id == TypeIds.T_JavaxInjectInject) {
        return true; // no concept of "optional"
      } else if (annotation.resolvedType.id == TypeIds.T_ComGoogleInjectInject) {
        MemberValuePair[] memberValuePairs = annotation.memberValuePairs();
        if (memberValuePairs == Annotation.NoValuePairs)
          return true;
        for (int j = 0; j < memberValuePairs.length; j++) {
          // if "optional=false" is specified, don't rely on initialization by the injector:
          if (CharOperation.equals(memberValuePairs[j].name, TypeConstants.OPTIONAL))
            return memberValuePairs[j].value instanceof FalseLiteral;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

boolean isValueProvidedUsingAnnotation(FieldDeclaration fieldDecl) {
  // a member field annotated with @Inject is considered to be initialized by the injector 
  if (fieldDecl.annotations != null) {
    int length = fieldDecl.annotations.length;
    for (int i = 0; i < length; i++) {
      Annotation annotation = fieldDecl.annotations[i];
      if (annotation.resolvedType.id == TypeIds.T_JavaxInjectInject) {
        return true; // no concept of "optional"
      } else if (annotation.resolvedType.id == TypeIds.T_ComGoogleInjectInject) {
        MemberValuePair[] memberValuePairs = annotation.memberValuePairs();
        if (memberValuePairs == Annotation.NoValuePairs)
          return true;
        for (int j = 0; j < memberValuePairs.length; j++) {
          // if "optional=false" is specified, don't rely on initialization by the injector:
          if (CharOperation.equals(memberValuePairs[j].name, TypeConstants.OPTIONAL))
            return memberValuePairs[j].value instanceof FalseLiteral;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/ecj

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public void checkRepeatableMetaAnnotation(BlockScope scope) {
  
  // `this' is the @Repeatable meta annotation, its recipient is the *repeatable* annotation type - we are at the declaration site, not the repeating use site.
  
  ReferenceBinding repeatableAnnotationType = (ReferenceBinding) this.recipient; // know it to be an annotation type. On target miss we don't get here
  
  MemberValuePair[] valuePairs = this.memberValuePairs();
  if (valuePairs == null || valuePairs.length != 1)
    return;
  
  Object value = valuePairs[0].compilerElementPair.value;
  if (!(value instanceof ReferenceBinding))
    return; // Has deeper problems, will bark elsewhere.
  ReferenceBinding containerAnnotationType = (ReferenceBinding) value;
  if (!containerAnnotationType.isAnnotationType())
    return; // Has deeper problems, will bark elsewhere.
  
  repeatableAnnotationType.setContainerAnnotationType(containerAnnotationType); // For now. May be reset later to PRB in case of problems.
  checkContainerAnnotationType(valuePairs[0], scope, containerAnnotationType, repeatableAnnotationType, false); // false => not use site, i.e declaration site error reporting requested.
}

代码示例来源:origin: com.amazon.device.tools.build/gradle-core

public AnnotationData createData(@NonNull String name, @NonNull Annotation annotation) {
  MemberValuePair[] pairs = annotation.memberValuePairs();
  if (pairs == null || pairs.length == 0) {
    return new AnnotationData(name);
  }
  return new AnnotationData(name, pairs);
}

代码示例来源:origin: com.android.tools.build/gradle-core

public AnnotationData createData(@NonNull String name, @NonNull Annotation annotation) {
  MemberValuePair[] pairs = annotation.memberValuePairs();
  if (pairs == null || pairs.length == 0) {
    return new AnnotationData(name);
  }
  return new AnnotationData(name, pairs);
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.compiler.apt

private static Annotation findAnnotation(Annotation elementAnnotation, AnnotationBinding annotationBinding) {
  if (annotationBinding == elementAnnotation.getCompilerAnnotation()) {
    return elementAnnotation;
  }
  MemberValuePair[] memberValuePairs = elementAnnotation.memberValuePairs();
  for (MemberValuePair mvp : memberValuePairs) {
    Expression v = mvp.value;
    if (v instanceof Annotation) {
      Annotation a = findAnnotation((Annotation) v, annotationBinding);
      if (a != null) {
        return a;
      }
    } else if (v instanceof ArrayInitializer) {
      Expression[] expressions = ((ArrayInitializer) v).expressions;
      for (Expression e : expressions) {
        if (e instanceof Annotation) {
          Annotation a = findAnnotation((Annotation) e, annotationBinding);
          if (a != null) {
            return a;
          }
        }
      }
    }
  }
  return null;
}

相关文章