public EnumConstantImpl(final JavaEnumSource parent) { init(parent); this.enumConstant = ast.newEnumConstantDeclaration(); }
public EnumConstantImpl(final JavaEnumSource parent) { init(parent); this.enumConstant = ast.newEnumConstantDeclaration(); }
/** * Add a constant to a Java 5 enum definition. This method is used for enums which use the name as the value. * * @param value constant * @param doc documentation text, or <code>null</code> if none */ public void addEnumConstant(String value, String doc) { if (m_class instanceof EnumDeclaration) { EnumConstantDeclaration enumdecl = getAST().newEnumConstantDeclaration(); enumdecl.setName(getAST().newSimpleName(value)); addJavaDoc(doc, enumdecl); ((EnumDeclaration)m_class).enumConstants().add(enumdecl); } else { // should not be possible, but just in case of added types in future throw new IllegalStateException("Internal error - cannot add constant to class type"); } }
/** * Add a constant to a Java 5 enum definition. This method is used for enums which have a value separate from the * name. * * @param name constant * @param doc documentation text, or <code>null</code> if none * @param value Value */ public void addEnumConstant(String name, String doc, String value) { if (m_class instanceof EnumDeclaration) { EnumConstantDeclaration enumdecl = getAST().newEnumConstantDeclaration(); enumdecl.setName(getAST().newSimpleName(name)); StringLiteral strlit = getAST().newStringLiteral(); strlit.setLiteralValue(value); enumdecl.arguments().add(strlit); addJavaDoc(doc, enumdecl); ((EnumDeclaration)m_class).enumConstants().add(enumdecl); } else { // should not be possible, but just in case of added types in future throw new IllegalStateException("Internal error - cannot add constant to class type"); } }
.getOwnedLiterals(); for (EnumerationLiteral enumLiteral : enumerationLiterals) { EnumConstantDeclaration ec = ast.newEnumConstantDeclaration(); ec.setName(ast.newSimpleName(enumLiteral.getName().toUpperCase())); generateClassJavadoc(enumLiteral, ast, ec);
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) { SimpleName node= fOriginalNode; ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast= newTypeDecl.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); return rewrite; } return null; }
EnumConstantDeclaration enumConstantDeclaration = ast.newEnumConstantDeclaration();
EnumConstantDeclaration enumConstantDeclaration = ast.newEnumConstantDeclaration();
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) throws CoreException { SimpleName node= fOriginalNode; ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast= newTypeDecl.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME); return rewrite; } return null; }
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) { SimpleName node= fOriginalNode; ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast= newTypeDecl.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME); return rewrite; } return null; }
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) { SimpleName node= fOriginalNode; ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast= newTypeDecl.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME); return rewrite; } return null; }
final EnumConstantDeclaration l = ast.newEnumConstantDeclaration();
} else if (bodyDeclaration instanceof EnumConstantDeclaration) { EnumConstantDeclaration constantDeclaration= (EnumConstantDeclaration) bodyDeclaration; EnumConstantDeclaration newConstDeclaration= targetAst.newEnumConstantDeclaration(); newConstDeclaration.setName((SimpleName) ASTNode.copySubtree(targetAst, constantDeclaration.getName())); AnonymousClassDeclaration anonymousDeclaration= constantDeclaration.getAnonymousClassDeclaration();
} else if (bodyDeclaration instanceof EnumConstantDeclaration) { EnumConstantDeclaration constantDeclaration= (EnumConstantDeclaration) bodyDeclaration; EnumConstantDeclaration newConstDeclaration= targetAst.newEnumConstantDeclaration(); newConstDeclaration.setName((SimpleName) ASTNode.copySubtree(targetAst, constantDeclaration.getName())); AnonymousClassDeclaration anonymousDeclaration= constantDeclaration.getAnonymousClassDeclaration();
} else if (bodyDeclaration instanceof EnumConstantDeclaration) { EnumConstantDeclaration constantDeclaration= (EnumConstantDeclaration) bodyDeclaration; EnumConstantDeclaration newConstDeclaration= targetAst.newEnumConstantDeclaration(); newConstDeclaration.setName((SimpleName) ASTNode.copySubtree(targetAst, constantDeclaration.getName())); AnonymousClassDeclaration anonymousDeclaration= constantDeclaration.getAnonymousClassDeclaration();
} else if (bodyDeclaration instanceof EnumConstantDeclaration) { EnumConstantDeclaration constantDeclaration= (EnumConstantDeclaration) bodyDeclaration; EnumConstantDeclaration newConstDeclaration= targetAst.newEnumConstantDeclaration(); newConstDeclaration.setName((SimpleName) ASTNode.copySubtree(targetAst, constantDeclaration.getName())); AnonymousClassDeclaration anonymousDeclaration= constantDeclaration.getAnonymousClassDeclaration();