List of usage examples for org.eclipse.jdt.core.dom EnumConstantDeclaration getAnonymousClassDeclaration
public AnonymousClassDeclaration getAnonymousClassDeclaration()
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(EnumConstantDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }//from w ww . j av a 2 s . com printModifiers(node.modifiers()); node.getName().accept(this); if (!node.arguments().isEmpty()) { this.fBuffer.append("(");//$NON-NLS-1$ for (Iterator<Expression> it = node.arguments().iterator(); it.hasNext();) { Expression e = it.next(); e.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(")");//$NON-NLS-1$ } if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(EnumConstantDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }//w w w . j a v a 2s.c o m printIndent(); printModifiers(node.modifiers()); node.getName().accept(this); if (!node.arguments().isEmpty()) { this.buffer.append("(");//$NON-NLS-1$ for (Iterator it = node.arguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); e.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(")");//$NON-NLS-1$ } if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }
From source file:com.bsiag.eclipse.jdt.java.formatter.LineBreaksPreparator.java
License:Open Source License
@Override public boolean visit(EnumDeclaration node) { handleBracedCode(node, node.getName(), this.options.brace_position_for_enum_declaration, this.options.indent_body_declarations_compare_to_enum_declaration_header, this.options.insert_new_line_in_empty_enum_declaration); handleBodyDeclarations(node.bodyDeclarations()); List<EnumConstantDeclaration> enumConstants = node.enumConstants(); for (int i = 0; i < enumConstants.size(); i++) { EnumConstantDeclaration declaration = enumConstants.get(i); if (declaration.getJavadoc() != null) this.tm.firstTokenIn(declaration, TokenNameCOMMENT_JAVADOC).breakBefore(); if (declaration.getAnonymousClassDeclaration() != null && i < enumConstants.size() - 1) this.tm.firstTokenAfter(declaration, TokenNameCOMMA).breakAfter(); }/*from w ww. j ava 2 s .c o m*/ // put breaks after semicolons int index = enumConstants.isEmpty() ? this.tm.firstIndexAfter(node.getName(), TokenNameLBRACE) + 1 : this.tm.firstIndexAfter(enumConstants.get(enumConstants.size() - 1), -1); for (;; index++) { Token token = this.tm.get(index); if (token.isComment()) continue; if (token.tokenType == TokenNameSEMICOLON) token.breakAfter(); else break; } this.declarationModifierVisited = false; return true; }
From source file:com.bsiag.eclipse.jdt.java.formatter.linewrap.WrapPreparator.java
License:Open Source License
@Override public boolean visit(EnumConstantDeclaration node) { handleArguments(node.arguments(), this.options.alignment_for_arguments_in_enum_constant); AnonymousClassDeclaration anonymousClass = node.getAnonymousClassDeclaration(); if (anonymousClass != null) { forceContinuousWrapping(anonymousClass, this.tm.firstIndexIn(node.getName(), -1)); }//from w ww . j a va2 s .co m return true; }
From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java
License:Open Source License
@Override public boolean visit(EnumConstantDeclaration node) { List<Expression> arguments = node.arguments(); Token openingParen = null;/*from w ww .j a va 2s. co m*/ if (!arguments.isEmpty()) { openingParen = this.tm.firstTokenIn(node, TokenNameLPAREN); if (this.options.insert_space_after_opening_paren_in_enum_constant) openingParen.spaceAfter(); handleTokenAfter(arguments.get(arguments.size() - 1), TokenNameRPAREN, this.options.insert_space_before_closing_paren_in_enum_constant, false); } else { // look for empty parenthesis, may not be there int from = this.tm.firstIndexIn(node.getName(), TokenNameIdentifier) + 1; AnonymousClassDeclaration classDeclaration = node.getAnonymousClassDeclaration(); int to = classDeclaration != null ? this.tm.firstIndexBefore(classDeclaration, -1) : this.tm.lastIndexIn(node, -1); for (int i = from; i <= to; i++) { if (this.tm.get(i).tokenType == TokenNameLPAREN) { openingParen = this.tm.get(i); if (this.options.insert_space_between_empty_parens_in_enum_constant) openingParen.spaceAfter(); break; } } } if (openingParen != null && this.options.insert_space_before_opening_paren_in_enum_constant) openingParen.spaceBefore(); handleCommas(arguments, this.options.insert_space_before_comma_in_enum_constant_arguments, this.options.insert_space_after_comma_in_enum_constant_arguments); return true; }
From source file:com.google.dart.java2dart.SyntaxTranslator.java
License:Open Source License
@Override public boolean visit(org.eclipse.jdt.core.dom.EnumConstantDeclaration node) { String fieldName = node.getName().getIdentifier(); IMethodBinding constructorBinding = node.resolveConstructorBinding(); // prepare enum name org.eclipse.jdt.core.dom.EnumDeclaration parentEnum = (org.eclipse.jdt.core.dom.EnumDeclaration) node .getParent();//from ww w.j a va 2s . com String enumTypeName = parentEnum.getName().getIdentifier(); // may be create Dart top-level class for Java inner class String innerClassName = null; { AnonymousClassDeclaration anoClassDeclaration = node.getAnonymousClassDeclaration(); if (anoClassDeclaration != null) { innerClassName = enumTypeName + "_" + fieldName; declareInnerClass(constructorBinding, anoClassDeclaration, innerClassName, new String[] { "String", ENUM_NAME_FIELD_NAME, "int", ENUM_ORDINAL_FIELD_NAME }); } } // prepare field type TypeName type = typeName(enumTypeName); // prepare field variables List<VariableDeclaration> variables = Lists.newArrayList(); { List<Expression> argList = translateArguments(null, node.arguments()); { int ordinal = parentEnum.enumConstants().indexOf(node); argList.add(0, integer(ordinal)); argList.add(0, string(fieldName)); } InstanceCreationExpression init; if (innerClassName == null) { init = instanceCreationExpression(Keyword.NEW, typeName(enumTypeName), argList); context.getConstructorDescription(constructorBinding).instanceCreations.add(init); } else { init = instanceCreationExpression(Keyword.NEW, typeName(innerClassName), argList); } variables.add(variableDeclaration(fieldName, init)); } return done(fieldDeclaration(translateJavadoc(node), true, Keyword.FINAL, type, variables)); }
From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java
License:Apache License
@Override public boolean visit(EnumConstantDeclaration node) { sb.printIndent();/* w w w .j a v a 2s . com*/ printModifiers(node.getModifiers()); node.getName().accept(this); if (!node.getArguments().isEmpty()) { sb.print('('); for (Iterator<Expression> it = node.getArguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); e.accept(this); if (it.hasNext()) { sb.print(','); } } sb.print(')'); } if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }
From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java
License:Apache License
/** Visitor method for {@link EnumConstantDeclaration}s. */ @Override/*from w ww . j a v a 2s . co m*/ public boolean visit(EnumConstantDeclaration node) { sync(node); List<Op> breaks = visitModifiers(node.modifiers(), Direction.VERTICAL, Optional.<BreakTag>absent()); if (!breaks.isEmpty()) { builder.open(ZERO); builder.addAll(breaks); builder.close(); } visit(node.getName()); if (node.arguments().isEmpty()) { builder.guessToken("("); builder.guessToken(")"); } else { addArguments(node.arguments(), plusFour); } if (node.getAnonymousClassDeclaration() != null) { visit(node.getAnonymousClassDeclaration()); } return false; }
From source file:com.ibm.wala.cast.java.translator.jdt.JDTJava2CAstTranslator.java
License:Open Source License
/** * Called only from visitFieldInitNode(node,context) *//*from w w w . j a v a 2 s. c o m*/ private CAstNode createEnumConstantDeclarationInit(EnumConstantDeclaration node, WalkContext context) { String hiddenVariableName = (String) node .getProperty("com.ibm.wala.cast.java.translator.jdt.fakeValuesDeclName"); if (hiddenVariableName == null) { FieldReference fieldRef = fIdentityMapper.getFieldRef(node.resolveVariable()); // We use null to indicate an OBJECT_REF to a static field CAstNode lhsNode = makeNode(context, fFactory, node, CAstNode.OBJECT_REF, makeNode(context, fFactory, null, CAstNode.VOID), fFactory.makeConstant(fieldRef)); // CONSTRUCT ARGUMENTS & "new MyEnum(...)" statement ArrayList<Object> arguments = new ArrayList<Object>(); arguments.add(fFactory.makeConstant(node.getName().getIdentifier())); // name of constant arguments.add(fFactory.makeConstant(node.resolveVariable().getVariableId())); // id arguments.addAll(node.arguments()); CAstNode rhsNode = createClassInstanceCreation(node, arguments, node.resolveConstructorBinding(), null, node.getAnonymousClassDeclaration(), context); CAstNode assNode = makeNode(context, fFactory, node, CAstNode.ASSIGN, lhsNode, rhsNode); return assNode; // their naming, not mine } else { // String[] x = (new Direction[] { // NORTH, EAST, SOUTH, WEST, $VALUES, $VALUES$ // }); return null; } }
From source file:com.j2swift.ast.DebugASTPrinter.java
License:Apache License
@Override public boolean visit(EnumConstantDeclaration node) { sb.printIndent();/*from w w w . j av a 2 s.c o m*/ printAnnotations(node.getAnnotations()); printModifiers(node.getModifiers()); node.getName().accept(this); if (!node.getArguments().isEmpty()) { sb.print('('); for (Iterator<Expression> it = node.getArguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); e.accept(this); if (it.hasNext()) { sb.print(','); } } sb.print(')'); } if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }