Package org.eclipse.jdt.core.dom

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


      }
      Annotation annotation = (Annotation) a;

      LocationInformation locationInfo = null;
      if (node instanceof NormalAnnotation) {
        NormalAnnotation normalAnnotation = (NormalAnnotation) node;
        @SuppressWarnings("unchecked")
        List<MemberValuePair> pairs = normalAnnotation.values();

        for (MemberValuePair pair : pairs) {
          Expression expression = pair.getValue();
          if (expression instanceof StringLiteral) {
            locationInfo = getLocationInformation((StringLiteral) expression, javaContext);
View Full Code Here


        node = assistContext.getCoveredNode();
      }

      LocationInformation locationInfo = null;
      if (node instanceof NormalAnnotation) {
        NormalAnnotation normalAnnotation = (NormalAnnotation) node;
        @SuppressWarnings("unchecked")
        List<MemberValuePair> pairs = normalAnnotation.values();

        for (MemberValuePair pair : pairs) {
          Expression expression = pair.getValue();
          if (expression instanceof StringLiteral) {
            locationInfo = getLocationInformation((StringLiteral) expression, javaContext);
View Full Code Here

      }
      Annotation annotation = (Annotation) a;

      LocationInformation locationInfo = null;
      if (node instanceof NormalAnnotation) {
        NormalAnnotation normalAnnotation = (NormalAnnotation) node;
        @SuppressWarnings("unchecked")
        List<MemberValuePair> pairs = normalAnnotation.values();

        for (MemberValuePair pair : pairs) {
          Expression expression = pair.getValue();
          if (expression instanceof StringLiteral) {
            locationInfo = getLocationInformation((StringLiteral) expression, javaContext);
View Full Code Here

        if (value instanceof StringLiteral) {
          return ((StringLiteral) value).getLiteralValue();
        }
      }
      else if (annotation.isNormalAnnotation()) {
        NormalAnnotation nAnnotation = (NormalAnnotation) annotation;
        @SuppressWarnings("unchecked")
        List<MemberValuePair> valuePairs = nAnnotation.values();
        for (MemberValuePair valuePair : valuePairs) {
          if ("value".equals(valuePair.getName().getIdentifier())) {
            Expression value = valuePair.getValue();
            if (value instanceof StringLiteral) {
              return ((StringLiteral) value).getLiteralValue();
View Full Code Here

      return astRewrite;
    }

    // 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);
    }

    return astRewrite;
View Full Code Here

  @SuppressWarnings("unchecked")
  public static MemberValuePair getRequiredMemberValuePair(BodyDeclaration decl) {
    Set<Annotation> annotations = ProposalCalculatorUtil.findAnnotations("Autowired", decl);
    for (Annotation annotation : annotations) {
      if (annotation instanceof NormalAnnotation) {
        NormalAnnotation normalAnnotation = (NormalAnnotation) annotation;
        List<MemberValuePair> values = normalAnnotation.values();
        for (MemberValuePair valuePair : values) {
          if ("required".equals(valuePair.getName().toString())) {
            return valuePair;
          }
        }
View Full Code Here

    if (annotation instanceof SingleMemberAnnotation) {
      SingleMemberAnnotation sAnnotation = (SingleMemberAnnotation) annotation;
      return getUriTemplateVariables(sAnnotation.getValue());
    }
    else if (annotation instanceof NormalAnnotation) {
      NormalAnnotation nAnnotation = (NormalAnnotation) annotation;
      List<MemberValuePair> pairs = nAnnotation.values();
      for (MemberValuePair pair : pairs) {
        if ("value".equals(pair.getName().getFullyQualifiedName())) {
          return getUriTemplateVariables(pair.getValue());
        }
      }
View Full Code Here

      else if (methodType == Method.POST) {
        methodTypeString = "POST";
      }

      ASTRewrite astRewrite = ASTRewrite.create(decl.getAST());
      NormalAnnotation annotation = astRewrite.getAST().newNormalAnnotation();

      annotation.setTypeName(astRewrite.getAST().newSimpleName("RequestMapping")); //$NON-NLS-1$
      if (methodTypeString != null) {
        importEdit = JdtQuickfixUtils.getTextEditForImport(cu, REQUEST_METHOD_IMPORT);
        if (importEdit != null) {
          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));
View Full Code Here

    if (importEdit != null) {
      edit.addChild(importEdit);
    }

    ASTRewrite astRewrite = ASTRewrite.create(decl.getAST());
    NormalAnnotation annotation = astRewrite.getAST().newNormalAnnotation();

    annotation.setTypeName(astRewrite.getAST().newSimpleName("RequestMapping"));
    astRewrite.getListRewrite(decl, TypeDeclaration.MODIFIERS2_PROPERTY).insertFirst(annotation, null);

    ITrackedNodePosition tracker = astRewrite.track(annotation.getTypeName());
    edit.addChild(astRewrite.rewriteAST());

    edit.apply(document);

    setReplacementOffset(tracker.getStartPosition() + annotation.getTypeName().getFullyQualifiedName().length() + 1);
  }
View Full Code Here

        return proposals;
      }

      LocationInformation locationInfo = null;
      if (node instanceof NormalAnnotation) {
        NormalAnnotation normalAnnotation = (NormalAnnotation) node;
        @SuppressWarnings("unchecked")
        List<MemberValuePair> pairs = normalAnnotation.values();

        for (MemberValuePair pair : pairs) {
          Expression expression = pair.getValue();
          if (expression instanceof StringLiteral) {
            locationInfo = getLocationInformation((StringLiteral) expression, javaContext);
View Full Code Here

TOP

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

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.