List of usage examples for org.eclipse.jdt.core.dom Type accept
public final void accept(ASTVisitor visitor)
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
private void printReferenceTypeArguments(List<Type> typeArguments) { this.fBuffer.append("::");//$NON-NLS-1$ if (!typeArguments.isEmpty()) { this.fBuffer.append('<'); for (Iterator<Type> it = typeArguments.iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(','); }/*from www. j a va 2 s. co m*/ } this.fBuffer.append('>'); } }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(ArrayCreation node) { this.fBuffer.append("new ");//$NON-NLS-1$ ArrayType at = node.getType(); int dims = at.getDimensions(); Type elementType = at.getElementType(); elementType.accept(this); for (Iterator<Expression> it = node.dimensions().iterator(); it.hasNext();) { this.fBuffer.append("[");//$NON-NLS-1$ Expression e = it.next(); e.accept(this); this.fBuffer.append("]");//$NON-NLS-1$ dims--;// w w w . j av a 2 s. co m } // add empty "[]" for each extra array dimension for (int i = 0; i < dims; i++) { this.fBuffer.append("[]");//$NON-NLS-1$ } if (node.getInitializer() != null) { node.getInitializer().accept(this); } return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(ClassInstanceCreation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.fBuffer.append(".");//$NON-NLS-1$ }// www . ja va 2 s . c o m this.fBuffer.append("new ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(">");//$NON-NLS-1$ } node.getType().accept(this); } 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:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(ConstructorInvocation node) { if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ }/*from w ww . j a va 2 s .co m*/ } this.fBuffer.append(">");//$NON-NLS-1$ } } this.fBuffer.append("this(");//$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$ return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(EnumDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }/*w ww.jav a 2 s .c om*/ printModifiers(node.modifiers()); this.fBuffer.append("enum ");//$NON-NLS-1$ node.getName().accept(this); this.fBuffer.append(" ");//$NON-NLS-1$ if (!node.superInterfaceTypes().isEmpty()) { this.fBuffer.append("implements ");//$NON-NLS-1$ for (Iterator<Type> it = node.superInterfaceTypes().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(", ");//$NON-NLS-1$ } } this.fBuffer.append(" ");//$NON-NLS-1$ } this.fBuffer.append("{");//$NON-NLS-1$ for (Iterator<EnumConstantDeclaration> it = node.enumConstants().iterator(); it.hasNext();) { EnumConstantDeclaration d = it.next(); d.accept(this); // enum constant declarations do not include punctuation if (it.hasNext()) { // enum constant declarations are separated by commas this.fBuffer.append(", ");//$NON-NLS-1$ } } if (!node.bodyDeclarations().isEmpty()) { this.fBuffer.append("; ");//$NON-NLS-1$ for (Iterator<BodyDeclaration> it = node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d = it.next(); d.accept(this); // other body declarations include trailing punctuation } } this.fBuffer.append("}");//$NON-NLS-1$ return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(IntersectionType node) { for (Iterator<Type> it = node.types().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(" & "); //$NON-NLS-1$ }/*from w w w . jav a 2s . com*/ } return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(MethodDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }/* ww w . j a v a 2 s. c om*/ if (node.getAST().apiLevel() >= JLS3) { printModifiers(node.modifiers()); if (!node.typeParameters().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<TypeParameter> it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(", ");//$NON-NLS-1$ } } this.fBuffer.append("> ");//$NON-NLS-1$ } } if (!node.isConstructor()) { if (node.getReturnType2() != null) { node.getReturnType2().accept(this); } else { // methods really ought to have a return type this.fBuffer.append("void");//$NON-NLS-1$ } this.fBuffer.append(" ");//$NON-NLS-1$ } node.getName().accept(this); this.fBuffer.append("(");//$NON-NLS-1$ if (node.getAST().apiLevel() >= AST.JLS8) { Type receiverType = node.getReceiverType(); if (receiverType != null) { receiverType.accept(this); this.fBuffer.append(' '); SimpleName qualifier = node.getReceiverQualifier(); if (qualifier != null) { qualifier.accept(this); this.fBuffer.append('.'); } this.fBuffer.append("this"); //$NON-NLS-1$ if (node.parameters().size() > 0) { this.fBuffer.append(','); } } } for (Iterator<SingleVariableDeclaration> it = node.parameters().iterator(); it.hasNext();) { SingleVariableDeclaration v = it.next(); v.accept(this); if (it.hasNext()) { this.fBuffer.append(", ");//$NON-NLS-1$ } } this.fBuffer.append(")");//$NON-NLS-1$ if (node.getAST().apiLevel() >= AST.JLS8) { List<Dimension> dimensions = node.extraDimensions(); for (Iterator<Dimension> it = dimensions.iterator(); it.hasNext();) { Dimension e = it.next(); e.accept(this); } } else { for (int i = 0; i < node.getExtraDimensions(); i++) { this.fBuffer.append("[]"); //$NON-NLS-1$ } } List<? extends ASTNode> thrownExceptions = node.getAST().apiLevel() >= AST.JLS8 ? node.thrownExceptionTypes() : getThrownExceptions(node); if (!thrownExceptions.isEmpty()) { this.fBuffer.append(" throws ");//$NON-NLS-1$ for (Iterator<? extends ASTNode> it = thrownExceptions.iterator(); it.hasNext();) { ASTNode n = it.next(); n.accept(this); if (it.hasNext()) { this.fBuffer.append(", ");//$NON-NLS-1$ } } this.fBuffer.append(" ");//$NON-NLS-1$ } if (node.getBody() == null) { this.fBuffer.append(";");//$NON-NLS-1$ } else { node.getBody().accept(this); } return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(MethodInvocation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.fBuffer.append(".");//$NON-NLS-1$ }/*www .j av a 2s . co m*/ if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(">");//$NON-NLS-1$ } } node.getName().accept(this); 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$ return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(ParameterizedType node) { node.getType().accept(this); this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ }/*from w w w . ja va2s .co m*/ } this.fBuffer.append(">");//$NON-NLS-1$ return false; }
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(SuperConstructorInvocation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.fBuffer.append(".");//$NON-NLS-1$ }//from w w w . j a v a2 s. co m if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(">");//$NON-NLS-1$ } } this.fBuffer.append("super(");//$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$ return false; }