Examples of EnumConstant


Examples of com.bacoder.parser.java.api.EnumConstant

    super(adapters);
  }

  @Override
  public EnumConstant adapt(EnumConstantContext context) {
    EnumConstant enumConstant = createNode(context);

    List<Annotation> annotations =
        transform(context, AnnotationContext.class, new Function<AnnotationContext, Annotation>() {
          @Override
          public Annotation apply(AnnotationContext context) {
            return getAdapter(AnnotationAdapter.class).adapt(context);
          }
        });
    enumConstant.setAnnotations(annotations);

    TerminalNode identifierNode = getTerminalNode(context, JavaParser.Identifier);
    if (identifierNode != null) {
      enumConstant.setName(getAdapter(IdentifierAdapter.class).adapt(identifierNode));
    }

    ArgumentsContext argumentsContext = getChild(context, ArgumentsContext.class);
    if (argumentsContext != null) {
      enumConstant.setArguments(getAdapter(ArgumentsAdapter.class).adapt(argumentsContext));
    }

    ClassBodyContext classBodyContext = getChild(context, ClassBodyContext.class);
    if (classBodyContext != null) {
      enumConstant.setMemberDeclarations(
          getAdapter(ClassBodyAdapter.class).adapt(classBodyContext));
    }

    return enumConstant;
  }
View Full Code Here

Examples of lombok.ast.EnumConstant

    if (values != null) for (Node n : values) body.rawMembers().addToEnd(n);
    return posify(body);
  }
 
  public Node createEnumConstant(List<Node> annotations, Node name, Node arguments, Node body) {
    EnumConstant result = new EnumConstant().astName(createIdentifierIfNeeded(name, currentPos())).rawBody(body);
    if (annotations != null) for (Node n : annotations) if (n != null) result.rawAnnotations().addToEnd(n);
    if (arguments instanceof TemporaryNode.MethodArguments) {
      for (Node arg : ((TemporaryNode.MethodArguments)arguments).arguments) {
        result.rawArguments().addToEnd(arg);
      }
    }
    return posify(result);
  }
View Full Code Here

Examples of lombok.ast.EnumConstant

        for (JCTree def : node.defs) {
          if (def instanceof JCVariableDecl) {
            JCVariableDecl vd = (JCVariableDecl) def;
            if (vd.mods != null && (vd.mods.flags & ENUM_CONSTANT_FLAGS) == ENUM_CONSTANT_FLAGS) {
              // This is an enum constant, not a field of the enum class.
              EnumConstant ec = new EnumConstant();
              setPos(def, ec);
              ec.astName(new Identifier().astValue(vd.getName().toString()));
              fillList(vd.mods.annotations, ec.rawAnnotations());
              if (vd.init instanceof JCNewClass) {
                JCNewClass init = (JCNewClass) vd.init;
                fillList(init.getArguments(), ec.rawArguments());
                if (init.getClassBody() != null) {
                  NormalTypeBody constantBody = setPos(init, new NormalTypeBody());
                  fillList(init.getClassBody().getMembers(), constantBody.rawMembers());
                  ec.astBody(constantBody);
                }
                setConversionPositionInfo(ec, "newClass", getPosition(init));
              }
              body.astConstants().addToEnd(ec);
              continue;
View Full Code Here

Examples of org.jboss.forge.roaster.model.EnumConstant

   @Test
   @SuppressWarnings("rawtypes")
   public void testAddEnumConstant()
   {
      int i = javaEnum.getEnumConstants().size();
      EnumConstant enumConstant = javaEnum.addEnumConstant().setName("BLAH");
      assertEquals(i + 1, javaEnum.getEnumConstants().size());
      assertEquals("BLAH", enumConstant.getName());
   }
View Full Code Here

Examples of org.jboss.forge.roaster.model.EnumConstant

   @Test
   @SuppressWarnings("rawtypes")
   public void testAddEnumConstantFromDeclaration()
   {
      int i = javaEnum.getEnumConstants().size();
      EnumConstant enumConstant = javaEnum.addEnumConstant("BLAH");
      assertEquals(i + 1, javaEnum.getEnumConstants().size());
      assertEquals("BLAH", enumConstant.getName());
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.