use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(EnumConstantDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<Expression> args = visit(_n.getArgs(), _arg);
List<BodyDeclaration> classBody = visit(_n.getClassBody(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
EnumConstantDeclaration r = new EnumConstantDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), annotations, _n.getName(), args, classBody);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class LexicalDifferenceCalculatorTest method simpleEnumConstantDeclaration.
@Test
public void simpleEnumConstantDeclaration() throws IOException {
EnumConstantDeclaration ecd = considerEcd("A");
LexicalDifferenceCalculator.CalculatedSyntaxModel csm = new LexicalDifferenceCalculator().calculatedSyntaxModelForNode(ecd);
int i = 0;
assertEquals(new LexicalDifferenceCalculator.CsmChild(ecd.getName()), csm.elements.get(i++));
assertEquals(i, csm.elements.size());
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class TokenKindGenerator method generateEnumEntry.
private void generateEnumEntry(EnumDeclaration kindEnum, String name, IntegerLiteralExpr kind) {
final EnumConstantDeclaration enumEntry = new EnumConstantDeclaration(name);
enumEntry.getArguments().add(kind);
kindEnum.addEntry(enumEntry);
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class PropertyGenerator method generateObservableProperty.
private void generateObservableProperty(EnumDeclaration observablePropertyEnum, PropertyMetaModel property, boolean derived) {
boolean isAttribute = !Node.class.isAssignableFrom(property.getType());
String name = property.getName();
String constantName = camelCaseToScreaming(name.startsWith("is") ? name.substring(2) : name);
EnumConstantDeclaration enumConstantDeclaration = observablePropertyEnum.addEnumConstant(constantName);
if (isAttribute) {
if (property.isEnumSet()) {
enumConstantDeclaration.addArgument("Type.MULTIPLE_ATTRIBUTE");
} else {
enumConstantDeclaration.addArgument("Type.SINGLE_ATTRIBUTE");
}
} else {
if (property.isNodeList()) {
enumConstantDeclaration.addArgument("Type.MULTIPLE_REFERENCE");
} else {
enumConstantDeclaration.addArgument("Type.SINGLE_REFERENCE");
}
}
if (derived) {
enumConstantDeclaration.addArgument("true");
}
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class EnumDeclarationTransformationsTest method addingConstants.
@Test
public void addingConstants() {
EnumDeclaration ed = consider("enum A {" + EOL + " E1" + EOL + "}");
ed.getEntries().addLast(new EnumConstantDeclaration("E2"));
assertTransformedToString("enum A {" + EOL + " E1," + EOL + " E2" + EOL + "}", ed);
}
Aggregations