List of usage examples for org.eclipse.jdt.core.dom TypeParameter accept
public final void accept(ASTVisitor visitor)
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); }//from w ww . j av a 2s . c o m 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(TypeDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }//from w w w .j a v a 2 s . co m if (node.getAST().apiLevel() >= JLS3) { printModifiers(node.modifiers()); } this.fBuffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$ node.getName().accept(this); if (node.getAST().apiLevel() >= JLS3) { 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$ } } this.fBuffer.append(" ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= JLS3) { if (node.getSuperclassType() != null) { this.fBuffer.append("extends ");//$NON-NLS-1$ node.getSuperclassType().accept(this); this.fBuffer.append(" ");//$NON-NLS-1$ } if (!node.superInterfaceTypes().isEmpty()) { this.fBuffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$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$ BodyDeclaration prev = null; for (Iterator<BodyDeclaration> it = node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d = it.next(); if (prev instanceof EnumConstantDeclaration) { // enum constant declarations do not include punctuation if (d instanceof EnumConstantDeclaration) { // enum constant declarations are separated by commas this.fBuffer.append(", ");//$NON-NLS-1$ } else { // semicolon separates last enum constant declaration from // first class body declarations this.fBuffer.append("; ");//$NON-NLS-1$ } } d.accept(this); prev = d; } this.fBuffer.append("}");//$NON-NLS-1$ return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(MethodDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }/*from ww w. ja v a 2 s . com*/ printIndent(); hook_beforeVisitMethodDeclaration(node); if (node.getAST().apiLevel() >= AST.JLS3) { printModifiers(node.modifiers()); if (!node.typeParameters().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.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.buffer.append("void");//$NON-NLS-1$ } this.buffer.append(" ");//$NON-NLS-1$ } node.getName().accept(this); this.buffer.append("(");//$NON-NLS-1$ for (Iterator it = node.parameters().iterator(); it.hasNext();) { SingleVariableDeclaration v = (SingleVariableDeclaration) it.next(); v.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(")");//$NON-NLS-1$ for (int i = 0; i < node.getExtraDimensions(); i++) { this.buffer.append("[]"); //$NON-NLS-1$ } if (!node.thrownExceptions().isEmpty()) { this.buffer.append(" throws ");//$NON-NLS-1$ for (Iterator it = node.thrownExceptions().iterator(); it.hasNext();) { Name n = (Name) it.next(); n.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } if (node.getBody() == null) { this.buffer.append(";\n");//$NON-NLS-1$ } else { node.getBody().accept(this); } return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(TypeDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }/*from w w w . ja v a 2s. c o m*/ if (node.getAST().apiLevel() >= AST.JLS3) { printModifiers(node.modifiers()); } this.buffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$ node.getName().accept(this); if (node.getAST().apiLevel() >= AST.JLS3) { if (!node.typeParameters().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= AST.JLS3) { if (node.getSuperclassType() != null) { this.buffer.append("extends ");//$NON-NLS-1$ node.getSuperclassType().accept(this); this.buffer.append(" ");//$NON-NLS-1$ } if (!node.superInterfaceTypes().isEmpty()) { this.buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$ for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } } this.buffer.append("{\n");//$NON-NLS-1$ this.indent++; BodyDeclaration prev = null; for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d = (BodyDeclaration) it.next(); if (prev instanceof EnumConstantDeclaration) { // enum constant declarations do not include punctuation if (d instanceof EnumConstantDeclaration) { // enum constant declarations are separated by commas this.buffer.append(", ");//$NON-NLS-1$ } else { // semicolon separates last enum constant declaration from // first class body declarations this.buffer.append("; ");//$NON-NLS-1$ } } d.accept(this); } this.indent--; printIndent(); this.buffer.append("}\n");//$NON-NLS-1$ return false; }
From source file:de.ovgu.cide.export.physical.ahead.FSTComposerJavaPrettyPrinter.java
License:Open Source License
public boolean visit(JakClassRefinement node) { currentRefinement.push(node);/* w w w . j a v a 2s. com*/ // if (node.getJavadoc() != null) { // node.getJavadoc().accept(this); // } printModifiers(node.modifiers()); this.buffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$ node.getName().accept(this); if (!node.typeParameters().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator<?> it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } this.buffer.append(" ");//$NON-NLS-1$ if (node.getSuperclassType() != null) { this.buffer.append("extends ");//$NON-NLS-1$ node.getSuperclassType().accept(this); this.buffer.append(" ");//$NON-NLS-1$ } if (!node.superInterfaceTypes().isEmpty()) { this.buffer.append("implements ");//$NON-NLS-2$//$NON-NLS-1$ for (Iterator<?> it = node.superInterfaceTypes().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } this.buffer.append("{\n");//$NON-NLS-1$ this.indent++; BodyDeclaration prev = null; for (Iterator<?> it = node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d = (BodyDeclaration) it.next(); if (prev instanceof EnumConstantDeclaration) { // enum constant declarations do not include punctuation if (d instanceof EnumConstantDeclaration) { // enum constant declarations are separated by commas this.buffer.append(", ");//$NON-NLS-1$ } else { // semicolon separates last enum constant declaration from // first class body declarations this.buffer.append("; ");//$NON-NLS-1$ } } d.accept(this); } if (options.isDebugPrintInnerClassRefinements() || !options.getMethodObjectsInStaticToplevelClass()) { for (JakClassRefinement ref : node.getInnerClassRefinements()) { ref.accept(this); } } this.indent--; printIndent(); this.buffer.append("}\n");//$NON-NLS-1$ return false; }
From source file:de.ovgu.cide.export.physical.ahead.JakPrettyPrinter.java
License:Open Source License
public boolean visit(JakClassRefinement node) { currentRefinement.push(node);/* w ww. ja v a 2 s . co m*/ // if (node.getJavadoc() != null) { // node.getJavadoc().accept(this); // } printAnnotations(node.modifiers()); this.buffer.append("refines ");//$NON-NLS-2$//$NON-NLS-1$ printOnlyModifiers(node.modifiers()); this.buffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$ node.getName().accept(this); if (!node.typeParameters().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator<?> it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } this.buffer.append(" ");//$NON-NLS-1$ if (node.getSuperclassType() != null) { this.buffer.append("extends ");//$NON-NLS-1$ node.getSuperclassType().accept(this); this.buffer.append(" ");//$NON-NLS-1$ } if (!node.superInterfaceTypes().isEmpty()) { this.buffer.append("implements ");//$NON-NLS-2$//$NON-NLS-1$ for (Iterator<?> it = node.superInterfaceTypes().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } this.buffer.append("{\n");//$NON-NLS-1$ this.indent++; BodyDeclaration prev = null; for (Iterator<?> it = node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d = (BodyDeclaration) it.next(); if (prev instanceof EnumConstantDeclaration) { // enum constant declarations do not include punctuation if (d instanceof EnumConstantDeclaration) { // enum constant declarations are separated by commas this.buffer.append(", ");//$NON-NLS-1$ } else { // semicolon separates last enum constant declaration from // first class body declarations this.buffer.append("; ");//$NON-NLS-1$ } } d.accept(this); } if (options.isDebugPrintInnerClassRefinements() || !options.getMethodObjectsInStaticToplevelClass()) { for (JakClassRefinement ref : node.getInnerClassRefinements()) { ref.accept(this); } } this.indent--; printIndent(); this.buffer.append("}\n");//$NON-NLS-1$ return false; }
From source file:org.codemucker.jmutate.ast.JAstFlattener.java
License:Open Source License
public boolean visit(MethodDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }/* w w w . j a va 2 s . c o m*/ printIndent(); if (node.getAST().apiLevel() == JLS2) { printModifiers(node.getModifiers()); } if (node.getAST().apiLevel() >= JLS3) { printModifiers(node.modifiers()); if (!node.typeParameters().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } } if (!node.isConstructor()) { if (node.getAST().apiLevel() == JLS2) { getReturnType(node).accept(this); } else { if (node.getReturnType2() != null) { node.getReturnType2().accept(this); } else { // methods really ought to have a return type this.buffer.append("void");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } node.getName().accept(this); this.buffer.append("(");//$NON-NLS-1$ if (node.getAST().apiLevel() >= AST.JLS8) { Type receiverType = node.getReceiverType(); if (receiverType != null) { receiverType.accept(this); this.buffer.append(' '); SimpleName qualifier = node.getReceiverQualifier(); if (qualifier != null) { qualifier.accept(this); this.buffer.append('.'); } this.buffer.append("this"); //$NON-NLS-1$ if (node.parameters().size() > 0) { this.buffer.append(','); } } } for (Iterator it = node.parameters().iterator(); it.hasNext();) { SingleVariableDeclaration v = (SingleVariableDeclaration) it.next(); v.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(")");//$NON-NLS-1$ int size = node.getExtraDimensions(); if (node.getAST().apiLevel() >= AST.JLS8) { List dimensions = node.extraDimensions(); for (int i = 0; i < size; i++) { visit((Dimension) dimensions.get(i)); } } else { for (int i = 0; i < size; i++) { this.buffer.append("[]"); //$NON-NLS-1$ } } if (node.getAST().apiLevel() < AST.JLS8) { if (!thrownExceptions(node).isEmpty()) { this.buffer.append(" throws ");//$NON-NLS-1$ for (Iterator it = thrownExceptions(node).iterator(); it.hasNext();) { Name n = (Name) it.next(); n.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } } else { if (!node.thrownExceptionTypes().isEmpty()) { this.buffer.append(" throws ");//$NON-NLS-1$ for (Iterator it = node.thrownExceptionTypes().iterator(); it.hasNext();) { Type n = (Type) it.next(); n.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } } if (node.getBody() == null) { this.buffer.append(";\n");//$NON-NLS-1$ } else { node.getBody().accept(this); } return false; }
From source file:org.codemucker.jmutate.ast.JAstFlattener.java
License:Open Source License
public boolean visit(TypeDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); }// ww w. j a v a 2s . c o m if (node.getAST().apiLevel() == JLS2) { printModifiers(node.getModifiers()); } if (node.getAST().apiLevel() >= JLS3) { printModifiers(node.modifiers()); } this.buffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$ node.getName().accept(this); if (node.getAST().apiLevel() >= JLS3) { if (!node.typeParameters().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ if (node.getAST().apiLevel() == JLS2) { if (getSuperclass(node) != null) { this.buffer.append("extends ");//$NON-NLS-1$ getSuperclass(node).accept(this); this.buffer.append(" ");//$NON-NLS-1$ } if (!superInterfaces(node).isEmpty()) { this.buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$ for (Iterator it = superInterfaces(node).iterator(); it.hasNext();) { Name n = (Name) it.next(); n.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } } if (node.getAST().apiLevel() >= JLS3) { if (node.getSuperclassType() != null) { this.buffer.append("extends ");//$NON-NLS-1$ node.getSuperclassType().accept(this); this.buffer.append(" ");//$NON-NLS-1$ } if (!node.superInterfaceTypes().isEmpty()) { this.buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$ for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } this.buffer.append(" ");//$NON-NLS-1$ } } this.buffer.append("{\n");//$NON-NLS-1$ this.indent++; for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) { BodyDeclaration d = (BodyDeclaration) it.next(); d.accept(this); } this.indent--; printIndent(); this.buffer.append("}\n");//$NON-NLS-1$ return false; }
From source file:org.mybatis.generator.eclipse.core.merge.visitors.MethodSignatureStringifier.java
License:Apache License
@SuppressWarnings("unchecked") private void visitTypeParameters(MethodDeclaration node) { if (!node.typeParameters().isEmpty()) { buffer.append('<'); for (Iterator<TypeParameter> it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = it.next(); t.accept(this); if (it.hasNext()) { buffer.append(','); }/*www.j a va2 s.c o m*/ } buffer.append("> "); //$NON-NLS-1$ } }
From source file:ptolemy.backtrack.eclipse.ast.ASTFormatter.java
License:Open Source License
/** Visit an ast node, and return whether its children should be further * visited.//from w w w. j av a 2 s .c o m * * @param node The AST node. * @return Whether its children should be further visited. */ public boolean visit(MethodDeclaration node) { if (node.getJavadoc() != null) { node.getJavadoc().accept(this); } _output(_indent); _outputModifiers(node.modifiers()); if (!node.typeParameters().isEmpty()) { _output("<"); Iterator it; for (it = node.typeParameters().iterator(); it.hasNext();) { TypeParameter t = (TypeParameter) it.next(); t.accept(this); if (it.hasNext()) { _output(", "); } } _output(">"); } if (!node.isConstructor()) { if (node.getReturnType2() != null) { node.getReturnType2().accept(this); } else { // methods really ought to have a return type _output("void"); } _output(" "); } node.getName().accept(this); _output("("); for (Iterator it = node.parameters().iterator(); it.hasNext();) { SingleVariableDeclaration v = (SingleVariableDeclaration) it.next(); v.accept(this); if (it.hasNext()) { _output(", "); } } _output(")"); for (int i = 0; i < node.getExtraDimensions(); i++) { _output("[]"); } if (!node.thrownExceptions().isEmpty()) { _output(" throws "); Iterator it; for (it = node.thrownExceptions().iterator(); it.hasNext();) { Name n = (Name) it.next(); n.accept(this); if (it.hasNext()) { _output(", "); } } _output(" "); } if (node.getBody() == null) { _output(";\n"); } else { _output(" "); node.getBody().accept(this); } _output("\n"); return false; }