diff options
Diffstat (limited to 'javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser')
117 files changed, 18248 insertions, 0 deletions
diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ASTHelper.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ASTHelper.java new file mode 100644 index 000000000..7e706cd64 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ASTHelper.java @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.QualifiedNameExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.PrimitiveType; +import com.github.javaparser.ast.type.ReferenceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.type.VoidType; +import com.github.javaparser.ast.type.PrimitiveType.Primitive; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class helps to construct new nodes. + * + * @author Júlio Vilmar Gesser + */ +public final class ASTHelper { + + public static final PrimitiveType BYTE_TYPE = new PrimitiveType(Primitive.Byte); + + public static final PrimitiveType SHORT_TYPE = new PrimitiveType(Primitive.Short); + + public static final PrimitiveType INT_TYPE = new PrimitiveType(Primitive.Int); + + public static final PrimitiveType LONG_TYPE = new PrimitiveType(Primitive.Long); + + public static final PrimitiveType FLOAT_TYPE = new PrimitiveType(Primitive.Float); + + public static final PrimitiveType DOUBLE_TYPE = new PrimitiveType(Primitive.Double); + + public static final PrimitiveType BOOLEAN_TYPE = new PrimitiveType(Primitive.Boolean); + + public static final PrimitiveType CHAR_TYPE = new PrimitiveType(Primitive.Char); + + public static final VoidType VOID_TYPE = new VoidType(); + + private ASTHelper() { + // nop + } + + /** + * Creates a new {@link NameExpr} from a qualified name.<br> + * The qualified name can contains "." (dot) characters. + * + * @param qualifiedName + * qualified name + * @return instanceof {@link NameExpr} + */ + public static NameExpr createNameExpr(String qualifiedName) { + String[] split = qualifiedName.split("\\."); + NameExpr ret = new NameExpr(split[0]); + for (int i = 1; i < split.length; i++) { + ret = new QualifiedNameExpr(ret, split[i]); + } + return ret; + } + + /** + * Creates a new {@link Parameter}. + * + * @param type + * type of the parameter + * @param name + * name of the parameter + * @return instance of {@link Parameter} + */ + public static Parameter createParameter(Type type, String name) { + return new Parameter(type, new VariableDeclaratorId(name)); + } + + /** + * Creates a {@link FieldDeclaration}. + * + * @param modifiers + * modifiers + * @param type + * type + * @param variable + * variable declarator + * @return instance of {@link FieldDeclaration} + */ + public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, VariableDeclarator variable) { + List<VariableDeclarator> variables = new ArrayList<VariableDeclarator>(); + variables.add(variable); + FieldDeclaration ret = new FieldDeclaration(modifiers, type, variables); + return ret; + } + + /** + * Creates a {@link FieldDeclaration}. + * + * @param modifiers + * modifiers + * @param type + * type + * @param name + * field name + * @return instance of {@link FieldDeclaration} + */ + public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, String name) { + VariableDeclaratorId id = new VariableDeclaratorId(name); + VariableDeclarator variable = new VariableDeclarator(id); + return createFieldDeclaration(modifiers, type, variable); + } + + /** + * Creates a {@link VariableDeclarationExpr}. + * + * @param type + * type + * @param name + * name + * @return instance of {@link VariableDeclarationExpr} + */ + public static VariableDeclarationExpr createVariableDeclarationExpr(Type type, String name) { + List<VariableDeclarator> vars = new ArrayList<VariableDeclarator>(); + vars.add(new VariableDeclarator(new VariableDeclaratorId(name))); + return new VariableDeclarationExpr(type, vars); + } + + /** + * Adds the given parameter to the method. The list of parameters will be + * initialized if it is <code>null</code>. + * + * @param method + * method + * @param parameter + * parameter + */ + public static void addParameter(MethodDeclaration method, Parameter parameter) { + List<Parameter> parameters = method.getParameters(); + if (parameters == null) { + parameters = new ArrayList<Parameter>(); + method.setParameters(parameters); + } + parameters.add(parameter); + } + + /** + * Adds the given argument to the method call. The list of arguments will be + * initialized if it is <code>null</code>. + * + * @param call + * method call + * @param arg + * argument value + */ + public static void addArgument(MethodCallExpr call, Expression arg) { + List<Expression> args = call.getArgs(); + if (args == null) { + args = new ArrayList<Expression>(); + call.setArgs(args); + } + args.add(arg); + } + + /** + * Adds the given type declaration to the compilation unit. The list of + * types will be initialized if it is <code>null</code>. + * + * @param cu + * compilation unit + * @param type + * type declaration + */ + public static void addTypeDeclaration(CompilationUnit cu, TypeDeclaration type) { + List<TypeDeclaration> types = cu.getTypes(); + if (types == null) { + types = new ArrayList<TypeDeclaration>(); + cu.setTypes(types); + } + types.add(type); + + } + + /** + * Creates a new {@link ReferenceType} for a class or interface. + * + * @param name + * name of the class or interface + * @param arrayCount + * number of arrays or <code>0</code> if is not a array. + * @return instanceof {@link ReferenceType} + */ + public static ReferenceType createReferenceType(String name, int arrayCount) { + return new ReferenceType(new ClassOrInterfaceType(name), arrayCount); + } + + /** + * Creates a new {@link ReferenceType} for the given primitive type. + * + * @param type + * primitive type + * @param arrayCount + * number of arrays or <code>0</code> if is not a array. + * @return instanceof {@link ReferenceType} + */ + public static ReferenceType createReferenceType(PrimitiveType type, int arrayCount) { + return new ReferenceType(type, arrayCount); + } + + /** + * Adds the given statement to the specified block. The list of statements + * will be initialized if it is <code>null</code>. + * + * @param block to have expression added to + * @param stmt to be added + */ + public static void addStmt(BlockStmt block, Statement stmt) { + List<Statement> stmts = block.getStmts(); + if (stmts == null) { + stmts = new ArrayList<Statement>(); + block.setStmts(stmts); + } + stmts.add(stmt); + } + + /** + * Adds the given expression to the specified block. The list of statements + * will be initialized if it is <code>null</code>. + * + * @param block to have expression added to + * @param expr to be added + */ + public static void addStmt(BlockStmt block, Expression expr) { + addStmt(block, new ExpressionStmt(expr)); + } + + /** + * Adds the given declaration to the specified type. The list of members + * will be initialized if it is <code>null</code>. + * + * @param type + * type declaration + * @param decl + * member declaration + */ + public static void addMember(TypeDeclaration type, BodyDeclaration decl) { + List<BodyDeclaration> members = type.getMembers(); + if (members == null) { + members = new ArrayList<BodyDeclaration>(); + type.setMembers(members); + } + members.add(decl); + } + + public static <N extends Node> List<N> getNodesByType(Node container, Class<N> clazz) { + List<N> nodes = new ArrayList<N>(); + for (Node child : container.getChildrenNodes()) { + if (clazz.isInstance(child)) { + nodes.add(clazz.cast(child)); + } + nodes.addAll(getNodesByType(child, clazz)); + } + return nodes; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/JavaParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/JavaParser.java new file mode 100644 index 000000000..431255051 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/JavaParser.java @@ -0,0 +1,452 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import static com.github.javaparser.PositionUtils.areInOrder; +import static com.github.javaparser.PositionUtils.sortByBeginPosition; + +import com.github.javaparser.ASTParser; +import com.github.javaparser.ParseException; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.CommentsCollection; +import com.github.javaparser.ast.comments.CommentsParser; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.Statement; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +// FIXME this file does not seem to be generated by javacc. Is the doc wrong, or the javacc config? +/** + * <p> + * This class was generated automatically by javacc, do not edit. + * </p> + * <p> + * Parse Java 1.5 source code and creates Abstract Syntax Tree classes. + * </p> + * + * @author Júlio Vilmar Gesser + */ +public final class JavaParser { + private JavaParser() { + // hide the constructor + } + + private static boolean _doNotAssignCommentsPreceedingEmptyLines = true; + + private static boolean _doNotConsiderAnnotationsAsNodeStartForCodeAttribution = false; + + public static boolean getDoNotConsiderAnnotationsAsNodeStartForCodeAttribution() + { + return _doNotConsiderAnnotationsAsNodeStartForCodeAttribution; + } + + public static void setDoNotConsiderAnnotationsAsNodeStartForCodeAttribution(boolean doNotConsiderAnnotationsAsNodeStartForCodeAttribution) { + _doNotConsiderAnnotationsAsNodeStartForCodeAttribution = doNotConsiderAnnotationsAsNodeStartForCodeAttribution; + } + + public static boolean getDoNotAssignCommentsPreceedingEmptyLines() + { + return _doNotAssignCommentsPreceedingEmptyLines; + } + + public static void setDoNotAssignCommentsPreceedingEmptyLines(boolean doNotAssignCommentsPreceedingEmptyLines) + { + _doNotAssignCommentsPreceedingEmptyLines = doNotAssignCommentsPreceedingEmptyLines; + } + + public static CompilationUnit parse(final InputStream in, + final String encoding) { + return parse(in,encoding,true); + } + + /** + * Parses the Java code contained in the {@link InputStream} and returns a + * {@link CompilationUnit} that represents it. + * + * @param in + * {@link InputStream} containing Java source code + * @param encoding + * encoding of the source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + */ + public static CompilationUnit parse(final InputStream in, + final String encoding, boolean considerComments) { + try { + String code = SourcesHelper.streamToString(in, encoding); + InputStream in1 = SourcesHelper.stringToStream(code, encoding); + CompilationUnit cu = new ASTParser(in1, encoding).CompilationUnit(); + if (considerComments){ + insertComments(cu,code); + } + return cu; + } catch (IOException ioe){ + throw new ParseException(ioe.getMessage()); + } + } + + /** + * Parses the Java code contained in the {@link InputStream} and returns a + * {@link CompilationUnit} that represents it. + * + * @param in + * {@link InputStream} containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + */ + public static CompilationUnit parse(final InputStream in) + { + return parse(in, null,true); + } + + public static CompilationUnit parse(final File file, final String encoding) + throws ParseException, IOException { + return parse(file,encoding,true); + } + + /** + * Parses the Java code contained in a {@link File} and returns a + * {@link CompilationUnit} that represents it. + * + * @param file + * {@link File} containing Java source code + * @param encoding + * encoding of the source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + * @throws IOException + */ + public static CompilationUnit parse(final File file, final String encoding, boolean considerComments) + throws ParseException, IOException { + final FileInputStream in = new FileInputStream(file); + try { + return parse(in, encoding, considerComments); + } finally { + in.close(); + } + } + + /** + * Parses the Java code contained in a {@link File} and returns a + * {@link CompilationUnit} that represents it. + * + * @param file + * {@link File} containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + * @throws IOException + */ + public static CompilationUnit parse(final File file) throws ParseException, + IOException { + return parse(file, null,true); + } + + public static CompilationUnit parse(final Reader reader, boolean considerComments) + { + try { + String code = SourcesHelper.readerToString(reader); + Reader reader1 = SourcesHelper.stringToReader(code); + CompilationUnit cu = new ASTParser(reader1).CompilationUnit(); + if (considerComments){ + insertComments(cu,code); + } + return cu; + } catch (IOException ioe){ + throw new ParseException(ioe.getMessage()); + } + } + + /** + * Parses the Java block contained in a {@link String} and returns a + * {@link BlockStmt} that represents it. + * + * @param blockStatement + * {@link String} containing Java block code + * @return BlockStmt representing the Java block + * @throws ParseException + * if the source code has parser errors + */ + public static BlockStmt parseBlock(final String blockStatement) + { + StringReader sr = new StringReader(blockStatement); + BlockStmt result = new ASTParser(sr).Block(); + sr.close(); + return result; + } + + /** + * Parses the Java statement contained in a {@link String} and returns a + * {@link Statement} that represents it. + * + * @param statement + * {@link String} containing Java statement code + * @return Statement representing the Java statement + * @throws ParseException + * if the source code has parser errors + */ + public static Statement parseStatement(final String statement) { + StringReader sr = new StringReader(statement); + Statement stmt = new ASTParser(sr).Statement(); + sr.close(); + return stmt; + } + + /** + * Parses the Java import contained in a {@link String} and returns a + * {@link ImportDeclaration} that represents it. + * + * @param importDeclaration + * {@link String} containing Java import code + * @return ImportDeclaration representing the Java import declaration + * @throws ParseException + * if the source code has parser errors + */ + public static ImportDeclaration parseImport(final String importDeclaration) { + StringReader sr = new StringReader(importDeclaration); + ImportDeclaration id = new ASTParser(sr).ImportDeclaration(); + sr.close(); + return id; + } + + /** + * Parses the Java expression contained in a {@link String} and returns a + * {@link Expression} that represents it. + * + * @param expression + * {@link String} containing Java expression + * @return Expression representing the Java expression + * @throws ParseException + * if the source code has parser errors + */ + public static Expression parseExpression(final String expression) { + StringReader sr = new StringReader(expression); + Expression e = new ASTParser(sr).Expression(); + sr.close(); + return e; + } + + /** + * Parses the Java annotation contained in a {@link String} and returns a + * {@link AnnotationExpr} that represents it. + * + * @param annotation + * {@link String} containing Java annotation + * @return AnnotationExpr representing the Java annotation + * @throws ParseException + * if the source code has parser errors + */ + public static AnnotationExpr parseAnnotation(final String annotation) { + StringReader sr = new StringReader(annotation); + AnnotationExpr ae = new ASTParser(sr).Annotation(); + sr.close(); + return ae; + } + + /** + * Parses the Java body declaration(e.g fields or methods) contained in a + * {@link String} and returns a {@link BodyDeclaration} that represents it. + * + * @param body + * {@link String} containing Java body declaration + * @return BodyDeclaration representing the Java annotation + * @throws ParseException + * if the source code has parser errors + */ + public static BodyDeclaration parseBodyDeclaration(final String body) { + StringReader sr = new StringReader(body); + BodyDeclaration bd = new ASTParser(sr).AnnotationBodyDeclaration(); + sr.close(); + return bd; + } + + /** + * Comments are attributed to the thing the comment and are removed from + * allComments. + */ + private static void insertCommentsInCu(CompilationUnit cu, CommentsCollection commentsCollection){ + if (commentsCollection.size()==0) return; + + // I should sort all the direct children and the comments, if a comment is the first thing then it + // a comment to the CompilationUnit + // FIXME if there is no package it could be also a comment to the following class... + // so I could use some heuristics in these cases to distinguish the two cases + + List<Comment> comments = commentsCollection.getAll(); + PositionUtils.sortByBeginPosition(comments); + List<Node> children = cu.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + if (cu.getPackage()!=null && (children.size()==0 || PositionUtils.areInOrder(comments.get(0), children.get(0)))){ + cu.setComment(comments.get(0)); + comments.remove(0); + } + + insertCommentsInNode(cu,comments); + } + + private static boolean attributeLineCommentToNodeOrChild(Node node, LineComment lineComment) + { + // The node start and end at the same line as the comment, + // let's give to it the comment + if (node.getBeginLine()==lineComment.getBeginLine() && !node.hasComment()) + { + node.setComment(lineComment); + return true; + } else { + // try with all the children, sorted by reverse position (so the + // first one is the nearest to the comment + List<Node> children = new LinkedList<Node>(); + children.addAll(node.getChildrenNodes()); + PositionUtils.sortByBeginPosition(children); + Collections.reverse(children); + + for (Node child : children) + { + if (attributeLineCommentToNodeOrChild(child, lineComment)) + { + return true; + } + } + + return false; + } + } + + /** + * This method try to attributes the nodes received to child of the node. + * It returns the node that were not attributed. + */ + private static void insertCommentsInNode(Node node, List<Comment> commentsToAttribute){ + if (commentsToAttribute.size()==0) return; + + // the comments can: + // 1) Inside one of the child, then it is the child that have to associate them + // 2) If they are not inside a child they could be preceeding nothing, a comment or a child + // if they preceed a child they are assigned to it, otherweise they remain "orphans" + + List<Node> children = node.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + for (Node child : children){ + List<Comment> commentsInsideChild = new LinkedList<Comment>(); + for (Comment c : commentsToAttribute){ + if (PositionUtils.nodeContains(child, c, _doNotConsiderAnnotationsAsNodeStartForCodeAttribution)){ + commentsInsideChild.add(c); + } + } + commentsToAttribute.removeAll(commentsInsideChild); + insertCommentsInNode(child,commentsInsideChild); + } + + // I can attribute in line comments to elements preceeding them, if there + // is something contained in their line + List<Comment> attributedComments = new LinkedList<Comment>(); + for (Comment comment : commentsToAttribute) + { + if (comment.isLineComment()) + { + for (Node child : children) + { + if (child.getEndLine()==comment.getBeginLine()) + { + if (attributeLineCommentToNodeOrChild(child, comment.asLineComment())) + { + attributedComments.add(comment); + } + } + } + } + } + + // at this point I create an ordered list of all remaining comments and children + Comment previousComment = null; + attributedComments = new LinkedList<Comment>(); + List<Node> childrenAndComments = new LinkedList<Node>(); + childrenAndComments.addAll(children); + childrenAndComments.addAll(commentsToAttribute); + PositionUtils.sortByBeginPosition(childrenAndComments, _doNotConsiderAnnotationsAsNodeStartForCodeAttribution); + + for (Node thing : childrenAndComments){ + if (thing instanceof Comment){ + previousComment = (Comment)thing; + if (!previousComment.isOrphan()) + { + previousComment = null; + } + } else { + if (previousComment != null && !thing.hasComment()){ + if (!_doNotAssignCommentsPreceedingEmptyLines || !thereAreLinesBetween(previousComment, thing)) { + thing.setComment(previousComment); + attributedComments.add(previousComment); + previousComment = null; + } + } + } + } + + commentsToAttribute.removeAll(attributedComments); + + // all the remaining are orphan nodes + for (Comment c : commentsToAttribute){ + if (c.isOrphan()) { + node.addOrphanComment(c); + } + } + } + + private static boolean thereAreLinesBetween(Node a, Node b) + { + if (!PositionUtils.areInOrder(a, b)) + { + return thereAreLinesBetween(b, a); + } + int endOfA = a.getEndLine(); + return b.getBeginLine()>(a.getEndLine()+1); + } + + private static void insertComments(CompilationUnit cu, String code) throws IOException { + CommentsParser commentsParser = new CommentsParser(); + CommentsCollection allComments = commentsParser.parse(code); + + insertCommentsInCu(cu,allComments); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/Position.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/Position.java new file mode 100644 index 000000000..522411c27 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/Position.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import com.github.javaparser.ast.Node; + +public class Position { + private int line; + private int column; + + public static final Position ABSOLUTE_START = new Position(Node.ABSOLUTE_BEGIN_LINE,-1); + public static final Position ABSOLUTE_END = new Position(Node.ABSOLUTE_END_LINE,-1); + + public static Position beginOf(Node node){ + return new Position(node.getBeginLine(),node.getBeginColumn()); + } + + public static Position endOf(Node node){ + return new Position(node.getEndLine(),node.getEndColumn()); + } + + public Position(int line, int column){ + this.line = line; + this.column = column; + } + + public int getLine(){ + return this.line; + } + + public int getColumn(){ + return this.column; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/PositionUtils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/PositionUtils.java new file mode 100644 index 000000000..41df81710 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/PositionUtils.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.AnnotableNode; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.lang.Override; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; + +import static java.lang.Integer.signum; + +public final class PositionUtils { + + private PositionUtils() { + // prevent instantiation + } + + public static <T extends Node> void sortByBeginPosition(List<T> nodes){ + sortByBeginPosition(nodes, false); + } + + public static <T extends Node> void sortByBeginPosition(List<T> nodes, final boolean ignoringAnnotations){ + Collections.sort(nodes, new Comparator<Node>() { + @Override + public int compare(Node o1, Node o2) { + return PositionUtils.compare(o1, o2, ignoringAnnotations); + } + }); + } + + public static boolean areInOrder(Node a, Node b){ + return areInOrder(a, b, false); + } + + public static boolean areInOrder(Node a, Node b, boolean ignoringAnnotations){ + return compare(a, b, ignoringAnnotations) <= 0; + } + + private static int compare(Node a, Node b, boolean ignoringAnnotations) { + if (ignoringAnnotations) { + int signLine = signum(beginLineWithoutConsideringAnnotation(a) - beginLineWithoutConsideringAnnotation(b)); + if (signLine == 0) { + return signum(beginColumnWithoutConsideringAnnotation(a) - beginColumnWithoutConsideringAnnotation(b)); + } else { + return signLine; + } + } + + int signLine = signum( a.getBeginLine() - b.getBeginLine() ); + if (signLine == 0) { + return signum(a.getBeginColumn() - b.getBeginColumn()); + } else { + return signLine; + } + } + + public static AnnotationExpr getLastAnnotation(Node node) { + if (node instanceof AnnotableNode){ + List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>(); + annotations.addAll(((AnnotableNode) node).getAnnotations()); + if (annotations.size()==0){ + return null; + } + sortByBeginPosition(annotations); + return annotations.get(annotations.size()-1); + } else { + return null; + } + } + + private static int beginLineWithoutConsideringAnnotation(Node node) { + return beginNodeWithoutConsideringAnnotations(node).getBeginLine(); + } + + + private static int beginColumnWithoutConsideringAnnotation(Node node) { + return beginNodeWithoutConsideringAnnotations(node).getBeginColumn(); + } + + private static Node beginNodeWithoutConsideringAnnotations(Node node) { + if (node instanceof MethodDeclaration) { + MethodDeclaration casted = (MethodDeclaration) node; + return casted.getType(); + } else if (node instanceof FieldDeclaration) { + FieldDeclaration casted = (FieldDeclaration) node; + return casted.getType(); + } else if (node instanceof ClassOrInterfaceDeclaration) { + ClassOrInterfaceDeclaration casted = (ClassOrInterfaceDeclaration) node; + return casted.getNameExpr(); + } else { + return node; + } + } + + public static boolean nodeContains(Node container, Node contained, boolean ignoringAnnotations){ + if (!ignoringAnnotations || PositionUtils.getLastAnnotation(container)==null){ + return container.contains(contained); + } + if (!container.contains(contained)){ + return false; + } + // if the node is contained, but it comes immediately after the annotations, + // let's not consider it contained + if (container instanceof AnnotableNode){ + int bl = beginLineWithoutConsideringAnnotation(container); + int bc = beginColumnWithoutConsideringAnnotation(container); + if (bl>contained.getBeginLine()) return false; + if (bl==contained.getBeginLine() && bc>contained.getBeginColumn()) return false; + if (container.getEndLine()<contained.getEndLine()) return false; + if (container.getEndLine()==contained.getEndLine() && container.getEndColumn()<contained.getEndColumn()) return false; + return true; + } + return true; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/SourcesHelper.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/SourcesHelper.java new file mode 100644 index 000000000..87f83f0da --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/SourcesHelper.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import java.io.*; + +public class SourcesHelper { + + static String streamToString(InputStream in, String encoding){ + if (encoding == null) { + return streamToString(in); + } else { + java.util.Scanner s = new java.util.Scanner(in, encoding).useDelimiter("\\A"); + return s.hasNext() ? s.next() : ""; + } + } + + static String streamToString(InputStream in){ + java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A"); + return s.hasNext() ? s.next() : ""; + } + + static InputStream stringToStream(String s, String encoding) throws UnsupportedEncodingException { + byte[] rawData = encoding != null ? s.getBytes(encoding) : s.getBytes(); + return new ByteArrayInputStream(rawData); + } + + static String readerToString(Reader reader) throws IOException { + char[] arr = new char[8*1024]; // 8K at a time + StringBuilder buf = new StringBuilder(); + int numChars; + + while ((numChars = reader.read(arr, 0, arr.length)) > 0) { + buf.append(arr, 0, numChars); + } + + return buf.toString(); + } + + static Reader stringToReader(String s){ + return new StringReader(s); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/AccessSpecifier.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/AccessSpecifier.java new file mode 100644 index 000000000..5eafdac64 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/AccessSpecifier.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +/** + * Access specifier. Represents one of the possible levels of + * access permitted by the language. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public enum AccessSpecifier { + + PUBLIC("public"), + PRIVATE("private"), + PROTECTED("protected"), + DEFAULT(""); + + private String codeRepresenation; + + private AccessSpecifier(String codeRepresentation) { + this.codeRepresenation = codeRepresentation; + } + + public String getCodeRepresenation(){ + return this.codeRepresenation; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/CompilationUnit.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/CompilationUnit.java new file mode 100644 index 000000000..f3db30274 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/CompilationUnit.java @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the entire compilation unit. Each java file denotes a + * compilation unit. + * </p> + * The CompilationUnit is constructed following the syntax:<br> + * <pre> + * {@code + * CompilationUnit ::= ( }{@link PackageDeclaration}{@code )? + * ( }{@link ImportDeclaration}{@code )* + * ( }{@link TypeDeclaration}{@code )* + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class CompilationUnit extends Node { + + private PackageDeclaration pakage; + + private List<ImportDeclaration> imports; + + private List<TypeDeclaration> types; + + public CompilationUnit() { + } + + public CompilationUnit(PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) { + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + public CompilationUnit(int beginLine, int beginColumn, int endLine, int endColumn, PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) { + super(beginLine, beginColumn, endLine, endColumn); + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return a list containing all comments declared in this compilation unit. + * Including javadocs, line comments and block comments of all types, + * inner-classes and other members.<br> + * If there is no comment, <code>null</code> is returned. + * + * @return list with all comments of this compilation unit or + * <code>null</code> + * @see JavadocComment + * @see com.github.javaparser.ast.comments.LineComment + * @see com.github.javaparser.ast.comments.BlockComment + */ + public List<Comment> getComments() { + return this.getAllContainedComments(); + } + + /** + * Retrieves the list of imports declared in this compilation unit or + * <code>null</code> if there is no import. + * + * @return the list of imports or <code>null</code> if there is no import + */ + public List<ImportDeclaration> getImports() { + return imports; + } + + /** + * Retrieves the package declaration of this compilation unit.<br> + * If this compilation unit has no package declaration (default package), + * <code>null</code> is returned. + * + * @return the package declaration or <code>null</code> + */ + public PackageDeclaration getPackage() { + return pakage; + } + + /** + * Return the list of types declared in this compilation unit.<br> + * If there is no types declared, <code>null</code> is returned. + * + * @return the list of types or <code>null</code> null if there is no type + * @see AnnotationDeclaration + * @see ClassOrInterfaceDeclaration + * @see EmptyTypeDeclaration + * @see EnumDeclaration + */ + public List<TypeDeclaration> getTypes() { + return types; + } + + /** + * Sets the list of comments of this compilation unit. + * + * @param comments + * the list of comments + */ + public void setComments(List<Comment> comments) { + throw new RuntimeException("Not implemented!"); + } + + /** + * Sets the list of imports of this compilation unit. The list is initially + * <code>null</code>. + * + * @param imports + * the list of imports + */ + public void setImports(List<ImportDeclaration> imports) { + this.imports = imports; + setAsParentNodeOf(this.imports); + } + + /** + * Sets or clear the package declarations of this compilation unit. + * + * @param pakage + * the pakage declaration to set or <code>null</code> to default + * package + */ + public void setPackage(PackageDeclaration pakage) { + this.pakage = pakage; + setAsParentNodeOf(this.pakage); + } + + /** + * Sets the list of types declared in this compilation unit. + * + * @param types + * the lis of types + */ + public void setTypes(List<TypeDeclaration> types) { + this.types = types; + setAsParentNodeOf(this.types); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/DocumentableNode.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/DocumentableNode.java new file mode 100644 index 000000000..0038831b8 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/DocumentableNode.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.comments.JavadocComment; + +/** + * Node which can be documented through a Javadoc comment. + */ +public interface DocumentableNode { + + public JavadocComment getJavaDoc(); + public void setJavaDoc(JavadocComment javadocComment); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/ImportDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/ImportDeclaration.java new file mode 100644 index 000000000..da249e20b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/ImportDeclaration.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * This class represents a import declaration. Imports are optional for the + * {@link CompilationUnit}. + * </p> + * The ImportDeclaration is constructed following the syntax:<br> + * <pre> + * {@code + * ImportDeclaration ::= "import" ( "static" )? }{@link NameExpr}{@code ( "." "*" )? ";" + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class ImportDeclaration extends Node { + + private NameExpr name; + + private boolean static_; + + private boolean asterisk; + + public ImportDeclaration() { + } + + public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk) { + setAsterisk(isAsterisk); + setName(name); + setStatic(isStatic); + } + + public ImportDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, NameExpr name, boolean isStatic, boolean isAsterisk) { + super(beginLine, beginColumn, endLine, endColumn); + setAsterisk(isAsterisk); + setName(name); + setStatic(isStatic); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the name of the import. + * + * @return the name of the import + */ + public NameExpr getName() { + return name; + } + + /** + * Return if the import ends with "*". + * + * @return <code>true</code> if the import ends with "*", <code>false</code> + * otherwise + */ + public boolean isAsterisk() { + return asterisk; + } + + /** + * Return if the import is static. + * + * @return <code>true</code> if the import is static, <code>false</code> + * otherwise + */ + public boolean isStatic() { + return static_; + } + + /** + * Sets if this import is asterisk. + * + * @param asterisk + * <code>true</code> if this import is asterisk + */ + public void setAsterisk(boolean asterisk) { + this.asterisk = asterisk; + } + + /** + * Sets the name this import. + * + * @param name + * the name to set + */ + public void setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + } + + /** + * Sets if this import is static. + * + * @param static_ + * <code>true</code> if this import is static + */ + public void setStatic(boolean static_) { + this.static_ = static_; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/NamedNode.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/NamedNode.java new file mode 100644 index 000000000..7885d71d2 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/NamedNode.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +/** + * A node having a name. + * + * The main reason for this interface is to permit users to manipulate homogeneously all nodes with a getName method. + * + * @since 2.0.1 + */ +public interface NamedNode { + String getName(); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/Node.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/Node.java new file mode 100644 index 000000000..f5f9cb238 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/Node.java @@ -0,0 +1,376 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.visitor.*; + +/** + * Abstract class for all nodes of the AST. + * + * Each Node can have one associated comment which describe it and + * a number of "orphan comments" which it contains but are not specifically + * associated to any element. + * + * @author Julio Vilmar Gesser + */ +public abstract class Node implements Cloneable { + + private int beginLine; + + private int beginColumn; + + private int endLine; + + private int endColumn; + + private Node parentNode; + + private List<Node> childrenNodes = new LinkedList<Node>(); + private List<Comment> orphanComments = new LinkedList<Comment>(); + + /** + * This attribute can store additional information from semantic analysis. + */ + private Object data; + + private Comment comment; + + public Node() { + } + + public Node(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + this.beginLine = beginLine; + this.beginColumn = beginColumn; + this.endLine = endLine; + this.endColumn = endColumn; + } + + /** + * Accept method for visitor support. + * + * @param <R> + * the type the return value of the visitor + * @param <A> + * the type the argument passed to the visitor + * @param v + * the visitor implementation + * @param arg + * the argument passed to the visitor + * @return the result of the visit + */ + public abstract <R, A> R accept(GenericVisitor<R, A> v, A arg); + + /** + * Accept method for visitor support. + * + * @param <A> + * the type the argument passed for the visitor + * @param v + * the visitor implementation + * @param arg + * any value relevant for the visitor + */ + public abstract <A> void accept(VoidVisitor<A> v, A arg); + + /** + * Return the begin column of this node. + * + * @return the begin column of this node + */ + public final int getBeginColumn() { + return beginColumn; + } + + /** + * Return the begin line of this node. + * + * @return the begin line of this node + */ + public final int getBeginLine() { + return beginLine; + } + + /** + * This is a comment associated with this node. + * + * @return comment property + */ + public final Comment getComment() { + return comment; + } + + /** + * Use this to retrieve additional information associated to this node. + * + * @return data property + */ + public final Object getData() { + return data; + } + + /** + * Return the end column of this node. + * + * @return the end column of this node + */ + public final int getEndColumn() { + return endColumn; + } + + /** + * Return the end line of this node. + * + * @return the end line of this node + */ + public final int getEndLine() { + return endLine; + } + + /** + * Sets the begin column of this node. + * + * @param beginColumn + * the begin column of this node + */ + public final void setBeginColumn(final int beginColumn) { + this.beginColumn = beginColumn; + } + + /** + * Sets the begin line of this node. + * + * @param beginLine + * the begin line of this node + */ + public final void setBeginLine(final int beginLine) { + this.beginLine = beginLine; + } + + /** + * Use this to store additional information to this node. + * + * @param comment to be set + */ + public final void setComment(final Comment comment) { + if (comment != null && (this instanceof Comment)) { + throw new RuntimeException("A comment can not be commented"); + } + if (this.comment != null) + { + this.comment.setCommentedNode(null); + } + this.comment = comment; + if (comment != null) { + this.comment.setCommentedNode(this); + } + } + + /** + * Use this to store additional information to this node. + * + * @param data to be set + */ + public final void setData(final Object data) { + this.data = data; + } + + /** + * Sets the end column of this node. + * + * @param endColumn + * the end column of this node + */ + public final void setEndColumn(final int endColumn) { + this.endColumn = endColumn; + } + + /** + * Sets the end line of this node. + * + * @param endLine + * the end line of this node + */ + public final void setEndLine(final int endLine) { + this.endLine = endLine; + } + + /** + * Return the String representation of this node. + * + * @return the String representation of this node + */ + @Override + public final String toString() { + final DumpVisitor visitor = new DumpVisitor(); + accept(visitor, null); + return visitor.getSource(); + } + + public final String toStringWithoutComments() { + final DumpVisitor visitor = new DumpVisitor(false); + accept(visitor, null); + return visitor.getSource(); + } + + @Override + public final int hashCode() { + return toString().hashCode(); + } + + @Override + public boolean equals(final Object obj) { + if (obj == null || !(obj instanceof Node)) { + return false; + } + return EqualsVisitor.equals(this, (Node) obj); + } + + @Override + public Node clone() { + return this.accept(new CloneVisitor(), null); + } + + public Node getParentNode() { + return parentNode; + } + + public List<Node> getChildrenNodes() { + return childrenNodes; + } + + public boolean contains(Node other) { + if (getBeginLine() > other.getBeginLine()) return false; + if (getBeginLine() == other.getBeginLine() && getBeginColumn() > other.getBeginColumn()) return false; + if (getEndLine() < other.getEndLine()) return false; + if (getEndLine() == other.getEndLine() && getEndColumn() < other.getEndColumn()) return false; + return true; + } + + public void addOrphanComment(Comment comment) { + orphanComments.add(comment); + comment.setParentNode(this); + } + + /** + * This is a list of Comment which are inside the node and are not associated + * with any meaningful AST Node. + * + * For example, comments at the end of methods (immediately before the parenthesis) + * or at the end of CompilationUnit are orphan comments. + * + * When more than one comments preceed a statement, the one immediately preceeding it + * it is associated with the statements, while the others are "orphan". + * @return all comments that cannot be attributed to a concept + */ + public List<Comment> getOrphanComments() { + return orphanComments; + } + + /** + * This is the list of Comment which are contained in the Node either because + * they are properly associated to one of its children or because they are floating + * around inside the Node + * @return all Comments within the node as a list + */ + public List<Comment> getAllContainedComments() { + List<Comment> comments = new LinkedList<Comment>(); + comments.addAll(getOrphanComments()); + + for (Node child : getChildrenNodes()) { + if (child.getComment() != null) { + comments.add(child.getComment()); + } + comments.addAll(child.getAllContainedComments()); + } + + return comments; + } + + /** + * Assign a new parent to this node, removing it + * from the list of children of the previous parent, if any. + * + * @param parentNode node to be set as parent + */ + public void setParentNode(Node parentNode) { + // remove from old parent, if any + if (this.parentNode != null) { + this.parentNode.childrenNodes.remove(this); + } + this.parentNode = parentNode; + // add to new parent, if any + if (this.parentNode != null) { + this.parentNode.childrenNodes.add(this); + } + } + + protected void setAsParentNodeOf(List<? extends Node> childNodes) { + if (childNodes != null) { + Iterator<? extends Node> it = childNodes.iterator(); + while (it.hasNext()) { + Node current = it.next(); + current.setParentNode(this); + } + } + } + + protected void setAsParentNodeOf(Node childNode) { + if (childNode != null) { + childNode.setParentNode(this); + } + } + + public static final int ABSOLUTE_BEGIN_LINE = -1; + public static final int ABSOLUTE_END_LINE = -2; + + public boolean isPositionedAfter(int line, int column) { + if (line == ABSOLUTE_BEGIN_LINE) return true; + if (getBeginLine() > line) { + return true; + } else if (getBeginLine() == line) { + return getBeginColumn() > column; + } else { + return false; + } + } + + public boolean isPositionedBefore(int line, int column) { + if (line == ABSOLUTE_END_LINE) return true; + if (getEndLine() < line) { + return true; + } else if (getEndLine() == line) { + return getEndColumn() < column; + } else { + return false; + } + } + + public boolean hasComment() + { + return comment != null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/PackageDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/PackageDeclaration.java new file mode 100644 index 000000000..d0aaf5b1e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/PackageDeclaration.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the package declaration. The package declaration is + * optional for the {@link CompilationUnit}. + * </p> + * The PackageDeclaration is constructed following the syntax:<br> + * <pre> + * {@code + * PackageDeclaration ::= ( }{@link AnnotationExpr}{@code )* "package" }{@link NameExpr}{@code ) ";" + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class PackageDeclaration extends Node { + + private List<AnnotationExpr> annotations; + + private NameExpr name; + + public PackageDeclaration() { + } + + public PackageDeclaration(NameExpr name) { + setName(name); + } + + public PackageDeclaration(List<AnnotationExpr> annotations, NameExpr name) { + setAnnotations(annotations); + setName(name); + } + + public PackageDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, NameExpr name) { + super(beginLine, beginColumn, endLine, endColumn); + setAnnotations(annotations); + setName(name); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the list of annotations declared before the package + * declaration. Return <code>null</code> if there are no annotations. + * + * @return list of annotations or <code>null</code> + */ + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + /** + * Return the name of the package. + * + * @return the name of the package + */ + public NameExpr getName() { + return name; + } + + /** + * @param annotations + * the annotations to set + */ + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } + + /** + * Sets the name of this package declaration. + * + * @param name + * the name to set + */ + public void setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TreeVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TreeVisitor.java new file mode 100644 index 000000000..f3b2672d0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TreeVisitor.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +public abstract class TreeVisitor { + + public void visitDepthFirst(Node node){ + process(node); + for (Node child : node.getChildrenNodes()){ + visitDepthFirst(child); + } + } + + public abstract void process(Node node); + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TypeParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TypeParameter.java new file mode 100644 index 000000000..c43d3793d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TypeParameter.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the declaration of a generics argument. + * </p> + * The TypeParameter is constructed following the syntax:<br> + * <pre> + * {@code + * TypeParameter ::= <IDENTIFIER> ( "extends" }{@link ClassOrInterfaceType}{@code ( "&" }{@link ClassOrInterfaceType}{@code )* )? + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class TypeParameter extends Node implements NamedNode { + + private String name; + + private List<AnnotationExpr> annotations; + + private List<ClassOrInterfaceType> typeBound; + + public TypeParameter() { + } + + public TypeParameter(final String name, final List<ClassOrInterfaceType> typeBound) { + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name, final List<ClassOrInterfaceType> typeBound) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(int beginLine, int beginColumn, int endLine, + int endColumn, String name, List<ClassOrInterfaceType> typeBound, List<AnnotationExpr> annotations) { + this(beginLine, beginColumn, endLine, endColumn, name, typeBound); + setName(name); + setTypeBound(typeBound); + this.annotations = annotations; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + /** + * Return the name of the paramenter. + * + * @return the name of the paramenter + */ + public String getName() { + return name; + } + + /** + * Return the list of {@link ClassOrInterfaceType} that this parameter + * extends. Return <code>null</code> null if there are no type. + * + * @return list of types that this paramente extends or <code>null</code> + */ + public List<ClassOrInterfaceType> getTypeBound() { + return typeBound; + } + + /** + * Sets the name of this type parameter. + * + * @param name + * the name to set + */ + public void setName(final String name) { + this.name = name; + } + + /** + * Sets the list o types. + * + * @param typeBound + * the typeBound to set + */ + public void setTypeBound(final List<ClassOrInterfaceType> typeBound) { + this.typeBound = typeBound; + setAsParentNodeOf(typeBound); + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotableNode.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotableNode.java new file mode 100644 index 000000000..47c8c4fe8 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotableNode.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +/** + * An element which can be the target of annotations. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public interface AnnotableNode { + public List<AnnotationExpr> getAnnotations(); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationDeclaration.java new file mode 100644 index 000000000..51f25617a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationDeclaration.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class AnnotationDeclaration extends TypeDeclaration implements DocumentableNode { + + public AnnotationDeclaration() { + } + + public AnnotationDeclaration(int modifiers, String name) { + super(modifiers, name); + } + + public AnnotationDeclaration(int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) { + super(annotations, modifiers, name, members); + } + + public AnnotationDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java new file mode 100644 index 000000000..a81e6cc71 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class AnnotationMemberDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode { + + private int modifiers; + + private Type type; + + private String name; + + private Expression defaultValue; + + public AnnotationMemberDeclaration() { + } + + public AnnotationMemberDeclaration(int modifiers, Type type, String name, Expression defaultValue) { + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + public AnnotationMemberDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) { + super(annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + public AnnotationMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getDefaultValue() { + return defaultValue; + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public String getName() { + return name; + } + + public Type getType() { + return type; + } + + public void setDefaultValue(Expression defaultValue) { + this.defaultValue = defaultValue; + setAsParentNodeOf(defaultValue); + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public void setName(String name) { + this.name = name; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(type); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BaseParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BaseParameter.java new file mode 100644 index 000000000..e14deb177 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BaseParameter.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +public abstract class BaseParameter extends Node { + private int modifiers; + + private List<AnnotationExpr> annotations; + + private VariableDeclaratorId id; + + public BaseParameter() { + } + + public BaseParameter(VariableDeclaratorId id) { + setId(id); + } + + public BaseParameter(int modifiers, VariableDeclaratorId id) { + setModifiers(modifiers); + setId(id); + } + + public BaseParameter(int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) { + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + } + + public BaseParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn); + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + public VariableDeclaratorId getId() { + return id; + } + + /** + * Return the modifiers of this parameter declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } + + public void setId(VariableDeclaratorId id) { + this.id = id; + setAsParentNodeOf(this.id); + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BodyDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BodyDeclaration.java new file mode 100644 index 000000000..bbf138b77 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BodyDeclaration.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class BodyDeclaration extends Node implements AnnotableNode { + + private List<AnnotationExpr> annotations; + + public BodyDeclaration() { + } + + public BodyDeclaration(List<AnnotationExpr> annotations) { + setAnnotations(annotations); + } + + public BodyDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) { + super(beginLine, beginColumn, endLine, endColumn); + setAnnotations(annotations); + } + + public final List<AnnotationExpr> getAnnotations() { + if (annotations==null){ + annotations = new ArrayList<AnnotationExpr>(); + } + return annotations; + } + + public final void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java new file mode 100644 index 000000000..e098f6edb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceDeclaration extends TypeDeclaration implements DocumentableNode { + + private boolean interface_; + + private List<TypeParameter> typeParameters; + + // Can contain more than one item if this is an interface + private List<ClassOrInterfaceType> extendsList; + + private List<ClassOrInterfaceType> implementsList; + + public ClassOrInterfaceDeclaration() { + } + + public ClassOrInterfaceDeclaration(final int modifiers, final boolean isInterface, final String name) { + super(modifiers, name); + setInterface(isInterface); + } + + public ClassOrInterfaceDeclaration(final int modifiers, + final List<AnnotationExpr> annotations, final boolean isInterface, final String name, + final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList, + final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) { + super(annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + public ClassOrInterfaceDeclaration(final int beginLine, final int beginColumn, final int endLine, + final int endColumn, final int modifiers, + final List<AnnotationExpr> annotations, final boolean isInterface, final String name, + final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList, + final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<ClassOrInterfaceType> getExtends() { + return extendsList; + } + + public List<ClassOrInterfaceType> getImplements() { + return implementsList; + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public boolean isInterface() { + return interface_; + } + + public void setExtends(final List<ClassOrInterfaceType> extendsList) { + this.extendsList = extendsList; + setAsParentNodeOf(this.extendsList); + } + + public void setImplements(final List<ClassOrInterfaceType> implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + } + + public void setInterface(final boolean interface_) { + this.interface_ = interface_; + } + + public void setTypeParameters(final List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ConstructorDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ConstructorDeclaration.java new file mode 100644 index 000000000..892810c59 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ConstructorDeclaration.java @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import java.util.List; +import java.util.ArrayList; + +import com.github.javaparser.ast.AccessSpecifier; +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ConstructorDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, + NamedNode { + + private int modifiers; + + private List<TypeParameter> typeParameters; + + private NameExpr name; + + private List<Parameter> parameters; + + private List<NameExpr> throws_; + + private BlockStmt block; + + public ConstructorDeclaration() { + } + + public ConstructorDeclaration(int modifiers, String name) { + setModifiers(modifiers); + setName(name); + } + + public ConstructorDeclaration(int modifiers, List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, + String name, List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) { + super(annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBlock(block); + } + + public ConstructorDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, + List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name, + List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBlock(block); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public String getName() { + return name == null ? null : name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public List<Parameter> getParameters() { + if (parameters == null) { + parameters = new ArrayList<Parameter>(); + } + return parameters; + } + + public List<NameExpr> getThrows() { + if (throws_ == null) { + throws_ = new ArrayList<NameExpr>(); + } + return throws_; + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public void setBlock(BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public void setName(String name) { + this.name = new NameExpr(name); + } + + public void setNameExpr(NameExpr name) { + this.name = name; + } + + public void setParameters(List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public void setThrows(List<NameExpr> throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + } + + public void setTypeParameters(List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + /** + * The declaration returned has this schema: + * + * [accessSpecifier] className ([paramType [paramName]]) + * [throws exceptionsList] + */ + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, + boolean includingParameterName) { + StringBuffer sb = new StringBuffer(); + if (includingModifiers) { + AccessSpecifier accessSpecifier = ModifierSet.getAccessSpecifier(getModifiers()); + sb.append(accessSpecifier.getCodeRepresenation()); + sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " "); + } + sb.append(getName()); + sb.append("("); + boolean firstParam = true; + for (Parameter param : getParameters()) + { + if (firstParam) { + firstParam = false; + } else { + sb.append(", "); + } + if (includingParameterName) { + sb.append(param.toStringWithoutComments()); + } else { + sb.append(param.getType().toStringWithoutComments()); + } + } + sb.append(")"); + if (includingThrows) { + boolean firstThrow = true; + for (NameExpr thr : getThrows()) { + if (firstThrow) { + firstThrow = false; + sb.append(" throws "); + } else { + sb.append(", "); + } + sb.append(thr.toStringWithoutComments()); + } + } + return sb.toString(); + } + + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows) { + return getDeclarationAsString(includingModifiers, includingThrows, true); + } + + @Override + public String getDeclarationAsString() { + return getDeclarationAsString(true, true, true); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyMemberDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyMemberDeclaration.java new file mode 100644 index 000000000..1c19d097f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyMemberDeclaration.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyMemberDeclaration extends BodyDeclaration implements DocumentableNode { + + public EmptyMemberDeclaration() { + super(null); + } + + public EmptyMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyTypeDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyTypeDeclaration.java new file mode 100644 index 000000000..59e868600 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyTypeDeclaration.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyTypeDeclaration extends TypeDeclaration implements DocumentableNode { + + public EmptyTypeDeclaration() { + super(null, 0, null, null); + } + + public EmptyTypeDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, null, 0, null, null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public JavadocComment getJavaDoc() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumConstantDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumConstantDeclaration.java new file mode 100644 index 000000000..d7c425cda --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumConstantDeclaration.java @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumConstantDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode { + + private String name; + + private List<Expression> args; + + private List<BodyDeclaration> classBody; + + public EnumConstantDeclaration() { + } + + public EnumConstantDeclaration(String name) { + setName(name); + } + + public EnumConstantDeclaration(List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) { + super(annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + public EnumConstantDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + return args; + } + + public List<BodyDeclaration> getClassBody() { + return classBody; + } + + public String getName() { + return name; + } + + public void setArgs(List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setClassBody(List<BodyDeclaration> classBody) { + this.classBody = classBody; + setAsParentNodeOf(this.classBody); + } + + public void setName(String name) { + this.name = name; + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumDeclaration.java new file mode 100644 index 000000000..34b8ee4e5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumDeclaration.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumDeclaration extends TypeDeclaration implements DocumentableNode { + + private List<ClassOrInterfaceType> implementsList; + + private List<EnumConstantDeclaration> entries; + + public EnumDeclaration() { + } + + public EnumDeclaration(int modifiers, String name) { + super(modifiers, name); + } + + public EnumDeclaration(int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) { + super(annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + public EnumDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<EnumConstantDeclaration> getEntries() { + return entries; + } + + public List<ClassOrInterfaceType> getImplements() { + return implementsList; + } + + public void setEntries(List<EnumConstantDeclaration> entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + } + + public void setImplements(List<ClassOrInterfaceType> implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/FieldDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/FieldDeclaration.java new file mode 100644 index 000000000..2f48ed8f5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/FieldDeclaration.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldDeclaration extends BodyDeclaration implements DocumentableNode { + + private int modifiers; + + private Type type; + + private List<VariableDeclarator> variables; + + public FieldDeclaration() { + } + + public FieldDeclaration(int modifiers, Type type, VariableDeclarator variable) { + setModifiers(modifiers); + setType(type); + List<VariableDeclarator> aux = new ArrayList<VariableDeclarator>(); + aux.add(variable); + setVariables(aux); + } + + public FieldDeclaration(int modifiers, Type type, List<VariableDeclarator> variables) { + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + public FieldDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) { + super(annotations); + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + public FieldDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public Type getType() { + return type; + } + + public List<VariableDeclarator> getVariables() { + return variables; + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setVariables(List<VariableDeclarator> variables) { + this.variables = variables; + setAsParentNodeOf(this.variables); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/InitializerDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/InitializerDeclaration.java new file mode 100644 index 000000000..ea1df9a98 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/InitializerDeclaration.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class InitializerDeclaration extends BodyDeclaration implements DocumentableNode { + + private boolean isStatic; + + private BlockStmt block; + + public InitializerDeclaration() { + } + + public InitializerDeclaration(boolean isStatic, BlockStmt block) { + super(null); + setStatic(isStatic); + setBlock(block); + } + + public InitializerDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, boolean isStatic, BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, null); + setStatic(isStatic); + setBlock(block); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + public boolean isStatic() { + return isStatic; + } + + public void setBlock(BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + } + + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MethodDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MethodDeclaration.java new file mode 100644 index 000000000..7f9ca0b7d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MethodDeclaration.java @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.AccessSpecifier; +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; +import java.util.ArrayList; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, NamedNode { + + private int modifiers; + + private List<TypeParameter> typeParameters; + + private Type type; + + private NameExpr name; + + private List<Parameter> parameters; + + private int arrayCount; + + private List<NameExpr> throws_; + + private BlockStmt body; + + private boolean isDefault = false; + + public MethodDeclaration() { + } + + public MethodDeclaration(final int modifiers, final Type type, final String name) { + setModifiers(modifiers); + setType(type); + setName(name); + } + + public MethodDeclaration(final int modifiers, final Type type, final String name, final List<Parameter> parameters) { + setModifiers(modifiers); + setType(type); + setName(name); + setParameters(parameters); + } + + public MethodDeclaration(final int modifiers, final List<AnnotationExpr> annotations, + final List<TypeParameter> typeParameters, final Type type, final String name, + final List<Parameter> parameters, final int arrayCount, final List<NameExpr> throws_, final BlockStmt block) { + super(annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setType(type); + setName(name); + setParameters(parameters); + setArrayCount(arrayCount); + setThrows(throws_); + setBody(block); + } + + public MethodDeclaration(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final int modifiers, final List<AnnotationExpr> annotations, + final List<TypeParameter> typeParameters, final Type type, final String name, + final List<Parameter> parameters, final int arrayCount, final List<NameExpr> throws_, final BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setType(type); + setName(name); + setParameters(parameters); + setArrayCount(arrayCount); + setThrows(throws_); + setBody(block); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + // FIXME this is called "Block" in the constructor. Pick one. + public BlockStmt getBody() { + return body; + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public List<Parameter> getParameters() { + if (parameters == null) { + parameters = new ArrayList<Parameter>(); + } + return parameters; + } + + public List<NameExpr> getThrows() { + if (throws_ == null) { + throws_ = new ArrayList<NameExpr>(); + } + return throws_; + } + + public Type getType() { + return type; + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public void setArrayCount(final int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setBody(final BlockStmt body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setModifiers(final int modifiers) { + this.modifiers = modifiers; + } + + public void setName(final String name) { + this.name = new NameExpr(name); + } + + public void setNameExpr(final NameExpr name) { + this.name = name; + } + + public void setParameters(final List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public void setThrows(final List<NameExpr> throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setTypeParameters(final List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(typeParameters); + } + + + public boolean isDefault() { + return isDefault; + } + + public void setDefault(boolean isDefault) { + this.isDefault = isDefault; + } + + + @Override + public String getDeclarationAsString() { + return getDeclarationAsString(true, true, true); + } + + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows) { + return getDeclarationAsString(includingModifiers, includingThrows, true); + } + + /** + * The declaration returned has this schema: + * + * [accessSpecifier] [static] [abstract] [final] [native] + * [synchronized] returnType methodName ([paramType [paramName]]) + * [throws exceptionsList] + * @return method declaration as String + */ + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName) { + StringBuffer sb = new StringBuffer(); + if (includingModifiers) { + AccessSpecifier accessSpecifier = ModifierSet.getAccessSpecifier(getModifiers()); + sb.append(accessSpecifier.getCodeRepresenation()); + sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " "); + if (ModifierSet.isStatic(getModifiers())){ + sb.append("static "); + } + if (ModifierSet.isAbstract(getModifiers())){ + sb.append("abstract "); + } + if (ModifierSet.isFinal(getModifiers())){ + sb.append("final "); + } + if (ModifierSet.isNative(getModifiers())){ + sb.append("native "); + } + if (ModifierSet.isSynchronized(getModifiers())){ + sb.append("synchronized "); + } + } + // TODO verify it does not print comments connected to the type + sb.append(getType().toStringWithoutComments()); + sb.append(" "); + sb.append(getName()); + sb.append("("); + boolean firstParam = true; + for (Parameter param : getParameters()) + { + if (firstParam) { + firstParam = false; + } else { + sb.append(", "); + } + if (includingParameterName) { + sb.append(param.toStringWithoutComments()); + } else { + sb.append(param.getType().toStringWithoutComments()); + if (param.isVarArgs()) { + sb.append("..."); + } + } + } + sb.append(")"); + if (includingThrows) { + boolean firstThrow = true; + for (NameExpr thr : getThrows()) { + if (firstThrow) { + firstThrow = false; + sb.append(" throws "); + } else { + sb.append(", "); + } + sb.append(thr.toStringWithoutComments()); + } + } + return sb.toString(); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ModifierSet.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ModifierSet.java new file mode 100644 index 000000000..6981ced30 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ModifierSet.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.AccessSpecifier; + +import java.lang.reflect.Modifier; + +/** + * Class to hold modifiers.<br> + * The modifier constants declared here holds equivalent values to + * {@link Modifier} constants. + */ +public final class ModifierSet { + + /* Definitions of the bits in the modifiers field. */ + + public static final int PUBLIC = Modifier.PUBLIC; + + public static final int PRIVATE = Modifier.PRIVATE; + + public static final int PROTECTED = Modifier.PROTECTED; + + public static final int STATIC = Modifier.STATIC; + + public static final int FINAL = Modifier.FINAL; + + public static final int SYNCHRONIZED = Modifier.SYNCHRONIZED; + + public static final int VOLATILE = Modifier.VOLATILE; + + public static final int TRANSIENT = Modifier.TRANSIENT; + + public static final int NATIVE = Modifier.NATIVE; + + public static final int ABSTRACT = Modifier.ABSTRACT; + + public static final int STRICTFP = Modifier.STRICT; + + public static AccessSpecifier getAccessSpecifier(int modifiers) { + if (isPublic(modifiers)){ + return AccessSpecifier.PUBLIC; + } else if (isProtected(modifiers)){ + return AccessSpecifier.PROTECTED; + } else if (isPrivate(modifiers)){ + return AccessSpecifier.PRIVATE; + } else { + return AccessSpecifier.DEFAULT; + } + } + + public static int addModifier(int modifiers, int mod) { + return modifiers | mod; + } + + public static boolean hasModifier(int modifiers, int modifier) { + return (modifiers & modifier) != 0; + } + + public static boolean isAbstract(int modifiers) { + return (modifiers & ABSTRACT) != 0; + } + + public static boolean isFinal(int modifiers) { + return (modifiers & FINAL) != 0; + } + + public static boolean isNative(int modifiers) { + return (modifiers & NATIVE) != 0; + } + + public static boolean isPrivate(int modifiers) { + return (modifiers & PRIVATE) != 0; + } + + public static boolean isProtected(int modifiers) { + return (modifiers & PROTECTED) != 0; + } + + /** + * Is the element accessible from within the package? + * It is the level of access which is applied if no modifiers are chosen, + * it is sometimes called "default". + * @param modifiers indicator + * @return true if modifier denotes package level access + */ + public static boolean hasPackageLevelAccess(int modifiers) { + return !isPublic(modifiers) && !isProtected(modifiers) && !isPrivate(modifiers); + } + + public static boolean isPublic(int modifiers) { + return (modifiers & PUBLIC) != 0; + } + + public static boolean isStatic(int modifiers) { + return (modifiers & STATIC) != 0; + } + + public static boolean isStrictfp(int modifiers) { + return (modifiers & STRICTFP) != 0; + } + + public static boolean isSynchronized(int modifiers) { + return (modifiers & SYNCHRONIZED) != 0; + } + + public static boolean isTransient(int modifiers) { + return (modifiers & TRANSIENT) != 0; + } + + public static boolean isVolatile(int modifiers) { + return (modifiers & VOLATILE) != 0; + } + + /** + * Removes the given modifier. + * @param modifiers existing modifiers + * @param mod modifier to be removed + * @return result for removing modifier + */ + public static int removeModifier(int modifiers, int mod) { + return modifiers & ~mod; + } + + private ModifierSet() { + } +}
\ No newline at end of file diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MultiTypeParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MultiTypeParameter.java new file mode 100644 index 000000000..6dad24c71 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MultiTypeParameter.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +public class MultiTypeParameter extends BaseParameter { + private List<Type> types; + + public MultiTypeParameter() {} + + public MultiTypeParameter(int modifiers, List<AnnotationExpr> annotations, List<Type> types, VariableDeclaratorId id) { + super(modifiers, annotations, id); + this.types = types; + } + + public MultiTypeParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, List<Type> types, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id); + this.types = types; + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Type> getTypes() { + return types; + } + + public void setTypes(List<Type> types) { + this.types = types; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/Parameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/Parameter.java new file mode 100644 index 000000000..6113d702a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/Parameter.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class Parameter extends BaseParameter { + private Type type; + + private boolean isVarArgs; + + public Parameter() { + } + + public Parameter(Type type, VariableDeclaratorId id) { + super(id); + setType(type); + } + + public Parameter(int modifiers, Type type, VariableDeclaratorId id) { + super(modifiers, id); + setType(type); + } + + public Parameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, boolean isVarArgs, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id); + setType(type); + setVarArgs(isVarArgs); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Type getType() { + return type; + } + + public boolean isVarArgs() { + return isVarArgs; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/TypeDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/TypeDeclaration.java new file mode 100644 index 000000000..bd7c09327 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/TypeDeclaration.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class TypeDeclaration extends BodyDeclaration implements NamedNode { + + private NameExpr name; + + private int modifiers; + + private List<BodyDeclaration> members; + + public TypeDeclaration() { + } + + public TypeDeclaration(int modifiers, String name) { + setName(name); + setModifiers(modifiers); + } + + public TypeDeclaration(List<AnnotationExpr> annotations, + int modifiers, String name, + List<BodyDeclaration> members) { + super(annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public TypeDeclaration(int beginLine, int beginColumn, int endLine, + int endColumn, List<AnnotationExpr> annotations, + int modifiers, String name, + List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public final List<BodyDeclaration> getMembers() { + return members; + } + + /** + * Return the modifiers of this type declaration. + * + * @see ModifierSet + * @return modifiers + */ + public final int getModifiers() { + return modifiers; + } + + public final String getName() { + return name.getName(); + } + + public void setMembers(List<BodyDeclaration> members) { + this.members = members; + setAsParentNodeOf(this.members); + } + + public final void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public final void setName(String name) { + this.name = new NameExpr(name); + } + + public final void setNameExpr(NameExpr nameExpr) { + this.name = nameExpr; + } + + public final NameExpr getNameExpr() { + return name; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclarator.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclarator.java new file mode 100644 index 000000000..50097b863 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclarator.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclarator extends Node { + + private VariableDeclaratorId id; + + private Expression init; + + public VariableDeclarator() { + } + + public VariableDeclarator(VariableDeclaratorId id) { + setId(id); + } + + public VariableDeclarator(VariableDeclaratorId id, Expression init) { + setId(id); + setInit(init); + } + + public VariableDeclarator(int beginLine, int beginColumn, int endLine, int endColumn, VariableDeclaratorId id, Expression init) { + super(beginLine, beginColumn, endLine, endColumn); + setId(id); + setInit(init); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public VariableDeclaratorId getId() { + return id; + } + + public Expression getInit() { + return init; + } + + public void setId(VariableDeclaratorId id) { + this.id = id; + setAsParentNodeOf(this.id); + } + + public void setInit(Expression init) { + this.init = init; + setAsParentNodeOf(this.init); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclaratorId.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclaratorId.java new file mode 100644 index 000000000..c56bd8e7f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclaratorId.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclaratorId extends Node implements NamedNode { + + private String name; + + private int arrayCount; + + public VariableDeclaratorId() { + } + + public VariableDeclaratorId(String name) { + setName(name); + } + + public VariableDeclaratorId(int beginLine, int beginColumn, int endLine, int endColumn, String name, int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setArrayCount(arrayCount); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public String getName() { + return name; + } + + public void setArrayCount(int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/WithDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/WithDeclaration.java new file mode 100644 index 000000000..8f1725ce6 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/WithDeclaration.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +/** + * Element with a declaration representable as a String. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public interface WithDeclaration { + + /** + * As {@link WithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including + * the modifiers, the throws clause and the parameters with both type and name. + * @return String representation of declaration + */ + String getDeclarationAsString(); + + /** + * As {@link WithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including + * the parameters with both type and name. + * @param includingModifiers flag to include the modifiers (if present) in the string produced + * @param includingThrows flag to include the throws clause (if present) in the string produced + * @return String representation of declaration based on parameter flags + */ + String getDeclarationAsString(boolean includingModifiers, boolean includingThrows); + + /** + * A simple representation of the element declaration. + * It should fit one string. + * @param includingModifiers flag to include the modifiers (if present) in the string produced + * @param includingThrows flag to include the throws clause (if present) in the string produced + * @param includingParameterName flag to include the parameter name (while the parameter type is always included) in the string produced + * @return String representation of declaration based on parameter flags + */ + String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/BlockComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/BlockComment.java new file mode 100644 index 000000000..299493b87 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/BlockComment.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * AST node that represent block comments. + * </p> + * Block comments can has multi lines and are delimited by "/*" and + * "*/". + * + * @author Julio Vilmar Gesser + */ +public final class BlockComment extends Comment { + + public BlockComment() { + } + + public BlockComment(String content) { + super(content); + } + + public BlockComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/Comment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/Comment.java new file mode 100644 index 000000000..135972b92 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/Comment.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.Node; + +/** + * Abstract class for all AST nodes that represent comments. + * + * @see BlockComment + * @see LineComment + * @see JavadocComment + * @author Julio Vilmar Gesser + */ +public abstract class Comment extends Node { + + private String content; + private Node commentedNode; + + public Comment() { + } + + public Comment(String content) { + this.content = content; + } + + public Comment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn); + this.content = content; + } + + /** + * Return the text of the comment. + * + * @return text of the comment + */ + public final String getContent() { + return content; + } + + /** + * Sets the text of the comment. + * + * @param content + * the text of the comment to set + */ + public void setContent(String content) { + this.content = content; + } + + public boolean isLineComment() + { + return false; + } + + public LineComment asLineComment() + { + if (isLineComment()) + { + return (LineComment) this; + } else { + throw new UnsupportedOperationException("Not a line comment"); + } + } + + public Node getCommentedNode() + { + return this.commentedNode; + } + + public void setCommentedNode(Node commentedNode) + { + if (commentedNode==null) + { + this.commentedNode = commentedNode; + return; + } + if (commentedNode==this) + { + throw new IllegalArgumentException(); + } + if (commentedNode instanceof Comment) + { + throw new IllegalArgumentException(); + } + this.commentedNode = commentedNode; + } + + public boolean isOrphan() + { + return this.commentedNode == null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsCollection.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsCollection.java new file mode 100644 index 000000000..ac94c61d5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsCollection.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import java.util.LinkedList; +import java.util.List; + +/** + * Set of comments produced by CommentsParser. + */ +public class CommentsCollection { + private List<LineComment> lineComments = new LinkedList<LineComment>(); + private List<BlockComment> blockComments = new LinkedList<BlockComment>(); + private List<JavadocComment> javadocComments = new LinkedList<JavadocComment>(); + + public List<LineComment> getLineComments(){ + return lineComments; + } + + public List<BlockComment> getBlockComments(){ + return blockComments; + } + + public List<JavadocComment> getJavadocComments(){ + return javadocComments; + } + + public void addComment(LineComment lineComment){ + this.lineComments.add(lineComment); + } + + public void addComment(BlockComment blockComment){ + this.blockComments.add(blockComment); + } + + public void addComment(JavadocComment javadocComment){ + this.javadocComments.add(javadocComment); + } + + public boolean contains(Comment comment){ + for (Comment c : getAll()){ + // we tollerate a difference of one element in the end column: + // it depends how \r and \n are calculated... + if ( c.getBeginLine()==comment.getBeginLine() && + c.getBeginColumn()==comment.getBeginColumn() && + c.getEndLine()==comment.getEndLine() && + Math.abs(c.getEndColumn()-comment.getEndColumn())<2 ){ + return true; + } + } + return false; + } + + public List<Comment> getAll(){ + List<Comment> comments = new LinkedList<Comment>(); + comments.addAll(lineComments); + comments.addAll(blockComments); + comments.addAll(javadocComments); + return comments; + } + + public int size(){ + return lineComments.size()+blockComments.size()+javadocComments.size(); + } + + public CommentsCollection minus(CommentsCollection other){ + CommentsCollection result = new CommentsCollection(); + for (LineComment comment : lineComments){ + if (!other.contains(comment)){ + result.lineComments.add(comment); + } + } + for (BlockComment comment : blockComments){ + if (!other.contains(comment)){ + result.blockComments.add(comment); + } + } + for (JavadocComment comment : javadocComments){ + if (!other.contains(comment)){ + result.javadocComments.add(comment); + } + } + return result; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsParser.java new file mode 100644 index 000000000..3d3a59d45 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsParser.java @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import java.io.*; +import java.nio.charset.Charset; +import java.util.*; + +/** + * This parser cares exclusively about comments. + */ +public class CommentsParser { + + private enum State { + CODE, + IN_LINE_COMMENT, + IN_BLOCK_COMMENT, + IN_STRING, + IN_CHAR; + } + + private static final int COLUMNS_PER_TAB = 4; + + public CommentsCollection parse(final String source) throws IOException, UnsupportedEncodingException { + InputStream in = new ByteArrayInputStream(source.getBytes(Charset.defaultCharset())); + return parse(in, Charset.defaultCharset().name()); + } + + public CommentsCollection parse(final InputStream in, final String charsetName) throws IOException, UnsupportedEncodingException { + boolean lastWasASlashR = false; + BufferedReader br = new BufferedReader(new InputStreamReader(in, charsetName)); + CommentsCollection comments = new CommentsCollection(); + int r; + + Deque prevTwoChars = new LinkedList<Character>(Arrays.asList('z','z')); + + State state = State.CODE; + LineComment currentLineComment = null; + BlockComment currentBlockComment = null; + StringBuffer currentContent = null; + + int currLine = 1; + int currCol = 1; + + while ((r=br.read()) != -1){ + char c = (char)r; + if (c=='\r'){ + lastWasASlashR = true; + } else if (c=='\n'&&lastWasASlashR){ + lastWasASlashR=false; + continue; + } else { + lastWasASlashR=false; + } + switch (state) { + case CODE: + if (prevTwoChars.peekLast().equals('/') && c == '/') { + currentLineComment = new LineComment(); + currentLineComment.setBeginLine(currLine); + currentLineComment.setBeginColumn(currCol - 1); + state = State.IN_LINE_COMMENT; + currentContent = new StringBuffer(); + } else if (prevTwoChars.peekLast().equals('/') && c == '*') { + currentBlockComment = new BlockComment(); + currentBlockComment.setBeginLine(currLine); + currentBlockComment.setBeginColumn(currCol - 1); + state = State.IN_BLOCK_COMMENT; + currentContent = new StringBuffer(); + } else if (c == '"') { + state = State.IN_STRING; + } else if (c == '\'') { + state = State.IN_CHAR; + } else { + // nothing to do + } + break; + case IN_LINE_COMMENT: + if (c=='\n' || c=='\r'){ + currentLineComment.setContent(currentContent.toString()); + currentLineComment.setEndLine(currLine); + currentLineComment.setEndColumn(currCol); + comments.addComment(currentLineComment); + state = State.CODE; + } else { + currentContent.append(c); + } + break; + case IN_BLOCK_COMMENT: + if (prevTwoChars.peekLast().equals('*') && c=='/' && !prevTwoChars.peekFirst().equals('/')){ + + // delete last character + String content = currentContent.deleteCharAt(currentContent.toString().length()-1).toString(); + + if (content.startsWith("*")){ + JavadocComment javadocComment = new JavadocComment(); + javadocComment.setContent(content.substring(1)); + javadocComment.setBeginLine(currentBlockComment.getBeginLine()); + javadocComment.setBeginColumn(currentBlockComment.getBeginColumn()); + javadocComment.setEndLine(currLine); + javadocComment.setEndColumn(currCol+1); + comments.addComment(javadocComment); + } else { + currentBlockComment.setContent(content); + currentBlockComment.setEndLine(currLine); + currentBlockComment.setEndColumn(currCol+1); + comments.addComment(currentBlockComment); + } + state = State.CODE; + } else { + currentContent.append(c=='\r'?'\n':c); + } + break; + case IN_STRING: + if (!prevTwoChars.peekLast().equals('\\') && c == '"') { + state = State.CODE; + } + break; + case IN_CHAR: + if (!prevTwoChars.peekLast().equals('\\') && c == '\'') { + state = State.CODE; + } + break; + default: + throw new RuntimeException("Unexpected"); + } + switch (c){ + case '\n': + case '\r': + currLine+=1; + currCol = 1; + break; + case '\t': + currCol+=COLUMNS_PER_TAB; + break; + default: + currCol+=1; + } + prevTwoChars.remove(); + prevTwoChars.add(c); + } + + if (state==State.IN_LINE_COMMENT){ + currentLineComment.setContent(currentContent.toString()); + currentLineComment.setEndLine(currLine); + currentLineComment.setEndColumn(currCol); + comments.addComment(currentLineComment); + } + + return comments; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/JavadocComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/JavadocComment.java new file mode 100644 index 000000000..a070321ff --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/JavadocComment.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class JavadocComment extends Comment { + + public JavadocComment() { + } + + public JavadocComment(String content) { + super(content); + } + + public JavadocComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/LineComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/LineComment.java new file mode 100644 index 000000000..b3df1df0e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/LineComment.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * AST node that represent line comments. + * </p> + * Line comments are started with "//" and finish at the end of the line ("\n"). + * + * @author Julio Vilmar Gesser + */ +public final class LineComment extends Comment { + + public LineComment() { + } + + public LineComment(String content) { + super(content); + } + + public LineComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean isLineComment() + { + return true; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AnnotationExpr.java new file mode 100644 index 000000000..8c65e926f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AnnotationExpr.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class AnnotationExpr extends Expression { + + protected NameExpr name; + + public AnnotationExpr() {} + + public AnnotationExpr(int beginLine, int beginColumn, int endLine, + int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + public NameExpr getName() { + return name; + } + + public void setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(name); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayAccessExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayAccessExpr.java new file mode 100644 index 000000000..7026d15eb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayAccessExpr.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayAccessExpr extends Expression { + + private Expression name; + + private Expression index; + + public ArrayAccessExpr() { + } + + public ArrayAccessExpr(Expression name, Expression index) { + setName(name); + setIndex(index); + } + + public ArrayAccessExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression name, Expression index) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setIndex(index); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getIndex() { + return index; + } + + public Expression getName() { + return name; + } + + public void setIndex(Expression index) { + this.index = index; + setAsParentNodeOf(this.index); + } + + public void setName(Expression name) { + this.name = name; + setAsParentNodeOf(this.name); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayCreationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayCreationExpr.java new file mode 100644 index 000000000..1ca425b51 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayCreationExpr.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayCreationExpr extends Expression { + + private Type type; + + private int arrayCount; + + private ArrayInitializerExpr initializer; + + private List<Expression> dimensions; + + private List<List<AnnotationExpr>> arraysAnnotations; + + public ArrayCreationExpr() { + } + + public ArrayCreationExpr(Type type, int arrayCount, ArrayInitializerExpr initializer) { + setType(type); + setArrayCount(arrayCount); + setInitializer(initializer); + setDimensions(null); + } + + public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, int arrayCount, ArrayInitializerExpr initializer) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + setInitializer(initializer); + setDimensions(null); + } + + public ArrayCreationExpr(Type type, List<Expression> dimensions, int arrayCount) { + setType(type); + setArrayCount(arrayCount); + setDimensions(dimensions); + setInitializer(null); + } + + public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, List<Expression> dimensions, int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + setDimensions(dimensions); + setInitializer(null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public List<Expression> getDimensions() { + return dimensions; + } + + public ArrayInitializerExpr getInitializer() { + return initializer; + } + + public Type getType() { + return type; + } + + public void setArrayCount(int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setDimensions(List<Expression> dimensions) { + this.dimensions = dimensions; + setAsParentNodeOf(this.dimensions); + } + + public void setInitializer(ArrayInitializerExpr initializer) { + this.initializer = initializer; + setAsParentNodeOf(this.initializer); + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public List<List<AnnotationExpr>> getArraysAnnotations() { + return arraysAnnotations; + } + + public void setArraysAnnotations( + List<List<AnnotationExpr>> arraysAnnotations) { + this.arraysAnnotations = arraysAnnotations; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayInitializerExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayInitializerExpr.java new file mode 100644 index 000000000..f7fa424cf --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayInitializerExpr.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayInitializerExpr extends Expression { + + private List<Expression> values; + + public ArrayInitializerExpr() { + } + + public ArrayInitializerExpr(List<Expression> values) { + setValues(values); + } + + public ArrayInitializerExpr(int beginLine, int beginColumn, int endLine, int endColumn, List<Expression> values) { + super(beginLine, beginColumn, endLine, endColumn); + setValues(values); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Expression> getValues() { + return values; + } + + public void setValues(List<Expression> values) { + this.values = values; + setAsParentNodeOf(this.values); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AssignExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AssignExpr.java new file mode 100644 index 000000000..b3d508fe9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AssignExpr.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class AssignExpr extends Expression { + + public static enum Operator { + assign, // = + plus, // += + minus, // -= + star, // *= + slash, // /= + and, // &= + or, // |= + xor, // ^= + rem, // %= + lShift, // <<= + rSignedShift, // >>= + rUnsignedShift, // >>>= + } + + private Expression target; + + private Expression value; + + private Operator op; + + public AssignExpr() { + } + + public AssignExpr(Expression target, Expression value, Operator op) { + setTarget(target); + setValue(value); + setOperator(op); + } + + public AssignExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression target, Expression value, Operator op) { + super(beginLine, beginColumn, endLine, endColumn); + setTarget(target); + setValue(value); + setOperator(op); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Operator getOperator() { + return op; + } + + public Expression getTarget() { + return target; + } + + public Expression getValue() { + return value; + } + + public void setOperator(Operator op) { + this.op = op; + } + + public void setTarget(Expression target) { + this.target = target; + setAsParentNodeOf(this.target); + } + + public void setValue(Expression value) { + this.value = value; + setAsParentNodeOf(this.value); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BinaryExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BinaryExpr.java new file mode 100644 index 000000000..4ace4bec4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BinaryExpr.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BinaryExpr extends Expression { + + public static enum Operator { + or, // || + and, // && + binOr, // | + binAnd, // & + xor, // ^ + equals, // == + notEquals, // != + less, // < + greater, // > + lessEquals, // <= + greaterEquals, // >= + lShift, // << + rSignedShift, // >> + rUnsignedShift, // >>> + plus, // + + minus, // - + times, // * + divide, // / + remainder, // % + } + + private Expression left; + + private Expression right; + + private Operator op; + + public BinaryExpr() { + } + + public BinaryExpr(Expression left, Expression right, Operator op) { + setLeft(left); + setRight(right); + setOperator(op); + } + + public BinaryExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression left, Expression right, Operator op) { + super(beginLine, beginColumn, endLine, endColumn); + setLeft(left); + setRight(right); + setOperator(op); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getLeft() { + return left; + } + + public Operator getOperator() { + return op; + } + + public Expression getRight() { + return right; + } + + public void setLeft(Expression left) { + this.left = left; + setAsParentNodeOf(this.left); + } + + public void setOperator(Operator op) { + this.op = op; + } + + public void setRight(Expression right) { + this.right = right; + setAsParentNodeOf(this.right); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BooleanLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BooleanLiteralExpr.java new file mode 100644 index 000000000..e92244a62 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BooleanLiteralExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BooleanLiteralExpr extends LiteralExpr { + + private boolean value; + + public BooleanLiteralExpr() { + } + + public BooleanLiteralExpr(boolean value) { + setValue(value); + } + + public BooleanLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, boolean value) { + super(beginLine, beginColumn, endLine, endColumn); + setValue(value); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CastExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CastExpr.java new file mode 100644 index 000000000..843386968 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CastExpr.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class CastExpr extends Expression { + + private Type type; + + private Expression expr; + + public CastExpr() { + } + + public CastExpr(Type type, Expression expr) { + setType(type); + setExpr(expr); + } + + public CastExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setExpr(expr); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Type getType() { + return type; + } + + public void setExpr(Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CharLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CharLiteralExpr.java new file mode 100644 index 000000000..061805d47 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CharLiteralExpr.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class CharLiteralExpr extends StringLiteralExpr { + + public CharLiteralExpr() { + } + + public CharLiteralExpr(String value) { + super(value); + } + + public CharLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ClassExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ClassExpr.java new file mode 100644 index 000000000..bd33c6730 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ClassExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassExpr extends Expression { + + private Type type; + + public ClassExpr() { + } + + public ClassExpr(Type type) { + setType(type); + } + + public ClassExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ConditionalExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ConditionalExpr.java new file mode 100644 index 000000000..31db61cca --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ConditionalExpr.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ConditionalExpr extends Expression { + + private Expression condition; + + private Expression thenExpr; + + private Expression elseExpr; + + public ConditionalExpr() { + } + + public ConditionalExpr(Expression condition, Expression thenExpr, Expression elseExpr) { + setCondition(condition); + setThenExpr(thenExpr); + setElseExpr(elseExpr); + } + + public ConditionalExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression condition, Expression thenExpr, Expression elseExpr) { + super(beginLine, beginColumn, endLine, endColumn); + setCondition(condition); + setThenExpr(thenExpr); + setElseExpr(elseExpr); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getCondition() { + return condition; + } + + public Expression getElseExpr() { + return elseExpr; + } + + public Expression getThenExpr() { + return thenExpr; + } + + public void setCondition(Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } + + public void setElseExpr(Expression elseExpr) { + this.elseExpr = elseExpr; + setAsParentNodeOf(this.elseExpr); + } + + public void setThenExpr(Expression thenExpr) { + this.thenExpr = thenExpr; + setAsParentNodeOf(this.thenExpr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/DoubleLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/DoubleLiteralExpr.java new file mode 100644 index 000000000..ce6962d7b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/DoubleLiteralExpr.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class DoubleLiteralExpr extends StringLiteralExpr { + + public DoubleLiteralExpr() { + } + + public DoubleLiteralExpr(final String value) { + super(value); + } + + public DoubleLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/EnclosedExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/EnclosedExpr.java new file mode 100644 index 000000000..72f9de2a1 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/EnclosedExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnclosedExpr extends Expression { + + private Expression inner; + + public EnclosedExpr() { + } + + public EnclosedExpr(final Expression inner) { + setInner(inner); + } + + public EnclosedExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression inner) { + super(beginLine, beginColumn, endLine, endColumn); + setInner(inner); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getInner() { + return inner; + } + + public void setInner(final Expression inner) { + this.inner = inner; + setAsParentNodeOf(this.inner); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/Expression.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/Expression.java new file mode 100644 index 000000000..8b36d6b1d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/Expression.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.Node; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Expression extends Node { + + public Expression() { + } + + public Expression(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/FieldAccessExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/FieldAccessExpr.java new file mode 100644 index 000000000..b57bf7fe0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/FieldAccessExpr.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldAccessExpr extends Expression { + + private Expression scope; + + private List<Type> typeArgs; + + private NameExpr field; + + public FieldAccessExpr() { + } + + public FieldAccessExpr(final Expression scope, final String field) { + setScope(scope); + setField(field); + } + + public FieldAccessExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression scope, final List<Type> typeArgs, final String field) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setTypeArgs(typeArgs); + setField(field); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getField() { + return field.getName(); + } + + public NameExpr getFieldExpr() { + return field; + } + + public Expression getScope() { + return scope; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public void setField(final String field) { + this.field = new NameExpr(field); + } + + public void setFieldExpr(NameExpr field) { + this.field = field; + } + + public void setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/InstanceOfExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/InstanceOfExpr.java new file mode 100644 index 000000000..9a9786512 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/InstanceOfExpr.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class InstanceOfExpr extends Expression { + + private Expression expr; + + private Type type; + + public InstanceOfExpr() { + } + + public InstanceOfExpr(final Expression expr, final Type type) { + setExpr(expr); + setType(type); + } + + public InstanceOfExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr, final Type type) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + setType(type); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Type getType() { + return type; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralExpr.java new file mode 100644 index 000000000..b326c5770 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralExpr.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class IntegerLiteralExpr extends StringLiteralExpr { + + private static final String UNSIGNED_MIN_VALUE = "2147483648"; + + protected static final String MIN_VALUE = "-" + UNSIGNED_MIN_VALUE; + + public IntegerLiteralExpr() { + } + + public IntegerLiteralExpr(final String value) { + super(value); + } + + public IntegerLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final boolean isMinValue() { + return value != null && // + value.length() == 10 && // + value.equals(UNSIGNED_MIN_VALUE); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java new file mode 100644 index 000000000..238b56431 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class IntegerLiteralMinValueExpr extends IntegerLiteralExpr { + + public IntegerLiteralMinValueExpr() { + super(MIN_VALUE); + } + + public IntegerLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LambdaExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LambdaExpr.java new file mode 100644 index 000000000..4e4e93444 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LambdaExpr.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + + +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * Lambda expressions. + * @author Raquel Pau + * + */ +public class LambdaExpr extends Expression { + + private List<Parameter> parameters; + + private boolean parametersEnclosed; + + private Statement body; + + public LambdaExpr() { + } + + public LambdaExpr(int beginLine, int beginColumn, int endLine, + int endColumn, List<Parameter> parameters, Statement body, + boolean parametersEnclosed) { + + super(beginLine, beginColumn, endLine, endColumn); + setParameters(parameters); + setBody(body); + setParametersEnclosed(parametersEnclosed); + } + + public List<Parameter> getParameters() { + return parameters; + } + + public void setParameters(List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public Statement getBody() { + return body; + } + + public void setBody(Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean isParametersEnclosed() { + return parametersEnclosed; + } + + public void setParametersEnclosed(boolean parametersEnclosed) { + this.parametersEnclosed = parametersEnclosed; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LiteralExpr.java new file mode 100644 index 000000000..7827f7866 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LiteralExpr.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class LiteralExpr extends Expression { + + public LiteralExpr() { + } + + public LiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralExpr.java new file mode 100644 index 000000000..15ea255ba --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralExpr.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class LongLiteralExpr extends StringLiteralExpr { + + private static final String UNSIGNED_MIN_VALUE = "9223372036854775808"; + + protected static final String MIN_VALUE = "-" + UNSIGNED_MIN_VALUE + "L"; + + public LongLiteralExpr() { + } + + public LongLiteralExpr(final String value) { + super(value); + } + + public LongLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final boolean isMinValue() { + return value != null && // + value.length() == 20 && // + value.startsWith(UNSIGNED_MIN_VALUE) && // + (value.charAt(19) == 'L' || value.charAt(19) == 'l'); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java new file mode 100644 index 000000000..f351f7a59 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class LongLiteralMinValueExpr extends LongLiteralExpr { + + public LongLiteralMinValueExpr() { + super(MIN_VALUE); + } + + public LongLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java new file mode 100644 index 000000000..c1a354530 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class MarkerAnnotationExpr extends AnnotationExpr { + + public MarkerAnnotationExpr() { + } + + public MarkerAnnotationExpr(final NameExpr name) { + setName(name); + } + + public MarkerAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr name) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MemberValuePair.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MemberValuePair.java new file mode 100644 index 000000000..e0fa80c66 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MemberValuePair.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class MemberValuePair extends Node implements NamedNode { + + private String name; + + private Expression value; + + public MemberValuePair() { + } + + public MemberValuePair(final String name, final Expression value) { + setName(name); + setValue(value); + } + + public MemberValuePair(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name, final Expression value) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setValue(value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getName() { + return name; + } + + public Expression getValue() { + return value; + } + + public void setName(final String name) { + this.name = name; + } + + public void setValue(final Expression value) { + this.value = value; + setAsParentNodeOf(this.value); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodCallExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodCallExpr.java new file mode 100644 index 000000000..9d5d10f06 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodCallExpr.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodCallExpr extends Expression { + + private Expression scope; + + private List<Type> typeArgs; + + private NameExpr name; + + private List<Expression> args; + + public MethodCallExpr() { + } + + public MethodCallExpr(final Expression scope, final String name) { + setScope(scope); + setName(name); + } + + public MethodCallExpr(final Expression scope, final String name, final List<Expression> args) { + setScope(scope); + setName(name); + setArgs(args); + } + + public MethodCallExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setTypeArgs(typeArgs); + setName(name); + setArgs(args); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + return args; + } + + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public Expression getScope() { + return scope; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setName(final String name) { + this.name = new NameExpr(name); + } + + public void setNameExpr(NameExpr name) { + this.name = name; + } + + public void setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodReferenceExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodReferenceExpr.java new file mode 100644 index 000000000..918ad3f2a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodReferenceExpr.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * Method reference expressions introduced in Java 8 specifically designed to simplify lambda Expressions. + * These are some examples: + * + * System.out::println; + * + * (test ? stream.map(String::trim) : stream)::toArray; + * @author Raquel Pau + * + */ +public class MethodReferenceExpr extends Expression { + + private Expression scope; + + private List<TypeParameter> typeParameters; + + private String identifier; + + public MethodReferenceExpr() { + } + + public MethodReferenceExpr(int beginLine, int beginColumn, int endLine, + int endColumn, Expression scope, + List<TypeParameter> typeParameters, String identifier) { + + super(beginLine, beginColumn, endLine, endColumn); + setIdentifier(identifier); + setScope(scope); + setTypeParameters(typeParameters); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getScope() { + return scope; + } + + public void setScope(Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public void setTypeParameters(List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NameExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NameExpr.java new file mode 100644 index 000000000..5cdbbbb6c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NameExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class NameExpr extends Expression implements NamedNode { + + private String name; + + public NameExpr() { + } + + public NameExpr(final String name) { + this.name = name; + } + + public NameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name) { + super(beginLine, beginColumn, endLine, endColumn); + this.name = name; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final String getName() { + return name; + } + + public final void setName(final String name) { + this.name = name; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NormalAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NormalAnnotationExpr.java new file mode 100644 index 000000000..2b2adfd72 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NormalAnnotationExpr.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class NormalAnnotationExpr extends AnnotationExpr { + + private List<MemberValuePair> pairs; + + public NormalAnnotationExpr() { + } + + public NormalAnnotationExpr(final NameExpr name, final List<MemberValuePair> pairs) { + setName(name); + setPairs(pairs); + } + + public NormalAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr name, final List<MemberValuePair> pairs) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setPairs(pairs); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<MemberValuePair> getPairs() { + return pairs; + } + + public void setPairs(final List<MemberValuePair> pairs) { + this.pairs = pairs; + setAsParentNodeOf(this.pairs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NullLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NullLiteralExpr.java new file mode 100644 index 000000000..c7bc177d5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NullLiteralExpr.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class NullLiteralExpr extends LiteralExpr { + + public NullLiteralExpr() { + } + + public NullLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ObjectCreationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ObjectCreationExpr.java new file mode 100644 index 000000000..228dabc2c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ObjectCreationExpr.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ObjectCreationExpr extends Expression { + + private Expression scope; + + private ClassOrInterfaceType type; + + private List<Type> typeArgs; + + private List<Expression> args; + + private List<BodyDeclaration> anonymousClassBody; + + public ObjectCreationExpr() { + } + + public ObjectCreationExpr(final Expression scope, final ClassOrInterfaceType type, final List<Expression> args) { + setScope(scope); + setType(type); + setArgs(args); + } + + public ObjectCreationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression scope, final ClassOrInterfaceType type, final List<Type> typeArgs, + final List<Expression> args, final List<BodyDeclaration> anonymousBody) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setType(type); + setTypeArgs(typeArgs); + setArgs(args); + setAnonymousClassBody(anonymousBody); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<BodyDeclaration> getAnonymousClassBody() { + return anonymousClassBody; + } + + public List<Expression> getArgs() { + return args; + } + + public Expression getScope() { + return scope; + } + + public ClassOrInterfaceType getType() { + return type; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public void setAnonymousClassBody(final List<BodyDeclaration> anonymousClassBody) { + this.anonymousClassBody = anonymousClassBody; + setAsParentNodeOf(this.anonymousClassBody); + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setType(final ClassOrInterfaceType type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/QualifiedNameExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/QualifiedNameExpr.java new file mode 100644 index 000000000..00a65aa7f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/QualifiedNameExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class QualifiedNameExpr extends NameExpr { + + private NameExpr qualifier; + + public QualifiedNameExpr() { + } + + public QualifiedNameExpr(final NameExpr scope, final String name) { + super(name); + setQualifier(scope); + } + + public QualifiedNameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr scope, final String name) { + super(beginLine, beginColumn, endLine, endColumn, name); + setQualifier(scope); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public NameExpr getQualifier() { + return qualifier; + } + + public void setQualifier(final NameExpr qualifier) { + this.qualifier = qualifier; + setAsParentNodeOf(this.qualifier); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java new file mode 100644 index 000000000..bd8adb116 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SingleMemberAnnotationExpr extends AnnotationExpr { + + private Expression memberValue; + + public SingleMemberAnnotationExpr() { + } + + public SingleMemberAnnotationExpr(final NameExpr name, final Expression memberValue) { + setName(name); + setMemberValue(memberValue); + } + + public SingleMemberAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, + final int endColumn, final NameExpr name, final Expression memberValue) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setMemberValue(memberValue); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getMemberValue() { + return memberValue; + } + + public void setMemberValue(final Expression memberValue) { + this.memberValue = memberValue; + setAsParentNodeOf(this.memberValue); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/StringLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/StringLiteralExpr.java new file mode 100644 index 000000000..6876fa23e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/StringLiteralExpr.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class StringLiteralExpr extends LiteralExpr { + + protected String value; + + public StringLiteralExpr() { + } + + public StringLiteralExpr(final String value) { + this.value = value; + } + + public StringLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn); + this.value = value; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final String getValue() { + return value; + } + + public final void setValue(final String value) { + this.value = value; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SuperExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SuperExpr.java new file mode 100644 index 000000000..791d28bc9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SuperExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SuperExpr extends Expression { + + private Expression classExpr; + + public SuperExpr() { + } + + public SuperExpr(final Expression classExpr) { + setClassExpr(classExpr); + } + + public SuperExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression classExpr) { + super(beginLine, beginColumn, endLine, endColumn); + setClassExpr(classExpr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getClassExpr() { + return classExpr; + } + + public void setClassExpr(final Expression classExpr) { + this.classExpr = classExpr; + setAsParentNodeOf(this.classExpr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ThisExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ThisExpr.java new file mode 100644 index 000000000..c269376c9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ThisExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ThisExpr extends Expression { + + private Expression classExpr; + + public ThisExpr() { + } + + public ThisExpr(final Expression classExpr) { + setClassExpr(classExpr); + } + + public ThisExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression classExpr) { + super(beginLine, beginColumn, endLine, endColumn); + setClassExpr(classExpr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getClassExpr() { + return classExpr; + } + + public void setClassExpr(final Expression classExpr) { + this.classExpr = classExpr; + setAsParentNodeOf(this.classExpr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/TypeExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/TypeExpr.java new file mode 100644 index 000000000..636d2c4a0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/TypeExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * This class is just instantiated as scopes for MethodReferenceExpr nodes to encapsulate Types. + * @author Raquel Pau + * + */ +public class TypeExpr extends Expression{ + + private Type type; + + public TypeExpr(){} + + public TypeExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/UnaryExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/UnaryExpr.java new file mode 100644 index 000000000..19d936018 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/UnaryExpr.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class UnaryExpr extends Expression { + + public static enum Operator { + positive, // + + negative, // - + preIncrement, // ++ + preDecrement, // -- + not, // ! + inverse, // ~ + posIncrement, // ++ + posDecrement, // -- + } + + private Expression expr; + + private Operator op; + + public UnaryExpr() { + } + + public UnaryExpr(final Expression expr, final Operator op) { + setExpr(expr); + setOperator(op); + } + + public UnaryExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr, final Operator op) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + setOperator(op); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Operator getOperator() { + return op; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setOperator(final Operator op) { + this.op = op; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/VariableDeclarationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/VariableDeclarationExpr.java new file mode 100644 index 000000000..2dcaa2299 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/VariableDeclarationExpr.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.body.ModifierSet; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclarationExpr extends Expression { + + private int modifiers; + + private List<AnnotationExpr> annotations; + + private Type type; + + private List<VariableDeclarator> vars; + + public VariableDeclarationExpr() { + } + + public VariableDeclarationExpr(final Type type, final List<VariableDeclarator> vars) { + setType(type); + setVars(vars); + } + + public VariableDeclarationExpr(final int modifiers, final Type type, final List<VariableDeclarator> vars) { + setModifiers(modifiers); + setType(type); + setVars(vars); + } + + public VariableDeclarationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final int modifiers, final List<AnnotationExpr> annotations, final Type type, + final List<VariableDeclarator> vars) { + super(beginLine, beginColumn, endLine, endColumn); + setModifiers(modifiers); + setAnnotations(annotations); + setType(type); + setVars(vars); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + /** + * Return the modifiers of this variable declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public Type getType() { + return type; + } + + public List<VariableDeclarator> getVars() { + return vars; + } + + public void setAnnotations(final List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } + + public void setModifiers(final int modifiers) { + this.modifiers = modifiers; + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setVars(final List<VariableDeclarator> vars) { + this.vars = vars; + setAsParentNodeOf(this.vars); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/internal/Utils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/internal/Utils.java new file mode 100644 index 000000000..0bb7abbba --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/internal/Utils.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.internal; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * @author Federico Tomassetti + * @since 2.0.1 + */ +public class Utils { + + public static <T> List<T> ensureNotNull(List<T> list) { + return list == null ? Collections.<T>emptyList() : list; + } + + public static <E> boolean isNullOrEmpty(Collection<E> collection) { + return collection == null || collection.isEmpty(); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/AssertStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/AssertStmt.java new file mode 100644 index 000000000..60f61bca5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/AssertStmt.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class AssertStmt extends Statement { + + private Expression check; + + private Expression msg; + + public AssertStmt() { + } + + public AssertStmt(final Expression check) { + setCheck(check); + } + + public AssertStmt(final Expression check, final Expression msg) { + setCheck(check); + setMessage(msg); + } + + public AssertStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression check, final Expression msg) { + super(beginLine, beginColumn, endLine, endColumn); + + setCheck(check); + setMessage(msg); + + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getCheck() { + return check; + } + + public Expression getMessage() { + return msg; + } + + public void setCheck(final Expression check) { + this.check = check; + setAsParentNodeOf(this.check); + } + + public void setMessage(final Expression msg) { + this.msg = msg; + setAsParentNodeOf(this.msg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BlockStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BlockStmt.java new file mode 100644 index 000000000..d8b16738e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BlockStmt.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class BlockStmt extends Statement { + + private List<Statement> stmts; + + public BlockStmt() { + } + + public BlockStmt(final List<Statement> stmts) { + setStmts(stmts); + } + + public BlockStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final List<Statement> stmts) { + super(beginLine, beginColumn, endLine, endColumn); + setStmts(stmts); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Statement> getStmts() { + return stmts; + } + + public void setStmts(final List<Statement> stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BreakStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BreakStmt.java new file mode 100644 index 000000000..1a80f3e67 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BreakStmt.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BreakStmt extends Statement { + + private String id; + + public BreakStmt() { + } + + public BreakStmt(final String id) { + this.id = id; + } + + public BreakStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, final String id) { + super(beginLine, beginColumn, endLine, endColumn); + this.id = id; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/CatchClause.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/CatchClause.java new file mode 100644 index 000000000..3f43e7977 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/CatchClause.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class CatchClause extends Node { + + private MultiTypeParameter except; + + private BlockStmt catchBlock; + + public CatchClause() { + } + + public CatchClause(final MultiTypeParameter except, final BlockStmt catchBlock) { + setExcept(except); + setCatchBlock(catchBlock); + } + + public CatchClause(int exceptModifier, List<AnnotationExpr> exceptAnnotations, List<Type> exceptTypes, VariableDeclaratorId exceptId, BlockStmt catchBlock) { + this(new MultiTypeParameter(exceptModifier, exceptAnnotations, exceptTypes, exceptId), catchBlock); + } + + public CatchClause(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final List<Type> exceptTypes, + final VariableDeclaratorId exceptId, final BlockStmt catchBlock) { + super(beginLine, beginColumn, endLine, endColumn); + setExcept(new MultiTypeParameter(beginLine, beginColumn, endLine, endColumn, exceptModifier, exceptAnnotations, exceptTypes, exceptId)); + setCatchBlock(catchBlock); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public BlockStmt getCatchBlock() { + return catchBlock; + } + + public MultiTypeParameter getExcept() { + return except; + } + + public void setCatchBlock(final BlockStmt catchBlock) { + this.catchBlock = catchBlock; + setAsParentNodeOf(this.catchBlock); + } + + public void setExcept(final MultiTypeParameter except) { + this.except = except; + setAsParentNodeOf(this.except); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ContinueStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ContinueStmt.java new file mode 100644 index 000000000..81760d0a0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ContinueStmt.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ContinueStmt extends Statement { + + private String id; + + public ContinueStmt() { + } + + public ContinueStmt(final String id) { + this.id = id; + } + + public ContinueStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String id) { + super(beginLine, beginColumn, endLine, endColumn); + this.id = id; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/DoStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/DoStmt.java new file mode 100644 index 000000000..0a6a77040 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/DoStmt.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class DoStmt extends Statement { + + private Statement body; + + private Expression condition; + + public DoStmt() { + } + + public DoStmt(final Statement body, final Expression condition) { + setBody(body); + setCondition(condition); + } + + public DoStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Statement body, final Expression condition) { + super(beginLine, beginColumn, endLine, endColumn); + setBody(body); + setCondition(condition); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCondition() { + return condition; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/EmptyStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/EmptyStmt.java new file mode 100644 index 000000000..fb16c4d98 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/EmptyStmt.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyStmt extends Statement { + + public EmptyStmt() { + } + + public EmptyStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java new file mode 100644 index 000000000..d0a9efe8c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ExplicitConstructorInvocationStmt extends Statement { + + private List<Type> typeArgs; + + private boolean isThis; + + private Expression expr; + + private List<Expression> args; + + public ExplicitConstructorInvocationStmt() { + } + + public ExplicitConstructorInvocationStmt(final boolean isThis, + final Expression expr, final List<Expression> args) { + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + public ExplicitConstructorInvocationStmt(final int beginLine, + final int beginColumn, final int endLine, final int endColumn, + final List<Type> typeArgs, final boolean isThis, + final Expression expr, final List<Expression> args) { + super(beginLine, beginColumn, endLine, endColumn); + setTypeArgs(typeArgs); + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + return args; + } + + public Expression getExpr() { + return expr; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public boolean isThis() { + return isThis; + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setThis(final boolean isThis) { + this.isThis = isThis; + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExpressionStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExpressionStmt.java new file mode 100644 index 000000000..3c441e2a3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExpressionStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ExpressionStmt extends Statement { + + private Expression expr; + + public ExpressionStmt() { + } + + public ExpressionStmt(final Expression expr) { + setExpression(expr); + } + + public ExpressionStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setExpression(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpression() { + return expr; + } + + public void setExpression(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForStmt.java new file mode 100644 index 000000000..8e349bf2c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForStmt.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForStmt extends Statement { + + private List<Expression> init; + + private Expression compare; + + private List<Expression> update; + + private Statement body; + + public ForStmt() { + } + + public ForStmt(final List<Expression> init, final Expression compare, + final List<Expression> update, final Statement body) { + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + public ForStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, + final List<Expression> init, final Expression compare, + final List<Expression> update, final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCompare() { + return compare; + } + + public List<Expression> getInit() { + return init; + } + + public List<Expression> getUpdate() { + return update; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setCompare(final Expression compare) { + this.compare = compare; + setAsParentNodeOf(this.compare); + } + + public void setInit(final List<Expression> init) { + this.init = init; + setAsParentNodeOf(this.init); + } + + public void setUpdate(final List<Expression> update) { + this.update = update; + setAsParentNodeOf(this.update); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForeachStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForeachStmt.java new file mode 100644 index 000000000..245622fc5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForeachStmt.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForeachStmt extends Statement { + + private VariableDeclarationExpr var; + + private Expression iterable; + + private Statement body; + + public ForeachStmt() { + } + + public ForeachStmt(final VariableDeclarationExpr var, + final Expression iterable, final Statement body) { + setVariable(var); + setIterable(iterable); + setBody(body); + } + + public ForeachStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, + final VariableDeclarationExpr var, final Expression iterable, + final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setVariable(var); + setIterable(iterable); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getIterable() { + return iterable; + } + + public VariableDeclarationExpr getVariable() { + return var; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setIterable(final Expression iterable) { + this.iterable = iterable; + setAsParentNodeOf(this.iterable); + } + + public void setVariable(final VariableDeclarationExpr var) { + this.var = var; + setAsParentNodeOf(this.var); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/IfStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/IfStmt.java new file mode 100644 index 000000000..ccddd903e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/IfStmt.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class IfStmt extends Statement { + + private Expression condition; + + private Statement thenStmt; + + private Statement elseStmt; + + public IfStmt() { + } + + public IfStmt(final Expression condition, final Statement thenStmt, final Statement elseStmt) { + setCondition(condition); + setThenStmt(thenStmt); + setElseStmt(elseStmt); + } + + public IfStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression condition, final Statement thenStmt, final Statement elseStmt) { + super(beginLine, beginColumn, endLine, endColumn); + setCondition(condition); + setThenStmt(thenStmt); + setElseStmt(elseStmt); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getCondition() { + return condition; + } + + public Statement getElseStmt() { + return elseStmt; + } + + public Statement getThenStmt() { + return thenStmt; + } + + public void setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } + + public void setElseStmt(final Statement elseStmt) { + this.elseStmt = elseStmt; + setAsParentNodeOf(this.elseStmt); + } + + public void setThenStmt(final Statement thenStmt) { + this.thenStmt = thenStmt; + setAsParentNodeOf(this.thenStmt); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/LabeledStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/LabeledStmt.java new file mode 100644 index 000000000..85d8e7b99 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/LabeledStmt.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class LabeledStmt extends Statement { + + private String label; + + private Statement stmt; + + public LabeledStmt() { + } + + public LabeledStmt(final String label, final Statement stmt) { + setLabel(label); + setStmt(stmt); + } + + public LabeledStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String label, final Statement stmt) { + super(beginLine, beginColumn, endLine, endColumn); + setLabel(label); + setStmt(stmt); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getLabel() { + return label; + } + + public Statement getStmt() { + return stmt; + } + + public void setLabel(final String label) { + this.label = label; + } + + public void setStmt(final Statement stmt) { + this.stmt = stmt; + setAsParentNodeOf(this.stmt); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ReturnStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ReturnStmt.java new file mode 100644 index 000000000..3ac6fa65e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ReturnStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ReturnStmt extends Statement { + + private Expression expr; + + public ReturnStmt() { + } + + public ReturnStmt(final Expression expr) { + setExpr(expr); + } + + public ReturnStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/Statement.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/Statement.java new file mode 100644 index 000000000..30c462d05 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/Statement.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.Node; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Statement extends Node { + + public Statement() { + } + + public Statement(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchEntryStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchEntryStmt.java new file mode 100644 index 000000000..8f5a85ad5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchEntryStmt.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchEntryStmt extends Statement { + + private Expression label; + + private List<Statement> stmts; + + public SwitchEntryStmt() { + } + + public SwitchEntryStmt(final Expression label, final List<Statement> stmts) { + setLabel(label); + setStmts(stmts); + } + + public SwitchEntryStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression label, + final List<Statement> stmts) { + super(beginLine, beginColumn, endLine, endColumn); + setLabel(label); + setStmts(stmts); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getLabel() { + return label; + } + + public List<Statement> getStmts() { + return stmts; + } + + public void setLabel(final Expression label) { + this.label = label; + setAsParentNodeOf(this.label); + } + + public void setStmts(final List<Statement> stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchStmt.java new file mode 100644 index 000000000..49fe903da --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchStmt.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchStmt extends Statement { + + private Expression selector; + + private List<SwitchEntryStmt> entries; + + public SwitchStmt() { + } + + public SwitchStmt(final Expression selector, + final List<SwitchEntryStmt> entries) { + setSelector(selector); + setEntries(entries); + } + + public SwitchStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression selector, + final List<SwitchEntryStmt> entries) { + super(beginLine, beginColumn, endLine, endColumn); + setSelector(selector); + setEntries(entries); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<SwitchEntryStmt> getEntries() { + return entries; + } + + public Expression getSelector() { + return selector; + } + + public void setEntries(final List<SwitchEntryStmt> entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + } + + public void setSelector(final Expression selector) { + this.selector = selector; + setAsParentNodeOf(this.selector); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SynchronizedStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SynchronizedStmt.java new file mode 100644 index 000000000..e91fc0b19 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SynchronizedStmt.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SynchronizedStmt extends Statement { + + private Expression expr; + + private BlockStmt block; + + public SynchronizedStmt() { + } + + public SynchronizedStmt(final Expression expr, final BlockStmt block) { + setExpr(expr); + setBlock(block); + } + + public SynchronizedStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression expr, + final BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + setBlock(block); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + public Expression getExpr() { + return expr; + } + + public void setBlock(final BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ThrowStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ThrowStmt.java new file mode 100644 index 000000000..48283b16d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ThrowStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ThrowStmt extends Statement { + + private Expression expr; + + public ThrowStmt() { + } + + public ThrowStmt(final Expression expr) { + setExpr(expr); + } + + public ThrowStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TryStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TryStmt.java new file mode 100644 index 000000000..44009c4c9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TryStmt.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class TryStmt extends Statement { + + private List<VariableDeclarationExpr> resources; + + private BlockStmt tryBlock; + + private List<CatchClause> catchs; + + private BlockStmt finallyBlock; + + public TryStmt() { + } + + public TryStmt(final BlockStmt tryBlock, final List<CatchClause> catchs, + final BlockStmt finallyBlock) { + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + public TryStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, List<VariableDeclarationExpr> resources, + final BlockStmt tryBlock, final List<CatchClause> catchs, final BlockStmt finallyBlock) { + super(beginLine, beginColumn, endLine, endColumn); + setResources(resources); + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<CatchClause> getCatchs() { + return catchs; + } + + public BlockStmt getFinallyBlock() { + return finallyBlock; + } + + public BlockStmt getTryBlock() { + return tryBlock; + } + + public List<VariableDeclarationExpr> getResources() { + return resources; + } + + public void setCatchs(final List<CatchClause> catchs) { + this.catchs = catchs; + setAsParentNodeOf(this.catchs); + } + + public void setFinallyBlock(final BlockStmt finallyBlock) { + this.finallyBlock = finallyBlock; + setAsParentNodeOf(this.finallyBlock); + } + + public void setTryBlock(final BlockStmt tryBlock) { + this.tryBlock = tryBlock; + setAsParentNodeOf(this.tryBlock); + } + + public void setResources(List<VariableDeclarationExpr> resources) { + this.resources = resources; + setAsParentNodeOf(this.resources); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java new file mode 100644 index 000000000..79b507a1f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class TypeDeclarationStmt extends Statement { + + private TypeDeclaration typeDecl; + + public TypeDeclarationStmt() { + } + + public TypeDeclarationStmt(final TypeDeclaration typeDecl) { + setTypeDeclaration(typeDecl); + } + + public TypeDeclarationStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final TypeDeclaration typeDecl) { + super(beginLine, beginColumn, endLine, endColumn); + setTypeDeclaration(typeDecl); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public TypeDeclaration getTypeDeclaration() { + return typeDecl; + } + + public void setTypeDeclaration(final TypeDeclaration typeDecl) { + this.typeDecl = typeDecl; + setAsParentNodeOf(this.typeDecl); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/WhileStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/WhileStmt.java new file mode 100644 index 000000000..51b2a1a23 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/WhileStmt.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class WhileStmt extends Statement { + + private Expression condition; + + private Statement body; + + public WhileStmt() { + } + + public WhileStmt(final Expression condition, final Statement body) { + setCondition(condition); + setBody(body); + } + + public WhileStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression condition, final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setCondition(condition); + setBody(body); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCondition() { + return condition; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ClassOrInterfaceType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ClassOrInterfaceType.java new file mode 100644 index 000000000..a7efbf4e3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ClassOrInterfaceType.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceType extends Type { + + private ClassOrInterfaceType scope; + + private String name; + + private List<Type> typeArgs; + + public ClassOrInterfaceType() { + } + + public ClassOrInterfaceType(final String name) { + setName(name); + } + + public ClassOrInterfaceType(final ClassOrInterfaceType scope, final String name) { + setScope(scope); + setName(name); + } + + public ClassOrInterfaceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final ClassOrInterfaceType scope, final String name, final List<Type> typeArgs) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setName(name); + setTypeArgs(typeArgs); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getName() { + return name; + } + + public ClassOrInterfaceType getScope() { + return scope; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public boolean isBoxedType() { + return PrimitiveType.unboxMap.containsKey(name); + } + + public PrimitiveType toUnboxedType() throws UnsupportedOperationException { + if (!isBoxedType()) throw new UnsupportedOperationException(name + " isn't a boxed type."); + return new PrimitiveType(PrimitiveType.unboxMap.get(name)); + } + + public void setName(final String name) { + this.name = name; + } + + public void setScope(final ClassOrInterfaceType scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/PrimitiveType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/PrimitiveType.java new file mode 100644 index 000000000..561a89657 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/PrimitiveType.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import java.util.HashMap; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class PrimitiveType extends Type { + + public enum Primitive { + Boolean ("Boolean"), + Char ("Character"), + Byte ("Byte"), + Short ("Short"), + Int ("Integer"), + Long ("Long"), + Float ("Float"), + Double ("Double"); + + final String nameOfBoxedType; + + public ClassOrInterfaceType toBoxedType() { + return new ClassOrInterfaceType(nameOfBoxedType); + } + + private Primitive(String nameOfBoxedType) { + this.nameOfBoxedType = nameOfBoxedType; + } + } + + static final HashMap<String, Primitive> unboxMap = new HashMap<String, Primitive>(); + static { + for(Primitive unboxedType : Primitive.values()) { + unboxMap.put(unboxedType.nameOfBoxedType, unboxedType); + } + } + + private Primitive type; + + public PrimitiveType() { + } + + public PrimitiveType(final Primitive type) { + this.type = type; + } + + public PrimitiveType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Primitive type) { + super(beginLine, beginColumn, endLine, endColumn); + this.type = type; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Primitive getType() { + return type; + } + + public ClassOrInterfaceType toBoxedType() { + return type.toBoxedType(); + } + + public void setType(final Primitive type) { + this.type = type; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ReferenceType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ReferenceType.java new file mode 100644 index 000000000..608848fc0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ReferenceType.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ReferenceType extends Type { + + private Type type; + + private int arrayCount; + + private List<List<AnnotationExpr>> arraysAnnotations; + + public ReferenceType() { + } + + public ReferenceType(final Type type) { + setType(type); + } + + public ReferenceType(final Type type, final int arrayCount) { + setType(type); + setArrayCount(arrayCount); + } + + public ReferenceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Type type, final int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + } + + public ReferenceType(int beginLine, int beginColumn, int endLine, + int endColumn, Type type, int arrayCount, + List<AnnotationExpr> annotations, + List<List<AnnotationExpr>> arraysAnnotations) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setType(type); + setArrayCount(arrayCount); + this.arraysAnnotations = arraysAnnotations; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public Type getType() { + return type; + } + + public void setArrayCount(final int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + /** + * <p>Arrays annotations are annotations on the arrays modifiers of the type. + * Consider this example:</p> + * + * <p><pre> + * {@code + * int @Ann1 [] @Ann2 [] array; + * }</pre></p> + * + * <p>in this this method will return a list with the annotation expressions <pre>@Ann1</pre> + * and <pre>@Ann2</pre></p> + * + * <p>Note that the first list element of arraysAnnotations will refer to the first array modifier encountered. + * Considering the example the first element will be a list containing just @Ann1 while the second element will + * be a list containing just @Ann2. + * </p> + * + * <p>This property is guaranteed to hold: <pre>{@code getArraysAnnotations().size() == getArrayCount()}</pre> + * If a certain array modifier has no annotation the corresponding entry of arraysAnnotations will be null</p> + */ + public List<List<AnnotationExpr>> getArraysAnnotations() { + return arraysAnnotations; + } + + /** + * For a description of the arrayAnnotations field refer to {@link #getArraysAnnotations()} + */ + public void setArraysAnnotations(List<List<AnnotationExpr>> arraysAnnotations) { + this.arraysAnnotations = arraysAnnotations; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/Type.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/Type.java new file mode 100644 index 000000000..22c91240f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/Type.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Type extends Node { + + private List<AnnotationExpr> annotations; + + public Type() { + } + + public Type(List<AnnotationExpr> annotation){ + this.annotations = annotation; + } + + public Type(int beginLine, int beginColumn, int endLine, int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + public Type(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) { + super(beginLine, beginColumn, endLine, endColumn); + this.annotations = annotations; + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/UnknownType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/UnknownType.java new file mode 100644 index 000000000..af6d4d979 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/UnknownType.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * An unknown parameter type object. It plays the role of a null object for + * lambda parameters that have no explicit type declared. As such, it has no + * lexical representation and hence gets no comment attributed. + * + * @author Didier Villevalois + */ +public final class UnknownType extends Type { + + public UnknownType() { + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/VoidType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/VoidType.java new file mode 100644 index 000000000..5dacbe1e7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/VoidType.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VoidType extends Type { + + public VoidType() { + } + + public VoidType(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/WildcardType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/WildcardType.java new file mode 100644 index 000000000..8016ed70e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/WildcardType.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class WildcardType extends Type { + + private ReferenceType ext; + + private ReferenceType sup; + + public WildcardType() { + } + + public WildcardType(final ReferenceType ext) { + setExtends(ext); + } + + public WildcardType(final ReferenceType ext, final ReferenceType sup) { + setExtends(ext); + setSuper(sup); + } + + public WildcardType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final ReferenceType ext, final ReferenceType sup) { + super(beginLine, beginColumn, endLine, endColumn); + setExtends(ext); + setSuper(sup); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public ReferenceType getExtends() { + return ext; + } + + public ReferenceType getSuper() { + return sup; + } + + public void setExtends(final ReferenceType ext) { + this.ext = ext; + setAsParentNodeOf(this.ext); + } + + public void setSuper(final ReferenceType sup) { + this.sup = sup; + setAsParentNodeOf(this.sup); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/CloneVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/CloneVisitor.java new file mode 100644 index 000000000..3d8d299aa --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/CloneVisitor.java @@ -0,0 +1,1211 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.*; +import com.github.javaparser.ast.type.*; + +public class CloneVisitor implements GenericVisitor<Node, Object> { + + @Override + public Node visit(CompilationUnit _n, Object _arg) { + PackageDeclaration package_ = cloneNodes(_n.getPackage(), _arg); + List<ImportDeclaration> imports = visit(_n.getImports(), _arg); + List<TypeDeclaration> types = visit(_n.getTypes(), _arg); + + return new CompilationUnit( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + package_, imports, types + ); + } + + @Override + public Node visit(PackageDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + PackageDeclaration r = new PackageDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + annotations, name + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ImportDeclaration _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ImportDeclaration r = new ImportDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, _n.isStatic(), _n.isAsterisk() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TypeParameter _n, Object _arg) { + List<ClassOrInterfaceType> typeBound = visit(_n.getTypeBound(), _arg); + + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + TypeParameter r = new TypeParameter(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName(), typeBound, annotations); + + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LineComment _n, Object _arg) { + return new LineComment(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getContent()); + } + + @Override + public Node visit(BlockComment _n, Object _arg) { + return new BlockComment(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getContent()); + } + + @Override + public Node visit(ClassOrInterfaceDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + List<ClassOrInterfaceType> extendsList = visit(_n.getExtends(), _arg); + List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg); + List<BodyDeclaration> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassOrInterfaceDeclaration r = new ClassOrInterfaceDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, _n.isInterface(), _n.getName(), typeParameters, extendsList, implementsList, members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnumDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg); + List<EnumConstantDeclaration> entries = visit(_n.getEntries(), _arg); + List<BodyDeclaration> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnumDeclaration r = new EnumDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, _n.getName(), implementsList, entries, members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyTypeDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyTypeDeclaration r = new EmptyTypeDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn() + ); + r.setComment(comment); + return r; + } + + @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; + } + + @Override + public Node visit(AnnotationDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<BodyDeclaration> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AnnotationDeclaration r = new AnnotationDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, _n.getName(), members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AnnotationMemberDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + Expression defaultValue = cloneNodes(_n.getDefaultValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AnnotationMemberDeclaration r = new AnnotationMemberDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, _n.getName(), defaultValue + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(FieldDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<VariableDeclarator> variables = visit(_n.getVariables(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + FieldDeclaration r = new FieldDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, variables + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclarator _n, Object _arg) { + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Expression init = cloneNodes(_n.getInit(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + VariableDeclarator r = new VariableDeclarator( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + id, init + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclaratorId _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + VariableDeclaratorId r = new VariableDeclaratorId( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName(), _n.getArrayCount() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ConstructorDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + List<Parameter> parameters = visit(_n.getParameters(), _arg); + List<NameExpr> throws_ = visit(_n.getThrows(), _arg); + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ConstructorDeclaration r = new ConstructorDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, typeParameters, _n.getName(), parameters, throws_, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MethodDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<Parameter> parameters = visit(_n.getParameters(), _arg); + List<NameExpr> throws_ = visit(_n.getThrows(), _arg); + BlockStmt block = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MethodDeclaration r = new MethodDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(Parameter _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + Parameter r = new Parameter( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, _n.isVarArgs(), id + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MultiTypeParameter _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<Type> types = visit(_n.getTypes(), _arg); + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MultiTypeParameter r = new MultiTypeParameter( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, types, id + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyMemberDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyMemberDeclaration r = new EmptyMemberDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(InitializerDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + InitializerDeclaration r = new InitializerDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.isStatic(), block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(JavadocComment _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + JavadocComment r = new JavadocComment( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getContent() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ClassOrInterfaceType _n, Object _arg) { + ClassOrInterfaceType scope = cloneNodes(_n.getScope(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassOrInterfaceType r = new ClassOrInterfaceType( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, _n.getName(), typeArgs + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(PrimitiveType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + PrimitiveType r = new PrimitiveType( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getType() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ReferenceType _n, Object _arg) { + List<AnnotationExpr> ann = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<List<AnnotationExpr>> arraysAnnotations = _n.getArraysAnnotations(); + List<List<AnnotationExpr>> _arraysAnnotations = null; + if(arraysAnnotations != null){ + _arraysAnnotations = new LinkedList<List<AnnotationExpr>>(); + for(List<AnnotationExpr> aux: arraysAnnotations){ + _arraysAnnotations.add(visit(aux, _arg)); + } + } + + ReferenceType r = new ReferenceType(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), type_, + _n.getArrayCount(), ann, _arraysAnnotations); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VoidType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + VoidType r = new VoidType(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(WildcardType _n, Object _arg) { + ReferenceType ext = cloneNodes(_n.getExtends(), _arg); + ReferenceType sup = cloneNodes(_n.getSuper(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + WildcardType r = new WildcardType( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + ext, sup + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(UnknownType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + UnknownType r = new UnknownType(); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayAccessExpr _n, Object _arg) { + Expression name = cloneNodes(_n.getName(), _arg); + Expression index = cloneNodes(_n.getIndex(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ArrayAccessExpr r = new ArrayAccessExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, index + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayCreationExpr _n, Object _arg) { + Type type_ = cloneNodes(_n.getType(), _arg); + List<Expression> dimensions = visit(_n.getDimensions(), _arg); + ArrayCreationExpr r = new ArrayCreationExpr(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), type_, + dimensions, _n.getArrayCount()); + if (_n.getInitializer() != null) {// ArrayCreationExpr has two mutually + // exclusive constructors + r.setInitializer(cloneNodes(_n.getInitializer(), _arg)); + } + List<List<AnnotationExpr>> arraysAnnotations = _n.getArraysAnnotations(); + List<List<AnnotationExpr>> _arraysAnnotations = null; + if(arraysAnnotations != null){ + _arraysAnnotations = new LinkedList<List<AnnotationExpr>>(); + for(List<AnnotationExpr> aux: arraysAnnotations){ + _arraysAnnotations.add(visit(aux, _arg)); + } + } + r.setArraysAnnotations(_arraysAnnotations); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayInitializerExpr _n, Object _arg) { + List<Expression> values = visit(_n.getValues(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ArrayInitializerExpr r = new ArrayInitializerExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + values + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AssignExpr _n, Object _arg) { + Expression target = cloneNodes(_n.getTarget(), _arg); + Expression value = cloneNodes(_n.getValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AssignExpr r = new AssignExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + target, value, _n.getOperator()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BinaryExpr _n, Object _arg) { + Expression left = cloneNodes(_n.getLeft(), _arg); + Expression right = cloneNodes(_n.getRight(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + BinaryExpr r = new BinaryExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + left, right, _n.getOperator() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CastExpr _n, Object _arg) { + Type type_ = cloneNodes(_n.getType(), _arg); + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + CastExpr r = new CastExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + type_, expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ClassExpr _n, Object _arg) { + Type type_ = cloneNodes(_n.getType(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassExpr r = new ClassExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + type_ + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ConditionalExpr _n, Object _arg) { + Expression condition = cloneNodes(_n.getCondition(), _arg); + Expression thenExpr = cloneNodes(_n.getThenExpr(), _arg); + Expression elseExpr = cloneNodes(_n.getElseExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ConditionalExpr r = new ConditionalExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + condition, thenExpr, elseExpr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnclosedExpr _n, Object _arg) { + Expression inner = cloneNodes(_n.getInner(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnclosedExpr r = new EnclosedExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + inner + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(FieldAccessExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + FieldAccessExpr r = new FieldAccessExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, typeArgs, _n.getField() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(InstanceOfExpr _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + InstanceOfExpr r = new InstanceOfExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr, type_ + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(StringLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + StringLiteralExpr r = new StringLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IntegerLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + IntegerLiteralExpr r = new IntegerLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LongLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + LongLiteralExpr r = new LongLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IntegerLiteralMinValueExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + IntegerLiteralMinValueExpr r = new IntegerLiteralMinValueExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LongLiteralMinValueExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + LongLiteralMinValueExpr r = new LongLiteralMinValueExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CharLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + CharLiteralExpr r = new CharLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(DoubleLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + DoubleLiteralExpr r = new DoubleLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BooleanLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + BooleanLiteralExpr r = new BooleanLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NullLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + NullLiteralExpr r = new NullLiteralExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MethodCallExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MethodCallExpr r = new MethodCallExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, typeArgs, _n.getName(), args + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NameExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + NameExpr r = new NameExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ObjectCreationExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + ClassOrInterfaceType type_ = cloneNodes(_n.getType(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + List<BodyDeclaration> anonymousBody = visit(_n.getAnonymousClassBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ObjectCreationExpr r = new ObjectCreationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, type_, typeArgs, args, anonymousBody + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(QualifiedNameExpr _n, Object _arg) { + NameExpr scope = cloneNodes(_n.getQualifier(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + QualifiedNameExpr r = new QualifiedNameExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, _n.getName() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ThisExpr _n, Object _arg) { + Expression classExpr = cloneNodes(_n.getClassExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ThisExpr r = new ThisExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + classExpr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SuperExpr _n, Object _arg) { + Expression classExpr = cloneNodes(_n.getClassExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SuperExpr r = new SuperExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + classExpr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(UnaryExpr _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + UnaryExpr r = new UnaryExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr, _n.getOperator() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclarationExpr _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<VariableDeclarator> vars = visit(_n.getVars(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + VariableDeclarationExpr r = new VariableDeclarationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, vars + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MarkerAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MarkerAnnotationExpr r = new MarkerAnnotationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SingleMemberAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + Expression memberValue = cloneNodes(_n.getMemberValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SingleMemberAnnotationExpr r = new SingleMemberAnnotationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, memberValue + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NormalAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + List<MemberValuePair> pairs = visit(_n.getPairs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + NormalAnnotationExpr r = new NormalAnnotationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, pairs + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MemberValuePair _n, Object _arg) { + Expression value = cloneNodes(_n.getValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MemberValuePair r = new MemberValuePair( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName(), value + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ExplicitConstructorInvocationStmt _n, Object _arg) { + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + Expression expr = cloneNodes(_n.getExpr(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ExplicitConstructorInvocationStmt r = new ExplicitConstructorInvocationStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + typeArgs, _n.isThis(), expr, args + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TypeDeclarationStmt _n, Object _arg) { + TypeDeclaration typeDecl = cloneNodes(_n.getTypeDeclaration(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + TypeDeclarationStmt r = new TypeDeclarationStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + typeDecl + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AssertStmt _n, Object _arg) { + Expression check = cloneNodes(_n.getCheck(), _arg); + Expression message = cloneNodes(_n.getMessage(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AssertStmt r = new AssertStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + check, message + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BlockStmt _n, Object _arg) { + List<Statement> stmts = visit(_n.getStmts(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + BlockStmt r = new BlockStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + stmts + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LabeledStmt _n, Object _arg) { + Statement stmt = cloneNodes(_n.getStmt(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + LabeledStmt r = new LabeledStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getLabel(), stmt + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyStmt _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyStmt r = new EmptyStmt(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ExpressionStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpression(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ExpressionStmt r = new ExpressionStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SwitchStmt _n, Object _arg) { + Expression selector = cloneNodes(_n.getSelector(), _arg); + List<SwitchEntryStmt> entries = visit(_n.getEntries(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SwitchStmt r = new SwitchStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + selector, entries + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SwitchEntryStmt _n, Object _arg) { + Expression label = cloneNodes(_n.getLabel(), _arg); + List<Statement> stmts = visit(_n.getStmts(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SwitchEntryStmt r = new SwitchEntryStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + label, stmts + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BreakStmt _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + BreakStmt r = new BreakStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getId() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ReturnStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ReturnStmt r = new ReturnStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IfStmt _n, Object _arg) { + Expression condition = cloneNodes(_n.getCondition(), _arg); + Statement thenStmt = cloneNodes(_n.getThenStmt(), _arg); + Statement elseStmt = cloneNodes(_n.getElseStmt(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + IfStmt r = new IfStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + condition, thenStmt, elseStmt + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(WhileStmt _n, Object _arg) { + Expression condition = cloneNodes(_n.getCondition(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + WhileStmt r = new WhileStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + condition, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ContinueStmt _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + ContinueStmt r = new ContinueStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getId() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(DoStmt _n, Object _arg) { + Statement body = cloneNodes(_n.getBody(), _arg); + Expression condition = cloneNodes(_n.getCondition(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + DoStmt r = new DoStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + body, condition + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ForeachStmt _n, Object _arg) { + VariableDeclarationExpr var = cloneNodes(_n.getVariable(), _arg); + Expression iterable = cloneNodes(_n.getIterable(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ForeachStmt r = new ForeachStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + var, iterable, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ForStmt _n, Object _arg) { + List<Expression> init = visit(_n.getInit(), _arg); + Expression compare = cloneNodes(_n.getCompare(), _arg); + List<Expression> update = visit(_n.getUpdate(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ForStmt r = new ForStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + init, compare, update, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ThrowStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ThrowStmt r = new ThrowStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SynchronizedStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SynchronizedStmt r = new SynchronizedStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TryStmt _n, Object _arg) { + List<VariableDeclarationExpr> resources = visit(_n.getResources(),_arg); + BlockStmt tryBlock = cloneNodes(_n.getTryBlock(), _arg); + List<CatchClause> catchs = visit(_n.getCatchs(), _arg); + BlockStmt finallyBlock = cloneNodes(_n.getFinallyBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + TryStmt r = new TryStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + resources, tryBlock, catchs, finallyBlock + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CatchClause _n, Object _arg) { + MultiTypeParameter except = cloneNodes(_n.getExcept(), _arg); + BlockStmt catchBlock = cloneNodes(_n.getCatchBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + CatchClause r = new CatchClause( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + except.getModifiers(), except.getAnnotations(), except.getTypes(), except.getId(), catchBlock + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LambdaExpr _n, Object _arg) { + + List<Parameter> lambdaParameters = visit(_n.getParameters(), _arg); + + Statement body = cloneNodes(_n.getBody(), _arg); + + LambdaExpr r = new LambdaExpr(_n.getBeginLine(), _n.getBeginColumn(), + _n.getEndLine(), _n.getEndColumn(), lambdaParameters, body, + _n.isParametersEnclosed()); + + return r; + } + + @Override + public Node visit(MethodReferenceExpr _n, Object arg) { + + List<TypeParameter> typeParams = visit(_n.getTypeParameters(), arg); + Expression scope = cloneNodes(_n.getScope(), arg); + + MethodReferenceExpr r = new MethodReferenceExpr(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), scope, + typeParams, _n.getIdentifier()); + return r; + } + + @Override + public Node visit(TypeExpr n, Object arg) { + + Type t = cloneNodes(n.getType(), arg); + + TypeExpr r = new TypeExpr(n.getBeginLine(), n.getBeginColumn(), + n.getEndLine(), n.getEndColumn(), t); + + return r; + } + + public <T extends Node> List<T> visit(List<T> _nodes, Object _arg) { + if (_nodes == null) + return null; + List<T> r = new ArrayList<T>(_nodes.size()); + for (T n : _nodes) { + T rN = cloneNodes(n, _arg); + if (rN != null) + r.add(rN); + } + return r; + } + + protected <T extends Node> T cloneNodes(T _node, Object _arg) { + if (_node == null) + return null; + Node r = _node.accept(this, _arg); + if (r == null) + return null; + return (T) r; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/DumpVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/DumpVisitor.java new file mode 100644 index 000000000..8b04afe0a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/DumpVisitor.java @@ -0,0 +1,1657 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import static com.github.javaparser.PositionUtils.sortByBeginPosition; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.ModifierSet; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import static com.github.javaparser.ast.internal.Utils.isNullOrEmpty; + +/** + * Dumps the AST to formatted Java source code. + * + * @author Julio Vilmar Gesser + */ +public final class DumpVisitor implements VoidVisitor<Object> { + + private boolean printComments; + + public DumpVisitor() { + this(true); + } + + public DumpVisitor(boolean printComments) { + this.printComments = printComments; + } + + private static class SourcePrinter { + + private int level = 0; + + private boolean indented = false; + + private final StringBuilder buf = new StringBuilder(); + + public void indent() { + level++; + } + + public void unindent() { + level--; + } + + private void makeIndent() { + for (int i = 0; i < level; i++) { + buf.append(" "); + } + } + + public void print(final String arg) { + if (!indented) { + makeIndent(); + indented = true; + } + buf.append(arg); + } + + public void printLn(final String arg) { + print(arg); + printLn(); + } + + public void printLn() { + buf.append(System.getProperty("line.separator")); + indented = false; + } + + public String getSource() { + return buf.toString(); + } + + @Override public String toString() { + return getSource(); + } + } + + private final SourcePrinter printer = new SourcePrinter(); + + public String getSource() { + return printer.getSource(); + } + + private void printModifiers(final int modifiers) { + if (ModifierSet.isPrivate(modifiers)) { + printer.print("private "); + } + if (ModifierSet.isProtected(modifiers)) { + printer.print("protected "); + } + if (ModifierSet.isPublic(modifiers)) { + printer.print("public "); + } + if (ModifierSet.isAbstract(modifiers)) { + printer.print("abstract "); + } + if (ModifierSet.isStatic(modifiers)) { + printer.print("static "); + } + if (ModifierSet.isFinal(modifiers)) { + printer.print("final "); + } + if (ModifierSet.isNative(modifiers)) { + printer.print("native "); + } + if (ModifierSet.isStrictfp(modifiers)) { + printer.print("strictfp "); + } + if (ModifierSet.isSynchronized(modifiers)) { + printer.print("synchronized "); + } + if (ModifierSet.isTransient(modifiers)) { + printer.print("transient "); + } + if (ModifierSet.isVolatile(modifiers)) { + printer.print("volatile "); + } + } + + private void printMembers(final List<BodyDeclaration> members, final Object arg) { + for (final BodyDeclaration member : members) { + printer.printLn(); + member.accept(this, arg); + printer.printLn(); + } + } + + private void printMemberAnnotations(final List<AnnotationExpr> annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.printLn(); + } + } + } + + private void printAnnotations(final List<AnnotationExpr> annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.print(" "); + } + } + } + + private void printTypeArgs(final List<Type> args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator<Type> i = args.iterator(); i.hasNext();) { + final Type t = i.next(); + t.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + } + + private void printTypeParameters(final List<TypeParameter> args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator<TypeParameter> i = args.iterator(); i.hasNext();) { + final TypeParameter t = i.next(); + t.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + } + + private void printArguments(final List<Expression> args, final Object arg) { + printer.print("("); + if (!isNullOrEmpty(args)) { + for (final Iterator<Expression> i = args.iterator(); i.hasNext();) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + } + + private void printJavadoc(final JavadocComment javadoc, final Object arg) { + if (javadoc != null) { + javadoc.accept(this, arg); + } + } + + private void printJavaComment(final Comment javacomment, final Object arg) { + if (javacomment != null) { + javacomment.accept(this, arg); + } + } + + @Override public void visit(final CompilationUnit n, final Object arg) { + printJavaComment(n.getComment(), arg); + + if (n.getPackage() != null) { + n.getPackage().accept(this, arg); + } + + if (n.getImports() != null) { + for (final ImportDeclaration i : n.getImports()) { + i.accept(this, arg); + } + printer.printLn(); + } + + if (n.getTypes() != null) { + for (final Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) { + i.next().accept(this, arg); + printer.printLn(); + if (i.hasNext()) { + printer.printLn(); + } + } + } + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final PackageDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), arg); + printer.print("package "); + n.getName().accept(this, arg); + printer.printLn(";"); + printer.printLn(); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final NameExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final QualifiedNameExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getQualifier().accept(this, arg); + printer.print("."); + printer.print(n.getName()); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final ImportDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("import "); + if (n.isStatic()) { + printer.print("static "); + } + n.getName().accept(this, arg); + if (n.isAsterisk()) { + printer.print(".*"); + } + printer.printLn(";"); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final ClassOrInterfaceDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + if (n.isInterface()) { + printer.print("interface "); + } else { + printer.print("class "); + } + + printer.print(n.getName()); + + printTypeParameters(n.getTypeParameters(), arg); + + if (!isNullOrEmpty(n.getExtends())) { + printer.print(" extends "); + for (final Iterator<ClassOrInterfaceType> i = n.getExtends().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + if (!isNullOrEmpty(n.getImplements())) { + printer.print(" implements "); + for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + printer.printLn(" {"); + printer.indent(); + if (!isNullOrEmpty(n.getMembers())) { + printMembers(n.getMembers(), arg); + } + + printOrphanCommentsEnding(n); + + printer.unindent(); + printer.print("}"); + } + + @Override public void visit(final EmptyTypeDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printer.print(";"); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final JavadocComment n, final Object arg) { + printer.print("/**"); + printer.print(n.getContent()); + printer.printLn("*/"); + } + + @Override public void visit(final ClassOrInterfaceType n, final Object arg) { + printJavaComment(n.getComment(), arg); + + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + + if (n.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + printer.print(n.getName()); + printTypeArgs(n.getTypeArgs(), arg); + } + + @Override public void visit(final TypeParameter n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ann : n.getAnnotations()) { + ann.accept(this, arg); + printer.print(" "); + } + } + printer.print(n.getName()); + if (n.getTypeBound() != null) { + printer.print(" extends "); + for (final Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(" & "); + } + } + } + } + + @Override public void visit(final PrimitiveType n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + switch (n.getType()) { + case Boolean: + printer.print("boolean"); + break; + case Byte: + printer.print("byte"); + break; + case Char: + printer.print("char"); + break; + case Double: + printer.print("double"); + break; + case Float: + printer.print("float"); + break; + case Int: + printer.print("int"); + break; + case Long: + printer.print("long"); + break; + case Short: + printer.print("short"); + break; + } + } + + @Override public void visit(final ReferenceType n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + n.getType().accept(this, arg); + List<List<AnnotationExpr>> arraysAnnotations = n.getArraysAnnotations(); + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + List<AnnotationExpr> annotations = arraysAnnotations.get(i); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + printer.print(" "); + ae.accept(this, arg); + + } + } + } + printer.print("[]"); + } + } + + @Override public void visit(final WildcardType n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + printer.print(" "); + ae.accept(this, arg); + } + } + printer.print("?"); + if (n.getExtends() != null) { + printer.print(" extends "); + n.getExtends().accept(this, arg); + } + if (n.getSuper() != null) { + printer.print(" super "); + n.getSuper().accept(this, arg); + } + } + + @Override public void visit(final UnknownType n, final Object arg) { + // Nothing to dump + } + + @Override public void visit(final FieldDeclaration n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + n.getType().accept(this, arg); + + printer.print(" "); + for (final Iterator<VariableDeclarator> i = n.getVariables().iterator(); i.hasNext();) { + final VariableDeclarator var = i.next(); + var.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + + printer.print(";"); + } + + @Override public void visit(final VariableDeclarator n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getId().accept(this, arg); + if (n.getInit() != null) { + printer.print(" = "); + n.getInit().accept(this, arg); + } + } + + @Override public void visit(final VariableDeclaratorId n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + for (int i = 0; i < n.getArrayCount(); i++) { + printer.print("[]"); + } + } + + @Override public void visit(final ArrayInitializerExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("{"); + if (n.getValues() != null) { + printer.print(" "); + for (final Iterator<Expression> i = n.getValues().iterator(); i.hasNext();) { + final Expression expr = i.next(); + expr.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(" "); + } + printer.print("}"); + } + + @Override public void visit(final VoidType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("void"); + } + + @Override public void visit(final ArrayAccessExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getName().accept(this, arg); + printer.print("["); + n.getIndex().accept(this, arg); + printer.print("]"); + } + + @Override public void visit(final ArrayCreationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("new "); + n.getType().accept(this, arg); + List<List<AnnotationExpr>> arraysAnnotations = n.getArraysAnnotations(); + if (n.getDimensions() != null) { + int j = 0; + for (final Expression dim : n.getDimensions()) { + + if (arraysAnnotations != null && j < arraysAnnotations.size()) { + List<AnnotationExpr> annotations = arraysAnnotations.get(j); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + printer.print(" "); + ae.accept(this, arg); + } + } + } + printer.print("["); + dim.accept(this, arg); + printer.print("]"); + j++; + } + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + + List<AnnotationExpr> annotations = arraysAnnotations.get(i); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + printer.print(" "); + ae.accept(this, arg); + + } + } + } + printer.print("[]"); + } + + } else { + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + List<AnnotationExpr> annotations = arraysAnnotations.get(i); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + ae.accept(this, arg); + printer.print(" "); + } + } + } + printer.print("[]"); + } + printer.print(" "); + n.getInitializer().accept(this, arg); + } + } + + @Override public void visit(final AssignExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getTarget().accept(this, arg); + printer.print(" "); + switch (n.getOperator()) { + case assign: + printer.print("="); + break; + case and: + printer.print("&="); + break; + case or: + printer.print("|="); + break; + case xor: + printer.print("^="); + break; + case plus: + printer.print("+="); + break; + case minus: + printer.print("-="); + break; + case rem: + printer.print("%="); + break; + case slash: + printer.print("/="); + break; + case star: + printer.print("*="); + break; + case lShift: + printer.print("<<="); + break; + case rSignedShift: + printer.print(">>="); + break; + case rUnsignedShift: + printer.print(">>>="); + break; + } + printer.print(" "); + n.getValue().accept(this, arg); + } + + @Override public void visit(final BinaryExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getLeft().accept(this, arg); + printer.print(" "); + switch (n.getOperator()) { + case or: + printer.print("||"); + break; + case and: + printer.print("&&"); + break; + case binOr: + printer.print("|"); + break; + case binAnd: + printer.print("&"); + break; + case xor: + printer.print("^"); + break; + case equals: + printer.print("=="); + break; + case notEquals: + printer.print("!="); + break; + case less: + printer.print("<"); + break; + case greater: + printer.print(">"); + break; + case lessEquals: + printer.print("<="); + break; + case greaterEquals: + printer.print(">="); + break; + case lShift: + printer.print("<<"); + break; + case rSignedShift: + printer.print(">>"); + break; + case rUnsignedShift: + printer.print(">>>"); + break; + case plus: + printer.print("+"); + break; + case minus: + printer.print("-"); + break; + case times: + printer.print("*"); + break; + case divide: + printer.print("/"); + break; + case remainder: + printer.print("%"); + break; + } + printer.print(" "); + n.getRight().accept(this, arg); + } + + @Override public void visit(final CastExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("("); + n.getType().accept(this, arg); + printer.print(") "); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final ClassExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getType().accept(this, arg); + printer.print(".class"); + } + + @Override public void visit(final ConditionalExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + printer.print(" ? "); + n.getThenExpr().accept(this, arg); + printer.print(" : "); + n.getElseExpr().accept(this, arg); + } + + @Override public void visit(final EnclosedExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("("); + if (n.getInner() != null) { + n.getInner().accept(this, arg); + } + printer.print(")"); + } + + @Override public void visit(final FieldAccessExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getScope().accept(this, arg); + printer.print("."); + printer.print(n.getField()); + } + + @Override public void visit(final InstanceOfExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + printer.print(" instanceof "); + n.getType().accept(this, arg); + } + + @Override public void visit(final CharLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("'"); + printer.print(n.getValue()); + printer.print("'"); + } + + @Override public void visit(final DoubleLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final IntegerLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final LongLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final IntegerLiteralMinValueExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final LongLiteralMinValueExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final StringLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("\""); + printer.print(n.getValue()); + printer.print("\""); + } + + @Override public void visit(final BooleanLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(String.valueOf(n.getValue())); + } + + @Override public void visit(final NullLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("null"); + } + + @Override public void visit(final ThisExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + printer.print("."); + } + printer.print("this"); + } + + @Override public void visit(final SuperExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + printer.print("."); + } + printer.print("super"); + } + + @Override public void visit(final MethodCallExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + printTypeArgs(n.getTypeArgs(), arg); + printer.print(n.getName()); + printArguments(n.getArgs(), arg); + } + + @Override public void visit(final ObjectCreationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + + printer.print("new "); + + printTypeArgs(n.getTypeArgs(), arg); + if (!isNullOrEmpty(n.getTypeArgs())) { + printer.print(" "); + } + + n.getType().accept(this, arg); + + printArguments(n.getArgs(), arg); + + if (n.getAnonymousClassBody() != null) { + printer.printLn(" {"); + printer.indent(); + printMembers(n.getAnonymousClassBody(), arg); + printer.unindent(); + printer.print("}"); + } + } + + @Override public void visit(final UnaryExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + switch (n.getOperator()) { + case positive: + printer.print("+"); + break; + case negative: + printer.print("-"); + break; + case inverse: + printer.print("~"); + break; + case not: + printer.print("!"); + break; + case preIncrement: + printer.print("++"); + break; + case preDecrement: + printer.print("--"); + break; + default: + } + + n.getExpr().accept(this, arg); + + switch (n.getOperator()) { + case posIncrement: + printer.print("++"); + break; + case posDecrement: + printer.print("--"); + break; + default: + } + } + + @Override public void visit(final ConstructorDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printTypeParameters(n.getTypeParameters(), arg); + if (n.getTypeParameters() != null) { + printer.print(" "); + } + printer.print(n.getName()); + + printer.print("("); + if (n.getParameters() != null) { + for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) { + final Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + + if (!isNullOrEmpty(n.getThrows())) { + printer.print(" throws "); + for (final Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) { + final NameExpr name = i.next(); + name.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(" "); + n.getBlock().accept(this, arg); + } + + @Override public void visit(final MethodDeclaration n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + if (n.isDefault()) { + printer.print("default "); + } + printTypeParameters(n.getTypeParameters(), arg); + if (n.getTypeParameters() != null) { + printer.print(" "); + } + + n.getType().accept(this, arg); + printer.print(" "); + printer.print(n.getName()); + + printer.print("("); + if (n.getParameters() != null) { + for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) { + final Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + + for (int i = 0; i < n.getArrayCount(); i++) { + printer.print("[]"); + } + + if (!isNullOrEmpty(n.getThrows())) { + printer.print(" throws "); + for (final Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) { + final NameExpr name = i.next(); + name.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (n.getBody() == null) { + printer.print(";"); + } else { + printer.print(" "); + n.getBody().accept(this, arg); + } + } + + @Override public void visit(final Parameter n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + if (n.getType() != null) { + n.getType().accept(this, arg); + } + if (n.isVarArgs()) { + printer.print("..."); + } + printer.print(" "); + n.getId().accept(this, arg); + } + + @Override public void visit(MultiTypeParameter n, Object arg) { + printAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + Iterator<Type> types = n.getTypes().iterator(); + types.next().accept(this, arg); + while (types.hasNext()) { + printer.print(" | "); + types.next().accept(this, arg); + } + + printer.print(" "); + n.getId().accept(this, arg); + } + + @Override public void visit(final ExplicitConstructorInvocationStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.isThis()) { + printTypeArgs(n.getTypeArgs(), arg); + printer.print("this"); + } else { + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + printer.print("."); + } + printTypeArgs(n.getTypeArgs(), arg); + printer.print("super"); + } + printArguments(n.getArgs(), arg); + printer.print(";"); + } + + @Override public void visit(final VariableDeclarationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + n.getType().accept(this, arg); + printer.print(" "); + + for (final Iterator<VariableDeclarator> i = n.getVars().iterator(); i.hasNext();) { + final VariableDeclarator v = i.next(); + v.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + @Override public void visit(final TypeDeclarationStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getTypeDeclaration().accept(this, arg); + } + + @Override public void visit(final AssertStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("assert "); + n.getCheck().accept(this, arg); + if (n.getMessage() != null) { + printer.print(" : "); + n.getMessage().accept(this, arg); + } + printer.print(";"); + } + + @Override public void visit(final BlockStmt n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + printJavaComment(n.getComment(), arg); + printer.printLn("{"); + if (n.getStmts() != null) { + printer.indent(); + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + printer.printLn(); + } + printer.unindent(); + } + printOrphanCommentsEnding(n); + printer.print("}"); + + } + + @Override public void visit(final LabeledStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getLabel()); + printer.print(": "); + n.getStmt().accept(this, arg); + } + + @Override public void visit(final EmptyStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(";"); + } + + @Override public void visit(final ExpressionStmt n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + printJavaComment(n.getComment(), arg); + n.getExpression().accept(this, arg); + printer.print(";"); + } + + @Override public void visit(final SwitchStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("switch("); + n.getSelector().accept(this, arg); + printer.printLn(") {"); + if (n.getEntries() != null) { + printer.indent(); + for (final SwitchEntryStmt e : n.getEntries()) { + e.accept(this, arg); + } + printer.unindent(); + } + printer.print("}"); + + } + + @Override public void visit(final SwitchEntryStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getLabel() != null) { + printer.print("case "); + n.getLabel().accept(this, arg); + printer.print(":"); + } else { + printer.print("default:"); + } + printer.printLn(); + printer.indent(); + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + printer.printLn(); + } + } + printer.unindent(); + } + + @Override public void visit(final BreakStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("break"); + if (n.getId() != null) { + printer.print(" "); + printer.print(n.getId()); + } + printer.print(";"); + } + + @Override public void visit(final ReturnStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("return"); + if (n.getExpr() != null) { + printer.print(" "); + n.getExpr().accept(this, arg); + } + printer.print(";"); + } + + @Override public void visit(final EnumDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printer.print("enum "); + printer.print(n.getName()); + + if (n.getImplements() != null) { + printer.print(" implements "); + for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + printer.printLn(" {"); + printer.indent(); + if (n.getEntries() != null) { + printer.printLn(); + for (final Iterator<EnumConstantDeclaration> i = n.getEntries().iterator(); i.hasNext();) { + final EnumConstantDeclaration e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (n.getMembers() != null) { + printer.printLn(";"); + printMembers(n.getMembers(), arg); + } else { + if (n.getEntries() != null) { + printer.printLn(); + } + } + printer.unindent(); + printer.print("}"); + } + + @Override public void visit(final EnumConstantDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printer.print(n.getName()); + + if (n.getArgs() != null) { + printArguments(n.getArgs(), arg); + } + + if (n.getClassBody() != null) { + printer.printLn(" {"); + printer.indent(); + printMembers(n.getClassBody(), arg); + printer.unindent(); + printer.printLn("}"); + } + } + + @Override public void visit(final EmptyMemberDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printer.print(";"); + } + + @Override public void visit(final InitializerDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + if (n.isStatic()) { + printer.print("static "); + } + n.getBlock().accept(this, arg); + } + + @Override public void visit(final IfStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("if ("); + n.getCondition().accept(this, arg); + final boolean thenBlock = n.getThenStmt() instanceof BlockStmt; + if (thenBlock) // block statement should start on the same line + printer.print(") "); + else { + printer.printLn(")"); + printer.indent(); + } + n.getThenStmt().accept(this, arg); + if (!thenBlock) + printer.unindent(); + if (n.getElseStmt() != null) { + if (thenBlock) + printer.print(" "); + else + printer.printLn(); + final boolean elseIf = n.getElseStmt() instanceof IfStmt; + final boolean elseBlock = n.getElseStmt() instanceof BlockStmt; + if (elseIf || elseBlock) // put chained if and start of block statement on a same level + printer.print("else "); + else { + printer.printLn("else"); + printer.indent(); + } + n.getElseStmt().accept(this, arg); + if (!(elseIf || elseBlock)) + printer.unindent(); + } + } + + @Override public void visit(final WhileStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("while ("); + n.getCondition().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ContinueStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("continue"); + if (n.getId() != null) { + printer.print(" "); + printer.print(n.getId()); + } + printer.print(";"); + } + + @Override public void visit(final DoStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("do "); + n.getBody().accept(this, arg); + printer.print(" while ("); + n.getCondition().accept(this, arg); + printer.print(");"); + } + + @Override public void visit(final ForeachStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("for ("); + n.getVariable().accept(this, arg); + printer.print(" : "); + n.getIterable().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ForStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("for ("); + if (n.getInit() != null) { + for (final Iterator<Expression> i = n.getInit().iterator(); i.hasNext();) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print("; "); + if (n.getCompare() != null) { + n.getCompare().accept(this, arg); + } + printer.print("; "); + if (n.getUpdate() != null) { + for (final Iterator<Expression> i = n.getUpdate().iterator(); i.hasNext();) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ThrowStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("throw "); + n.getExpr().accept(this, arg); + printer.print(";"); + } + + @Override public void visit(final SynchronizedStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("synchronized ("); + n.getExpr().accept(this, arg); + printer.print(") "); + n.getBlock().accept(this, arg); + } + + @Override public void visit(final TryStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("try "); + if (!n.getResources().isEmpty()) { + printer.print("("); + Iterator<VariableDeclarationExpr> resources = n.getResources().iterator(); + boolean first = true; + while (resources.hasNext()) { + visit(resources.next(), arg); + if (resources.hasNext()) { + printer.print(";"); + printer.printLn(); + if (first) { + printer.indent(); + } + } + first = false; + } + if (n.getResources().size() > 1) { + printer.unindent(); + } + printer.print(") "); + } + n.getTryBlock().accept(this, arg); + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + c.accept(this, arg); + } + } + if (n.getFinallyBlock() != null) { + printer.print(" finally "); + n.getFinallyBlock().accept(this, arg); + } + } + + @Override public void visit(final CatchClause n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(" catch ("); + n.getExcept().accept(this, arg); + printer.print(") "); + n.getCatchBlock().accept(this, arg); + + } + + @Override public void visit(final AnnotationDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printer.print("@interface "); + printer.print(n.getName()); + printer.printLn(" {"); + printer.indent(); + if (n.getMembers() != null) { + printMembers(n.getMembers(), arg); + } + printer.unindent(); + printer.print("}"); + } + + @Override public void visit(final AnnotationMemberDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + n.getType().accept(this, arg); + printer.print(" "); + printer.print(n.getName()); + printer.print("()"); + if (n.getDefaultValue() != null) { + printer.print(" default "); + n.getDefaultValue().accept(this, arg); + } + printer.print(";"); + } + + @Override public void visit(final MarkerAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + } + + @Override public void visit(final SingleMemberAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + printer.print("("); + n.getMemberValue().accept(this, arg); + printer.print(")"); + } + + @Override public void visit(final NormalAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + printer.print("("); + if (n.getPairs() != null) { + for (final Iterator<MemberValuePair> i = n.getPairs().iterator(); i.hasNext();) { + final MemberValuePair m = i.next(); + m.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + } + + @Override public void visit(final MemberValuePair n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + printer.print(" = "); + n.getValue().accept(this, arg); + } + + @Override public void visit(final LineComment n, final Object arg) { + if (!this.printComments) { + return; + } + printer.print("//"); + String tmp = n.getContent(); + tmp = tmp.replace('\r', ' '); + tmp = tmp.replace('\n', ' '); + printer.printLn(tmp); + } + + @Override public void visit(final BlockComment n, final Object arg) { + if (!this.printComments) { + return; + } + printer.print("/*"); + printer.print(n.getContent()); + printer.printLn("*/"); + } + + @Override + public void visit(LambdaExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + + List<Parameter> parameters = n.getParameters(); + boolean printPar = false; + printPar = n.isParametersEnclosed(); + + if (printPar) { + printer.print("("); + } + if (parameters != null) { + for (Iterator<Parameter> i = parameters.iterator(); i.hasNext();) { + Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (printPar) { + printer.print(")"); + } + + printer.print(" -> "); + Statement body = n.getBody(); + if (body instanceof ExpressionStmt) { + // Print the expression directly + ((ExpressionStmt) body).getExpression().accept(this, arg); + } else { + body.accept(this, arg); + } + } + + + @Override + public void visit(MethodReferenceExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + Expression scope = n.getScope(); + String identifier = n.getIdentifier(); + if (scope != null) { + n.getScope().accept(this, arg); + } + + printer.print("::"); + if (n.getTypeParameters() != null) { + printer.print("<"); + for (Iterator<TypeParameter> i = n.getTypeParameters().iterator(); i + .hasNext();) { + TypeParameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + if (identifier != null) { + printer.print(identifier); + } + + } + + @Override + public void visit(TypeExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getType() != null) { + n.getType().accept(this, arg); + } + } + + private void printOrphanCommentsBeforeThisChildNode(final Node node){ + if (node instanceof Comment) return; + + Node parent = node.getParentNode(); + if (parent==null) return; + List<Node> everything = new LinkedList<Node>(); + everything.addAll(parent.getChildrenNodes()); + sortByBeginPosition(everything); + int positionOfTheChild = -1; + for (int i=0;i<everything.size();i++){ + if (everything.get(i)==node) positionOfTheChild=i; + } + if (positionOfTheChild==-1) throw new RuntimeException("My index not found!!! "+node); + int positionOfPreviousChild = -1; + for (int i=positionOfTheChild-1;i>=0 && positionOfPreviousChild==-1;i--){ + if (!(everything.get(i) instanceof Comment)) positionOfPreviousChild = i; + } + for (int i=positionOfPreviousChild+1;i<positionOfTheChild;i++){ + Node nodeToPrint = everything.get(i); + if (!(nodeToPrint instanceof Comment)) throw new RuntimeException("Expected comment, instead "+nodeToPrint.getClass()+". Position of previous child: "+positionOfPreviousChild+", position of child "+positionOfTheChild); + nodeToPrint.accept(this,null); + } + } + + + private void printOrphanCommentsEnding(final Node node){ + List<Node> everything = new LinkedList<Node>(); + everything.addAll(node.getChildrenNodes()); + sortByBeginPosition(everything); + if (everything.size()==0) return; + + int commentsAtEnd = 0; + boolean findingComments = true; + while (findingComments&&commentsAtEnd<everything.size()){ + Node last = everything.get(everything.size()-1-commentsAtEnd); + findingComments = (last instanceof Comment); + if (findingComments) commentsAtEnd++; + } + for (int i=0;i<commentsAtEnd;i++){ + everything.get(everything.size()-commentsAtEnd+i).accept(this,null); + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/EqualsVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/EqualsVisitor.java new file mode 100644 index 000000000..8f4a786c0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/EqualsVisitor.java @@ -0,0 +1,1468 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BaseParameter; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import java.util.Iterator; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public class EqualsVisitor implements GenericVisitor<Boolean, Node> { + + private static final EqualsVisitor SINGLETON = new EqualsVisitor(); + + public static boolean equals(final Node n1, final Node n2) { + return SINGLETON.nodeEquals(n1, n2); + } + + private EqualsVisitor() { + // hide constructor + } + + /** + * Check for equality that can be applied to each kind of node, + * to not repeat it in every method we store that here. + */ + private boolean commonNodeEquality(Node n1, Node n2) { + if (!nodeEquals(n1.getComment(), n2.getComment())) { + return false; + } + if (!nodesEquals(n1.getOrphanComments(), n2.getOrphanComments())){ + return false; + } + return true; + } + + private <T extends Node> boolean nodesEquals(final List<T> nodes1, final List<T> nodes2) { + if (nodes1 == null) { + if (nodes2 == null) { + return true; + } + return false; + } else if (nodes2 == null) { + return false; + } + if (nodes1.size() != nodes2.size()) { + return false; + } + for (int i = 0; i < nodes1.size(); i++) { + if (!nodeEquals(nodes1.get(i), nodes2.get(i))) { + return false; + } + } + return true; + } + + private <T extends Node> boolean nodeEquals(final T n1, final T n2) { + if (n1 == n2) { + return true; + } + if (n1 == null) { + if (n2 == null) { + return true; + } + return false; + } else if (n2 == null) { + return false; + } + if (n1.getClass() != n2.getClass()) { + return false; + } + if (!commonNodeEquality(n1, n2)){ + return false; + } + return n1.accept(this, n2).booleanValue(); + } + + private boolean objEquals(final Object n1, final Object n2) { + if (n1 == n2) { + return true; + } + if (n1 == null) { + if (n2 == null) { + return true; + } + return false; + } else if (n2 == null) { + return false; + } + return n1.equals(n2); + } + + @Override public Boolean visit(final CompilationUnit n1, final Node arg) { + final CompilationUnit n2 = (CompilationUnit) arg; + + if (!nodeEquals(n1.getPackage(), n2.getPackage())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getImports(), n2.getImports())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypes(), n2.getTypes())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getComments(), n2.getComments())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final PackageDeclaration n1, final Node arg) { + final PackageDeclaration n2 = (PackageDeclaration) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ImportDeclaration n1, final Node arg) { + final ImportDeclaration n2 = (ImportDeclaration) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final TypeParameter n1, final Node arg) { + final TypeParameter n2 = (TypeParameter) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeBound(), n2.getTypeBound())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final LineComment n1, final Node arg) { + final LineComment n2 = (LineComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getBeginLine(), n2.getBeginLine())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BlockComment n1, final Node arg) { + final BlockComment n2 = (BlockComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getBeginLine(), n2.getBeginLine())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ClassOrInterfaceDeclaration n1, final Node arg) { + final ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (n1.isInterface() != n2.isInterface()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getExtends(), n2.getExtends())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getImplements(), n2.getImplements())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EnumDeclaration n1, final Node arg) { + final EnumDeclaration n2 = (EnumDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getImplements(), n2.getImplements())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getEntries(), n2.getEntries())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EmptyTypeDeclaration n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final EnumConstantDeclaration n1, final Node arg) { + final EnumConstantDeclaration n2 = (EnumConstantDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getClassBody(), n2.getClassBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AnnotationDeclaration n1, final Node arg) { + final AnnotationDeclaration n2 = (AnnotationDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AnnotationMemberDeclaration n1, final Node arg) { + final AnnotationMemberDeclaration n2 = (AnnotationMemberDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getDefaultValue(), n2.getDefaultValue())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final FieldDeclaration n1, final Node arg) { + final FieldDeclaration n2 = (FieldDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getVariables(), n2.getVariables())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final VariableDeclarator n1, final Node arg) { + final VariableDeclarator n2 = (VariableDeclarator) arg; + + if (!nodeEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getInit(), n2.getInit())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final VariableDeclaratorId n1, final Node arg) { + final VariableDeclaratorId n2 = (VariableDeclaratorId) arg; + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ConstructorDeclaration n1, final Node arg) { + final ConstructorDeclaration n2 = (ConstructorDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getThrows(), n2.getThrows())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final MethodDeclaration n1, final Node arg) { + final MethodDeclaration n2 = (MethodDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getThrows(), n2.getThrows())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + if(n1.isDefault() != n2.isDefault()){ + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final Parameter n1, final Node arg) { + final Parameter n2 = (Parameter) arg; + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + return visit((BaseParameter) n1, arg); + } + + @Override public Boolean visit(MultiTypeParameter n1, Node arg) { + MultiTypeParameter n2 = (MultiTypeParameter) arg; + if (n1.getTypes().size() != n2.getTypes().size()) { + return Boolean.FALSE; + } + Iterator<Type> n1types = n1.getTypes().iterator(); + Iterator<Type> n2types = n2.getTypes().iterator(); + while (n1types.hasNext() && n2types.hasNext()) { + if (!nodeEquals(n1types.next(), n2types.next())) { + return Boolean.FALSE; + } + } + return visit((BaseParameter) n1, arg); + } + + protected Boolean visit(final BaseParameter n1, final Node arg) { + final BaseParameter n2 = (BaseParameter) arg; + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EmptyMemberDeclaration n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final InitializerDeclaration n1, final Node arg) { + final InitializerDeclaration n2 = (InitializerDeclaration) arg; + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final JavadocComment n1, final Node arg) { + final JavadocComment n2 = (JavadocComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ClassOrInterfaceType n1, final Node arg) { + final ClassOrInterfaceType n2 = (ClassOrInterfaceType) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final PrimitiveType n1, final Node arg) { + final PrimitiveType n2 = (PrimitiveType) arg; + + if (n1.getType() != n2.getType()) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final ReferenceType n1, final Node arg) { + final ReferenceType n2 = (ReferenceType) arg; + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + List<List<AnnotationExpr>> n1a = n1.getArraysAnnotations(); + List<List<AnnotationExpr>> n2a = n2.getArraysAnnotations(); + + if (n1a !=null && n2a!= null) { + if(n1a.size() != n2a.size()){ + return Boolean.FALSE; + } + else{ + int i = 0; + for(List<AnnotationExpr> aux: n1a){ + if(!nodesEquals(aux, n2a.get(i))){ + return Boolean.FALSE; + } + i++; + } + } + } + else if (n1a != n2a){ + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + public Boolean visit(VoidType n1, Node arg) { + VoidType n2 = (VoidType) arg; + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final WildcardType n1, final Node arg) { + final WildcardType n2 = (WildcardType) arg; + + if (!nodeEquals(n1.getExtends(), n2.getExtends())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getSuper(), n2.getSuper())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final UnknownType n1, final Node arg) { + final WildcardType n2 = (WildcardType) arg; + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final ArrayAccessExpr n1, final Node arg) { + final ArrayAccessExpr n2 = (ArrayAccessExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getIndex(), n2.getIndex())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ArrayCreationExpr n1, final Node arg) { + final ArrayCreationExpr n2 = (ArrayCreationExpr) arg; + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getInitializer(), n2.getInitializer())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getDimensions(), n2.getDimensions())) { + return Boolean.FALSE; + } + List<List<AnnotationExpr>> n1a = n1.getArraysAnnotations(); + List<List<AnnotationExpr>> n2a = n2.getArraysAnnotations(); + + if (n1a !=null && n2a!= null) { + if(n1a.size() != n2a.size()){ + return Boolean.FALSE; + } + else{ + int i = 0; + for(List<AnnotationExpr> aux: n1a){ + if(!nodesEquals(aux, n2a.get(i))){ + return Boolean.FALSE; + } + i++; + } + } + } + else if (n1a != n2a){ + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final ArrayInitializerExpr n1, final Node arg) { + final ArrayInitializerExpr n2 = (ArrayInitializerExpr) arg; + + if (!nodesEquals(n1.getValues(), n2.getValues())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AssignExpr n1, final Node arg) { + final AssignExpr n2 = (AssignExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getTarget(), n2.getTarget())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BinaryExpr n1, final Node arg) { + final BinaryExpr n2 = (BinaryExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getLeft(), n2.getLeft())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getRight(), n2.getRight())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final CastExpr n1, final Node arg) { + final CastExpr n2 = (CastExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ClassExpr n1, final Node arg) { + final ClassExpr n2 = (ClassExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ConditionalExpr n1, final Node arg) { + final ConditionalExpr n2 = (ConditionalExpr) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getThenExpr(), n2.getThenExpr())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getElseExpr(), n2.getElseExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EnclosedExpr n1, final Node arg) { + final EnclosedExpr n2 = (EnclosedExpr) arg; + + if (!nodeEquals(n1.getInner(), n2.getInner())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final FieldAccessExpr n1, final Node arg) { + final FieldAccessExpr n2 = (FieldAccessExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getField(), n2.getField())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final InstanceOfExpr n1, final Node arg) { + final InstanceOfExpr n2 = (InstanceOfExpr) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final StringLiteralExpr n1, final Node arg) { + final StringLiteralExpr n2 = (StringLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final IntegerLiteralExpr n1, final Node arg) { + final IntegerLiteralExpr n2 = (IntegerLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final LongLiteralExpr n1, final Node arg) { + final LongLiteralExpr n2 = (LongLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final IntegerLiteralMinValueExpr n1, final Node arg) { + final IntegerLiteralMinValueExpr n2 = (IntegerLiteralMinValueExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final LongLiteralMinValueExpr n1, final Node arg) { + final LongLiteralMinValueExpr n2 = (LongLiteralMinValueExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final CharLiteralExpr n1, final Node arg) { + final CharLiteralExpr n2 = (CharLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final DoubleLiteralExpr n1, final Node arg) { + final DoubleLiteralExpr n2 = (DoubleLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BooleanLiteralExpr n1, final Node arg) { + final BooleanLiteralExpr n2 = (BooleanLiteralExpr) arg; + + if (n1.getValue() != n2.getValue()) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final NullLiteralExpr n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final MethodCallExpr n1, final Node arg) { + final MethodCallExpr n2 = (MethodCallExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final NameExpr n1, final Node arg) { + final NameExpr n2 = (NameExpr) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ObjectCreationExpr n1, final Node arg) { + final ObjectCreationExpr n2 = (ObjectCreationExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnonymousClassBody(), n2.getAnonymousClassBody())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final QualifiedNameExpr n1, final Node arg) { + final QualifiedNameExpr n2 = (QualifiedNameExpr) arg; + + if (!nodeEquals(n1.getQualifier(), n2.getQualifier())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ThisExpr n1, final Node arg) { + final ThisExpr n2 = (ThisExpr) arg; + + if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SuperExpr n1, final Node arg) { + final SuperExpr n2 = (SuperExpr) arg; + + if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final UnaryExpr n1, final Node arg) { + final UnaryExpr n2 = (UnaryExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final VariableDeclarationExpr n1, final Node arg) { + final VariableDeclarationExpr n2 = (VariableDeclarationExpr) arg; + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getVars(), n2.getVars())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final MarkerAnnotationExpr n1, final Node arg) { + final MarkerAnnotationExpr n2 = (MarkerAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SingleMemberAnnotationExpr n1, final Node arg) { + final SingleMemberAnnotationExpr n2 = (SingleMemberAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getMemberValue(), n2.getMemberValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final NormalAnnotationExpr n1, final Node arg) { + final NormalAnnotationExpr n2 = (NormalAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getPairs(), n2.getPairs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final MemberValuePair n1, final Node arg) { + final MemberValuePair n2 = (MemberValuePair) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ExplicitConstructorInvocationStmt n1, final Node arg) { + final ExplicitConstructorInvocationStmt n2 = (ExplicitConstructorInvocationStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final TypeDeclarationStmt n1, final Node arg) { + final TypeDeclarationStmt n2 = (TypeDeclarationStmt) arg; + + if (!nodeEquals(n1.getTypeDeclaration(), n2.getTypeDeclaration())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AssertStmt n1, final Node arg) { + final AssertStmt n2 = (AssertStmt) arg; + + if (!nodeEquals(n1.getCheck(), n2.getCheck())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getMessage(), n2.getMessage())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BlockStmt n1, final Node arg) { + final BlockStmt n2 = (BlockStmt) arg; + + if (!nodesEquals(n1.getStmts(), n2.getStmts())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final LabeledStmt n1, final Node arg) { + final LabeledStmt n2 = (LabeledStmt) arg; + + if (!nodeEquals(n1.getStmt(), n2.getStmt())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EmptyStmt n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final ExpressionStmt n1, final Node arg) { + final ExpressionStmt n2 = (ExpressionStmt) arg; + + if (!nodeEquals(n1.getExpression(), n2.getExpression())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SwitchStmt n1, final Node arg) { + final SwitchStmt n2 = (SwitchStmt) arg; + + if (!nodeEquals(n1.getSelector(), n2.getSelector())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getEntries(), n2.getEntries())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SwitchEntryStmt n1, final Node arg) { + final SwitchEntryStmt n2 = (SwitchEntryStmt) arg; + + if (!nodeEquals(n1.getLabel(), n2.getLabel())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getStmts(), n2.getStmts())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BreakStmt n1, final Node arg) { + final BreakStmt n2 = (BreakStmt) arg; + + if (!objEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ReturnStmt n1, final Node arg) { + final ReturnStmt n2 = (ReturnStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final IfStmt n1, final Node arg) { + final IfStmt n2 = (IfStmt) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getThenStmt(), n2.getThenStmt())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getElseStmt(), n2.getElseStmt())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final WhileStmt n1, final Node arg) { + final WhileStmt n2 = (WhileStmt) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ContinueStmt n1, final Node arg) { + final ContinueStmt n2 = (ContinueStmt) arg; + + if (!objEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final DoStmt n1, final Node arg) { + final DoStmt n2 = (DoStmt) arg; + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ForeachStmt n1, final Node arg) { + final ForeachStmt n2 = (ForeachStmt) arg; + + if (!nodeEquals(n1.getVariable(), n2.getVariable())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getIterable(), n2.getIterable())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ForStmt n1, final Node arg) { + final ForStmt n2 = (ForStmt) arg; + + if (!nodesEquals(n1.getInit(), n2.getInit())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getCompare(), n2.getCompare())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getUpdate(), n2.getUpdate())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ThrowStmt n1, final Node arg) { + final ThrowStmt n2 = (ThrowStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SynchronizedStmt n1, final Node arg) { + final SynchronizedStmt n2 = (SynchronizedStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final TryStmt n1, final Node arg) { + final TryStmt n2 = (TryStmt) arg; + + if (!nodeEquals(n1.getTryBlock(), n2.getTryBlock())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getCatchs(), n2.getCatchs())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getFinallyBlock(), n2.getFinallyBlock())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final CatchClause n1, final Node arg) { + final CatchClause n2 = (CatchClause) arg; + + if (!nodeEquals(n1.getExcept(), n2.getExcept())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getCatchBlock(), n2.getCatchBlock())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override + public Boolean visit(LambdaExpr n1, Node arg) { + LambdaExpr n2 = (LambdaExpr) arg; + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return Boolean.FALSE; + } + if(n1.isParametersEnclosed() != n2.isParametersEnclosed()){ + return Boolean.FALSE; + } + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override + public Boolean visit(MethodReferenceExpr n1, Node arg) { + MethodReferenceExpr n2 = (MethodReferenceExpr) arg; + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + if (!objEquals(n1.getIdentifier(), n2.getIdentifier())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override + public Boolean visit(TypeExpr n, Node arg) { + TypeExpr n2 = (TypeExpr) arg; + if (!nodeEquals(n.getType(), n2.getType())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitor.java new file mode 100644 index 000000000..58fbf6db9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitor.java @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * A visitor that has a return value. + * + * @author Julio Vilmar Gesser + */ +public interface GenericVisitor<R, A> { + + //- Compilation Unit ---------------------------------- + + public R visit(CompilationUnit n, A arg); + + public R visit(PackageDeclaration n, A arg); + + public R visit(ImportDeclaration n, A arg); + + public R visit(TypeParameter n, A arg); + + public R visit(LineComment n, A arg); + + public R visit(BlockComment n, A arg); + + //- Body ---------------------------------------------- + + public R visit(ClassOrInterfaceDeclaration n, A arg); + + public R visit(EnumDeclaration n, A arg); + + public R visit(EmptyTypeDeclaration n, A arg); + + public R visit(EnumConstantDeclaration n, A arg); + + public R visit(AnnotationDeclaration n, A arg); + + public R visit(AnnotationMemberDeclaration n, A arg); + + public R visit(FieldDeclaration n, A arg); + + public R visit(VariableDeclarator n, A arg); + + public R visit(VariableDeclaratorId n, A arg); + + public R visit(ConstructorDeclaration n, A arg); + + public R visit(MethodDeclaration n, A arg); + + public R visit(Parameter n, A arg); + + public R visit(MultiTypeParameter n, A arg); + + public R visit(EmptyMemberDeclaration n, A arg); + + public R visit(InitializerDeclaration n, A arg); + + public R visit(JavadocComment n, A arg); + + //- Type ---------------------------------------------- + + public R visit(ClassOrInterfaceType n, A arg); + + public R visit(PrimitiveType n, A arg); + + public R visit(ReferenceType n, A arg); + + public R visit(VoidType n, A arg); + + public R visit(WildcardType n, A arg); + + public R visit(UnknownType n, A arg); + + //- Expression ---------------------------------------- + + public R visit(ArrayAccessExpr n, A arg); + + public R visit(ArrayCreationExpr n, A arg); + + public R visit(ArrayInitializerExpr n, A arg); + + public R visit(AssignExpr n, A arg); + + public R visit(BinaryExpr n, A arg); + + public R visit(CastExpr n, A arg); + + public R visit(ClassExpr n, A arg); + + public R visit(ConditionalExpr n, A arg); + + public R visit(EnclosedExpr n, A arg); + + public R visit(FieldAccessExpr n, A arg); + + public R visit(InstanceOfExpr n, A arg); + + public R visit(StringLiteralExpr n, A arg); + + public R visit(IntegerLiteralExpr n, A arg); + + public R visit(LongLiteralExpr n, A arg); + + public R visit(IntegerLiteralMinValueExpr n, A arg); + + public R visit(LongLiteralMinValueExpr n, A arg); + + public R visit(CharLiteralExpr n, A arg); + + public R visit(DoubleLiteralExpr n, A arg); + + public R visit(BooleanLiteralExpr n, A arg); + + public R visit(NullLiteralExpr n, A arg); + + public R visit(MethodCallExpr n, A arg); + + public R visit(NameExpr n, A arg); + + public R visit(ObjectCreationExpr n, A arg); + + public R visit(QualifiedNameExpr n, A arg); + + public R visit(ThisExpr n, A arg); + + public R visit(SuperExpr n, A arg); + + public R visit(UnaryExpr n, A arg); + + public R visit(VariableDeclarationExpr n, A arg); + + public R visit(MarkerAnnotationExpr n, A arg); + + public R visit(SingleMemberAnnotationExpr n, A arg); + + public R visit(NormalAnnotationExpr n, A arg); + + public R visit(MemberValuePair n, A arg); + + //- Statements ---------------------------------------- + + public R visit(ExplicitConstructorInvocationStmt n, A arg); + + public R visit(TypeDeclarationStmt n, A arg); + + public R visit(AssertStmt n, A arg); + + public R visit(BlockStmt n, A arg); + + public R visit(LabeledStmt n, A arg); + + public R visit(EmptyStmt n, A arg); + + public R visit(ExpressionStmt n, A arg); + + public R visit(SwitchStmt n, A arg); + + public R visit(SwitchEntryStmt n, A arg); + + public R visit(BreakStmt n, A arg); + + public R visit(ReturnStmt n, A arg); + + public R visit(IfStmt n, A arg); + + public R visit(WhileStmt n, A arg); + + public R visit(ContinueStmt n, A arg); + + public R visit(DoStmt n, A arg); + + public R visit(ForeachStmt n, A arg); + + public R visit(ForStmt n, A arg); + + public R visit(ThrowStmt n, A arg); + + public R visit(SynchronizedStmt n, A arg); + + public R visit(TryStmt n, A arg); + + public R visit(CatchClause n, A arg); + + public R visit(LambdaExpr n, A arg); + + public R visit(MethodReferenceExpr n, A arg); + + public R visit(TypeExpr n, A arg); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java new file mode 100644 index 000000000..eac9cab40 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java @@ -0,0 +1,1613 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class GenericVisitorAdapter<R, A> implements GenericVisitor<R, A> { + + @Override + public R visit(final AnnotationDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final AnnotationMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getDefaultValue() != null) { + { + R result = n.getDefaultValue().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ArrayAccessExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getIndex().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ArrayCreationExpr n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getDimensions() != null) { + for (final Expression dim : n.getDimensions()) { + { + R result = dim.accept(this, arg); + if (result != null) { + return result; + } + } + } + } else { + { + R result = n.getInitializer().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ArrayInitializerExpr n, final A arg) { + if (n.getValues() != null) { + for (final Expression expr : n.getValues()) { + { + R result = expr.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final AssertStmt n, final A arg) { + { + R result = n.getCheck().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getMessage() != null) { + { + R result = n.getMessage().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final AssignExpr n, final A arg) { + { + R result = n.getTarget().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getValue().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final BinaryExpr n, final A arg) { + { + R result = n.getLeft().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getRight().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final BlockStmt n, final A arg) { + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + { + R result = s.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + + } + + @Override + public R visit(final BooleanLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final BreakStmt n, final A arg) { + return null; + } + + @Override + public R visit(final CastExpr n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final CatchClause n, final A arg) { + { + R result = n.getExcept().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getCatchBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + + } + + @Override + public R visit(final CharLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final ClassExpr n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ClassOrInterfaceDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getExtends() != null) { + for (final ClassOrInterfaceType c : n.getExtends()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ClassOrInterfaceType n, final A arg) { + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final CompilationUnit n, final A arg) { + if (n.getPackage() != null) { + { + R result = n.getPackage().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getImports() != null) { + for (final ImportDeclaration i : n.getImports()) { + { + R result = i.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypes() != null) { + for (final TypeDeclaration typeDeclaration : n.getTypes()) { + { + R result = typeDeclaration.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ConditionalExpr n, final A arg) { + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getThenExpr().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getElseExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ConstructorDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + { + R result = p.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + { + R result = name.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ContinueStmt n, final A arg) { + return null; + } + + @Override + public R visit(final DoStmt n, final A arg) { + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final DoubleLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final EmptyMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final EmptyStmt n, final A arg) { + return null; + } + + @Override + public R visit(final EmptyTypeDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final EnclosedExpr n, final A arg) { + { + R result = n.getInner().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final EnumConstantDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getClassBody() != null) { + for (final BodyDeclaration member : n.getClassBody()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final EnumDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getEntries() != null) { + for (final EnumConstantDeclaration e : n.getEntries()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ExplicitConstructorInvocationStmt n, final A arg) { + if (!n.isThis()) { + if (n.getExpr() != null) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ExpressionStmt n, final A arg) { + { + R result = n.getExpression().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final FieldAccessExpr n, final A arg) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final FieldDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + for (final VariableDeclarator var : n.getVariables()) { + { + R result = var.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ForeachStmt n, final A arg) { + { + R result = n.getVariable().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getIterable().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ForStmt n, final A arg) { + if (n.getInit() != null) { + for (final Expression e : n.getInit()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getCompare() != null) { + { + R result = n.getCompare().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getUpdate() != null) { + for (final Expression e : n.getUpdate()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final IfStmt n, final A arg) { + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getThenStmt().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getElseStmt() != null) { + { + R result = n.getElseStmt().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ImportDeclaration n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final InitializerDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final InstanceOfExpr n, final A arg) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final IntegerLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final IntegerLiteralMinValueExpr n, final A arg) { + return null; + } + + @Override + public R visit(final JavadocComment n, final A arg) { + return null; + } + + @Override + public R visit(final LabeledStmt n, final A arg) { + { + R result = n.getStmt().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final LongLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final LongLiteralMinValueExpr n, final A arg) { + return null; + } + + @Override + public R visit(final MarkerAnnotationExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final MemberValuePair n, final A arg) { + { + R result = n.getValue().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final MethodCallExpr n, final A arg) { + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final MethodDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + { + R result = p.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + { + R result = name.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getBody() != null) { + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final NameExpr n, final A arg) { + return null; + } + + @Override + public R visit(final NormalAnnotationExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getPairs() != null) { + for (final MemberValuePair m : n.getPairs()) { + { + R result = m.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final NullLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final ObjectCreationExpr n, final A arg) { + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getAnonymousClassBody() != null) { + for (final BodyDeclaration member : n.getAnonymousClassBody()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final PackageDeclaration n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final Parameter n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getId().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final MultiTypeParameter n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + for (final Type type : n.getTypes()) { + R result = type.accept(this, arg); + if (result != null) { + return result; + } + } + } + { + R result = n.getId().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final PrimitiveType n, final A arg) { + return null; + } + + @Override + public R visit(final QualifiedNameExpr n, final A arg) { + { + R result = n.getQualifier().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ReferenceType n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ReturnStmt n, final A arg) { + if (n.getExpr() != null) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final SingleMemberAnnotationExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getMemberValue().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final StringLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final SuperExpr n, final A arg) { + if (n.getClassExpr() != null) { + { + R result = n.getClassExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final SwitchEntryStmt n, final A arg) { + if (n.getLabel() != null) { + { + R result = n.getLabel().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + { + R result = s.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final SwitchStmt n, final A arg) { + { + R result = n.getSelector().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getEntries() != null) { + for (final SwitchEntryStmt e : n.getEntries()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + + } + + @Override + public R visit(final SynchronizedStmt n, final A arg) { + { + if (n.getExpr() != null) { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ThisExpr n, final A arg) { + if (n.getClassExpr() != null) { + { + R result = n.getClassExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ThrowStmt n, final A arg) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final TryStmt n, final A arg) { + if (n.getResources() != null) { + for (final VariableDeclarationExpr v : n.getResources()) { + { + R result = v.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getTryBlock().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getFinallyBlock() != null) { + { + R result = n.getFinallyBlock().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final TypeDeclarationStmt n, final A arg) { + { + R result = n.getTypeDeclaration().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final TypeParameter n, final A arg) { + if (n.getTypeBound() != null) { + for (final ClassOrInterfaceType c : n.getTypeBound()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final UnaryExpr n, final A arg) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final UnknownType n, final A arg) { + return null; + } + + @Override + public R visit(final VariableDeclarationExpr n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + for (final VariableDeclarator v : n.getVars()) { + { + R result = v.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final VariableDeclarator n, final A arg) { + { + R result = n.getId().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getInit() != null) { + { + R result = n.getInit().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final VariableDeclaratorId n, final A arg) { + return null; + } + + @Override + public R visit(final VoidType n, final A arg) { + return null; + } + + @Override + public R visit(final WhileStmt n, final A arg) { + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final WildcardType n, final A arg) { + if (n.getExtends() != null) { + { + R result = n.getExtends().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getSuper() != null) { + { + R result = n.getSuper().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(LambdaExpr n, A arg) { + return null; + } + + @Override + public R visit(MethodReferenceExpr n, A arg){ + return null; + } + + @Override + public R visit(TypeExpr n, A arg){ + return null; + } + + @Override + public R visit(final BlockComment n, final A arg) { + return null; + } + + @Override + public R visit(final LineComment n, final A arg) { + return null; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java new file mode 100644 index 000000000..3d23cea5a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java @@ -0,0 +1,973 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BaseParameter; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.ArrayAccessExpr; +import com.github.javaparser.ast.expr.ArrayCreationExpr; +import com.github.javaparser.ast.expr.ArrayInitializerExpr; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.BinaryExpr; +import com.github.javaparser.ast.expr.BooleanLiteralExpr; +import com.github.javaparser.ast.expr.CastExpr; +import com.github.javaparser.ast.expr.CharLiteralExpr; +import com.github.javaparser.ast.expr.ClassExpr; +import com.github.javaparser.ast.expr.ConditionalExpr; +import com.github.javaparser.ast.expr.DoubleLiteralExpr; +import com.github.javaparser.ast.expr.EnclosedExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.FieldAccessExpr; +import com.github.javaparser.ast.expr.InstanceOfExpr; +import com.github.javaparser.ast.expr.IntegerLiteralExpr; +import com.github.javaparser.ast.expr.IntegerLiteralMinValueExpr; +import com.github.javaparser.ast.expr.LambdaExpr; +import com.github.javaparser.ast.expr.LongLiteralExpr; +import com.github.javaparser.ast.expr.LongLiteralMinValueExpr; +import com.github.javaparser.ast.expr.MarkerAnnotationExpr; +import com.github.javaparser.ast.expr.MemberValuePair; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.MethodReferenceExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.NormalAnnotationExpr; +import com.github.javaparser.ast.expr.NullLiteralExpr; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.QualifiedNameExpr; +import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.expr.SuperExpr; +import com.github.javaparser.ast.expr.ThisExpr; +import com.github.javaparser.ast.expr.TypeExpr; +import com.github.javaparser.ast.expr.UnaryExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import java.util.LinkedList; +import java.util.List; + +/** + * This visitor adapter can be used to save time when some specific nodes needs + * to be changed. To do that just extend this class and override the methods + * from the nodes who needs to be changed, returning the changed node. + * + * @author Julio Vilmar Gesser + */ +public abstract class ModifierVisitorAdapter<A> implements GenericVisitor<Node, A> { + + private void removeNulls(final List<?> list) { + for (int i = list.size() - 1; i >= 0; i--) { + if (list.get(i) == null) { + list.remove(i); + } + } + } + + @Override public Node visit(final AnnotationDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<BodyDeclaration> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final AnnotationMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + if (n.getDefaultValue() != null) { + n.setDefaultValue((Expression) n.getDefaultValue().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ArrayAccessExpr n, final A arg) { + n.setName((Expression) n.getName().accept(this, arg)); + n.setIndex((Expression) n.getIndex().accept(this, arg)); + return n; + } + + @Override public Node visit(final ArrayCreationExpr n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + if (n.getDimensions() != null) { + final List<Expression> dimensions = n.getDimensions(); + if (dimensions != null) { + for (int i = 0; i < dimensions.size(); i++) { + dimensions.set(i, (Expression) dimensions.get(i).accept(this, arg)); + } + removeNulls(dimensions); + } + } else { + n.setInitializer((ArrayInitializerExpr) n.getInitializer().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ArrayInitializerExpr n, final A arg) { + if (n.getValues() != null) { + final List<Expression> values = n.getValues(); + if (values != null) { + for (int i = 0; i < values.size(); i++) { + values.set(i, (Expression) values.get(i).accept(this, arg)); + } + removeNulls(values); + } + } + return n; + } + + @Override public Node visit(final AssertStmt n, final A arg) { + n.setCheck((Expression) n.getCheck().accept(this, arg)); + if (n.getMessage() != null) { + n.setMessage((Expression) n.getMessage().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final AssignExpr n, final A arg) { + n.setTarget((Expression) n.getTarget().accept(this, arg)); + n.setValue((Expression) n.getValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final BinaryExpr n, final A arg) { + n.setLeft((Expression) n.getLeft().accept(this, arg)); + n.setRight((Expression) n.getRight().accept(this, arg)); + return n; + } + + @Override public Node visit(final BlockStmt n, final A arg) { + final List<Statement> stmts = n.getStmts(); + if (stmts != null) { + for (int i = 0; i < stmts.size(); i++) { + stmts.set(i, (Statement) stmts.get(i).accept(this, arg)); + } + removeNulls(stmts); + } + return n; + } + + @Override public Node visit(final BooleanLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final BreakStmt n, final A arg) { + return n; + } + + @Override public Node visit(final CastExpr n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final CatchClause n, final A arg) { + n.setExcept((MultiTypeParameter) n.getExcept().accept(this, arg)); + n.setCatchBlock((BlockStmt) n.getCatchBlock().accept(this, arg)); + return n; + + } + + @Override public Node visit(final CharLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final ClassExpr n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final ClassOrInterfaceDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + final List<ClassOrInterfaceType> extendz = n.getExtends(); + if (extendz != null) { + for (int i = 0; i < extendz.size(); i++) { + extendz.set(i, (ClassOrInterfaceType) extendz.get(i).accept(this, arg)); + } + removeNulls(extendz); + } + final List<ClassOrInterfaceType> implementz = n.getImplements(); + if (implementz != null) { + for (int i = 0; i < implementz.size(); i++) { + implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg)); + } + removeNulls(implementz); + } + final List<BodyDeclaration> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final ClassOrInterfaceType n, final A arg) { + if (n.getScope() != null) { + n.setScope((ClassOrInterfaceType) n.getScope().accept(this, arg)); + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + return n; + } + + @Override public Node visit(final CompilationUnit n, final A arg) { + if (n.getPackage() != null) { + n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg)); + } + final List<ImportDeclaration> imports = n.getImports(); + if (imports != null) { + for (int i = 0; i < imports.size(); i++) { + imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg)); + } + removeNulls(imports); + } + final List<TypeDeclaration> types = n.getTypes(); + if (types != null) { + for (int i = 0; i < types.size(); i++) { + types.set(i, (TypeDeclaration) types.get(i).accept(this, arg)); + } + removeNulls(types); + } + return n; + } + + @Override public Node visit(final ConditionalExpr n, final A arg) { + n.setCondition((Expression) n.getCondition().accept(this, arg)); + n.setThenExpr((Expression) n.getThenExpr().accept(this, arg)); + n.setElseExpr((Expression) n.getElseExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final ConstructorDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + final List<Parameter> parameters = n.getParameters(); + if (parameters != null) { + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + } + final List<NameExpr> throwz = n.getThrows(); + if (throwz != null) { + for (int i = 0; i < throwz.size(); i++) { + throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg)); + } + removeNulls(throwz); + } + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final ContinueStmt n, final A arg) { + return n; + } + + @Override public Node visit(final DoStmt n, final A arg) { + n.setBody((Statement) n.getBody().accept(this, arg)); + n.setCondition((Expression) n.getCondition().accept(this, arg)); + return n; + } + + @Override public Node visit(final DoubleLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final EmptyMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final EmptyStmt n, final A arg) { + return n; + } + + @Override public Node visit(final EmptyTypeDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final EnclosedExpr n, final A arg) { + n.setInner((Expression) n.getInner().accept(this, arg)); + return n; + } + + @Override public Node visit(final EnumConstantDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + final List<BodyDeclaration> classBody = n.getClassBody(); + if (classBody != null) { + for (int i = 0; i < classBody.size(); i++) { + classBody.set(i, (BodyDeclaration) classBody.get(i).accept(this, arg)); + } + removeNulls(classBody); + } + return n; + } + + @Override public Node visit(final EnumDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<ClassOrInterfaceType> implementz = n.getImplements(); + if (implementz != null) { + for (int i = 0; i < implementz.size(); i++) { + implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg)); + } + removeNulls(implementz); + } + final List<EnumConstantDeclaration> entries = n.getEntries(); + if (entries != null) { + for (int i = 0; i < entries.size(); i++) { + entries.set(i, (EnumConstantDeclaration) entries.get(i).accept(this, arg)); + } + removeNulls(entries); + } + final List<BodyDeclaration> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final ExplicitConstructorInvocationStmt n, final A arg) { + if (!n.isThis()) { + if (n.getExpr() != null) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + } + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + return n; + } + + @Override public Node visit(final ExpressionStmt n, final A arg) { + n.setExpression((Expression) n.getExpression().accept(this, arg)); + return n; + } + + @Override public Node visit(final FieldAccessExpr n, final A arg) { + n.setScope((Expression) n.getScope().accept(this, arg)); + return n; + } + + @Override public Node visit(final FieldDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + final List<VariableDeclarator> variables = n.getVariables(); + for (int i = 0; i < variables.size(); i++) { + variables.set(i, (VariableDeclarator) variables.get(i).accept(this, arg)); + } + removeNulls(variables); + return n; + } + + @Override public Node visit(final ForeachStmt n, final A arg) { + n.setVariable((VariableDeclarationExpr) n.getVariable().accept(this, arg)); + n.setIterable((Expression) n.getIterable().accept(this, arg)); + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final ForStmt n, final A arg) { + final List<Expression> init = n.getInit(); + if (init != null) { + for (int i = 0; i < init.size(); i++) { + init.set(i, (Expression) init.get(i).accept(this, arg)); + } + removeNulls(init); + } + if (n.getCompare() != null) { + n.setCompare((Expression) n.getCompare().accept(this, arg)); + } + final List<Expression> update = n.getUpdate(); + if (update != null) { + for (int i = 0; i < update.size(); i++) { + update.set(i, (Expression) update.get(i).accept(this, arg)); + } + removeNulls(update); + } + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final IfStmt n, final A arg) { + n.setCondition((Expression) n.getCondition().accept(this, arg)); + n.setThenStmt((Statement) n.getThenStmt().accept(this, arg)); + if (n.getElseStmt() != null) { + n.setElseStmt((Statement) n.getElseStmt().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ImportDeclaration n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final InitializerDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final InstanceOfExpr n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final IntegerLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final IntegerLiteralMinValueExpr n, final A arg) { + return n; + } + + @Override public Node visit(final JavadocComment n, final A arg) { + return n; + } + + @Override public Node visit(final LabeledStmt n, final A arg) { + n.setStmt((Statement) n.getStmt().accept(this, arg)); + return n; + } + + @Override public Node visit(final LongLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final LongLiteralMinValueExpr n, final A arg) { + return n; + } + + @Override public Node visit(final MarkerAnnotationExpr n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final MemberValuePair n, final A arg) { + n.setValue((Expression) n.getValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final MethodCallExpr n, final A arg) { + if (n.getScope() != null) { + n.setScope((Expression) n.getScope().accept(this, arg)); + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + return n; + } + + @Override public Node visit(final MethodDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + n.setType((Type) n.getType().accept(this, arg)); + final List<Parameter> parameters = n.getParameters(); + if (parameters != null) { + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + } + final List<NameExpr> throwz = n.getThrows(); + if (throwz != null) { + for (int i = 0; i < throwz.size(); i++) { + throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg)); + } + removeNulls(throwz); + } + if (n.getBody() != null) { + n.setBody((BlockStmt) n.getBody().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final NameExpr n, final A arg) { + return n; + } + + @Override public Node visit(final NormalAnnotationExpr n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + final List<MemberValuePair> pairs = n.getPairs(); + if (pairs != null) { + for (int i = 0; i < pairs.size(); i++) { + pairs.set(i, (MemberValuePair) pairs.get(i).accept(this, arg)); + } + removeNulls(pairs); + } + return n; + } + + @Override public Node visit(final NullLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final ObjectCreationExpr n, final A arg) { + if (n.getScope() != null) { + n.setScope((Expression) n.getScope().accept(this, arg)); + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + n.setType((ClassOrInterfaceType) n.getType().accept(this, arg)); + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + final List<BodyDeclaration> anonymousClassBody = n.getAnonymousClassBody(); + if (anonymousClassBody != null) { + for (int i = 0; i < anonymousClassBody.size(); i++) { + anonymousClassBody.set(i, (BodyDeclaration) anonymousClassBody.get(i).accept(this, arg)); + } + removeNulls(anonymousClassBody); + } + return n; + } + + @Override public Node visit(final PackageDeclaration n, final A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final Parameter n, final A arg) { + visit((BaseParameter) n, arg); + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(MultiTypeParameter n, A arg) { + visit((BaseParameter) n, arg); + List<Type> types = new LinkedList<Type>(); + for (Type type : n.getTypes()) { + types.add((Type) type.accept(this, arg)); + } + n.setTypes(types); + return n; + } + + protected Node visit(final BaseParameter n, final A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + + n.setId((VariableDeclaratorId) n.getId().accept(this, arg)); + return n; + } + + @Override public Node visit(final PrimitiveType n, final A arg) { + return n; + } + + @Override public Node visit(final QualifiedNameExpr n, final A arg) { + n.setQualifier((NameExpr) n.getQualifier().accept(this, arg)); + return n; + } + + @Override public Node visit(final ReferenceType n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final ReturnStmt n, final A arg) { + if (n.getExpr() != null) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final SingleMemberAnnotationExpr n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + n.setMemberValue((Expression) n.getMemberValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final StringLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final SuperExpr n, final A arg) { + if (n.getClassExpr() != null) { + n.setClassExpr((Expression) n.getClassExpr().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final SwitchEntryStmt n, final A arg) { + if (n.getLabel() != null) { + n.setLabel((Expression) n.getLabel().accept(this, arg)); + } + final List<Statement> stmts = n.getStmts(); + if (stmts != null) { + for (int i = 0; i < stmts.size(); i++) { + stmts.set(i, (Statement) stmts.get(i).accept(this, arg)); + } + removeNulls(stmts); + } + return n; + } + + @Override public Node visit(final SwitchStmt n, final A arg) { + n.setSelector((Expression) n.getSelector().accept(this, arg)); + final List<SwitchEntryStmt> entries = n.getEntries(); + if (entries != null) { + for (int i = 0; i < entries.size(); i++) { + entries.set(i, (SwitchEntryStmt) entries.get(i).accept(this, arg)); + } + removeNulls(entries); + } + return n; + + } + + @Override public Node visit(final SynchronizedStmt n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final ThisExpr n, final A arg) { + if (n.getClassExpr() != null) { + n.setClassExpr((Expression) n.getClassExpr().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ThrowStmt n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final TryStmt n, final A arg) { + n.setTryBlock((BlockStmt) n.getTryBlock().accept(this, arg)); + final List<CatchClause> catchs = n.getCatchs(); + if (catchs != null) { + for (int i = 0; i < catchs.size(); i++) { + catchs.set(i, (CatchClause) catchs.get(i).accept(this, arg)); + } + removeNulls(catchs); + } + if (n.getFinallyBlock() != null) { + n.setFinallyBlock((BlockStmt) n.getFinallyBlock().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final TypeDeclarationStmt n, final A arg) { + n.setTypeDeclaration((TypeDeclaration) n.getTypeDeclaration().accept(this, arg)); + return n; + } + + @Override public Node visit(final TypeParameter n, final A arg) { + final List<ClassOrInterfaceType> typeBound = n.getTypeBound(); + if (typeBound != null) { + for (int i = 0; i < typeBound.size(); i++) { + typeBound.set(i, (ClassOrInterfaceType) typeBound.get(i).accept(this, arg)); + } + removeNulls(typeBound); + } + return n; + } + + @Override public Node visit(final UnaryExpr n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final UnknownType n, final A arg) { + return n; + } + + @Override public Node visit(final VariableDeclarationExpr n, final A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + final List<VariableDeclarator> vars = n.getVars(); + for (int i = 0; i < vars.size(); i++) { + vars.set(i, (VariableDeclarator) vars.get(i).accept(this, arg)); + } + removeNulls(vars); + return n; + } + + @Override public Node visit(final VariableDeclarator n, final A arg) { + n.setId((VariableDeclaratorId) n.getId().accept(this, arg)); + if (n.getInit() != null) { + n.setInit((Expression) n.getInit().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final VariableDeclaratorId n, final A arg) { + return n; + } + + @Override public Node visit(final VoidType n, final A arg) { + return n; + } + + @Override public Node visit(final WhileStmt n, final A arg) { + n.setCondition((Expression) n.getCondition().accept(this, arg)); + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final WildcardType n, final A arg) { + if (n.getExtends() != null) { + n.setExtends((ReferenceType) n.getExtends().accept(this, arg)); + } + if (n.getSuper() != null) { + n.setSuper((ReferenceType) n.getSuper().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final LambdaExpr n, final A arg) { + return n; + } + + @Override public Node visit(final MethodReferenceExpr n, final A arg){ + return n; + } + + @Override public Node visit(final TypeExpr n, final A arg){ + return n; + } + + @Override public Node visit(final BlockComment n, final A arg) { + return n; + } + + @Override public Node visit(final LineComment n, final A arg) { + return n; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitor.java new file mode 100644 index 000000000..b85bd55a7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitor.java @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * A visitor that does not return anything. + * + * @author Julio Vilmar Gesser + */ +public interface VoidVisitor<A> { + + //- Compilation Unit ---------------------------------- + + void visit(CompilationUnit n, A arg); + + void visit(PackageDeclaration n, A arg); + + void visit(ImportDeclaration n, A arg); + + void visit(TypeParameter n, A arg); + + void visit(LineComment n, A arg); + + void visit(BlockComment n, A arg); + + //- Body ---------------------------------------------- + + void visit(ClassOrInterfaceDeclaration n, A arg); + + void visit(EnumDeclaration n, A arg); + + void visit(EmptyTypeDeclaration n, A arg); + + void visit(EnumConstantDeclaration n, A arg); + + void visit(AnnotationDeclaration n, A arg); + + void visit(AnnotationMemberDeclaration n, A arg); + + void visit(FieldDeclaration n, A arg); + + void visit(VariableDeclarator n, A arg); + + void visit(VariableDeclaratorId n, A arg); + + void visit(ConstructorDeclaration n, A arg); + + void visit(MethodDeclaration n, A arg); + + void visit(Parameter n, A arg); + + void visit(MultiTypeParameter n, A arg); + + void visit(EmptyMemberDeclaration n, A arg); + + void visit(InitializerDeclaration n, A arg); + + void visit(JavadocComment n, A arg); + + //- Type ---------------------------------------------- + + void visit(ClassOrInterfaceType n, A arg); + + void visit(PrimitiveType n, A arg); + + void visit(ReferenceType n, A arg); + + void visit(VoidType n, A arg); + + void visit(WildcardType n, A arg); + + void visit(UnknownType n, A arg); + + //- Expression ---------------------------------------- + + void visit(ArrayAccessExpr n, A arg); + + void visit(ArrayCreationExpr n, A arg); + + void visit(ArrayInitializerExpr n, A arg); + + void visit(AssignExpr n, A arg); + + void visit(BinaryExpr n, A arg); + + void visit(CastExpr n, A arg); + + void visit(ClassExpr n, A arg); + + void visit(ConditionalExpr n, A arg); + + void visit(EnclosedExpr n, A arg); + + void visit(FieldAccessExpr n, A arg); + + void visit(InstanceOfExpr n, A arg); + + void visit(StringLiteralExpr n, A arg); + + void visit(IntegerLiteralExpr n, A arg); + + void visit(LongLiteralExpr n, A arg); + + void visit(IntegerLiteralMinValueExpr n, A arg); + + void visit(LongLiteralMinValueExpr n, A arg); + + void visit(CharLiteralExpr n, A arg); + + void visit(DoubleLiteralExpr n, A arg); + + void visit(BooleanLiteralExpr n, A arg); + + void visit(NullLiteralExpr n, A arg); + + void visit(MethodCallExpr n, A arg); + + void visit(NameExpr n, A arg); + + void visit(ObjectCreationExpr n, A arg); + + void visit(QualifiedNameExpr n, A arg); + + void visit(ThisExpr n, A arg); + + void visit(SuperExpr n, A arg); + + void visit(UnaryExpr n, A arg); + + void visit(VariableDeclarationExpr n, A arg); + + void visit(MarkerAnnotationExpr n, A arg); + + void visit(SingleMemberAnnotationExpr n, A arg); + + void visit(NormalAnnotationExpr n, A arg); + + void visit(MemberValuePair n, A arg); + + //- Statements ---------------------------------------- + + void visit(ExplicitConstructorInvocationStmt n, A arg); + + void visit(TypeDeclarationStmt n, A arg); + + void visit(AssertStmt n, A arg); + + void visit(BlockStmt n, A arg); + + void visit(LabeledStmt n, A arg); + + void visit(EmptyStmt n, A arg); + + void visit(ExpressionStmt n, A arg); + + void visit(SwitchStmt n, A arg); + + void visit(SwitchEntryStmt n, A arg); + + void visit(BreakStmt n, A arg); + + void visit(ReturnStmt n, A arg); + + void visit(IfStmt n, A arg); + + void visit(WhileStmt n, A arg); + + void visit(ContinueStmt n, A arg); + + void visit(DoStmt n, A arg); + + void visit(ForeachStmt n, A arg); + + void visit(ForStmt n, A arg); + + void visit(ThrowStmt n, A arg); + + void visit(SynchronizedStmt n, A arg); + + void visit(TryStmt n, A arg); + + void visit(CatchClause n, A arg); + + void visit(LambdaExpr n, A arg); + + void visit(MethodReferenceExpr n, A arg); + + void visit(TypeExpr n, A arg); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java new file mode 100644 index 000000000..ddad12fb7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java @@ -0,0 +1,846 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import static com.github.javaparser.ast.internal.Utils.isNullOrEmpty; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class VoidVisitorAdapter<A> implements VoidVisitor<A> { + + @Override public void visit(final AnnotationDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final AnnotationMemberDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + if (n.getDefaultValue() != null) { + n.getDefaultValue().accept(this, arg); + } + } + + @Override public void visit(final ArrayAccessExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + n.getIndex().accept(this, arg); + } + + @Override public void visit(final ArrayCreationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + if (!isNullOrEmpty(n.getDimensions())) { + for (final Expression dim : n.getDimensions()) { + dim.accept(this, arg); + } + } else { + n.getInitializer().accept(this, arg); + } + } + + @Override public void visit(final ArrayInitializerExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getValues() != null) { + for (final Expression expr : n.getValues()) { + expr.accept(this, arg); + } + } + } + + @Override public void visit(final AssertStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getCheck().accept(this, arg); + if (n.getMessage() != null) { + n.getMessage().accept(this, arg); + } + } + + @Override public void visit(final AssignExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getTarget().accept(this, arg); + n.getValue().accept(this, arg); + } + + @Override public void visit(final BinaryExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getLeft().accept(this, arg); + n.getRight().accept(this, arg); + } + + @Override public void visit(final BlockComment n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final BlockStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + } + } + } + + @Override public void visit(final BooleanLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final BreakStmt n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final CastExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final CatchClause n, final A arg) { + visitComment(n.getComment(), arg); + n.getExcept().accept(this, arg); + n.getCatchBlock().accept(this, arg); + } + + @Override public void visit(final CharLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final ClassExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + } + + @Override public void visit(final ClassOrInterfaceDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + if (n.getExtends() != null) { + for (final ClassOrInterfaceType c : n.getExtends()) { + c.accept(this, arg); + } + } + + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + c.accept(this, arg); + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final ClassOrInterfaceType n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + } + + @Override public void visit(final CompilationUnit n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getPackage() != null) { + n.getPackage().accept(this, arg); + } + if (n.getImports() != null) { + for (final ImportDeclaration i : n.getImports()) { + i.accept(this, arg); + } + } + if (n.getTypes() != null) { + for (final TypeDeclaration typeDeclaration : n.getTypes()) { + typeDeclaration.accept(this, arg); + } + } + } + + @Override public void visit(final ConditionalExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + n.getThenExpr().accept(this, arg); + n.getElseExpr().accept(this, arg); + } + + @Override public void visit(final ConstructorDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + p.accept(this, arg); + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + name.accept(this, arg); + } + } + n.getBlock().accept(this, arg); + } + + @Override public void visit(final ContinueStmt n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final DoStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getBody().accept(this, arg); + n.getCondition().accept(this, arg); + } + + @Override public void visit(final DoubleLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final EmptyMemberDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + } + + @Override public void visit(final EmptyStmt n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final EmptyTypeDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + } + + @Override public void visit(final EnclosedExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getInner().accept(this, arg); + } + + @Override public void visit(final EnumConstantDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + if (n.getClassBody() != null) { + for (final BodyDeclaration member : n.getClassBody()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final EnumDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + c.accept(this, arg); + } + } + if (n.getEntries() != null) { + for (final EnumConstantDeclaration e : n.getEntries()) { + e.accept(this, arg); + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final ExplicitConstructorInvocationStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (!n.isThis()) { + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + } + + @Override public void visit(final ExpressionStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpression().accept(this, arg); + } + + @Override public void visit(final FieldAccessExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getScope().accept(this, arg); + } + + @Override public void visit(final FieldDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + for (final VariableDeclarator var : n.getVariables()) { + var.accept(this, arg); + } + } + + @Override public void visit(final ForeachStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getVariable().accept(this, arg); + n.getIterable().accept(this, arg); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ForStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getInit() != null) { + for (final Expression e : n.getInit()) { + e.accept(this, arg); + } + } + if (n.getCompare() != null) { + n.getCompare().accept(this, arg); + } + if (n.getUpdate() != null) { + for (final Expression e : n.getUpdate()) { + e.accept(this, arg); + } + } + n.getBody().accept(this, arg); + } + + @Override public void visit(final IfStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + n.getThenStmt().accept(this, arg); + if (n.getElseStmt() != null) { + n.getElseStmt().accept(this, arg); + } + } + + @Override public void visit(final ImportDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + } + + @Override public void visit(final InitializerDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + n.getBlock().accept(this, arg); + } + + @Override public void visit(final InstanceOfExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + n.getType().accept(this, arg); + } + + @Override public void visit(final IntegerLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final IntegerLiteralMinValueExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final JavadocComment n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final LabeledStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getStmt().accept(this, arg); + } + + @Override public void visit(final LineComment n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final LongLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final LongLiteralMinValueExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final MarkerAnnotationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + } + + @Override public void visit(final MemberValuePair n, final A arg) { + visitComment(n.getComment(), arg); + n.getValue().accept(this, arg); + } + + @Override public void visit(final MethodCallExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + } + + @Override public void visit(final MethodDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + n.getType().accept(this, arg); + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + p.accept(this, arg); + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + name.accept(this, arg); + } + } + if (n.getBody() != null) { + n.getBody().accept(this, arg); + } + } + + @Override public void visit(final NameExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final NormalAnnotationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + if (n.getPairs() != null) { + for (final MemberValuePair m : n.getPairs()) { + m.accept(this, arg); + } + } + } + + @Override public void visit(final NullLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final ObjectCreationExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + n.getType().accept(this, arg); + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + if (n.getAnonymousClassBody() != null) { + for (final BodyDeclaration member : n.getAnonymousClassBody()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final PackageDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getName().accept(this, arg); + } + + @Override public void visit(final Parameter n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + n.getId().accept(this, arg); + } + + @Override public void visit(final MultiTypeParameter n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + for (final Type type : n.getTypes()) { + type.accept(this, arg); + } + n.getId().accept(this, arg); + } + + @Override public void visit(final PrimitiveType n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final QualifiedNameExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getQualifier().accept(this, arg); + } + + @Override public void visit(final ReferenceType n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + } + + @Override public void visit(final ReturnStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + } + } + + @Override public void visit(final SingleMemberAnnotationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + n.getMemberValue().accept(this, arg); + } + + @Override public void visit(final StringLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final SuperExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + } + } + + @Override public void visit(final SwitchEntryStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getLabel() != null) { + n.getLabel().accept(this, arg); + } + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + } + } + } + + @Override public void visit(final SwitchStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getSelector().accept(this, arg); + if (n.getEntries() != null) { + for (final SwitchEntryStmt e : n.getEntries()) { + e.accept(this, arg); + } + } + } + + @Override public void visit(final SynchronizedStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + n.getBlock().accept(this, arg); + } + + @Override public void visit(final ThisExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + } + } + + @Override public void visit(final ThrowStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final TryStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getResources() != null) { + for (final VariableDeclarationExpr v : n.getResources()) { + v.accept(this, arg); + } + } + n.getTryBlock().accept(this, arg); + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + c.accept(this, arg); + } + } + if (n.getFinallyBlock() != null) { + n.getFinallyBlock().accept(this, arg); + } + } + + @Override public void visit(final TypeDeclarationStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getTypeDeclaration().accept(this, arg); + } + + @Override public void visit(final TypeParameter n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getTypeBound() != null) { + for (final ClassOrInterfaceType c : n.getTypeBound()) { + c.accept(this, arg); + } + } + } + + @Override public void visit(final UnaryExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final UnknownType n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final VariableDeclarationExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + for (final VariableDeclarator v : n.getVars()) { + v.accept(this, arg); + } + } + + @Override public void visit(final VariableDeclarator n, final A arg) { + visitComment(n.getComment(), arg); + n.getId().accept(this, arg); + if (n.getInit() != null) { + n.getInit().accept(this, arg); + } + } + + @Override public void visit(final VariableDeclaratorId n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final VoidType n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final WhileStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + n.getBody().accept(this, arg); + } + + @Override public void visit(final WildcardType n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getExtends() != null) { + n.getExtends().accept(this, arg); + } + if (n.getSuper() != null) { + n.getSuper().accept(this, arg); + } + } + + @Override + public void visit(LambdaExpr n, final A arg) { + if (n.getParameters() != null) { + for (final Parameter a : n.getParameters()) { + a.accept(this, arg); + } + } + if (n.getBody() != null) { + n.getBody().accept(this, arg); + } + } + + @Override + public void visit(MethodReferenceExpr n, final A arg) { + if (n.getTypeParameters() != null) { + for (final TypeParameter a : n.getTypeParameters()) { + a.accept(this, arg); + } + } + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + } + + @Override + public void visit(TypeExpr n, final A arg) { + if (n.getType() != null) { + n.getType().accept(this, arg); + } + } + + private void visitComment(final Comment n, final A arg) { + if (n != null) { + n.accept(this, arg); + } + } +} |