Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.MemberValuePair


      {
         for (Object v : ((NormalAnnotation) annotation).values())
         {
            if (v instanceof MemberValuePair)
            {
               MemberValuePair pair = (MemberValuePair) v;
               if (pair.getName().getFullyQualifiedName().equals(name))
               {
                  @SuppressWarnings("unchecked")
                  final E result = (E) pair.getValue();
                  return result;
               }
            }
         }
      }
View Full Code Here


    List values= annotation.values();
   
    if(null != values && !values.isEmpty()) {
      for(int i= 0; i < values.size(); i++) {
        MemberValuePair pair= (MemberValuePair) values.get(i);
        String name = pair.getName().toString();
        if(DEPENDS_ON_METHODS.equals(name)) {
          m_dependsOnMethods.addAll(extractValues(pair.getValue()));
        }
        else if(DEPENDS_ON_GROUPS.equals(name)) {
          m_dependsOnGroups.addAll(extractValues(pair.getValue()));
        }
      }
    }
   
    return false;
View Full Code Here

      MethodDeclaration md = e.getKey();
      Annotation ignored = e.getValue();
      // Add the @Test(enabled = false)
      NormalAnnotation test = ast.newNormalAnnotation();
      test.setTypeName(ast.newName("Test"));
      MemberValuePair mvp = ast.newMemberValuePair();
      mvp.setName(ast.newSimpleName("enabled"));
      mvp.setValue(ast.newBooleanLiteral(false));
      test.values().add(mvp);
      result.remove(ignored, null);
      ListRewrite lr = result.getListRewrite(md, MethodDeclaration.MODIFIERS2_PROPERTY);
      lr.insertFirst(test, null);
    }
View Full Code Here

      result = ast.newMarkerAnnotation();
    }
    result.setTypeName(ast.newName(name));
    if (attributes != null) {
      for (Entry<String, Boolean> a : attributes.entrySet()) {
        MemberValuePair mvp = ast.newMemberValuePair();
        mvp.setName(ast.newSimpleName(a.getKey()));
        mvp.setValue(ast.newBooleanLiteral(a.getValue()));
        normalAnnotation.values().add(mvp);
      }
    }
    return result;
  }
View Full Code Here

      } else if (methodName.startsWith("_test") || (methodName.startsWith("test") && isPrivate)) {
        m_disabledTestMethods.add(md);
      }
    }  else if (hasAnnotation(md, "Test")) {
      m_hasTestMethods = true// to make sure we import org.testng.annotations.Test
      MemberValuePair mvp = getAttribute(md, "expected");
      if (mvp != null) {
        m_testsWithExpected.put(mvp, "expectedExceptions");
      }
      mvp = getAttribute(md, "timeout");
      if (mvp != null) {
View Full Code Here

      if (m.isAnnotation()) {
        Annotation a = (Annotation) m;
        if ("Test".equals(a.getTypeName().toString()) && a instanceof NormalAnnotation) {
          NormalAnnotation na = (NormalAnnotation) a;
          for (Object o : na.values()) {
            MemberValuePair mvp = (MemberValuePair) o;
            if (mvp.getName().toString().equals(attribute)) return mvp;
          }
        }
      }
    }
View Full Code Here

   
    List values= annotation.values();
   
    if(null != values && !values.isEmpty()) {
      for(int i= 0; i < values.size(); i++) {
        MemberValuePair pair= (MemberValuePair) values.get(i);
        if("parameters".equals(pair.getName().toString())) {
          Expression paramAttr= pair.getValue();
          if(paramAttr instanceof ArrayInitializer) {
            record((MethodDeclaration) annotation.getParent(), (ArrayInitializer) paramAttr);
          } else if (paramAttr instanceof StringLiteral) {
            record((MethodDeclaration) annotation.getParent(), (StringLiteral) paramAttr);
          }
View Full Code Here

    return false;
  }

  private void findAnnotationRequiredToRemove(BodyDeclaration decl, IInvocationContext context) {
    Set<Annotation> annotations = ProposalCalculatorUtil.findAnnotations("Autowired", decl);
    MemberValuePair valuePair = ProposalCalculatorUtil.getRequiredMemberValuePair(decl);
    if (valuePair != null) {
      if (valuePair.getValue() instanceof BooleanLiteral
          && ((BooleanLiteral) valuePair.getValue()).booleanValue()) {
        valuePairs.add(valuePair);
      }
    }
    else if (annotations.size() > 0) {
      annotations.addAll(annotations);
View Full Code Here

    // add required=false to annotation
    else {
      NormalAnnotation newAnnotation = ast.newNormalAnnotation();
      newAnnotation.setTypeName(ast.newSimpleName(annotation.getTypeName().getFullyQualifiedName()));

      MemberValuePair requiredValue = ast.newMemberValuePair();
      requiredValue.setName(ast.newSimpleName("required"));
      requiredValue.setValue(ast.newBooleanLiteral(false));
      newAnnotation.values().add(requiredValue);

      astRewrite.replace(annotation, newAnnotation, null);
    }
View Full Code Here

          edit.addChild(importEdit);
        }

        ListRewrite listRewrite = astRewrite.getListRewrite(annotation, NormalAnnotation.VALUES_PROPERTY);
        AST annotationAST = annotation.getAST();
        MemberValuePair pair = annotationAST.newMemberValuePair();
        pair.setName(annotationAST.newSimpleName("method"));

        QualifiedName valueName = annotationAST.newQualifiedName(annotationAST.newSimpleName("RequestMethod"),
            annotationAST.newSimpleName(methodTypeString));
        pair.setValue(valueName);
        listRewrite.insertFirst(pair, null);
      }

      astRewrite.getListRewrite(decl, MethodDeclaration.MODIFIERS2_PROPERTY).insertFirst(annotation, null);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.MemberValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.