Package org.eclipse.jdt.core.dom

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


            MarkerAnnotation markerAnnotation = (MarkerAnnotation)annotation;
            return AnnotationMetadata.markerAnnotation(JavaMetadataUtil.getName(markerAnnotation.getTypeName()));
        }

        if (annotation instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation)annotation;
            return AnnotationMetadata.singleMemberAnnotation(JavaMetadataUtil.getName(singleMemberAnnotation.getTypeName()),
                                                             JavaMetadataUtil.expressionString(singleMemberAnnotation.getValue()));
        }

        return null;
    }
View Full Code Here


   public String getLiteralValue() throws IllegalStateException
   {
      String result = null;
      if (isSingleValue())
      {
         SingleMemberAnnotation sm = (SingleMemberAnnotation) annotation;
         result = sm.getValue().toString();
      }
      else if (isNormal())
      {
         List<ValuePair> values = getValues();
         for (ValuePair pair : values)
View Full Code Here

         convertTo(AnnotationType.SINGLE);
      }

      if (isSingleValue())
      {
         SingleMemberAnnotation sa = (SingleMemberAnnotation) annotation;

         String stub = "@" + getName() + "(" + value + ") public class Stub { }";
         JavaClass<?> temp = Roaster.parse(JavaClass.class, stub);

         SingleMemberAnnotation anno = (SingleMemberAnnotation) temp.getAnnotations().get(0).getInternal();

         Expression expression = anno.getValue();
         sa.setValue((Expression) ASTNode.copySubtree(ast, expression));
      }
      else
      {
         setLiteralValue(DEFAULT_VALUE, value);
View Full Code Here

   @Override
   public AnnotationSource<O> getAnnotationValue()
   {
      if (isSingleValue())
      {
         SingleMemberAnnotation single = (SingleMemberAnnotation) annotation;
         Expression value = single.getValue();
         if (value instanceof org.eclipse.jdt.core.dom.Annotation)
         {
            return new Nested(this, value);
         }
      }
View Full Code Here

   public String getLiteralValue() throws IllegalStateException
   {
      String result = null;
      if (isSingleValue())
      {
         SingleMemberAnnotation sm = (SingleMemberAnnotation) annotation;
         result = sm.getValue().toString();
      }
      else if (isNormal())
      {
         List<ValuePair> values = getValues();
         for (ValuePair pair : values)
View Full Code Here

         convertTo(AnnotationType.SINGLE);
      }

      if (isSingleValue())
      {
         SingleMemberAnnotation sa = (SingleMemberAnnotation) annotation;

         String stub = "@" + getName() + "(" + value + ") public class Stub { }";
         JavaClass temp = (JavaClass) JavaParser.parse(stub);

         SingleMemberAnnotation anno = (SingleMemberAnnotation) temp.getAnnotations().get(0).getInternal();

         Expression expression = anno.getValue();
         sa.setValue((Expression) ASTNode.copySubtree(ast, expression));
      }
      else
      {
         setLiteralValue(DEFAULT_VALUE, value);
View Full Code Here

   @Override
   public Annotation<O> getAnnotationValue()
   {
      if (isSingleValue())
      {
         SingleMemberAnnotation single = (SingleMemberAnnotation) annotation;
         Expression value = single.getValue();
         if (value instanceof org.eclipse.jdt.core.dom.Annotation)
         {
            return new Nested(this, value);
         }
      }
View Full Code Here

    // Is this class annotated with @RunWith(Parameterized.class)?
    //
    List<IExtendedModifier> modifiers = td.modifiers();
    for (IExtendedModifier m : modifiers) {
      if (m.isAnnotation() && m instanceof SingleMemberAnnotation) {
        SingleMemberAnnotation a = (SingleMemberAnnotation) m;
        if ("RunWith".equals(a.getTypeName().toString()) &&
            "Parameterized.class".equals(a.getValue().toString())) {
          m_runWithParameterized = a;
        }
      }
    }
View Full Code Here

    }

    //
    // Convert @RunWith(Parameterized.class)
    //
    SingleMemberAnnotation runWith = visitor.getRunWithParameterized();
    if (runWith != null) {
      // Remove @RunWith
      result.remove(runWith, null);

      // Add imports
View Full Code Here

    if (exceptionNames.isEmpty()) {
      MarkerAnnotation mAnnotation = ast.newMarkerAnnotation();
      annotation = mAnnotation;
    }
    else {
      SingleMemberAnnotation sAnnotation = ast.newSingleMemberAnnotation();
      annotation = sAnnotation;
      Expression value;
      if (exceptionNames.size() == 1) {
        TypeLiteral typeLiteral = getTypeLiteral(exceptionNames.get(0), ast);
        value = typeLiteral;
        addLinkedPosition(astRewrite.track(typeLiteral.getType()), true, "ExceptionHandler");
      }
      else {
        ArrayInitializer arrayInitializer = ast.newArrayInitializer();
        List<Expression> expressions = arrayInitializer.expressions();
        for (int i = 0; i < exceptionNames.size(); i++) {
          String exceptionName = exceptionNames.get(i);
          TypeLiteral typeLiteral = getTypeLiteral(exceptionName, ast);
          addLinkedPosition(astRewrite.track(typeLiteral.getType()), i == 0, "ExceptionHandler" + i);
          expressions.add(typeLiteral);
        }

        value = arrayInitializer;
      }
      sAnnotation.setValue(value);
    }

    SimpleName name = ast.newSimpleName("ExceptionHandler");
    annotation.setTypeName(name);
View Full Code Here

TOP

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

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.