commit 1648bd2af5f477ae2e113970c5a7cf08ff1f8ac7 Author: Victor Date: Thu Nov 15 18:16:17 2018 +0200 Initial diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..81e5da2 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project JavaCompiler. + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..c37743f --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..9e634b3 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c102fd34 +build.xml.script.CRC32=d4fc063e +build.xml.stylesheet.CRC32=8064a381@1.79.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=c102fd34 +nbproject/build-impl.xml.script.CRC32=68744efb +nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.0.48 diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..fbbfe24 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=true +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=C:\\Users\\aNNiMON\\AppData\\Roaming\\NetBeans\\dev\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..6807a2b --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..0255796 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,76 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=JavaCompiler +application.vendor=aNNiMON +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/JavaCompiler.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=org.codehaus.janino.Compiler +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..10937dd --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + JavaCompiler + + + + + + + + + diff --git a/src/com/annimon/javac/Main.java b/src/com/annimon/javac/Main.java new file mode 100644 index 0000000..01c6a51 --- /dev/null +++ b/src/com/annimon/javac/Main.java @@ -0,0 +1,39 @@ +package com.annimon.javac; + +import com.github.javaparser.JavaParser; +import com.github.javaparser.ParseException; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.visitor.VoidVisitorAdapter; +import java.io.File; +import java.io.IOException; + +/** + * + * @author aNNiMON + */ +public final class Main { + + public static void main(String[] args) { + try { + CompilationUnit unit = JavaParser.parse(new File("E:/javac/Main.java"), "UTF-8", false); + System.out.println(unit); + new JavaVisitor().visit(unit, null); + } catch (ParseException | IOException ex) { + ex.printStackTrace(); + } + } + + private static class JavaVisitor extends VoidVisitorAdapter { + + @Override + public void visit(AssignExpr n, Object arg) { + super.visit(n, arg); + System.out.print(n.getTarget()); + System.out.print(' '); + System.out.print(n.getOperator()); + System.out.print(' '); + System.out.println(n.getValue()); + } + } +} diff --git a/src/com/github/javaparser/ASTHelper.java b/src/com/github/javaparser/ASTHelper.java new file mode 100644 index 0000000..a084dde --- /dev/null +++ b/src/com/github/javaparser/ASTHelper.java @@ -0,0 +1,299 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * 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.
+ * 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 variables = new ArrayList(); + 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 vars = new ArrayList(); + 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 null. + * + * @param method + * method + * @param parameter + * parameter + */ + public static void addParameter(MethodDeclaration method, Parameter parameter) { + List parameters = method.getParameters(); + if (isNullOrEmpty(parameters)) { + parameters = new ArrayList(); + method.setParameters(parameters); + } + parameters.add(parameter); + } + + /** + * Adds the given argument to the method call. The list of arguments will be + * initialized if it is null. + * + * @param call + * method call + * @param arg + * argument value + */ + public static void addArgument(MethodCallExpr call, Expression arg) { + List args = call.getArgs(); + if (isNullOrEmpty(args)) { + args = new ArrayList(); + 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 null. + * + * @param cu + * compilation unit + * @param type + * type declaration + */ + public static void addTypeDeclaration(CompilationUnit cu, TypeDeclaration type) { + List types = cu.getTypes(); + if (isNullOrEmpty(types)) { + types = new ArrayList(); + 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 0 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 0 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 null. + * + * @param block to have expression added to + * @param stmt to be added + */ + public static void addStmt(BlockStmt block, Statement stmt) { + List stmts = block.getStmts(); + if (isNullOrEmpty(stmts)) { + stmts = new ArrayList(); + block.setStmts(stmts); + } + stmts.add(stmt); + } + + /** + * Adds the given expression to the specified block. The list of statements + * will be initialized if it is null. + * + * @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 null. + * + * @param type + * type declaration + * @param decl + * member declaration + */ + public static void addMember(TypeDeclaration type, BodyDeclaration decl) { + List members = type.getMembers(); + if (isNullOrEmpty(members)) { + members = new ArrayList(); + type.setMembers(members); + } + members.add(decl); + } + + public static List getNodesByType(Node container, Class clazz) { + List nodes = new ArrayList(); + for (Node child : container.getChildrenNodes()) { + if (clazz.isInstance(child)) { + nodes.add(clazz.cast(child)); + } + nodes.addAll(getNodesByType(child, clazz)); + } + return nodes; + } + +} diff --git a/src/com/github/javaparser/ASTParser.java b/src/com/github/javaparser/ASTParser.java new file mode 100644 index 0000000..53f30b6 --- /dev/null +++ b/src/com/github/javaparser/ASTParser.java @@ -0,0 +1,9148 @@ +/* Generated By:JavaCC: Do not edit this line. ASTParser.java */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; + +import java.io.*; +import java.util.*; +import com.github.javaparser.ast.*; +import com.github.javaparser.ast.body.*; +import com.github.javaparser.ast.comments.*; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.*; +import com.github.javaparser.ast.type.*; + +/** + *

This class was generated automatically by javacc, do not edit.

+ */ +final class ASTParser implements ASTParserConstants { + + void reset(InputStream in, String encoding) { + ReInit(in, encoding); + } + + private List add(List list, Object obj) { + if (list == null) { + list = new LinkedList(); + } + list.add(obj); + return list; + } + + private List add(int pos, List list, Object obj) { + if (list == null) { + list = new LinkedList(); + } + list.add(pos, obj); + return list; + } + + private class Modifier { + + final int modifiers; + final List annotations; + final int beginLine; + final int beginColumn; + + public Modifier(int beginLine, int beginColumn, int modifiers, List annotations) { + this.beginLine = beginLine; + this.beginColumn = beginColumn; + this.modifiers = modifiers; + this.annotations = annotations; + } + } + + public int addModifier(int modifiers, int mod, Token token) throws ParseException { + if ((ModifierSet.hasModifier(modifiers, mod))) { + throwParseException(token, "Duplicated modifier"); + } + return ModifierSet.addModifier(modifiers, mod); + } + + private void throwParseException(Token token, String message) throws ParseException { + StringBuilder buf = new StringBuilder(); + buf.append(message); + buf.append(": \u005c""); + buf.append(token.image); + buf.append("\u005c" at line "); + buf.append(token.beginLine); + buf.append(", column "); + buf.append(token.beginColumn); + ParseException e = new ParseException(buf.toString()); + e.currentToken = token; + throw e; + } + + private Expression generateLambda(Expression ret, Statement lambdaBody) throws ParseException { + if (ret instanceof EnclosedExpr) { + Expression inner = ((EnclosedExpr) ret).getInner(); + if (inner != null && inner instanceof NameExpr) { + VariableDeclaratorId id = new VariableDeclaratorId(inner.getBeginLine(), inner.getBeginColumn(), inner.getEndLine(), inner.getEndColumn(), ((NameExpr)inner).getName(), 0); + List params = add(null, new Parameter(ret.getBeginLine(), ret.getBeginColumn(), ret.getEndLine(), ret.getEndColumn(), 0, null, new UnknownType(), false, id)); + ret = new LambdaExpr(ret.getBeginLine(), ret.getBeginColumn(), lambdaBody.getEndLine(), lambdaBody.getEndColumn(), params, lambdaBody, true); + } else { + ret = new LambdaExpr(ret.getBeginLine(), ret.getBeginColumn(), lambdaBody.getEndLine(), lambdaBody.getEndColumn(), null, lambdaBody, true); + } + } else if (ret instanceof NameExpr) { + VariableDeclaratorId id = new VariableDeclaratorId(ret.getBeginLine(), ret.getBeginColumn(), ret.getEndLine(), ret.getEndColumn(), ((NameExpr)ret).getName(), 0); + List params = add(null, new Parameter(ret.getBeginLine(), ret.getBeginColumn(), ret.getEndLine(), ret.getEndColumn(), 0, null, new UnknownType(), false, id)); + ret = new LambdaExpr(ret.getBeginLine(), ret.getBeginColumn(), ret.getEndLine(), ret.getEndColumn(), params, lambdaBody, false); + } else if (ret instanceof LambdaExpr) { + ((LambdaExpr) ret).setBody(lambdaBody); + ret.setEndLine(lambdaBody.getEndLine()); + ret.setEndColumn(lambdaBody.getEndColumn()); + } else { + throw new ParseException("Failed to parse lambda expression! Please create an issue at https://github.com/javaparser/javaparser/issues"); + } + return ret; + } + + static final class GTToken extends Token { + + int realKind = ASTParserConstants.GT; + + GTToken(int kind, String image) { + this.kind = kind; + this.image = image; + } + + public static Token newToken(int kind, String image) { + return new GTToken(kind, image); + } + } + + private Token last_special_token = null; + +/***************************************** + * THE JAVA LANGUAGE GRAMMAR STARTS HERE * + *****************************************/ + +/* + * Program structuring syntax follows. + */ + final public CompilationUnit CompilationUnit() throws ParseException { + PackageDeclaration pakage = null; + List imports = null; + ImportDeclaration in = null; + List types = null; + TypeDeclaration tn = null; + int line = -1; + int column = 0; + if (jj_2_1(2147483647)) { + pakage = PackageDeclaration(); + line = pakage.getBeginLine(); column = pakage.getBeginColumn(); + } else { + ; + } + label_1: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORT: + ; + break; + default: + jj_la1[0] = jj_gen; + break label_1; + } + in = ImportDeclaration(); + if(line==-1){line = in.getBeginLine(); column = in.getBeginColumn();} imports = add(imports, in); + } + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case CLASS: + case ENUM: + case FINAL: + case INTERFACE: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case SEMICOLON: + case AT: + ; + break; + default: + jj_la1[1] = jj_gen; + break label_2; + } + tn = TypeDeclaration(); + if(line==-1){line = tn.getBeginLine(); column = tn.getBeginColumn();} types = add(types, tn); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 0: + jj_consume_token(0); + break; + case 131: + jj_consume_token(131); + break; + default: + jj_la1[2] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return new CompilationUnit(line == -1 ? 0 : line, column, token.endLine, token.endColumn,pakage, imports, types);} + throw new Error("Missing return statement in function"); + } + + final public PackageDeclaration PackageDeclaration() throws ParseException { + List annotations = null; + AnnotationExpr ann; + NameExpr name; + int line; + int column; + label_3: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[3] = jj_gen; + break label_3; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + jj_consume_token(PACKAGE); + line=token.beginLine; column=token.beginColumn; + name = Name(); + jj_consume_token(SEMICOLON); + {if (true) return new PackageDeclaration(line, column, token.endLine, token.endColumn,annotations, name);} + throw new Error("Missing return statement in function"); + } + + final public ImportDeclaration ImportDeclaration() throws ParseException { + NameExpr name; + boolean isStatic = false; + boolean isAsterisk = false; + int line; + int column; + jj_consume_token(IMPORT); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STATIC: + jj_consume_token(STATIC); + isStatic = true; + break; + default: + jj_la1[4] = jj_gen; + ; + } + name = Name(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DOT: + jj_consume_token(DOT); + jj_consume_token(STAR); + isAsterisk = true; + break; + default: + jj_la1[5] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + {if (true) return new ImportDeclaration(line, column, token.endLine, token.endColumn,name, isStatic, isAsterisk);} + throw new Error("Missing return statement in function"); + } + +/* + * Modifiers. We match all modifiers in a single rule to reduce the chances of + * syntax errors for simple modifier mistakes. It will also enable us to give + * better error messages. + */ + final public Modifier Modifiers() throws ParseException { + int beginLine = -1; + int beginColumn = -1; + int modifiers = 0; + List annotations = null; + AnnotationExpr ann; + label_4: + while (true) { + if (jj_2_2(2)) { + ; + } else { + break label_4; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PUBLIC: + jj_consume_token(PUBLIC); + modifiers = addModifier(modifiers, ModifierSet.PUBLIC, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case STATIC: + jj_consume_token(STATIC); + modifiers = addModifier(modifiers, ModifierSet.STATIC, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case PROTECTED: + jj_consume_token(PROTECTED); + modifiers = addModifier(modifiers, ModifierSet.PROTECTED, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case PRIVATE: + jj_consume_token(PRIVATE); + modifiers = addModifier(modifiers, ModifierSet.PRIVATE, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case FINAL: + jj_consume_token(FINAL); + modifiers = addModifier(modifiers, ModifierSet.FINAL, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case ABSTRACT: + jj_consume_token(ABSTRACT); + modifiers = addModifier(modifiers, ModifierSet.ABSTRACT, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case SYNCHRONIZED: + jj_consume_token(SYNCHRONIZED); + modifiers = addModifier(modifiers, ModifierSet.SYNCHRONIZED, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case NATIVE: + jj_consume_token(NATIVE); + modifiers = addModifier(modifiers, ModifierSet.NATIVE, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case TRANSIENT: + jj_consume_token(TRANSIENT); + modifiers = addModifier(modifiers, ModifierSet.TRANSIENT, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case VOLATILE: + jj_consume_token(VOLATILE); + modifiers = addModifier(modifiers, ModifierSet.VOLATILE, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case STRICTFP: + jj_consume_token(STRICTFP); + modifiers = addModifier(modifiers, ModifierSet.STRICTFP, token); if(beginLine==-1) {beginLine=token.beginLine; beginColumn=token.beginColumn;} + break; + case AT: + ann = Annotation(); + annotations = add(annotations, ann); if(beginLine==-1) {beginLine=ann.getBeginLine(); beginColumn=ann.getBeginColumn();} + break; + default: + jj_la1[6] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return new Modifier(beginLine, beginColumn, modifiers, annotations);} + throw new Error("Missing return statement in function"); + } + +/* + * Declaration syntax follows. + */ + final public TypeDeclaration TypeDeclaration() throws ParseException { + Modifier modifier; + TypeDeclaration ret; + + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + jj_consume_token(SEMICOLON); + ret = new EmptyTypeDeclaration(token.beginLine, token.beginColumn, token.endLine, token.endColumn); + break; + case ABSTRACT: + case CLASS: + case ENUM: + case FINAL: + case INTERFACE: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case AT: + modifier = Modifiers(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CLASS: + case INTERFACE: + ret = ClassOrInterfaceDeclaration(modifier); + break; + case ENUM: + ret = EnumDeclaration(modifier); + break; + case AT: + ret = AnnotationTypeDeclaration(modifier); + break; + default: + jj_la1[7] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[8] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public ClassOrInterfaceDeclaration ClassOrInterfaceDeclaration(Modifier modifier) throws ParseException { + boolean isInterface = false; + NameExpr name; + List typePar = null; + List extList = null; + List impList = null; + List members; + int line = modifier.beginLine; + int column = modifier.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CLASS: + jj_consume_token(CLASS); + break; + case INTERFACE: + jj_consume_token(INTERFACE); + isInterface = true; + break; + default: + jj_la1[9] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + if (line == -1) {line=token.beginLine; column=token.beginColumn;} + name = Name(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typePar = TypeParameters(); + typePar.remove(0); + break; + default: + jj_la1[10] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EXTENDS: + extList = ExtendsList(isInterface); + break; + default: + jj_la1[11] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPLEMENTS: + impList = ImplementsList(isInterface); + break; + default: + jj_la1[12] = jj_gen; + ; + } + members = ClassOrInterfaceBody(isInterface); + ClassOrInterfaceDeclaration tmp = new ClassOrInterfaceDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, isInterface, null, typePar, extList, impList, members); + tmp.setNameExpr(name); + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public List ExtendsList(boolean isInterface) throws ParseException { + boolean extendsMoreThanOne = false; + List ret = new LinkedList(); + ClassOrInterfaceType cit; + AnnotationExpr ann; + List annotations = null; + jj_consume_token(EXTENDS); + label_5: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[13] = jj_gen; + break label_5; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + cit = ClassOrInterfaceType(); + cit.setAnnotations(annotations); ret.add(cit); + label_6: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[14] = jj_gen; + break label_6; + } + jj_consume_token(COMMA); + cit = ClassOrInterfaceType(); + ret.add(cit); extendsMoreThanOne = true; + } + if (extendsMoreThanOne && !isInterface) + throwParseException(token, "A class cannot extend more than one other class"); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List ImplementsList(boolean isInterface) throws ParseException { + List ret = new LinkedList(); + ClassOrInterfaceType cit; + AnnotationExpr ann; + List annotations = null; + jj_consume_token(IMPLEMENTS); + label_7: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[15] = jj_gen; + break label_7; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + cit = ClassOrInterfaceType(); + cit.setAnnotations(annotations); ret.add(cit); + label_8: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[16] = jj_gen; + break label_8; + } + jj_consume_token(COMMA); + cit = ClassOrInterfaceType(); + ret.add(cit); + } + if (isInterface) + throwParseException(token, "An interface cannot implement other interfaces"); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public EnumDeclaration EnumDeclaration(Modifier modifier) throws ParseException { + NameExpr name; + List impList = null; + EnumConstantDeclaration entry; + List entries = null; + BodyDeclaration member; + List members = null; + int line = modifier.beginLine; + int column = modifier.beginColumn; + jj_consume_token(ENUM); + if (line == -1) {line=token.beginLine; column=token.beginColumn;} + name = Name(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPLEMENTS: + impList = ImplementsList(false); + break; + default: + jj_la1[17] = jj_gen; + ; + } + jj_consume_token(LBRACE); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + case AT: + entries = new LinkedList(); + entry = EnumConstantDeclaration(); + entries.add(entry); + label_9: + while (true) { + if (jj_2_3(2)) { + ; + } else { + break label_9; + } + jj_consume_token(COMMA); + entry = EnumConstantDeclaration(); + entries.add(entry); + } + break; + default: + jj_la1[18] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + break; + default: + jj_la1[19] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + jj_consume_token(SEMICOLON); + label_10: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case _DEFAULT: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOID: + case VOLATILE: + case IDENTIFIER: + case LBRACE: + case SEMICOLON: + case AT: + case LT: + ; + break; + default: + jj_la1[20] = jj_gen; + break label_10; + } + member = ClassOrInterfaceBodyDeclaration(false); + members = add(members, member); + } + break; + default: + jj_la1[21] = jj_gen; + ; + } + jj_consume_token(RBRACE); + EnumDeclaration tmp = new EnumDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, null, impList, entries, members); + tmp.setNameExpr(name); + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public EnumConstantDeclaration EnumConstantDeclaration() throws ParseException { + List annotations = null; + AnnotationExpr ann; + String name; + List args = null; + List classBody = null; + int line = -1; + int column = -1; + + label_11: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[22] = jj_gen; + break label_11; + } + ann = Annotation(); + annotations = add(annotations, ann); if(line==-1){line=ann.getBeginLine(); column=ann.getBeginColumn();} + } + jj_consume_token(IDENTIFIER); + name = token.image; if(line==-1){line=token.beginLine; column=token.beginColumn;} + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LPAREN: + args = Arguments(); + break; + default: + jj_la1[23] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACE: + classBody = ClassOrInterfaceBody(false); + break; + default: + jj_la1[24] = jj_gen; + ; + } + EnumConstantDeclaration tmp = new EnumConstantDeclaration(line, column, token.endLine, token.endColumn, annotations, name, args, classBody); + + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public List TypeParameters() throws ParseException { + List ret = new LinkedList(); + TypeParameter tp; + List annotations = null; + AnnotationExpr ann; + jj_consume_token(LT); + ret.add(new int[]{token.beginLine, token.beginColumn}); + label_12: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[25] = jj_gen; + break label_12; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + tp = TypeParameter(); + ret.add(tp); tp.setAnnotations(annotations); annotations = null; + label_13: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[26] = jj_gen; + break label_13; + } + jj_consume_token(COMMA); + label_14: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[27] = jj_gen; + break label_14; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + tp = TypeParameter(); + ret.add(tp); tp.setAnnotations(annotations); annotations = null; + } + jj_consume_token(GT); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public TypeParameter TypeParameter() throws ParseException { + String name; + List typeBound = null; + int line; + int column; + jj_consume_token(IDENTIFIER); + name = token.image; line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EXTENDS: + typeBound = TypeBound(); + break; + default: + jj_la1[28] = jj_gen; + ; + } + {if (true) return new TypeParameter(line, column, token.endLine, token.endColumn,name, typeBound);} + throw new Error("Missing return statement in function"); + } + + final public List TypeBound() throws ParseException { + List ret = new LinkedList(); + ClassOrInterfaceType cit; + AnnotationExpr ann; + List annotations = null; + jj_consume_token(EXTENDS); + label_15: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[29] = jj_gen; + break label_15; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + cit = ClassOrInterfaceType(); + cit.setAnnotations(annotations); ret.add(cit); annotations=null; + label_16: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BIT_AND: + ; + break; + default: + jj_la1[30] = jj_gen; + break label_16; + } + jj_consume_token(BIT_AND); + label_17: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[31] = jj_gen; + break label_17; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + cit = ClassOrInterfaceType(); + cit.setAnnotations(annotations); ret.add(cit); annotations=null; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List ClassOrInterfaceBody(boolean isInterface) throws ParseException { + List ret = new LinkedList(); + BodyDeclaration member; + jj_consume_token(LBRACE); + label_18: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case _DEFAULT: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOID: + case VOLATILE: + case IDENTIFIER: + case LBRACE: + case SEMICOLON: + case AT: + case LT: + ; + break; + default: + jj_la1[32] = jj_gen; + break label_18; + } + member = ClassOrInterfaceBodyDeclaration(isInterface); + ret.add(member); + } + jj_consume_token(RBRACE); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public BodyDeclaration ClassOrInterfaceBodyDeclaration(boolean isInterface) throws ParseException { + boolean isNestedInterface = false; + Modifier modifier; + Modifier modifier2 = null; + int aux = 0; + BodyDeclaration ret; + boolean isDefault = false; + + if (jj_2_6(2)) { + ret = InitializerDeclaration(); + if (isInterface) + throwParseException(token, "An interface cannot have initializers"); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case _DEFAULT: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOID: + case VOLATILE: + case IDENTIFIER: + case AT: + case LT: + modifier = Modifiers(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case _DEFAULT: + jj_consume_token(_DEFAULT); + modifier2 = Modifiers(); + if(!isInterface) + { + throwParseException(token, "An interface cannot have default members"); + } + isDefault = true; + break; + default: + jj_la1[33] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CLASS: + case INTERFACE: + ret = ClassOrInterfaceDeclaration(modifier); + break; + case ENUM: + ret = EnumDeclaration(modifier); + break; + case AT: + ret = AnnotationTypeDeclaration(modifier); + break; + default: + jj_la1[34] = jj_gen; + if (jj_2_4(2147483647)) { + ret = ConstructorDeclaration(modifier); + } else if (jj_2_5(2147483647)) { + ret = FieldDeclaration(modifier); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case VOID: + case IDENTIFIER: + case LT: + ret = MethodDeclaration(modifier); + if(isDefault && ret!= null && ((MethodDeclaration)ret).getBody() == null) + { + throwParseException(token, "\u005c"default\u005c" methods must have a body"); + } + ((MethodDeclaration)ret).setDefault(isDefault); + if(modifier2!= null) + { + aux = modifier2.modifiers; + } + ((MethodDeclaration)ret).setModifiers(addModifier(modifier.modifiers, aux, token)); + break; + default: + jj_la1[35] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + if(isDefault && ! (ret instanceof MethodDeclaration)) + { + throwParseException(token, "Just methods can have the keyword \u005c"default\u005c"."); + } + break; + case SEMICOLON: + jj_consume_token(SEMICOLON); + ret = new EmptyMemberDeclaration(token.beginLine, token.beginColumn, token.endLine, token.endColumn); + break; + default: + jj_la1[36] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public FieldDeclaration FieldDeclaration(Modifier modifier) throws ParseException { + Type type; + List variables = new LinkedList(); + VariableDeclarator val; + // Modifiers are already matched in the caller + type = Type(); + val = VariableDeclarator(); + variables.add(val); + label_19: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[37] = jj_gen; + break label_19; + } + jj_consume_token(COMMA); + val = VariableDeclarator(); + variables.add(val); + } + jj_consume_token(SEMICOLON); + int line = modifier.beginLine; + int column = modifier.beginColumn; + if (line == -1) { line=type.getBeginLine(); column=type.getBeginColumn(); } + {if (true) return new FieldDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, variables);} + throw new Error("Missing return statement in function"); + } + + final public VariableDeclarator VariableDeclarator() throws ParseException { + VariableDeclaratorId id; + Expression init = null; + id = VariableDeclaratorId(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSIGN: + jj_consume_token(ASSIGN); + init = VariableInitializer(); + break; + default: + jj_la1[38] = jj_gen; + ; + } + {if (true) return new VariableDeclarator(id.getBeginLine(), id.getBeginColumn(), token.endLine, token.endColumn, id, init);} + throw new Error("Missing return statement in function"); + } + + final public VariableDeclaratorId VariableDeclaratorId() throws ParseException { + String name; + int arrayCount = 0; + int line; + int column; + jj_consume_token(IDENTIFIER); + name = token.image; line=token.beginLine; column=token.beginColumn; + label_20: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + ; + break; + default: + jj_la1[39] = jj_gen; + break label_20; + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + arrayCount++; + } + {if (true) return new VariableDeclaratorId(line, column, token.endLine, token.endColumn,name, arrayCount);} + throw new Error("Missing return statement in function"); + } + + final public Expression VariableInitializer() throws ParseException { + Expression ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACE: + ret = ArrayInitializer(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ret = Expression(); + break; + default: + jj_la1[40] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public ArrayInitializerExpr ArrayInitializer() throws ParseException { + List values = null; + Expression val; + int line; + int column; + jj_consume_token(LBRACE); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + val = VariableInitializer(); + values = add(values, val); + label_21: + while (true) { + if (jj_2_7(2)) { + ; + } else { + break label_21; + } + jj_consume_token(COMMA); + val = VariableInitializer(); + values = add(values, val); + } + break; + default: + jj_la1[41] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + break; + default: + jj_la1[42] = jj_gen; + ; + } + jj_consume_token(RBRACE); + {if (true) return new ArrayInitializerExpr(line, column, token.endLine, token.endColumn,values);} + throw new Error("Missing return statement in function"); + } + + final public MethodDeclaration MethodDeclaration(Modifier modifier) throws ParseException { + List typeParameters = null; + Type type; + NameExpr name; + List parameters; + int arrayCount = 0; + List throws_ = null; + BlockStmt block = null; + int line = modifier.beginLine; + int column = modifier.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typeParameters = TypeParameters(); + int[] lineCol=(int[])typeParameters.remove(0); if(line==-1){ line=lineCol[0]; column=lineCol[1];} + break; + default: + jj_la1[43] = jj_gen; + ; + } + type = ResultType(); + if(line==-1){line=type.getBeginLine(); column=type.getBeginColumn();} + name = Name(); + parameters = FormalParameters(); + label_22: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + ; + break; + default: + jj_la1[44] = jj_gen; + break label_22; + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + arrayCount++; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case THROWS: + jj_consume_token(THROWS); + throws_ = NameList(); + break; + default: + jj_la1[45] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACE: + block = Block(); + break; + case SEMICOLON: + jj_consume_token(SEMICOLON); + break; + default: + jj_la1[46] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + MethodDeclaration tmp = new MethodDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, typeParameters, type, null, parameters, arrayCount, throws_, block); + tmp.setNameExpr(name); + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public List FormalParameters() throws ParseException { + List ret = null; + Parameter par; + jj_consume_token(LPAREN); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case AT: + par = FormalParameter(); + ret = add(ret, par); + label_23: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[47] = jj_gen; + break label_23; + } + jj_consume_token(COMMA); + par = FormalParameter(); + ret = add(ret, par); + } + break; + default: + jj_la1[48] = jj_gen; + ; + } + jj_consume_token(RPAREN); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List FormalLambdaParameters() throws ParseException { + List ret = null; + Parameter par; + jj_consume_token(COMMA); + par = FormalParameter(); + ret = add(ret, par); + label_24: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[49] = jj_gen; + break label_24; + } + jj_consume_token(COMMA); + par = FormalParameter(); + ret = add(ret, par); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List InferredLambdaParameters() throws ParseException { + List ret = null; + VariableDeclaratorId id; + jj_consume_token(COMMA); + id = VariableDeclaratorId(); + ret = add(ret, new Parameter(id.getBeginLine(), id.getBeginColumn(), id.getEndLine(), id.getEndColumn(), 0, null, new UnknownType(), false, id)); + label_25: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[50] = jj_gen; + break label_25; + } + jj_consume_token(COMMA); + id = VariableDeclaratorId(); + ret = add(ret, new Parameter(id.getBeginLine(), id.getBeginColumn(), id.getEndLine(), id.getEndColumn(), 0, null, new UnknownType(), false, id)); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Parameter FormalParameter() throws ParseException { + Modifier modifier; + Type type; + boolean isVarArg = false; + VariableDeclaratorId id; + modifier = Modifiers(); + type = Type(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ELLIPSIS: + jj_consume_token(ELLIPSIS); + isVarArg = true; + break; + default: + jj_la1[51] = jj_gen; + ; + } + id = VariableDeclaratorId(); + int line = modifier.beginLine; + int column = modifier.beginColumn; + if(line==-1){ line=type.getBeginLine(); column=type.getBeginColumn(); } + {if (true) return new Parameter(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, isVarArg, id);} + throw new Error("Missing return statement in function"); + } + + final public ConstructorDeclaration ConstructorDeclaration(Modifier modifier) throws ParseException { + List typeParameters = null; + NameExpr name; + List parameters; + List throws_ = null; + ExplicitConstructorInvocationStmt exConsInv = null; + List stmts; + int line = modifier.beginLine; + int column = modifier.beginColumn; + int bbLine = 0; + int bbColumn = 0; + int beLine = 0; + int beColumn = 0; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typeParameters = TypeParameters(); + int[] lineCol=(int[])typeParameters.remove(0); if(line==-1){ line=lineCol[0]; column=lineCol[1];} + break; + default: + jj_la1[52] = jj_gen; + ; + } + // Modifiers matched in the caller + name = SimpleName(); + if(line==-1){line=token.beginLine; column=token.beginColumn;} + parameters = FormalParameters(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case THROWS: + jj_consume_token(THROWS); + throws_ = NameList(); + break; + default: + jj_la1[53] = jj_gen; + ; + } + jj_consume_token(LBRACE); + bbLine=token.beginLine; bbColumn=token.beginColumn; + if (jj_2_8(2147483647)) { + exConsInv = ExplicitConstructorInvocation(); + } else { + ; + } + stmts = Statements(); + jj_consume_token(RBRACE); + if (exConsInv != null) { + stmts = add(0, stmts, exConsInv); + } + ConstructorDeclaration tmp = new ConstructorDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, typeParameters, null, parameters, throws_, new BlockStmt(bbLine, bbColumn, token.endLine, token.endColumn, stmts)); + tmp.setNameExpr(name); + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public ExplicitConstructorInvocationStmt ExplicitConstructorInvocation() throws ParseException { + boolean isThis = false; + List args; + Expression expr = null; + List typeArgs = null; + int line = -1; + int column = 0; + if (jj_2_10(2147483647)) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + case 132: + typeArgs = TypeArguments(); + int[] lineCol=(int[])typeArgs.remove(0); line=lineCol[0]; column=lineCol[1]; + break; + default: + jj_la1[54] = jj_gen; + ; + } + jj_consume_token(THIS); + if (line == -1) {line=token.beginLine; column=token.beginColumn;} isThis = true; + args = Arguments(); + jj_consume_token(SEMICOLON); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LT: + case 132: + if (jj_2_9(2147483647)) { + expr = PrimaryExpressionWithoutSuperSuffix(); + jj_consume_token(DOT); + line=expr.getBeginLine(); column=expr.getBeginColumn(); + } else { + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + case 132: + typeArgs = TypeArguments(); + int[] lineCol=(int[])typeArgs.remove(0); if (line == -1) {line=lineCol[0]; column=lineCol[1];} + break; + default: + jj_la1[55] = jj_gen; + ; + } + jj_consume_token(SUPER); + if (line == -1) {line=token.beginLine; column=token.beginColumn;} + args = Arguments(); + jj_consume_token(SEMICOLON); + break; + default: + jj_la1[56] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return new ExplicitConstructorInvocationStmt(line, column, token.endLine, token.endColumn,typeArgs, isThis, expr, args);} + throw new Error("Missing return statement in function"); + } + + final public List Statements() throws ParseException { + List ret = null; + Statement stmt; + label_26: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case ASSERT: + case BOOLEAN: + case BREAK: + case BYTE: + case CHAR: + case CLASS: + case CONTINUE: + case DO: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case FOR: + case IF: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case RETURN: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SWITCH: + case SYNCHRONIZED: + case THIS: + case THROW: + case TRANSIENT: + case TRUE: + case TRY: + case VOID: + case VOLATILE: + case WHILE: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case SEMICOLON: + case AT: + case INCR: + case DECR: + ; + break; + default: + jj_la1[57] = jj_gen; + break label_26; + } + stmt = BlockStatement(); + ret = add(ret, stmt); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public InitializerDeclaration InitializerDeclaration() throws ParseException { + BlockStmt block; + int line = -1; + int column = 0; + boolean isStatic = false; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STATIC: + jj_consume_token(STATIC); + isStatic = true; line=token.beginLine; column=token.beginColumn; + break; + default: + jj_la1[58] = jj_gen; + ; + } + block = Block(); + if(line==-1){line=block.getBeginLine(); column=block.getBeginColumn();} + {if (true) return new InitializerDeclaration(line, column, token.endLine, token.endColumn, isStatic, block);} + throw new Error("Missing return statement in function"); + } + +/* + * Type, name and expression syntax follows. + */ + final public Type Type() throws ParseException { + Type ret; + if (jj_2_11(2)) { + ret = ReferenceType(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + ret = PrimitiveType(); + break; + default: + jj_la1[59] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public ReferenceType ReferenceType() throws ParseException { + Type type; + int arrayCount = 0; + List annotations = null; + List accum= null; + AnnotationExpr ann; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + type = PrimitiveType(); + label_27: + while (true) { + label_28: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[60] = jj_gen; + break label_28; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + arrayCount++; accum = add(accum, annotations); annotations= null; + if (jj_2_12(2)) { + ; + } else { + break label_27; + } + } + break; + case IDENTIFIER: + type = ClassOrInterfaceType(); + label_29: + while (true) { + if (jj_2_13(2)) { + ; + } else { + break label_29; + } + label_30: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[61] = jj_gen; + break label_30; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + arrayCount++; accum = add(accum, annotations); annotations= null; + } + break; + default: + jj_la1[62] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return new ReferenceType(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn, type, arrayCount, null, accum);} + throw new Error("Missing return statement in function"); + } + + final public ClassOrInterfaceType ClassOrInterfaceType() throws ParseException { + ClassOrInterfaceType ret; + String name; + List typeArgs = null; + int line; + int column; + List annotations = null; + AnnotationExpr ann; + jj_consume_token(IDENTIFIER); + line=token.beginLine; column=token.beginColumn; + name = token.image; + if (jj_2_14(2)) { + typeArgs = TypeArguments(); + typeArgs.remove(0); + } else { + ; + } + ret = new ClassOrInterfaceType(line, column, token.endLine, token.endColumn,null, name, typeArgs); + label_31: + while (true) { + if (jj_2_15(2)) { + ; + } else { + break label_31; + } + jj_consume_token(DOT); + label_32: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[63] = jj_gen; + break label_32; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + jj_consume_token(IDENTIFIER); + name = token.image; + if (jj_2_16(2)) { + typeArgs = TypeArguments(); + typeArgs.remove(0); + } else { + ; + } + ret = new ClassOrInterfaceType(line, column, token.endLine, token.endColumn,ret, name, typeArgs); ret.setAnnotations(annotations); annotations = null; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List TypeArguments() throws ParseException { + List ret = new LinkedList(); + Type type; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + jj_consume_token(LT); + ret.add(new int[]{token.beginLine, token.beginColumn}); + type = TypeArgument(); + ret.add(type); + label_33: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[64] = jj_gen; + break label_33; + } + jj_consume_token(COMMA); + type = TypeArgument(); + ret.add(type); + } + jj_consume_token(GT); + {if (true) return ret;} + break; + case 132: + jj_consume_token(132); + ret.add(null); + {if (true) return ret;} + break; + default: + jj_la1[65] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + final public Type TypeArgument() throws ParseException { + Type ret; + List annotations = null; + AnnotationExpr ann; + label_34: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[66] = jj_gen; + break label_34; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + ret = ReferenceType(); + break; + case HOOK: + ret = Wildcard(); + break; + default: + jj_la1[67] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret.setAnnotations(annotations); {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public WildcardType Wildcard() throws ParseException { + ReferenceType ext = null; + ReferenceType sup = null; + int line; + int column; + AnnotationExpr ann; + List annotations = null; + jj_consume_token(HOOK); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EXTENDS: + case SUPER: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EXTENDS: + jj_consume_token(EXTENDS); + label_35: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[68] = jj_gen; + break label_35; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + ext = ReferenceType(); + ext.setAnnotations(annotations); + break; + case SUPER: + jj_consume_token(SUPER); + label_36: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[69] = jj_gen; + break label_36; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + sup = ReferenceType(); + sup.setAnnotations(annotations); + break; + default: + jj_la1[70] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[71] = jj_gen; + ; + } + {if (true) return new WildcardType(line, column, token.endLine, token.endColumn,ext, sup);} + throw new Error("Missing return statement in function"); + } + + final public PrimitiveType PrimitiveType() throws ParseException { + PrimitiveType ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + jj_consume_token(BOOLEAN); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Boolean); + break; + case CHAR: + jj_consume_token(CHAR); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Char); + break; + case BYTE: + jj_consume_token(BYTE); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Byte); + break; + case SHORT: + jj_consume_token(SHORT); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Short); + break; + case INT: + jj_consume_token(INT); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Int); + break; + case LONG: + jj_consume_token(LONG); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Long); + break; + case FLOAT: + jj_consume_token(FLOAT); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Float); + break; + case DOUBLE: + jj_consume_token(DOUBLE); + ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Double); + break; + default: + jj_la1[72] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Type ResultType() throws ParseException { + Type ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case VOID: + jj_consume_token(VOID); + ret = new VoidType(token.beginLine, token.beginColumn, token.endLine, token.endColumn); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + ret = Type(); + break; + default: + jj_la1[73] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public NameExpr Name() throws ParseException { + NameExpr ret; + jj_consume_token(IDENTIFIER); + ret = new NameExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); + label_37: + while (true) { + if (jj_2_17(2)) { + ; + } else { + break label_37; + } + jj_consume_token(DOT); + jj_consume_token(IDENTIFIER); + ret = new QualifiedNameExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, token.image); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List ClassOrInterfaceTypeList() throws ParseException { + List ret = new LinkedList(); + ClassOrInterfaceType type; + List annotations= null; + AnnotationExpr ann; + label_38: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[74] = jj_gen; + break label_38; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + type = ClassOrInterfaceType(); + type.setAnnotations(annotations); ret.add(type); annotations=null; + label_39: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[75] = jj_gen; + break label_39; + } + jj_consume_token(COMMA); + label_40: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[76] = jj_gen; + break label_40; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + type = ClassOrInterfaceType(); + type.setAnnotations(annotations); ret.add(type); annotations=null; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public NameExpr SimpleName() throws ParseException { + NameExpr ret; + jj_consume_token(IDENTIFIER); + ret = new NameExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List NameList() throws ParseException { + List ret = new LinkedList(); + NameExpr name; + name = Name(); + ret.add(name); + label_41: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[77] = jj_gen; + break label_41; + } + jj_consume_token(COMMA); + name = Name(); + ret.add(name); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + +/* + * Expression syntax follows. + */ + final public Expression Expression() throws ParseException { + Expression ret; + AssignExpr.Operator op; + Expression value; + Statement lambdaBody = null; + List params = null; + List typeArgs = null; + VariableDeclaratorId id = null; + Expression inner = null; + ret = ConditionalExpression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSIGN: + case PLUSASSIGN: + case MINUSASSIGN: + case STARASSIGN: + case SLASHASSIGN: + case ANDASSIGN: + case ORASSIGN: + case XORASSIGN: + case REMASSIGN: + case LSHIFTASSIGN: + case RSIGNEDSHIFTASSIGN: + case RUNSIGNEDSHIFTASSIGN: + case ARROW: + case DOUBLECOLON: + if (jj_2_18(2)) { + op = AssignmentOperator(); + value = Expression(); + ret = new AssignExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, value, op); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ARROW: + jj_consume_token(ARROW); + lambdaBody = LambdaBody(); + if (ret instanceof CastExpr) + { + inner = generateLambda(((CastExpr)ret).getExpr(), lambdaBody); + ((CastExpr)ret).setExpr(inner); + } + else if (ret instanceof ConditionalExpr){ + ConditionalExpr ce = (ConditionalExpr) ret; + if(ce.getElseExpr() != null){ + ce.setElseExpr(generateLambda(ce.getElseExpr(), lambdaBody)); + } + } + else + { + ret = generateLambda(ret, lambdaBody); + } + break; + case DOUBLECOLON: + jj_consume_token(DOUBLECOLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typeArgs = TypeParameters(); + typeArgs.remove(0); + break; + default: + jj_la1[78] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case NEW: + jj_consume_token(NEW); + break; + default: + jj_la1[79] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = new MethodReferenceExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, token.image); + break; + default: + jj_la1[80] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + default: + jj_la1[81] = jj_gen; + ; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public AssignExpr.Operator AssignmentOperator() throws ParseException { + AssignExpr.Operator ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSIGN: + jj_consume_token(ASSIGN); + ret = AssignExpr.Operator.assign; + break; + case STARASSIGN: + jj_consume_token(STARASSIGN); + ret = AssignExpr.Operator.star; + break; + case SLASHASSIGN: + jj_consume_token(SLASHASSIGN); + ret = AssignExpr.Operator.slash; + break; + case REMASSIGN: + jj_consume_token(REMASSIGN); + ret = AssignExpr.Operator.rem; + break; + case PLUSASSIGN: + jj_consume_token(PLUSASSIGN); + ret = AssignExpr.Operator.plus; + break; + case MINUSASSIGN: + jj_consume_token(MINUSASSIGN); + ret = AssignExpr.Operator.minus; + break; + case LSHIFTASSIGN: + jj_consume_token(LSHIFTASSIGN); + ret = AssignExpr.Operator.lShift; + break; + case RSIGNEDSHIFTASSIGN: + jj_consume_token(RSIGNEDSHIFTASSIGN); + ret = AssignExpr.Operator.rSignedShift; + break; + case RUNSIGNEDSHIFTASSIGN: + jj_consume_token(RUNSIGNEDSHIFTASSIGN); + ret = AssignExpr.Operator.rUnsignedShift; + break; + case ANDASSIGN: + jj_consume_token(ANDASSIGN); + ret = AssignExpr.Operator.and; + break; + case XORASSIGN: + jj_consume_token(XORASSIGN); + ret = AssignExpr.Operator.xor; + break; + case ORASSIGN: + jj_consume_token(ORASSIGN); + ret = AssignExpr.Operator.or; + break; + default: + jj_la1[82] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression ConditionalExpression() throws ParseException { + Expression ret; + Expression left; + Expression right; + ret = ConditionalOrExpression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HOOK: + jj_consume_token(HOOK); + left = Expression(); + jj_consume_token(COLON); + right = ConditionalExpression(); + ret = new ConditionalExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, left, right); + break; + default: + jj_la1[83] = jj_gen; + ; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression ConditionalOrExpression() throws ParseException { + Expression ret; + Expression right; + ret = ConditionalAndExpression(); + label_42: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SC_OR: + ; + break; + default: + jj_la1[84] = jj_gen; + break label_42; + } + jj_consume_token(SC_OR); + right = ConditionalAndExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.or); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression ConditionalAndExpression() throws ParseException { + Expression ret; + Expression right; + ret = InclusiveOrExpression(); + label_43: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SC_AND: + ; + break; + default: + jj_la1[85] = jj_gen; + break label_43; + } + jj_consume_token(SC_AND); + right = InclusiveOrExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.and); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression InclusiveOrExpression() throws ParseException { + Expression ret; + Expression right; + ret = ExclusiveOrExpression(); + label_44: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BIT_OR: + ; + break; + default: + jj_la1[86] = jj_gen; + break label_44; + } + jj_consume_token(BIT_OR); + right = ExclusiveOrExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.binOr); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression ExclusiveOrExpression() throws ParseException { + Expression ret; + Expression right; + ret = AndExpression(); + label_45: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case XOR: + ; + break; + default: + jj_la1[87] = jj_gen; + break label_45; + } + jj_consume_token(XOR); + right = AndExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.xor); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression AndExpression() throws ParseException { + Expression ret; + Expression right; + ret = EqualityExpression(); + label_46: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BIT_AND: + ; + break; + default: + jj_la1[88] = jj_gen; + break label_46; + } + jj_consume_token(BIT_AND); + right = EqualityExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.binAnd); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression EqualityExpression() throws ParseException { + Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = InstanceOfExpression(); + label_47: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EQ: + case NE: + ; + break; + default: + jj_la1[89] = jj_gen; + break label_47; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EQ: + jj_consume_token(EQ); + op = BinaryExpr.Operator.equals; + break; + case NE: + jj_consume_token(NE); + op = BinaryExpr.Operator.notEquals; + break; + default: + jj_la1[90] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = InstanceOfExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression InstanceOfExpression() throws ParseException { + Expression ret; + Type type; + ret = RelationalExpression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INSTANCEOF: + jj_consume_token(INSTANCEOF); + type = Type(); + ret = new InstanceOfExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, type); + break; + default: + jj_la1[91] = jj_gen; + ; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression RelationalExpression() throws ParseException { + Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = ShiftExpression(); + label_48: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + case LE: + case GE: + case GT: + ; + break; + default: + jj_la1[92] = jj_gen; + break label_48; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + jj_consume_token(LT); + op = BinaryExpr.Operator.less; + break; + case GT: + jj_consume_token(GT); + op = BinaryExpr.Operator.greater; + break; + case LE: + jj_consume_token(LE); + op = BinaryExpr.Operator.lessEquals; + break; + case GE: + jj_consume_token(GE); + op = BinaryExpr.Operator.greaterEquals; + break; + default: + jj_la1[93] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = ShiftExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression ShiftExpression() throws ParseException { + Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = AdditiveExpression(); + label_49: + while (true) { + if (jj_2_19(1)) { + ; + } else { + break label_49; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LSHIFT: + jj_consume_token(LSHIFT); + op = BinaryExpr.Operator.lShift; + break; + default: + jj_la1[94] = jj_gen; + if (jj_2_20(1)) { + RSIGNEDSHIFT(); + op = BinaryExpr.Operator.rSignedShift; + } else if (jj_2_21(1)) { + RUNSIGNEDSHIFT(); + op = BinaryExpr.Operator.rUnsignedShift; + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } + right = AdditiveExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression AdditiveExpression() throws ParseException { + Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = MultiplicativeExpression(); + label_50: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + ; + break; + default: + jj_la1[95] = jj_gen; + break label_50; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + jj_consume_token(PLUS); + op = BinaryExpr.Operator.plus; + break; + case MINUS: + jj_consume_token(MINUS); + op = BinaryExpr.Operator.minus; + break; + default: + jj_la1[96] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = MultiplicativeExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression MultiplicativeExpression() throws ParseException { + Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = UnaryExpression(); + label_51: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STAR: + case SLASH: + case REM: + ; + break; + default: + jj_la1[97] = jj_gen; + break label_51; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STAR: + jj_consume_token(STAR); + op = BinaryExpr.Operator.times; + break; + case SLASH: + jj_consume_token(SLASH); + op = BinaryExpr.Operator.divide; + break; + case REM: + jj_consume_token(REM); + op = BinaryExpr.Operator.remainder; + break; + default: + jj_la1[98] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = UnaryExpression(); + ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression UnaryExpression() throws ParseException { + Expression ret; + UnaryExpr.Operator op; + int line = 0; + int column = 0; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INCR: + ret = PreIncrementExpression(); + break; + case DECR: + ret = PreDecrementExpression(); + break; + case PLUS: + case MINUS: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + jj_consume_token(PLUS); + op = UnaryExpr.Operator.positive; line=token.beginLine; column=token.beginColumn; + break; + case MINUS: + jj_consume_token(MINUS); + op = UnaryExpr.Operator.negative; line=token.beginLine; column=token.beginColumn; + break; + default: + jj_la1[99] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = UnaryExpression(); + if(op == UnaryExpr.Operator.negative) { + if (ret instanceof IntegerLiteralExpr && ((IntegerLiteralExpr)ret).isMinValue()) { + ret = new IntegerLiteralMinValueExpr(line, column, token.endLine, token.endColumn); + } else if (ret instanceof LongLiteralExpr && ((LongLiteralExpr)ret).isMinValue()) { + ret = new LongLiteralMinValueExpr(line, column, token.endLine, token.endColumn); + } else { + ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, op); + } + } else { + ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, op); + } + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + ret = UnaryExpressionNotPlusMinus(); + break; + default: + jj_la1[100] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PreIncrementExpression() throws ParseException { + Expression ret; + int line; + int column; + jj_consume_token(INCR); + line=token.beginLine; column=token.beginColumn; + ret = UnaryExpression(); + ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, UnaryExpr.Operator.preIncrement); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PreDecrementExpression() throws ParseException { + Expression ret; + int line; + int column; + jj_consume_token(DECR); + line=token.beginLine; column=token.beginColumn; + ret = UnaryExpression(); + ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, UnaryExpr.Operator.preDecrement); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression UnaryExpressionNotPlusMinus() throws ParseException { + Expression ret; + UnaryExpr.Operator op; + int line = 0; + int column = 0; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BANG: + case TILDE: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case TILDE: + jj_consume_token(TILDE); + op = UnaryExpr.Operator.inverse; line=token.beginLine; column=token.beginColumn; + break; + case BANG: + jj_consume_token(BANG); + op = UnaryExpr.Operator.not; line=token.beginLine; column=token.beginColumn; + break; + default: + jj_la1[101] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = UnaryExpression(); + ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, op); + break; + default: + jj_la1[102] = jj_gen; + if (jj_2_22(2147483647)) { + ret = CastExpression(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + ret = PostfixExpression(); + break; + default: + jj_la1[103] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PostfixExpression() throws ParseException { + Expression ret; + UnaryExpr.Operator op; + ret = PrimaryExpression(); + if (jj_2_23(2)) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INCR: + jj_consume_token(INCR); + op = UnaryExpr.Operator.posIncrement; + break; + case DECR: + jj_consume_token(DECR); + op = UnaryExpr.Operator.posDecrement; + break; + default: + jj_la1[104] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = new UnaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, op); + } else { + ; + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression CastExpression() throws ParseException { + Expression ret; + Type type; + int line; + int column; + AnnotationExpr ann; + List annotations = null; + jj_consume_token(LPAREN); + line=token.beginLine; column=token.beginColumn; + label_52: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[105] = jj_gen; + break label_52; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + if (jj_2_24(2)) { + type = PrimitiveType(); + jj_consume_token(RPAREN); + ret = UnaryExpression(); + type.setAnnotations(annotations); ret = new CastExpr(line, column, token.endLine, token.endColumn,type, ret); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + type = ReferenceType(); + jj_consume_token(RPAREN); + ret = UnaryExpressionNotPlusMinus(); + type.setAnnotations(annotations); ret = new CastExpr(line, column, token.endLine, token.endColumn,type, ret); + break; + default: + jj_la1[106] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PrimaryExpression() throws ParseException { + Expression ret; + Expression inner; + ret = PrimaryPrefix(); + label_53: + while (true) { + if (jj_2_25(2)) { + ; + } else { + break label_53; + } + ret = PrimarySuffix(ret); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PrimaryExpressionWithoutSuperSuffix() throws ParseException { + Expression ret; + Expression inner; + ret = PrimaryPrefix(); + label_54: + while (true) { + if (jj_2_26(2147483647)) { + ; + } else { + break label_54; + } + ret = PrimarySuffixWithoutSuper(ret); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PrimaryPrefix() throws ParseException { + Expression ret = null; + NameExpr name; + List typeArgs = null; + List args = null; + boolean hasArgs = false; + boolean isLambda = false; + Type type; + int line; + int column; + Parameter p = null; + VariableDeclaratorId id = null; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case FALSE: + case NULL: + case TRUE: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + ret = Literal(); + break; + case THIS: + jj_consume_token(THIS); + ret = new ThisExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, null); + break; + case SUPER: + jj_consume_token(SUPER); + ret = new SuperExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, null); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DOT: + jj_consume_token(DOT); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + case 132: + typeArgs = TypeArguments(); + typeArgs.remove(0); + break; + default: + jj_la1[107] = jj_gen; + ; + } + name = SimpleName(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LPAREN: + args = Arguments(); + hasArgs=true; + break; + default: + jj_la1[108] = jj_gen; + ; + } + if (hasArgs) { + MethodCallExpr m = new MethodCallExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, null, args); + m.setNameExpr(name); + ret = m; + } else { + FieldAccessExpr f = new FieldAccessExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, null, null); + f.setFieldExpr(name); + ret = f; + } + break; + case DOUBLECOLON: + jj_consume_token(DOUBLECOLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typeArgs = TypeParameters(); + typeArgs.remove(0); + break; + default: + jj_la1[109] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case NEW: + jj_consume_token(NEW); + break; + default: + jj_la1[110] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = new MethodReferenceExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, token.image); + break; + case LPAREN: + args = Arguments(); + new MethodCallExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, null, args); + break; + default: + jj_la1[111] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + case LPAREN: + jj_consume_token(LPAREN); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SYNCHRONIZED: + case THIS: + case TRANSIENT: + case TRUE: + case VOID: + case VOLATILE: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case AT: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + if (jj_2_27(2147483647)) { + p = FormalParameter(); + isLambda = true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + args = FormalLambdaParameters(); + break; + default: + jj_la1[112] = jj_gen; + ; + } + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ret = Expression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + args = InferredLambdaParameters(); + isLambda = true; + break; + default: + jj_la1[113] = jj_gen; + ; + } + break; + default: + jj_la1[114] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + default: + jj_la1[115] = jj_gen; + ; + } + jj_consume_token(RPAREN); + if(!isLambda) { ret = new EnclosedExpr(line, column, token.endLine, token.endColumn,ret);} + else{ + if(ret != null){ + if(ret instanceof NameExpr) + { + id = new VariableDeclaratorId(ret.getBeginLine(), ret.getBeginColumn(), ret.getEndLine(), ret.getEndColumn(), ((NameExpr)ret).getName(), 0); + p = new Parameter(ret.getBeginLine(), ret.getBeginColumn(), ret.getEndLine(), ret.getEndColumn(), 0, null, new UnknownType(), false, id); + } + + } + args = add(0, args, p); + ret = new LambdaExpr(p.getBeginLine(), p.getBeginColumn(), token.endLine, token.endColumn, args, null, true); + } + break; + case NEW: + ret = AllocationExpression(null); + break; + default: + jj_la1[119] = jj_gen; + if (jj_2_28(2147483647)) { + type = ResultType(); + jj_consume_token(DOT); + jj_consume_token(CLASS); + ret = new ClassExpr(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn, type); + } else if (jj_2_29(2147483647)) { + type = ResultType(); + jj_consume_token(DOUBLECOLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typeArgs = TypeParameters(); + typeArgs.remove(0); + break; + default: + jj_la1[116] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case NEW: + jj_consume_token(NEW); + break; + default: + jj_la1[117] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = new TypeExpr(type.getBeginLine(), type.getBeginColumn(), type.getEndLine(), type.getEndColumn(), type); + ret = new MethodReferenceExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, token.image); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + name = SimpleName(); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LPAREN: + args = Arguments(); + hasArgs=true; + break; + default: + jj_la1[118] = jj_gen; + ; + } + if (hasArgs) { + MethodCallExpr m = new MethodCallExpr(line, column, token.endLine, token.endColumn, null, null, null, args); + m.setNameExpr(name); + ret = m; + } else { + ret = name; + } + break; + default: + jj_la1[120] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PrimarySuffix(Expression scope) throws ParseException { + Expression ret; + if (jj_2_30(2)) { + ret = PrimarySuffixWithoutSuper(scope); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DOT: + jj_consume_token(DOT); + jj_consume_token(SUPER); + ret = new SuperExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope); + break; + default: + jj_la1[121] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression PrimarySuffixWithoutSuper(Expression scope) throws ParseException { + Expression ret; + List typeArgs = null; + List args = null; + boolean hasArgs = false; + NameExpr name; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DOT: + jj_consume_token(DOT); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case THIS: + jj_consume_token(THIS); + ret = new ThisExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope); + break; + case NEW: + ret = AllocationExpression(scope); + break; + default: + jj_la1[124] = jj_gen; + if (jj_2_31(2147483647)) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + case 132: + typeArgs = TypeArguments(); + typeArgs.remove(0); + break; + default: + jj_la1[122] = jj_gen; + ; + } + name = SimpleName(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LPAREN: + args = Arguments(); + hasArgs=true; + break; + default: + jj_la1[123] = jj_gen; + ; + } + if (hasArgs) { + MethodCallExpr m = new MethodCallExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, typeArgs, null, args); + m.setNameExpr(name); + ret = m; + } else { + FieldAccessExpr f = new FieldAccessExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, typeArgs, null); + f.setFieldExpr(name); + ret = f; + } + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + case LBRACKET: + jj_consume_token(LBRACKET); + ret = Expression(); + jj_consume_token(RBRACKET); + ret = new ArrayAccessExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, ret); + break; + default: + jj_la1[125] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression Literal() throws ParseException { + Expression ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTEGER_LITERAL: + jj_consume_token(INTEGER_LITERAL); + ret = new IntegerLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); + break; + case LONG_LITERAL: + jj_consume_token(LONG_LITERAL); + ret = new LongLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); + break; + case FLOATING_POINT_LITERAL: + jj_consume_token(FLOATING_POINT_LITERAL); + ret = new DoubleLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); + break; + case CHARACTER_LITERAL: + jj_consume_token(CHARACTER_LITERAL); + ret = new CharLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image.substring(1, token.image.length()-1)); + break; + case STRING_LITERAL: + jj_consume_token(STRING_LITERAL); + ret = new StringLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image.substring(1, token.image.length()-1)); + break; + case FALSE: + case TRUE: + ret = BooleanLiteral(); + break; + case NULL: + ret = NullLiteral(); + break; + default: + jj_la1[126] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression BooleanLiteral() throws ParseException { + Expression ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case TRUE: + jj_consume_token(TRUE); + ret = new BooleanLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, true); + break; + case FALSE: + jj_consume_token(FALSE); + ret = new BooleanLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, false); + break; + default: + jj_la1[127] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression NullLiteral() throws ParseException { + jj_consume_token(NULL); + {if (true) return new NullLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn);} + throw new Error("Missing return statement in function"); + } + + final public List Arguments() throws ParseException { + List ret = null; + jj_consume_token(LPAREN); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ret = ArgumentList(); + break; + default: + jj_la1[128] = jj_gen; + ; + } + jj_consume_token(RPAREN); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List ArgumentList() throws ParseException { + List ret = new LinkedList(); + Expression expr; + expr = Expression(); + ret.add(expr); + label_55: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[129] = jj_gen; + break label_55; + } + jj_consume_token(COMMA); + expr = Expression(); + ret.add(expr); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression AllocationExpression(Expression scope) throws ParseException { + Expression ret; + ArrayCreationExpr arrayExpr; + Type type; + Object[] arr = null; + List typeArgs = null; + List anonymousBody = null; + List args; + int line; + int column; + List annotations = null; + AnnotationExpr ann; + jj_consume_token(NEW); + if(scope==null) {line=token.beginLine; column=token.beginColumn;} else {line=scope.getBeginLine(); column=scope.getBeginColumn();} + label_56: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[130] = jj_gen; + break label_56; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + type = PrimitiveType(); + type.setAnnotations(annotations); + arr = ArrayDimsAndInits(); + arrayExpr = new ArrayCreationExpr(line, column, token.endLine, token.endColumn, type, null, 0); + arrayExpr.setArraysAnnotations((List)arr[2]); + if (arr[0] instanceof Integer) { + arrayExpr.setArrayCount(((Integer)arr[0]).intValue()); + arrayExpr.setInitializer((ArrayInitializerExpr)arr[1]); + } else { + arrayExpr.setArrayCount(((Integer)arr[1]).intValue()); + arrayExpr.setDimensions((List)arr[0]); + } + ret = arrayExpr; + break; + case IDENTIFIER: + case LT: + case 132: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + case 132: + typeArgs = TypeArguments(); + label_57: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[131] = jj_gen; + break label_57; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + typeArgs.remove(0); + break; + default: + jj_la1[132] = jj_gen; + ; + } + type = ClassOrInterfaceType(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + case AT: + arr = ArrayDimsAndInits(); + type.setAnnotations(annotations); arrayExpr = new ArrayCreationExpr(line, column, token.endLine, token.endColumn, type, null, 0); + arrayExpr.setArraysAnnotations((List)arr[2]); + if (arr[0] instanceof Integer) { + arrayExpr.setArrayCount(((Integer)arr[0]).intValue()); + arrayExpr.setInitializer((ArrayInitializerExpr)arr[1]); + } else { + arrayExpr.setArrayCount(((Integer)arr[1]).intValue()); + arrayExpr.setDimensions((List)arr[0]); + } + ret = arrayExpr; + break; + case LPAREN: + args = Arguments(); + if (jj_2_32(2)) { + anonymousBody = ClassOrInterfaceBody(false); + } else { + ; + } + type.setAnnotations(annotations); ret = new ObjectCreationExpr(line, column, token.endLine, token.endColumn, scope, (ClassOrInterfaceType) type, typeArgs, args, anonymousBody); + break; + default: + jj_la1[133] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[134] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + +/* + * The third LOOKAHEAD specification below is to parse to PrimarySuffix + * if there is an expression between the "[...]". + */ + final public Object[] ArrayDimsAndInits() throws ParseException { + Object[] ret = new Object[3]; + Expression expr; + List inits = null; + int i = 0; + List accum = null; + List annotations = null; + AnnotationExpr ann; + label_58: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[135] = jj_gen; + break label_58; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + if (jj_2_35(2)) { + label_59: + while (true) { + jj_consume_token(LBRACKET); + expr = Expression(); + accum = add(accum, annotations); annotations=null; inits = add(inits, expr); + jj_consume_token(RBRACKET); + if (jj_2_33(2)) { + ; + } else { + break label_59; + } + } + label_60: + while (true) { + if (jj_2_34(2)) { + ; + } else { + break label_60; + } + label_61: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ; + break; + default: + jj_la1[136] = jj_gen; + break label_61; + } + ann = Annotation(); + annotations = add(annotations, ann); + } + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + i++; + } + accum = add(accum, annotations); annotations=null; ret[0] = inits; ret[1] = new Integer(i); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + label_62: + while (true) { + jj_consume_token(LBRACKET); + jj_consume_token(RBRACKET); + i++; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + ; + break; + default: + jj_la1[137] = jj_gen; + break label_62; + } + } + expr = ArrayInitializer(); + accum = add(accum, annotations);annotations=null; ret[0] = new Integer(i); ret[1] = expr; + break; + default: + jj_la1[138] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + ret[2]=accum; {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + +/* + * Statement syntax follows. + */ + final public Statement Statement() throws ParseException { + Statement ret; + if (jj_2_36(2)) { + ret = LabeledStatement(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSERT: + ret = AssertStatement(); + break; + case LBRACE: + ret = Block(); + break; + case SEMICOLON: + ret = EmptyStatement(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case INCR: + case DECR: + ret = StatementExpression(); + break; + case SWITCH: + ret = SwitchStatement(); + break; + case IF: + ret = IfStatement(); + break; + case WHILE: + ret = WhileStatement(); + break; + case DO: + ret = DoStatement(); + break; + case FOR: + ret = ForStatement(); + break; + case BREAK: + ret = BreakStatement(); + break; + case CONTINUE: + ret = ContinueStatement(); + break; + case RETURN: + ret = ReturnStatement(); + break; + case THROW: + ret = ThrowStatement(); + break; + case SYNCHRONIZED: + ret = SynchronizedStatement(); + break; + case TRY: + ret = TryStatement(); + break; + default: + jj_la1[139] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public AssertStmt AssertStatement() throws ParseException { + Expression check; + Expression msg = null; + int line; + int column; + jj_consume_token(ASSERT); + line=token.beginLine; column=token.beginColumn; + check = Expression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + msg = Expression(); + break; + default: + jj_la1[140] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + {if (true) return new AssertStmt(line, column, token.endLine, token.endColumn,check, msg);} + throw new Error("Missing return statement in function"); + } + + final public LabeledStmt LabeledStatement() throws ParseException { + String label; + Statement stmt; + int line; + int column; + jj_consume_token(IDENTIFIER); + line=token.beginLine; column=token.beginColumn; + label = token.image; + jj_consume_token(COLON); + stmt = Statement(); + {if (true) return new LabeledStmt(line, column, token.endLine, token.endColumn,label, stmt);} + throw new Error("Missing return statement in function"); + } + + final public BlockStmt Block() throws ParseException { + List stmts; + int beginLine; + int beginColumn; + jj_consume_token(LBRACE); + beginLine=token.beginLine; beginColumn=token.beginColumn; + stmts = Statements(); + jj_consume_token(RBRACE); + {if (true) return new BlockStmt(beginLine, beginColumn, token.endLine, token.endColumn, stmts);} + throw new Error("Missing return statement in function"); + } + +/* + * Classes inside block stametents can only be abstract or final. The semantic must check it. + */ + final public Statement BlockStatement() throws ParseException { + Statement ret; + Expression expr; + ClassOrInterfaceDeclaration typeDecl; + Modifier modifier; + if (jj_2_37(2147483647)) { + + modifier = Modifiers(); + typeDecl = ClassOrInterfaceDeclaration(modifier); + ret = new TypeDeclarationStmt(typeDecl.getBeginLine(), typeDecl.getBeginColumn(), token.endLine, token.endColumn, typeDecl); + } else if (jj_2_38(2147483647)) { + expr = VariableDeclarationExpression(); + jj_consume_token(SEMICOLON); + ret = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSERT: + case BOOLEAN: + case BREAK: + case BYTE: + case CHAR: + case CONTINUE: + case DO: + case DOUBLE: + case FALSE: + case FLOAT: + case FOR: + case IF: + case INT: + case LONG: + case NEW: + case NULL: + case RETURN: + case SHORT: + case SUPER: + case SWITCH: + case SYNCHRONIZED: + case THIS: + case THROW: + case TRUE: + case TRY: + case VOID: + case WHILE: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case SEMICOLON: + case INCR: + case DECR: + ret = Statement(); + break; + default: + jj_la1[141] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public VariableDeclarationExpr VariableDeclarationExpression() throws ParseException { + Modifier modifier; + Type type; + List vars = new LinkedList(); + VariableDeclarator var; + modifier = Modifiers(); + type = Type(); + var = VariableDeclarator(); + vars.add(var); + label_63: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[142] = jj_gen; + break label_63; + } + jj_consume_token(COMMA); + var = VariableDeclarator(); + vars.add(var); + } + int line = modifier.beginLine; + int column = modifier.beginColumn; + if(line==-1) {line=type.getBeginLine(); column=type.getBeginColumn(); } + {if (true) return new VariableDeclarationExpr(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, vars);} + throw new Error("Missing return statement in function"); + } + + final public EmptyStmt EmptyStatement() throws ParseException { + jj_consume_token(SEMICOLON); + {if (true) return new EmptyStmt(token.beginLine, token.beginColumn, token.endLine, token.endColumn);} + throw new Error("Missing return statement in function"); + } + + final public Statement LambdaBody() throws ParseException { + Expression expr; + Statement n = null; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + expr = Expression(); + n = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr); + break; + case LBRACE: + n = Block(); + break; + default: + jj_la1[143] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return n;} + throw new Error("Missing return statement in function"); + } + + final public ExpressionStmt StatementExpression() throws ParseException { + Expression expr; + AssignExpr.Operator op; + Expression value; + Type type; + List typeArgs = null; + Statement lambdaBody = null; + VariableDeclaratorId id = null; + List params = null; + Expression inner = null; + if (jj_2_39(2)) { + expr = PreIncrementExpression(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DECR: + expr = PreDecrementExpression(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + expr = PrimaryExpression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSIGN: + case INCR: + case DECR: + case PLUSASSIGN: + case MINUSASSIGN: + case STARASSIGN: + case SLASHASSIGN: + case ANDASSIGN: + case ORASSIGN: + case XORASSIGN: + case REMASSIGN: + case LSHIFTASSIGN: + case RSIGNEDSHIFTASSIGN: + case RUNSIGNEDSHIFTASSIGN: + case ARROW: + case DOUBLECOLON: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INCR: + jj_consume_token(INCR); + expr = new UnaryExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, UnaryExpr.Operator.posIncrement); + break; + case DECR: + jj_consume_token(DECR); + expr = new UnaryExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, UnaryExpr.Operator.posDecrement); + break; + case ASSIGN: + case PLUSASSIGN: + case MINUSASSIGN: + case STARASSIGN: + case SLASHASSIGN: + case ANDASSIGN: + case ORASSIGN: + case XORASSIGN: + case REMASSIGN: + case LSHIFTASSIGN: + case RSIGNEDSHIFTASSIGN: + case RUNSIGNEDSHIFTASSIGN: + op = AssignmentOperator(); + value = Expression(); + expr = new AssignExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, value, op); + break; + case DOUBLECOLON: + jj_consume_token(DOUBLECOLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LT: + typeArgs = TypeParameters(); + typeArgs.remove(0); + break; + default: + jj_la1[144] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + break; + case NEW: + jj_consume_token(NEW); + break; + default: + jj_la1[145] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + expr = new MethodReferenceExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, typeArgs, token.image); + break; + case ARROW: + jj_consume_token(ARROW); + lambdaBody = LambdaBody(); + if (expr instanceof CastExpr) + { + inner = generateLambda(((CastExpr)expr).getExpr(), lambdaBody); + ((CastExpr)expr).setExpr(inner); + } + else + { + expr = generateLambda(expr, lambdaBody); + } + break; + default: + jj_la1[146] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[147] = jj_gen; + ; + } + break; + default: + jj_la1[148] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(SEMICOLON); + {if (true) return new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr);} + throw new Error("Missing return statement in function"); + } + + final public SwitchStmt SwitchStatement() throws ParseException { + Expression selector; + SwitchEntryStmt entry; + List entries = null; + int line; + int column; + jj_consume_token(SWITCH); + line=token.beginLine; column=token.beginColumn; + jj_consume_token(LPAREN); + selector = Expression(); + jj_consume_token(RPAREN); + jj_consume_token(LBRACE); + label_64: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CASE: + case _DEFAULT: + ; + break; + default: + jj_la1[149] = jj_gen; + break label_64; + } + entry = SwitchEntry(); + entries = add(entries, entry); + } + jj_consume_token(RBRACE); + {if (true) return new SwitchStmt(line, column, token.endLine, token.endColumn,selector, entries);} + throw new Error("Missing return statement in function"); + } + + final public SwitchEntryStmt SwitchEntry() throws ParseException { + Expression label = null; + List stmts; + int line; + int column; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CASE: + jj_consume_token(CASE); + line=token.beginLine; column=token.beginColumn; + label = Expression(); + break; + case _DEFAULT: + jj_consume_token(_DEFAULT); + line=token.beginLine; column=token.beginColumn; + break; + default: + jj_la1[150] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(COLON); + stmts = Statements(); + {if (true) return new SwitchEntryStmt(line, column, token.endLine, token.endColumn,label, stmts);} + throw new Error("Missing return statement in function"); + } + + final public IfStmt IfStatement() throws ParseException { + Expression condition; + Statement thenStmt; + Statement elseStmt = null; + int line; + int column; + Comment thenCmmt = null; + Comment elseCmmt = null; + jj_consume_token(IF); + line=token.beginLine; column=token.beginColumn; + jj_consume_token(LPAREN); + condition = Expression(); + jj_consume_token(RPAREN); + + thenStmt = Statement(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ELSE: + jj_consume_token(ELSE); + + elseStmt = Statement(); + break; + default: + jj_la1[151] = jj_gen; + ; + } + IfStmt tmp = new IfStmt(line, column, token.endLine, token.endColumn,condition, thenStmt, elseStmt); + + thenStmt.setComment(thenCmmt); + if (elseStmt != null) + elseStmt.setComment(elseCmmt); + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public WhileStmt WhileStatement() throws ParseException { + Expression condition; + Statement body; + int line; + int column; + jj_consume_token(WHILE); + line=token.beginLine; column=token.beginColumn; + jj_consume_token(LPAREN); + condition = Expression(); + jj_consume_token(RPAREN); + body = Statement(); + {if (true) return new WhileStmt(line, column, token.endLine, token.endColumn,condition, body);} + throw new Error("Missing return statement in function"); + } + + final public DoStmt DoStatement() throws ParseException { + Expression condition; + Statement body; + int line; + int column; + jj_consume_token(DO); + line=token.beginLine; column=token.beginColumn; + body = Statement(); + jj_consume_token(WHILE); + jj_consume_token(LPAREN); + condition = Expression(); + jj_consume_token(RPAREN); + jj_consume_token(SEMICOLON); + {if (true) return new DoStmt(line, column, token.endLine, token.endColumn,body, condition);} + throw new Error("Missing return statement in function"); + } + + final public Statement ForStatement() throws ParseException { + String id = null; + VariableDeclarationExpr varExpr = null; + Expression expr = null; + List init = null; + List update = null; + Statement body; + int line; + int column; + jj_consume_token(FOR); + line=token.beginLine; column=token.beginColumn; + jj_consume_token(LPAREN); + if (jj_2_40(2147483647)) { + varExpr = VariableDeclarationExpression(); + jj_consume_token(COLON); + expr = Expression(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SYNCHRONIZED: + case THIS: + case TRANSIENT: + case TRUE: + case VOID: + case VOLATILE: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case SEMICOLON: + case AT: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FINAL: + case FLOAT: + case INT: + case LONG: + case NATIVE: + case NEW: + case NULL: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SUPER: + case SYNCHRONIZED: + case THIS: + case TRANSIENT: + case TRUE: + case VOID: + case VOLATILE: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case AT: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + init = ForInit(); + break; + default: + jj_la1[152] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + expr = Expression(); + break; + default: + jj_la1[153] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + update = ForUpdate(); + break; + default: + jj_la1[154] = jj_gen; + ; + } + break; + default: + jj_la1[155] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RPAREN); + body = Statement(); + if (varExpr != null) { + {if (true) return new ForeachStmt(line, column, token.endLine, token.endColumn,varExpr, expr, body);} + } + {if (true) return new ForStmt(line, column, token.endLine, token.endColumn,init, expr, update, body);} + throw new Error("Missing return statement in function"); + } + + final public List ForInit() throws ParseException { + List ret; + Expression expr; + if (jj_2_41(2147483647)) { + expr = VariableDeclarationExpression(); + ret = new LinkedList(); ret.add(expr); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ret = ExpressionList(); + break; + default: + jj_la1[156] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List ExpressionList() throws ParseException { + List ret = new LinkedList(); + Expression expr; + expr = Expression(); + ret.add(expr); + label_65: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[157] = jj_gen; + break label_65; + } + jj_consume_token(COMMA); + expr = Expression(); + ret.add(expr); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public List ForUpdate() throws ParseException { + List ret; + ret = ExpressionList(); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public BreakStmt BreakStatement() throws ParseException { + String id = null; + int line; + int column; + jj_consume_token(BREAK); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + id = token.image; + break; + default: + jj_la1[158] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + {if (true) return new BreakStmt(line, column, token.endLine, token.endColumn,id);} + throw new Error("Missing return statement in function"); + } + + final public ContinueStmt ContinueStatement() throws ParseException { + String id = null; + int line; + int column; + jj_consume_token(CONTINUE); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + jj_consume_token(IDENTIFIER); + id = token.image; + break; + default: + jj_la1[159] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + {if (true) return new ContinueStmt(line, column, token.endLine, token.endColumn,id);} + throw new Error("Missing return statement in function"); + } + + final public ReturnStmt ReturnStatement() throws ParseException { + Expression expr = null; + int line; + int column; + jj_consume_token(RETURN); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + expr = Expression(); + break; + default: + jj_la1[160] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + {if (true) return new ReturnStmt(line, column, token.endLine, token.endColumn,expr);} + throw new Error("Missing return statement in function"); + } + + final public ThrowStmt ThrowStatement() throws ParseException { + Expression expr; + int line; + int column; + jj_consume_token(THROW); + line=token.beginLine; column=token.beginColumn; + expr = Expression(); + jj_consume_token(SEMICOLON); + {if (true) return new ThrowStmt(line, column, token.endLine, token.endColumn,expr);} + throw new Error("Missing return statement in function"); + } + + final public SynchronizedStmt SynchronizedStatement() throws ParseException { + Expression expr; + BlockStmt block; + int line; + int column; + jj_consume_token(SYNCHRONIZED); + line=token.beginLine; column=token.beginColumn; + jj_consume_token(LPAREN); + expr = Expression(); + jj_consume_token(RPAREN); + block = Block(); + {if (true) return new SynchronizedStmt(line, column, token.endLine, token.endColumn,expr, block);} + throw new Error("Missing return statement in function"); + } + + final public TryStmt TryStatement() throws ParseException { + List resources = new LinkedList(); + BlockStmt tryBlock; + BlockStmt finallyBlock = null; + List catchs = null; + Parameter except; + BlockStmt catchBlock; + Modifier exceptModifier; + Type exceptType; + List exceptTypes = new LinkedList(); + VariableDeclaratorId exceptId; + int line; + int column; + int cLine; + int cColumn; + jj_consume_token(TRY); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LPAREN: + resources = ResourceSpecification(); + break; + default: + jj_la1[161] = jj_gen; + ; + } + tryBlock = Block(); + label_66: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CATCH: + ; + break; + default: + jj_la1[162] = jj_gen; + break label_66; + } + jj_consume_token(CATCH); + cLine=token.beginLine; cColumn=token.beginColumn; + jj_consume_token(LPAREN); + exceptModifier = Modifiers(); + exceptType = Type(); + exceptTypes.add(exceptType); + label_67: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BIT_OR: + ; + break; + default: + jj_la1[163] = jj_gen; + break label_67; + } + jj_consume_token(BIT_OR); + exceptType = Type(); + exceptTypes.add(exceptType); + } + exceptId = VariableDeclaratorId(); + jj_consume_token(RPAREN); + catchBlock = Block(); + catchs = add(catchs, new CatchClause(cLine, cColumn, token.endLine, token.endColumn, exceptModifier.modifiers, exceptModifier.annotations, exceptTypes, exceptId, catchBlock)); exceptTypes = new LinkedList(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case FINALLY: + jj_consume_token(FINALLY); + finallyBlock = Block(); + break; + default: + jj_la1[164] = jj_gen; + ; + } + {if (true) return new TryStmt(line, column, token.endLine, token.endColumn, resources, tryBlock, catchs, finallyBlock);} + throw new Error("Missing return statement in function"); + } + + final public List ResourceSpecification() throws ParseException { +List vars; + jj_consume_token(LPAREN); + vars = Resources(); + if (jj_2_42(2)) { + jj_consume_token(SEMICOLON); + } else { + ; + } + jj_consume_token(RPAREN); + {if (true) return vars;} + throw new Error("Missing return statement in function"); + } + + final public List Resources() throws ParseException { + List vars = new LinkedList(); + VariableDeclarationExpr var; + /*this is a bit more lenient than we need to be, eg allowing access modifiers like private*/ + var = VariableDeclarationExpression(); + vars.add(var); + label_68: + while (true) { + if (jj_2_43(2)) { + ; + } else { + break label_68; + } + jj_consume_token(SEMICOLON); + var = VariableDeclarationExpression(); + vars.add(var); + } + {if (true) return vars;} + throw new Error("Missing return statement in function"); + } + +/* We use productions to match >>>, >> and > so that we can keep the + * type declaration syntax with generics clean + */ + final public void RUNSIGNEDSHIFT() throws ParseException { + if (getToken(1).kind == GT && + ((GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT) { + + } else { + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(GT); + jj_consume_token(GT); + jj_consume_token(GT); + } + + final public void RSIGNEDSHIFT() throws ParseException { + if (getToken(1).kind == GT && + ((GTToken)getToken(1)).realKind == RSIGNEDSHIFT) { + + } else { + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(GT); + jj_consume_token(GT); + } + +/* Annotation syntax follows. */ + final public AnnotationExpr Annotation() throws ParseException { + AnnotationExpr ret; + if (jj_2_44(2147483647)) { + ret = NormalAnnotation(); + } else if (jj_2_45(2147483647)) { + ret = SingleMemberAnnotation(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ret = MarkerAnnotation(); + break; + default: + jj_la1[165] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public NormalAnnotationExpr NormalAnnotation() throws ParseException { + NameExpr name; + List pairs = null; + int line; + int column; + jj_consume_token(AT); + line=token.beginLine; column=token.beginColumn; + name = Name(); + jj_consume_token(LPAREN); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENTIFIER: + pairs = MemberValuePairs(); + break; + default: + jj_la1[166] = jj_gen; + ; + } + jj_consume_token(RPAREN); + {if (true) return new NormalAnnotationExpr(line, column, token.endLine, token.endColumn,name, pairs);} + throw new Error("Missing return statement in function"); + } + + final public MarkerAnnotationExpr MarkerAnnotation() throws ParseException { + NameExpr name; + int line; + int column; + jj_consume_token(AT); + line=token.beginLine; column=token.beginColumn; + name = Name(); + {if (true) return new MarkerAnnotationExpr(line, column, token.endLine, token.endColumn,name);} + throw new Error("Missing return statement in function"); + } + + final public SingleMemberAnnotationExpr SingleMemberAnnotation() throws ParseException { + NameExpr name; + Expression memberVal; + int line; + int column; + jj_consume_token(AT); + line=token.beginLine; column=token.beginColumn; + name = Name(); + jj_consume_token(LPAREN); + memberVal = MemberValue(); + jj_consume_token(RPAREN); + {if (true) return new SingleMemberAnnotationExpr(line, column, token.endLine, token.endColumn,name, memberVal);} + throw new Error("Missing return statement in function"); + } + + final public List MemberValuePairs() throws ParseException { + List ret = new LinkedList(); + MemberValuePair pair; + pair = MemberValuePair(); + ret.add(pair); + label_69: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[167] = jj_gen; + break label_69; + } + jj_consume_token(COMMA); + pair = MemberValuePair(); + ret.add(pair); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public MemberValuePair MemberValuePair() throws ParseException { + String name; + Expression value; + int line; + int column; + jj_consume_token(IDENTIFIER); + name = token.image; line=token.beginLine; column=token.beginColumn; + jj_consume_token(ASSIGN); + value = MemberValue(); + {if (true) return new MemberValuePair(line, column, token.endLine, token.endColumn,name, value);} + throw new Error("Missing return statement in function"); + } + + final public Expression MemberValue() throws ParseException { + Expression ret; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AT: + ret = Annotation(); + break; + case LBRACE: + ret = MemberValueArrayInitializer(); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + ret = ConditionalExpression(); + break; + default: + jj_la1[168] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public Expression MemberValueArrayInitializer() throws ParseException { + List ret = new LinkedList(); + Expression member; + int line; + int column; + jj_consume_token(LBRACE); + line=token.beginLine; column=token.beginColumn; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FALSE: + case FLOAT: + case INT: + case LONG: + case NEW: + case NULL: + case SHORT: + case SUPER: + case THIS: + case TRUE: + case VOID: + case LONG_LITERAL: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case CHARACTER_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: + case LBRACE: + case AT: + case BANG: + case TILDE: + case INCR: + case DECR: + case PLUS: + case MINUS: + member = MemberValue(); + ret.add(member); + label_70: + while (true) { + if (jj_2_46(2)) { + ; + } else { + break label_70; + } + jj_consume_token(COMMA); + member = MemberValue(); + ret.add(member); + } + break; + default: + jj_la1[169] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + break; + default: + jj_la1[170] = jj_gen; + ; + } + jj_consume_token(RBRACE); + {if (true) return new ArrayInitializerExpr(line, column, token.endLine, token.endColumn,ret);} + throw new Error("Missing return statement in function"); + } + +/* Annotation Types. */ + final public AnnotationDeclaration AnnotationTypeDeclaration(Modifier modifier) throws ParseException { + NameExpr name; + List members; + int line = modifier.beginLine; + int column = modifier.beginColumn; + jj_consume_token(AT); + if (line == -1) {line=token.beginLine; column=token.beginColumn;} + jj_consume_token(INTERFACE); + name = Name(); + members = AnnotationTypeBody(); + AnnotationDeclaration tmp = new AnnotationDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, null, members); + tmp.setNameExpr(name); + {if (true) return tmp;} + throw new Error("Missing return statement in function"); + } + + final public List AnnotationTypeBody() throws ParseException { + List ret = null; + BodyDeclaration member; + jj_consume_token(LBRACE); + label_71: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case SEMICOLON: + case AT: + ; + break; + default: + jj_la1[171] = jj_gen; + break label_71; + } + member = AnnotationBodyDeclaration(); + ret = add(ret, member); + } + jj_consume_token(RBRACE); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public BodyDeclaration AnnotationBodyDeclaration() throws ParseException { + Modifier modifier; + BodyDeclaration ret; + + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + jj_consume_token(SEMICOLON); + ret = new EmptyTypeDeclaration(token.beginLine, token.beginColumn, token.endLine, token.endColumn); + break; + case ABSTRACT: + case BOOLEAN: + case BYTE: + case CHAR: + case CLASS: + case DOUBLE: + case ENUM: + case FINAL: + case FLOAT: + case INT: + case INTERFACE: + case LONG: + case NATIVE: + case PRIVATE: + case PROTECTED: + case PUBLIC: + case SHORT: + case STATIC: + case STRICTFP: + case SYNCHRONIZED: + case TRANSIENT: + case VOLATILE: + case IDENTIFIER: + case AT: + modifier = Modifiers(); + if (jj_2_47(2147483647)) { + ret = AnnotationTypeMemberDeclaration(modifier); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CLASS: + case INTERFACE: + ret = ClassOrInterfaceDeclaration(modifier); + break; + case ENUM: + ret = EnumDeclaration(modifier); + break; + case AT: + ret = AnnotationTypeDeclaration(modifier); + break; + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + ret = FieldDeclaration(modifier); + break; + default: + jj_la1[172] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + default: + jj_la1[173] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public AnnotationMemberDeclaration AnnotationTypeMemberDeclaration(Modifier modifier) throws ParseException { + Type type; + String name; + Expression defaultVal = null; + type = Type(); + jj_consume_token(IDENTIFIER); + name = token.image; + jj_consume_token(LPAREN); + jj_consume_token(RPAREN); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case _DEFAULT: + defaultVal = DefaultValue(); + break; + default: + jj_la1[174] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + int line = modifier.beginLine; + int column = modifier.beginColumn; + { if (line == -1) {line=type.getBeginLine(); column=type.getBeginColumn();} } + {if (true) return new AnnotationMemberDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, name, defaultVal);} + throw new Error("Missing return statement in function"); + } + + final public Expression DefaultValue() throws ParseException { + Expression ret; + jj_consume_token(_DEFAULT); + ret = MemberValue(); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + private boolean jj_2_1(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_1(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(0, xla); } + } + + private boolean jj_2_2(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_2(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(1, xla); } + } + + private boolean jj_2_3(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_3(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(2, xla); } + } + + private boolean jj_2_4(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_4(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(3, xla); } + } + + private boolean jj_2_5(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_5(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(4, xla); } + } + + private boolean jj_2_6(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_6(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(5, xla); } + } + + private boolean jj_2_7(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_7(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(6, xla); } + } + + private boolean jj_2_8(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_8(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(7, xla); } + } + + private boolean jj_2_9(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_9(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(8, xla); } + } + + private boolean jj_2_10(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_10(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(9, xla); } + } + + private boolean jj_2_11(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_11(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(10, xla); } + } + + private boolean jj_2_12(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_12(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(11, xla); } + } + + private boolean jj_2_13(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_13(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(12, xla); } + } + + private boolean jj_2_14(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_14(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(13, xla); } + } + + private boolean jj_2_15(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_15(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(14, xla); } + } + + private boolean jj_2_16(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_16(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(15, xla); } + } + + private boolean jj_2_17(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_17(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(16, xla); } + } + + private boolean jj_2_18(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_18(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(17, xla); } + } + + private boolean jj_2_19(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_19(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(18, xla); } + } + + private boolean jj_2_20(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_20(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(19, xla); } + } + + private boolean jj_2_21(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_21(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(20, xla); } + } + + private boolean jj_2_22(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_22(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(21, xla); } + } + + private boolean jj_2_23(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_23(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(22, xla); } + } + + private boolean jj_2_24(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_24(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(23, xla); } + } + + private boolean jj_2_25(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_25(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(24, xla); } + } + + private boolean jj_2_26(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_26(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(25, xla); } + } + + private boolean jj_2_27(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_27(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(26, xla); } + } + + private boolean jj_2_28(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_28(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(27, xla); } + } + + private boolean jj_2_29(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_29(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(28, xla); } + } + + private boolean jj_2_30(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_30(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(29, xla); } + } + + private boolean jj_2_31(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_31(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(30, xla); } + } + + private boolean jj_2_32(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_32(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(31, xla); } + } + + private boolean jj_2_33(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_33(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(32, xla); } + } + + private boolean jj_2_34(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_34(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(33, xla); } + } + + private boolean jj_2_35(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_35(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(34, xla); } + } + + private boolean jj_2_36(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_36(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(35, xla); } + } + + private boolean jj_2_37(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_37(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(36, xla); } + } + + private boolean jj_2_38(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_38(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(37, xla); } + } + + private boolean jj_2_39(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_39(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(38, xla); } + } + + private boolean jj_2_40(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_40(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(39, xla); } + } + + private boolean jj_2_41(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_41(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(40, xla); } + } + + private boolean jj_2_42(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_42(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(41, xla); } + } + + private boolean jj_2_43(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_43(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(42, xla); } + } + + private boolean jj_2_44(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_44(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(43, xla); } + } + + private boolean jj_2_45(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_45(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(44, xla); } + } + + private boolean jj_2_46(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_46(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(45, xla); } + } + + private boolean jj_2_47(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_47(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(46, xla); } + } + + private boolean jj_3R_172() { + if (jj_3R_168()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_207()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_294() { + if (jj_3R_133()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_25()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_422() { + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_155() { + if (jj_3R_94()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_201()) return true; + return false; + } + + private boolean jj_3R_424() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_437()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_438()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3_24() { + if (jj_3R_107()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3R_88() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_421() { + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_423() { + if (jj_3R_436()) return true; + return false; + } + + private boolean jj_3R_388() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_172()) return true; + return false; + } + + private boolean jj_3R_361() { + if (jj_scan_token(TRY)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_423()) jj_scanpos = xsp; + if (jj_3R_128()) return true; + xsp = jj_scanpos; + if (jj_3R_424()) { + jj_scanpos = xsp; + if (jj_3R_425()) return true; + } + return false; + } + + private boolean jj_3R_154() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_302() { + if (jj_3R_87()) return true; + if (jj_3R_172()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_388()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_104() { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_154()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3_24()) { + jj_scanpos = xsp; + if (jj_3R_155()) return true; + } + return false; + } + + private boolean jj_3R_241() { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_420() { + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_106() { + if (jj_scan_token(DECR)) return true; + return false; + } + + private boolean jj_3_23() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_105()) { + jj_scanpos = xsp; + if (jj_3R_106()) return true; + } + return false; + } + + private boolean jj_3R_105() { + if (jj_scan_token(INCR)) return true; + return false; + } + + private boolean jj_3_5() { + if (jj_3R_87()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_88()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_scan_token(88)) { + jj_scanpos = xsp; + if (jj_scan_token(91)) { + jj_scanpos = xsp; + if (jj_scan_token(87)) return true; + } + } + return false; + } + + private boolean jj_3R_86() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3_22() { + if (jj_3R_104()) return true; + return false; + } + + private boolean jj_3_4() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_86()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_216() { + if (jj_3R_245()) return true; + return false; + } + + private boolean jj_3R_267() { + if (jj_3R_294()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_23()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_277() { + if (jj_3R_303()) return true; + return false; + } + + private boolean jj_3R_360() { + if (jj_scan_token(SYNCHRONIZED)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_271() { + if (jj_scan_token(_DEFAULT)) return true; + if (jj_3R_116()) return true; + return false; + } + + private boolean jj_3R_276() { + if (jj_3R_302()) return true; + return false; + } + + private boolean jj_3R_235() { + if (jj_3R_104()) return true; + return false; + } + + private boolean jj_3R_236() { + if (jj_3R_267()) return true; + return false; + } + + private boolean jj_3R_266() { + if (jj_scan_token(BANG)) return true; + return false; + } + + private boolean jj_3R_275() { + if (jj_3R_301()) return true; + return false; + } + + private boolean jj_3R_265() { + if (jj_scan_token(TILDE)) return true; + return false; + } + + private boolean jj_3R_274() { + if (jj_3R_300()) return true; + return false; + } + + private boolean jj_3R_234() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_265()) { + jj_scanpos = xsp; + if (jj_3R_266()) return true; + } + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3R_273() { + if (jj_3R_299()) return true; + return false; + } + + private boolean jj_3R_272() { + if (jj_3R_298()) return true; + return false; + } + + private boolean jj_3R_359() { + if (jj_scan_token(THROW)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_201() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_234()) { + jj_scanpos = xsp; + if (jj_3R_235()) { + jj_scanpos = xsp; + if (jj_3R_236()) return true; + } + } + return false; + } + + private boolean jj_3R_358() { + if (jj_scan_token(RETURN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_422()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_461() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_240() { + if (jj_3R_116()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_271()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_272()) { + jj_scanpos = xsp; + if (jj_3R_273()) { + jj_scanpos = xsp; + if (jj_3R_274()) { + jj_scanpos = xsp; + if (jj_3R_275()) { + jj_scanpos = xsp; + if (jj_3R_276()) { + jj_scanpos = xsp; + if (jj_3R_277()) return true; + } + } + } + } + } + return false; + } + + private boolean jj_3R_242() { + if (jj_scan_token(DECR)) return true; + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3R_357() { + if (jj_scan_token(CONTINUE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_421()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3_6() { + if (jj_3R_89()) return true; + return false; + } + + private boolean jj_3R_417() { + if (jj_scan_token(ELSE)) return true; + if (jj_3R_306()) return true; + return false; + } + + private boolean jj_3R_118() { + if (jj_scan_token(INCR)) return true; + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3R_435() { + if (jj_3R_452()) return true; + return false; + } + + private boolean jj_3R_211() { + if (jj_3R_201()) return true; + return false; + } + + private boolean jj_3R_206() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_6()) { + jj_scanpos = xsp; + if (jj_3R_240()) { + jj_scanpos = xsp; + if (jj_3R_241()) return true; + } + } + return false; + } + + private boolean jj_3R_356() { + if (jj_scan_token(BREAK)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_420()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_171() { + if (jj_3R_206()) return true; + return false; + } + + private boolean jj_3R_452() { + if (jj_3R_459()) return true; + return false; + } + + private boolean jj_3R_279() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_244() { + if (jj_scan_token(MINUS)) return true; + return false; + } + + private boolean jj_3R_113() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_171()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_305() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_243() { + if (jj_scan_token(PLUS)) return true; + return false; + } + + private boolean jj_3R_210() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_243()) { + jj_scanpos = xsp; + if (jj_3R_244()) return true; + } + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3R_209() { + if (jj_3R_242()) return true; + return false; + } + + private boolean jj_3_41() { + if (jj_3R_116()) return true; + if (jj_3R_87()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_208() { + if (jj_3R_118()) return true; + return false; + } + + private boolean jj_3R_280() { + if (jj_scan_token(BIT_AND)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_305()) { jj_scanpos = xsp; break; } + } + if (jj_3R_198()) return true; + return false; + } + + private boolean jj_3R_459() { + if (jj_3R_100()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_461()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_245() { + if (jj_scan_token(EXTENDS)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_279()) { jj_scanpos = xsp; break; } + } + if (jj_3R_198()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_280()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_458() { + if (jj_3R_459()) return true; + return false; + } + + private boolean jj_3R_434() { + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_457() { + if (jj_3R_117()) return true; + return false; + } + + private boolean jj_3R_174() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_208()) { + jj_scanpos = xsp; + if (jj_3R_209()) { + jj_scanpos = xsp; + if (jj_3R_210()) { + jj_scanpos = xsp; + if (jj_3R_211()) return true; + } + } + } + return false; + } + + private boolean jj_3R_430() { + if (jj_scan_token(REM)) return true; + return false; + } + + private boolean jj_3_3() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_85()) return true; + return false; + } + + private boolean jj_3R_429() { + if (jj_scan_token(SLASH)) return true; + return false; + } + + private boolean jj_3R_182() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_216()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_428() { + if (jj_scan_token(STAR)) return true; + return false; + } + + private boolean jj_3R_451() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_457()) { + jj_scanpos = xsp; + if (jj_3R_458()) return true; + } + return false; + } + + private boolean jj_3R_412() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_428()) { + jj_scanpos = xsp; + if (jj_3R_429()) { + jj_scanpos = xsp; + if (jj_3R_430()) return true; + } + } + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3R_217() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_408() { + if (jj_3R_113()) return true; + return false; + } + + private boolean jj_3_40() { + if (jj_3R_117()) return true; + if (jj_scan_token(COLON)) return true; + return false; + } + + private boolean jj_3R_376() { + if (jj_3R_174()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_412()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_183() { + if (jj_scan_token(COMMA)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_217()) { jj_scanpos = xsp; break; } + } + if (jj_3R_182()) return true; + return false; + } + + private boolean jj_3R_181() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_433() { + if (jj_3R_451()) return true; + return false; + } + + private boolean jj_3R_414() { + if (jj_scan_token(MINUS)) return true; + return false; + } + + private boolean jj_3R_413() { + if (jj_scan_token(PLUS)) return true; + return false; + } + + private boolean jj_3R_125() { + if (jj_scan_token(LT)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_181()) { jj_scanpos = xsp; break; } + } + if (jj_3R_182()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_183()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_419() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_433()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + xsp = jj_scanpos; + if (jj_3R_434()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + xsp = jj_scanpos; + if (jj_3R_435()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_402() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_413()) { + jj_scanpos = xsp; + if (jj_3R_414()) return true; + } + if (jj_3R_376()) return true; + return false; + } + + private boolean jj_3R_418() { + if (jj_3R_117()) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_372() { + if (jj_3R_376()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_402()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_355() { + if (jj_scan_token(FOR)) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_418()) { + jj_scanpos = xsp; + if (jj_3R_419()) return true; + } + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_306()) return true; + return false; + } + + private boolean jj_3R_407() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3_21() { + if (jj_3R_103()) return true; + return false; + } + + private boolean jj_3_20() { + if (jj_3R_102()) return true; + return false; + } + + private boolean jj_3R_124() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_101() { + if (jj_scan_token(LSHIFT)) return true; + return false; + } + + private boolean jj_3_19() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_101()) { + jj_scanpos = xsp; + if (jj_3_20()) { + jj_scanpos = xsp; + if (jj_3_21()) return true; + } + } + if (jj_3R_372()) return true; + return false; + } + + private boolean jj_3R_85() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_124()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(IDENTIFIER)) return true; + xsp = jj_scanpos; + if (jj_3R_407()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_408()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_398() { + if (jj_3R_206()) return true; + return false; + } + + private boolean jj_3R_373() { + if (jj_scan_token(INSTANCEOF)) return true; + if (jj_3R_87()) return true; + return false; + } + + private boolean jj_3R_354() { + if (jj_scan_token(DO)) return true; + if (jj_3R_306()) return true; + if (jj_scan_token(WHILE)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_370() { + if (jj_3R_372()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_19()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_383() { + if (jj_scan_token(SEMICOLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_398()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_395() { + if (jj_scan_token(GE)) return true; + return false; + } + + private boolean jj_3R_394() { + if (jj_scan_token(LE)) return true; + return false; + } + + private boolean jj_3R_393() { + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_392() { + if (jj_scan_token(LT)) return true; + return false; + } + + private boolean jj_3R_377() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_392()) { + jj_scanpos = xsp; + if (jj_3R_393()) { + jj_scanpos = xsp; + if (jj_3R_394()) { + jj_scanpos = xsp; + if (jj_3R_395()) return true; + } + } + } + if (jj_3R_370()) return true; + return false; + } + + private boolean jj_3R_353() { + if (jj_scan_token(WHILE)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_306()) return true; + return false; + } + + private boolean jj_3R_382() { + if (jj_3R_85()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_3()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_368() { + if (jj_3R_370()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_377()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_381() { + if (jj_3R_397()) return true; + return false; + } + + private boolean jj_3R_369() { + if (jj_scan_token(BIT_AND)) return true; + if (jj_3R_345()) return true; + return false; + } + + private boolean jj_3R_299() { + if (jj_scan_token(ENUM)) return true; + if (jj_3R_119()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_381()) jj_scanpos = xsp; + if (jj_scan_token(LBRACE)) return true; + xsp = jj_scanpos; + if (jj_3R_382()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(88)) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_383()) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_364() { + if (jj_3R_368()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_373()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_352() { + if (jj_scan_token(IF)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_306()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_417()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_405() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_375() { + if (jj_scan_token(NE)) return true; + return false; + } + + private boolean jj_3R_374() { + if (jj_scan_token(EQ)) return true; + return false; + } + + private boolean jj_3R_371() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_374()) { + jj_scanpos = xsp; + if (jj_3R_375()) return true; + } + if (jj_3R_364()) return true; + return false; + } + + private boolean jj_3R_365() { + if (jj_scan_token(XOR)) return true; + if (jj_3R_315()) return true; + return false; + } + + private boolean jj_3R_346() { + if (jj_scan_token(BIT_OR)) return true; + if (jj_3R_293()) return true; + return false; + } + + private boolean jj_3R_406() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_198()) return true; + return false; + } + + private boolean jj_3R_345() { + if (jj_3R_364()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_371()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_450() { + if (jj_scan_token(_DEFAULT)) return true; + return false; + } + + private boolean jj_3R_449() { + if (jj_scan_token(CASE)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_397() { + if (jj_scan_token(IMPLEMENTS)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_405()) { jj_scanpos = xsp; break; } + } + if (jj_3R_198()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_406()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_403() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_316() { + if (jj_scan_token(SC_AND)) return true; + if (jj_3R_264()) return true; + return false; + } + + private boolean jj_3R_315() { + if (jj_3R_345()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_369()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_432() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_449()) { + jj_scanpos = xsp; + if (jj_3R_450()) return true; + } + if (jj_scan_token(COLON)) return true; + if (jj_3R_184()) return true; + return false; + } + + private boolean jj_3R_295() { + if (jj_scan_token(SC_OR)) return true; + if (jj_3R_233()) return true; + return false; + } + + private boolean jj_3R_404() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_198()) return true; + return false; + } + + private boolean jj_3R_396() { + if (jj_scan_token(EXTENDS)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_403()) { jj_scanpos = xsp; break; } + } + if (jj_3R_198()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_404()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_293() { + if (jj_3R_315()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_365()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_416() { + if (jj_3R_432()) return true; + return false; + } + + private boolean jj_3R_351() { + if (jj_scan_token(SWITCH)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_416()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_319() { + if (jj_scan_token(INTERFACE)) return true; + return false; + } + + private boolean jj_3R_264() { + if (jj_3R_293()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_346()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_380() { + if (jj_3R_397()) return true; + return false; + } + + private boolean jj_3R_173() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_172()) return true; + return false; + } + + private boolean jj_3R_379() { + if (jj_3R_396()) return true; + return false; + } + + private boolean jj_3R_378() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_456() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_233() { + if (jj_3R_264()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_316()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_298() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(20)) { + jj_scanpos = xsp; + if (jj_3R_319()) return true; + } + if (jj_3R_119()) return true; + xsp = jj_scanpos; + if (jj_3R_378()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_379()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_380()) jj_scanpos = xsp; + if (jj_3R_113()) return true; + return false; + } + + private boolean jj_3R_448() { + if (jj_scan_token(ARROW)) return true; + if (jj_3R_296()) return true; + return false; + } + + private boolean jj_3R_447() { + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_456()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(78)) { + jj_scanpos = xsp; + if (jj_scan_token(43)) return true; + } + return false; + } + + private boolean jj_3R_446() { + if (jj_3R_99()) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_445() { + if (jj_scan_token(DECR)) return true; + return false; + } + + private boolean jj_3R_200() { + if (jj_3R_233()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_295()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_444() { + if (jj_scan_token(INCR)) return true; + return false; + } + + private boolean jj_3R_431() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_444()) { + jj_scanpos = xsp; + if (jj_3R_445()) { + jj_scanpos = xsp; + if (jj_3R_446()) { + jj_scanpos = xsp; + if (jj_3R_447()) { + jj_scanpos = xsp; + if (jj_3R_448()) return true; + } + } + } + } + return false; + } + + private boolean jj_3R_367() { + if (jj_3R_294()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_431()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_366() { + if (jj_3R_242()) return true; + return false; + } + + private boolean jj_3R_268() { + if (jj_scan_token(HOOK)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_151() { + if (jj_3R_200()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_268()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3_39() { + if (jj_3R_118()) return true; + return false; + } + + private boolean jj_3R_350() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_39()) { + jj_scanpos = xsp; + if (jj_3R_366()) { + jj_scanpos = xsp; + if (jj_3R_367()) return true; + } + } + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_150() { + if (jj_scan_token(ORASSIGN)) return true; + return false; + } + + private boolean jj_3R_149() { + if (jj_scan_token(XORASSIGN)) return true; + return false; + } + + private boolean jj_3R_148() { + if (jj_scan_token(ANDASSIGN)) return true; + return false; + } + + private boolean jj_3R_147() { + if (jj_scan_token(RUNSIGNEDSHIFTASSIGN)) return true; + return false; + } + + private boolean jj_3R_146() { + if (jj_scan_token(RSIGNEDSHIFTASSIGN)) return true; + return false; + } + + private boolean jj_3R_145() { + if (jj_scan_token(LSHIFTASSIGN)) return true; + return false; + } + + private boolean jj_3R_144() { + if (jj_scan_token(MINUSASSIGN)) return true; + return false; + } + + private boolean jj_3R_143() { + if (jj_scan_token(PLUSASSIGN)) return true; + return false; + } + + private boolean jj_3R_142() { + if (jj_scan_token(REMASSIGN)) return true; + return false; + } + + private boolean jj_3R_141() { + if (jj_scan_token(SLASHASSIGN)) return true; + return false; + } + + private boolean jj_3R_140() { + if (jj_scan_token(STARASSIGN)) return true; + return false; + } + + private boolean jj_3R_139() { + if (jj_scan_token(ASSIGN)) return true; + return false; + } + + private boolean jj_3R_318() { + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_99() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_139()) { + jj_scanpos = xsp; + if (jj_3R_140()) { + jj_scanpos = xsp; + if (jj_3R_141()) { + jj_scanpos = xsp; + if (jj_3R_142()) { + jj_scanpos = xsp; + if (jj_3R_143()) { + jj_scanpos = xsp; + if (jj_3R_144()) { + jj_scanpos = xsp; + if (jj_3R_145()) { + jj_scanpos = xsp; + if (jj_3R_146()) { + jj_scanpos = xsp; + if (jj_3R_147()) { + jj_scanpos = xsp; + if (jj_3R_148()) { + jj_scanpos = xsp; + if (jj_3R_149()) { + jj_scanpos = xsp; + if (jj_3R_150()) return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_84() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_83() { + if (jj_scan_token(STRICTFP)) return true; + return false; + } + + private boolean jj_3R_297() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_317() { + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_82() { + if (jj_scan_token(VOLATILE)) return true; + return false; + } + + private boolean jj_3R_81() { + if (jj_scan_token(TRANSIENT)) return true; + return false; + } + + private boolean jj_3R_114() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_80() { + if (jj_scan_token(NATIVE)) return true; + return false; + } + + private boolean jj_3R_79() { + if (jj_scan_token(SYNCHRONIZED)) return true; + return false; + } + + private boolean jj_3R_270() { + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_297()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(78)) { + jj_scanpos = xsp; + if (jj_scan_token(43)) return true; + } + return false; + } + + private boolean jj_3R_296() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_317()) { + jj_scanpos = xsp; + if (jj_3R_318()) return true; + } + return false; + } + + private boolean jj_3R_78() { + if (jj_scan_token(ABSTRACT)) return true; + return false; + } + + private boolean jj_3R_415() { + if (jj_scan_token(COLON)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_77() { + if (jj_scan_token(FINAL)) return true; + return false; + } + + private boolean jj_3R_76() { + if (jj_scan_token(PRIVATE)) return true; + return false; + } + + private boolean jj_3R_75() { + if (jj_scan_token(PROTECTED)) return true; + return false; + } + + private boolean jj_3R_74() { + if (jj_scan_token(STATIC)) return true; + return false; + } + + private boolean jj_3R_349() { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3_34() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_114()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_73() { + if (jj_scan_token(PUBLIC)) return true; + return false; + } + + private boolean jj_3_2() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_73()) { + jj_scanpos = xsp; + if (jj_3R_74()) { + jj_scanpos = xsp; + if (jj_3R_75()) { + jj_scanpos = xsp; + if (jj_3R_76()) { + jj_scanpos = xsp; + if (jj_3R_77()) { + jj_scanpos = xsp; + if (jj_3R_78()) { + jj_scanpos = xsp; + if (jj_3R_79()) { + jj_scanpos = xsp; + if (jj_3R_80()) { + jj_scanpos = xsp; + if (jj_3R_81()) { + jj_scanpos = xsp; + if (jj_3R_82()) { + jj_scanpos = xsp; + if (jj_3R_83()) { + jj_scanpos = xsp; + if (jj_3R_84()) return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_116() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_2()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3_18() { + if (jj_3R_99()) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_269() { + if (jj_scan_token(ARROW)) return true; + if (jj_3R_296()) return true; + return false; + } + + private boolean jj_3R_411() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_119()) return true; + return false; + } + + private boolean jj_3R_239() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_18()) { + jj_scanpos = xsp; + if (jj_3R_269()) { + jj_scanpos = xsp; + if (jj_3R_270()) return true; + } + } + return false; + } + + private boolean jj_3_38() { + if (jj_3R_117()) return true; + return false; + } + + private boolean jj_3R_117() { + if (jj_3R_116()) return true; + if (jj_3R_87()) return true; + if (jj_3R_172()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_173()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_100() { + if (jj_3R_151()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_239()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3_37() { + if (jj_3R_116()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(20)) { + jj_scanpos = xsp; + if (jj_scan_token(40)) return true; + } + return false; + } + + private boolean jj_3R_283() { + if (jj_3R_306()) return true; + return false; + } + + private boolean jj_3R_282() { + if (jj_3R_117()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_281() { + if (jj_3R_116()) return true; + if (jj_3R_298()) return true; + return false; + } + + private boolean jj_3R_246() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_281()) { + jj_scanpos = xsp; + if (jj_3R_282()) { + jj_scanpos = xsp; + if (jj_3R_283()) return true; + } + } + return false; + } + + private boolean jj_3R_122() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_72() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_122()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(PACKAGE)) return true; + if (jj_3R_119()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3_1() { + if (jj_3R_72()) return true; + return false; + } + + private boolean jj_3R_401() { + if (jj_3R_119()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_411()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_128() { + if (jj_scan_token(LBRACE)) return true; + if (jj_3R_184()) return true; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_227() { + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_115() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_306()) return true; + return false; + } + + private boolean jj_3R_348() { + if (jj_scan_token(ASSERT)) return true; + if (jj_3R_100()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_415()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3_17() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_119() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_17()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_339() { + if (jj_3R_361()) return true; + return false; + } + + private boolean jj_3R_338() { + if (jj_3R_360()) return true; + return false; + } + + private boolean jj_3R_337() { + if (jj_3R_359()) return true; + return false; + } + + private boolean jj_3R_170() { + if (jj_3R_87()) return true; + return false; + } + + private boolean jj_3R_336() { + if (jj_3R_358()) return true; + return false; + } + + private boolean jj_3R_169() { + if (jj_scan_token(VOID)) return true; + return false; + } + + private boolean jj_3R_335() { + if (jj_3R_357()) return true; + return false; + } + + private boolean jj_3R_334() { + if (jj_3R_356()) return true; + return false; + } + + private boolean jj_3R_333() { + if (jj_3R_355()) return true; + return false; + } + + private boolean jj_3R_332() { + if (jj_3R_354()) return true; + return false; + } + + private boolean jj_3R_331() { + if (jj_3R_353()) return true; + return false; + } + + private boolean jj_3R_111() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_169()) { + jj_scanpos = xsp; + if (jj_3R_170()) return true; + } + return false; + } + + private boolean jj_3R_330() { + if (jj_3R_352()) return true; + return false; + } + + private boolean jj_3R_329() { + if (jj_3R_351()) return true; + return false; + } + + private boolean jj_3R_328() { + if (jj_3R_350()) return true; + return false; + } + + private boolean jj_3R_327() { + if (jj_3R_349()) return true; + return false; + } + + private boolean jj_3R_326() { + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_163() { + if (jj_scan_token(DOUBLE)) return true; + return false; + } + + private boolean jj_3R_325() { + if (jj_3R_348()) return true; + return false; + } + + private boolean jj_3R_162() { + if (jj_scan_token(FLOAT)) return true; + return false; + } + + private boolean jj_3R_161() { + if (jj_scan_token(LONG)) return true; + return false; + } + + private boolean jj_3_36() { + if (jj_3R_115()) return true; + return false; + } + + private boolean jj_3R_160() { + if (jj_scan_token(INT)) return true; + return false; + } + + private boolean jj_3R_363() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_159() { + if (jj_scan_token(SHORT)) return true; + return false; + } + + private boolean jj_3R_362() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_158() { + if (jj_scan_token(BYTE)) return true; + return false; + } + + private boolean jj_3R_157() { + if (jj_scan_token(CHAR)) return true; + return false; + } + + private boolean jj_3R_156() { + if (jj_scan_token(BOOLEAN)) return true; + return false; + } + + private boolean jj_3R_306() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_36()) { + jj_scanpos = xsp; + if (jj_3R_325()) { + jj_scanpos = xsp; + if (jj_3R_326()) { + jj_scanpos = xsp; + if (jj_3R_327()) { + jj_scanpos = xsp; + if (jj_3R_328()) { + jj_scanpos = xsp; + if (jj_3R_329()) { + jj_scanpos = xsp; + if (jj_3R_330()) { + jj_scanpos = xsp; + if (jj_3R_331()) { + jj_scanpos = xsp; + if (jj_3R_332()) { + jj_scanpos = xsp; + if (jj_3R_333()) { + jj_scanpos = xsp; + if (jj_3R_334()) { + jj_scanpos = xsp; + if (jj_3R_335()) { + jj_scanpos = xsp; + if (jj_3R_336()) { + jj_scanpos = xsp; + if (jj_3R_337()) { + jj_scanpos = xsp; + if (jj_3R_338()) { + jj_scanpos = xsp; + if (jj_3R_339()) return true; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_344() { + if (jj_scan_token(SUPER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_363()) { jj_scanpos = xsp; break; } + } + if (jj_3R_94()) return true; + return false; + } + + private boolean jj_3R_107() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_156()) { + jj_scanpos = xsp; + if (jj_3R_157()) { + jj_scanpos = xsp; + if (jj_3R_158()) { + jj_scanpos = xsp; + if (jj_3R_159()) { + jj_scanpos = xsp; + if (jj_3R_160()) { + jj_scanpos = xsp; + if (jj_3R_161()) { + jj_scanpos = xsp; + if (jj_3R_162()) { + jj_scanpos = xsp; + if (jj_3R_163()) return true; + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_342() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_343() { + if (jj_scan_token(EXTENDS)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_362()) { jj_scanpos = xsp; break; } + } + if (jj_3R_94()) return true; + return false; + } + + private boolean jj_3R_314() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_343()) { + jj_scanpos = xsp; + if (jj_3R_344()) return true; + } + return false; + } + + private boolean jj_3R_312() { + Token xsp; + if (jj_3R_342()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_342()) { jj_scanpos = xsp; break; } + } + if (jj_3R_185()) return true; + return false; + } + + private boolean jj_3_33() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3_32() { + if (jj_3R_113()) return true; + return false; + } + + private boolean jj_3_35() { + Token xsp; + if (jj_3_33()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3_33()) { jj_scanpos = xsp; break; } + } + while (true) { + xsp = jj_scanpos; + if (jj_3_34()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_229() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_199()) return true; + return false; + } + + private boolean jj_3R_311() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_289() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_311()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3_35()) { + jj_scanpos = xsp; + if (jj_3R_312()) return true; + } + return false; + } + + private boolean jj_3R_313() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_263() { + if (jj_scan_token(HOOK)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_314()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_292() { + if (jj_3R_187()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_32()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_232() { + if (jj_3R_263()) return true; + return false; + } + + private boolean jj_3R_231() { + if (jj_3R_94()) return true; + return false; + } + + private boolean jj_3R_460() { + if (jj_3R_462()) return true; + return false; + } + + private boolean jj_3R_230() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_199() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_230()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_231()) { + jj_scanpos = xsp; + if (jj_3R_232()) return true; + } + return false; + } + + private boolean jj_3R_291() { + if (jj_3R_289()) return true; + return false; + } + + private boolean jj_3R_96() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_98() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_290() { + if (jj_3R_97()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_313()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_138() { + if (jj_scan_token(132)) return true; + return false; + } + + private boolean jj_3R_262() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_290()) jj_scanpos = xsp; + if (jj_3R_198()) return true; + xsp = jj_scanpos; + if (jj_3R_291()) { + jj_scanpos = xsp; + if (jj_3R_292()) return true; + } + return false; + } + + private boolean jj_3R_95() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_284() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3_13() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_96()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_137() { + if (jj_scan_token(LT)) return true; + if (jj_3R_199()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_229()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_97() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_137()) { + jj_scanpos = xsp; + if (jj_3R_138()) return true; + } + return false; + } + + private boolean jj_3_16() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3_15() { + if (jj_scan_token(DOT)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_98()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(IDENTIFIER)) return true; + xsp = jj_scanpos; + if (jj_3_16()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_261() { + if (jj_3R_107()) return true; + if (jj_3R_289()) return true; + return false; + } + + private boolean jj_3_12() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_95()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_386() { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_401()) return true; + return false; + } + + private boolean jj_3_14() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_260() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_198() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_14()) jj_scanpos = xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_15()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_225() { + if (jj_scan_token(NEW)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_260()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_261()) { + jj_scanpos = xsp; + if (jj_3R_262()) return true; + } + return false; + } + + private boolean jj_3R_462() { + if (jj_scan_token(_DEFAULT)) return true; + if (jj_3R_121()) return true; + return false; + } + + private boolean jj_3R_136() { + if (jj_3R_198()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_13()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_135() { + if (jj_3R_107()) return true; + Token xsp; + if (jj_3_12()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3_12()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_94() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_135()) { + jj_scanpos = xsp; + if (jj_3R_136()) return true; + } + return false; + } + + private boolean jj_3R_247() { + if (jj_3R_100()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_284()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_455() { + if (jj_3R_87()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_scan_token(RPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_460()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_219() { + if (jj_3R_247()) return true; + return false; + } + + private boolean jj_3_47() { + if (jj_3R_87()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_443() { + if (jj_3R_302()) return true; + return false; + } + + private boolean jj_3R_442() { + if (jj_3R_300()) return true; + return false; + } + + private boolean jj_3R_187() { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_219()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_126() { + if (jj_3R_107()) return true; + return false; + } + + private boolean jj_3R_441() { + if (jj_3R_299()) return true; + return false; + } + + private boolean jj_3_11() { + if (jj_3R_94()) return true; + return false; + } + + private boolean jj_3R_440() { + if (jj_3R_298()) return true; + return false; + } + + private boolean jj_3R_87() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_11()) { + jj_scanpos = xsp; + if (jj_3R_126()) return true; + } + return false; + } + + private boolean jj_3R_439() { + if (jj_3R_455()) return true; + return false; + } + + private boolean jj_3R_286() { + if (jj_scan_token(NULL)) return true; + return false; + } + + private boolean jj_3R_308() { + if (jj_scan_token(FALSE)) return true; + return false; + } + + private boolean jj_3R_307() { + if (jj_scan_token(TRUE)) return true; + return false; + } + + private boolean jj_3_46() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_121()) return true; + return false; + } + + private boolean jj_3R_426() { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_427() { + if (jj_3R_116()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_439()) { + jj_scanpos = xsp; + if (jj_3R_440()) { + jj_scanpos = xsp; + if (jj_3R_441()) { + jj_scanpos = xsp; + if (jj_3R_442()) { + jj_scanpos = xsp; + if (jj_3R_443()) return true; + } + } + } + } + return false; + } + + private boolean jj_3R_127() { + if (jj_scan_token(STATIC)) return true; + return false; + } + + private boolean jj_3R_89() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_127()) jj_scanpos = xsp; + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_285() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_307()) { + jj_scanpos = xsp; + if (jj_3R_308()) return true; + } + return false; + } + + private boolean jj_3R_409() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_426()) { + jj_scanpos = xsp; + if (jj_3R_427()) return true; + } + return false; + } + + private boolean jj_3R_254() { + if (jj_3R_286()) return true; + return false; + } + + private boolean jj_3R_218() { + if (jj_3R_246()) return true; + return false; + } + + private boolean jj_3R_253() { + if (jj_3R_285()) return true; + return false; + } + + private boolean jj_3R_184() { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_218()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_399() { + if (jj_3R_409()) return true; + return false; + } + + private boolean jj_3_9() { + if (jj_3R_92()) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + private boolean jj_3R_252() { + if (jj_scan_token(STRING_LITERAL)) return true; + return false; + } + + private boolean jj_3R_251() { + if (jj_scan_token(CHARACTER_LITERAL)) return true; + return false; + } + + private boolean jj_3R_384() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_399()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_93() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_189() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3_10() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_93()) jj_scanpos = xsp; + if (jj_scan_token(THIS)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_250() { + if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; + return false; + } + + private boolean jj_3R_188() { + if (jj_3R_92()) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + private boolean jj_3R_249() { + if (jj_scan_token(LONG_LITERAL)) return true; + return false; + } + + private boolean jj_3R_132() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_188()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_189()) jj_scanpos = xsp; + if (jj_scan_token(SUPER)) return true; + if (jj_3R_187()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_186() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_248() { + if (jj_scan_token(INTEGER_LITERAL)) return true; + return false; + } + + private boolean jj_3R_131() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_186()) jj_scanpos = xsp; + if (jj_scan_token(THIS)) return true; + if (jj_3R_187()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_300() { + if (jj_scan_token(AT)) return true; + if (jj_scan_token(INTERFACE)) return true; + if (jj_3R_119()) return true; + if (jj_3R_384()) return true; + return false; + } + + private boolean jj_3R_112() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_220() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_248()) { + jj_scanpos = xsp; + if (jj_3R_249()) { + jj_scanpos = xsp; + if (jj_3R_250()) { + jj_scanpos = xsp; + if (jj_3R_251()) { + jj_scanpos = xsp; + if (jj_3R_252()) { + jj_scanpos = xsp; + if (jj_3R_253()) { + jj_scanpos = xsp; + if (jj_3R_254()) return true; + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_91() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_131()) { + jj_scanpos = xsp; + if (jj_3R_132()) return true; + } + return false; + } + + private boolean jj_3R_166() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3_31() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_112()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_324() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_323()) return true; + return false; + } + + private boolean jj_3R_347() { + if (jj_3R_121()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_46()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_238() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3R_237() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_278() { + if (jj_3R_304()) return true; + return false; + } + + private boolean jj_3_8() { + if (jj_3R_91()) return true; + return false; + } + + private boolean jj_3R_204() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_237()) jj_scanpos = xsp; + if (jj_3R_227()) return true; + xsp = jj_scanpos; + if (jj_3R_238()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_212() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_347()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(88)) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3_7() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_90()) return true; + return false; + } + + private boolean jj_3R_203() { + if (jj_3R_225()) return true; + return false; + } + + private boolean jj_3R_167() { + if (jj_scan_token(ELLIPSIS)) return true; + return false; + } + + private boolean jj_3R_202() { + if (jj_scan_token(THIS)) return true; + return false; + } + + private boolean jj_3R_177() { + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_287() { + if (jj_3R_309()) return true; + return false; + } + + private boolean jj_3R_176() { + if (jj_3R_212()) return true; + return false; + } + + private boolean jj_3R_175() { + if (jj_3R_123()) return true; + return false; + } + + private boolean jj_3R_387() { + if (jj_3R_91()) return true; + return false; + } + + private boolean jj_3R_340() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_110()) return true; + return false; + } + + private boolean jj_3R_165() { + if (jj_scan_token(DOT)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_202()) { + jj_scanpos = xsp; + if (jj_3R_203()) { + jj_scanpos = xsp; + if (jj_3R_204()) return true; + } + } + return false; + } + + private boolean jj_3R_320() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_301() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_320()) jj_scanpos = xsp; + if (jj_3R_227()) return true; + if (jj_3R_385()) return true; + xsp = jj_scanpos; + if (jj_3R_386()) jj_scanpos = xsp; + if (jj_scan_token(LBRACE)) return true; + xsp = jj_scanpos; + if (jj_3R_387()) jj_scanpos = xsp; + if (jj_3R_184()) return true; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_121() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_175()) { + jj_scanpos = xsp; + if (jj_3R_176()) { + jj_scanpos = xsp; + if (jj_3R_177()) return true; + } + } + return false; + } + + private boolean jj_3R_109() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_165()) { + jj_scanpos = xsp; + if (jj_3R_166()) return true; + } + return false; + } + + private boolean jj_3R_410() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_110()) return true; + return false; + } + + private boolean jj_3R_323() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(ASSIGN)) return true; + if (jj_3R_121()) return true; + return false; + } + + private boolean jj_3R_164() { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(SUPER)) return true; + return false; + } + + private boolean jj_3_30() { + if (jj_3R_109()) return true; + return false; + } + + private boolean jj_3R_226() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_304() { + if (jj_3R_323()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_324()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_108() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_30()) { + jj_scanpos = xsp; + if (jj_3R_164()) return true; + } + return false; + } + + private boolean jj_3R_228() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3R_110() { + if (jj_3R_116()) return true; + if (jj_3R_87()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_167()) jj_scanpos = xsp; + if (jj_3R_168()) return true; + return false; + } + + private boolean jj_3R_197() { + if (jj_3R_227()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_228()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3_29() { + if (jj_3R_111()) return true; + if (jj_scan_token(DOUBLECOLON)) return true; + return false; + } + + private boolean jj_3R_214() { + if (jj_scan_token(AT)) return true; + if (jj_3R_119()) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_121()) return true; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_389() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3_28() { + if (jj_3R_111()) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(CLASS)) return true; + return false; + } + + private boolean jj_3R_341() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_168()) return true; + return false; + } + + private boolean jj_3R_120() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(ASSIGN)) return true; + return false; + } + + private boolean jj_3R_205() { + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_288() { + if (jj_3R_310()) return true; + return false; + } + + private boolean jj_3R_310() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_168()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_341()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_196() { + if (jj_3R_111()) return true; + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_226()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(78)) { + jj_scanpos = xsp; + if (jj_scan_token(43)) return true; + } + return false; + } + + private boolean jj_3R_215() { + if (jj_scan_token(AT)) return true; + if (jj_3R_119()) return true; + return false; + } + + private boolean jj_3R_322() { + if (jj_3R_90()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_7()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_195() { + if (jj_3R_111()) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(CLASS)) return true; + return false; + } + + private boolean jj_3R_194() { + if (jj_3R_225()) return true; + return false; + } + + private boolean jj_3_27() { + if (jj_3R_110()) return true; + return false; + } + + private boolean jj_3_45() { + if (jj_scan_token(AT)) return true; + if (jj_3R_119()) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_309() { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_110()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_340()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3_43() { + if (jj_scan_token(SEMICOLON)) return true; + if (jj_3R_117()) return true; + return false; + } + + private boolean jj_3_44() { + if (jj_scan_token(AT)) return true; + if (jj_3R_119()) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_120()) { + jj_scanpos = xsp; + if (jj_scan_token(82)) return true; + } + return false; + } + + private boolean jj_3R_213() { + if (jj_scan_token(AT)) return true; + if (jj_3R_119()) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_278()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_400() { + if (jj_3R_110()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_410()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_180() { + if (jj_3R_215()) return true; + return false; + } + + private boolean jj_3R_259() { + if (jj_3R_100()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_288()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_258() { + if (jj_3R_110()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_287()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_179() { + if (jj_3R_214()) return true; + return false; + } + + private boolean jj_3R_224() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_258()) { + jj_scanpos = xsp; + if (jj_3R_259()) return true; + } + return false; + } + + private boolean jj_3R_385() { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_400()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_178() { + if (jj_3R_213()) return true; + return false; + } + + private boolean jj_3R_257() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_193() { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_224()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_222() { + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_257()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(78)) { + jj_scanpos = xsp; + if (jj_scan_token(43)) return true; + } + return false; + } + + private boolean jj_3R_123() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_178()) { + jj_scanpos = xsp; + if (jj_3R_179()) { + jj_scanpos = xsp; + if (jj_3R_180()) return true; + } + } + return false; + } + + private boolean jj_3R_223() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3R_152() { + return false; + } + + private boolean jj_3R_391() { + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_390() { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_401()) return true; + return false; + } + + private boolean jj_3R_321() { + if (jj_3R_125()) return true; + return false; + } + + private boolean jj_3R_303() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_321()) jj_scanpos = xsp; + if (jj_3R_111()) return true; + if (jj_3R_119()) return true; + if (jj_3R_385()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_389()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_390()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_391()) { + jj_scanpos = xsp; + if (jj_scan_token(87)) return true; + } + return false; + } + + private boolean jj_3R_153() { + return false; + } + + private boolean jj_3R_102() { + jj_lookingAhead = true; + jj_semLA = getToken(1).kind == GT && + ((GTToken)getToken(1)).realKind == RSIGNEDSHIFT; + jj_lookingAhead = false; + if (!jj_semLA || jj_3R_152()) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_256() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3R_221() { + if (jj_scan_token(DOT)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_255()) jj_scanpos = xsp; + if (jj_3R_227()) return true; + xsp = jj_scanpos; + if (jj_3R_256()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_255() { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3_26() { + if (jj_3R_109()) return true; + return false; + } + + private boolean jj_3R_192() { + if (jj_scan_token(SUPER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_221()) { + jj_scanpos = xsp; + if (jj_3R_222()) { + jj_scanpos = xsp; + if (jj_3R_223()) return true; + } + } + return false; + } + + private boolean jj_3R_103() { + jj_lookingAhead = true; + jj_semLA = getToken(1).kind == GT && + ((GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT; + jj_lookingAhead = false; + if (!jj_semLA || jj_3R_153()) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_191() { + if (jj_scan_token(THIS)) return true; + return false; + } + + private boolean jj_3R_185() { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_322()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(88)) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_190() { + if (jj_3R_220()) return true; + return false; + } + + private boolean jj_3R_134() { + if (jj_3R_109()) return true; + return false; + } + + private boolean jj_3R_130() { + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_129() { + if (jj_3R_185()) return true; + return false; + } + + private boolean jj_3R_207() { + if (jj_scan_token(ASSIGN)) return true; + if (jj_3R_90()) return true; + return false; + } + + private boolean jj_3R_453() { + if (jj_3R_117()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_43()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_133() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_190()) { + jj_scanpos = xsp; + if (jj_3R_191()) { + jj_scanpos = xsp; + if (jj_3R_192()) { + jj_scanpos = xsp; + if (jj_3R_193()) { + jj_scanpos = xsp; + if (jj_3R_194()) { + jj_scanpos = xsp; + if (jj_3R_195()) { + jj_scanpos = xsp; + if (jj_3R_196()) { + jj_scanpos = xsp; + if (jj_3R_197()) return true; + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3_25() { + if (jj_3R_108()) return true; + return false; + } + + private boolean jj_3R_90() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_129()) { + jj_scanpos = xsp; + if (jj_3R_130()) return true; + } + return false; + } + + private boolean jj_3R_454() { + if (jj_scan_token(BIT_OR)) return true; + if (jj_3R_87()) return true; + return false; + } + + private boolean jj_3R_438() { + if (jj_scan_token(FINALLY)) return true; + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_425() { + if (jj_scan_token(FINALLY)) return true; + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3_42() { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_436() { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_453()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_42()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_437() { + if (jj_scan_token(CATCH)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_116()) return true; + if (jj_3R_87()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_454()) { jj_scanpos = xsp; break; } + } + if (jj_3R_168()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_128()) return true; + return false; + } + + private boolean jj_3R_168() { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_205()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_92() { + if (jj_3R_133()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_134()) { jj_scanpos = xsp; break; } + } + return false; + } + + /** Generated Token Manager. */ + public ASTParserTokenManager token_source; + JavaCharStream jj_input_stream; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private Token jj_scanpos, jj_lastpos; + private int jj_la; + /** Whether we are looking ahead. */ + private boolean jj_lookingAhead = false; + private boolean jj_semLA; + private int jj_gen; + final private int[] jj_la1 = new int[175]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + static private int[] jj_la1_2; + static private int[] jj_la1_3; + static private int[] jj_la1_4; + static { + jj_la1_init_0(); + jj_la1_init_1(); + jj_la1_init_2(); + jj_la1_init_3(); + jj_la1_init_4(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x0,0x48101000,0x1,0x0,0x0,0x0,0x40001000,0x8100000,0x48101000,0x100000,0x0,0x10000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4a995000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10000000,0x0,0x0,0x0,0x4a995000,0x800000,0x8100000,0x2094000,0x4a995000,0x0,0x0,0x0,0x22094000,0x22094000,0x0,0x0,0x0,0x0,0x0,0x0,0x42095000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x22094000,0x6359f000,0x0,0x2094000,0x0,0x0,0x2094000,0x0,0x0,0x0,0x0,0x2094000,0x0,0x0,0x10000000,0x10000000,0x2094000,0x2094000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x22094000,0x0,0x0,0x22094000,0x0,0x0,0x2094000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x22094000,0x62095000,0x0,0x0,0x0,0x20000000,0x0,0x0,0x0,0x0,0x0,0x0,0x20000000,0x20000000,0x22094000,0x0,0x0,0x0,0x0,0x0,0x2094000,0x0,0x0,0x0,0x0,0x2349e000,0x0,0x2349e000,0x0,0x22094000,0x0,0x0,0x0,0x0,0x22094000,0x820000,0x820000,0x4000000,0x62095000,0x22094000,0x22094000,0x62095000,0x22094000,0x0,0x0,0x0,0x22094000,0x0,0x40000,0x0,0x80000000,0x0,0x0,0x0,0x22094000,0x22094000,0x0,0x4a195000,0xa194000,0x4a195000,0x800000,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x20,0x8899c500,0x0,0x0,0x80000,0x0,0x8899c400,0x100,0x8899c500,0x100,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0xc89dc781,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc89dc781,0x0,0x100,0x40040281,0xc89dc781,0x0,0x0,0x0,0x51241a81,0x51241a81,0x0,0x0,0x0,0x4000000,0x0,0x0,0x889dc681,0x0,0x0,0x0,0x0,0x4000000,0x0,0x0,0x51241a81,0xfbffdf8b,0x80000,0x40281,0x0,0x0,0x40281,0x0,0x0,0x0,0x0,0x40281,0x0,0x0,0x200000,0x200000,0x40281,0x40040281,0x0,0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x51241a81,0x0,0x0,0x51241a81,0x0,0x0,0x40281,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x51241a81,0xd9bdde81,0x0,0x800,0x0,0x11201800,0x0,0x0,0x0,0x0,0x1000800,0x0,0x10001000,0x10000000,0x51241a81,0x0,0x0,0x0,0x0,0x0,0x40281,0x0,0x0,0x0,0x0,0x73e61a8b,0x0,0x73e61a8b,0x0,0x51241a81,0x0,0x800,0x0,0x0,0x51241a81,0x0,0x0,0x0,0xd9bdde81,0x51241a81,0x51241a81,0xd9bdde81,0x51241a81,0x0,0x0,0x0,0x51241a81,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x51241a81,0x51241a81,0x0,0x889dc781,0x40381,0x889dc781,0x0,}; + } + private static void jj_la1_init_2() { + jj_la1_2 = new int[] {0x0,0x4800000,0x0,0x4000000,0x0,0x2000000,0x4000000,0x4000000,0x4800000,0x0,0x10000000,0x0,0x0,0x4000000,0x1000000,0x4000000,0x1000000,0x0,0x4004000,0x1000000,0x14884000,0x800000,0x4000000,0x20000,0x80000,0x4000000,0x1000000,0x4000000,0x0,0x4000000,0x0,0x4000000,0x14884000,0x0,0x4000000,0x10004000,0x14804000,0x1000000,0x8000000,0x200000,0x600a7086,0x600a7086,0x1000000,0x10000000,0x200000,0x0,0x880000,0x1000000,0x4004000,0x1000000,0x1000000,0x0,0x10000000,0x0,0x10000000,0x10000000,0x10027086,0x48a7087,0x0,0x0,0x4000000,0x4000000,0x4000,0x4000000,0x1000000,0x10000000,0x4000000,0x80004000,0x4000000,0x4000000,0x0,0x0,0x0,0x4000,0x4000000,0x1000000,0x4000000,0x1000000,0x10000000,0x4000,0x0,0x8000000,0x8000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10000000,0x10000000,0x0,0x0,0x0,0x0,0x0,0x0,0x60027086,0x60000000,0x60000000,0x27086,0x0,0x4000000,0x4000,0x10000000,0x20000,0x10000000,0x4000,0x2020000,0x1000000,0x1000000,0x60027086,0x64027086,0x10000000,0x4000,0x20000,0x23086,0x4000,0x2000000,0x10000000,0x20000,0x0,0x2200000,0x3086,0x0,0x60027086,0x1000000,0x4000000,0x4000000,0x10000000,0x4220000,0x10004000,0x4000000,0x4000000,0x200000,0x200000,0x8a7087,0x0,0x8a7087,0x1000000,0x600a7086,0x10000000,0x4000,0x8000000,0x8000000,0x27086,0x0,0x0,0x0,0x64027086,0x60027086,0x60027086,0x64827086,0x60027086,0x1000000,0x4000,0x4000,0x60027086,0x20000,0x0,0x0,0x0,0x4000000,0x4000,0x1000000,0x640a7086,0x640a7086,0x1000000,0x4804000,0x4004000,0x4804000,0x0,}; + } + private static void jj_la1_init_3() { + jj_la1_3 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780,0x780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000000,0x0,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0000000,0xdffc0000,0x1ffc0000,0x0,0x20,0x40,0x4000,0x8000,0x2000,0x12,0x12,0x0,0xc,0xc,0x20000,0x600,0x600,0x11800,0x11800,0x600,0x780,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x0,0x780,0x780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180,0x1,0x180,0x0,0x780,0x0,0x0,0xdffc0180,0xdffc0180,0x100,0x0,0x0,0x0,0x780,0x780,0x780,0x780,0x780,0x0,0x0,0x0,0x780,0x0,0x0,0x4000,0x0,0x0,0x0,0x0,0x780,0x780,0x0,0x0,0x0,0x0,0x0,}; + } + private static void jj_la1_init_4() { + jj_la1_4 = new int[] {0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + } + final private JJCalls[] jj_2_rtns = new JJCalls[47]; + private boolean jj_rescan = false; + private int jj_gc = 0; + + /** Constructor with InputStream. */ + public ASTParser(java.io.InputStream stream) { + this(stream, null); + } + /** Constructor with InputStream and supplied encoding */ + public ASTParser(java.io.InputStream stream, String encoding) { + try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source = new ASTParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 175; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream stream) { + ReInit(stream, null); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream stream, String encoding) { + try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 175; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Constructor. */ + public ASTParser(java.io.Reader stream) { + jj_input_stream = new JavaCharStream(stream, 1, 1); + token_source = new ASTParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 175; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader stream) { + jj_input_stream.ReInit(stream, 1, 1); + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 175; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Constructor with generated Token Manager. */ + public ASTParser(ASTParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 175; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(ASTParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 175; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + if (++jj_gc > 100) { + jj_gc = 0; + for (int i = 0; i < jj_2_rtns.length; i++) { + JJCalls c = jj_2_rtns[i]; + while (c != null) { + if (c.gen < jj_gen) c.first = null; + c = c.next; + } + } + } + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + static private final class LookaheadSuccess extends java.lang.Error { } + final private LookaheadSuccess jj_ls = new LookaheadSuccess(); + private boolean jj_scan_token(int kind) { + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_rescan) { + int i = 0; Token tok = token; + while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } + if (tok != null) jj_add_error_token(kind, i); + } + if (jj_scanpos.kind != kind) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; + return false; + } + + +/** Get the next Token. */ + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + +/** Get the specific Token. */ + final public Token getToken(int index) { + Token t = jj_lookingAhead ? jj_scanpos : token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } + + private int jj_ntk() { + if ((jj_nt=token.next) == null) + return (jj_ntk = (token.next=token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + private java.util.List jj_expentries = new java.util.ArrayList(); + private int[] jj_expentry; + private int jj_kind = -1; + private int[] jj_lasttokens = new int[100]; + private int jj_endpos; + + private void jj_add_error_token(int kind, int pos) { + if (pos >= 100) return; + if (pos == jj_endpos + 1) { + jj_lasttokens[jj_endpos++] = kind; + } else if (jj_endpos != 0) { + jj_expentry = new int[jj_endpos]; + for (int i = 0; i < jj_endpos; i++) { + jj_expentry[i] = jj_lasttokens[i]; + } + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); + if (oldentry.length == jj_expentry.length) { + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + continue jj_entries_loop; + } + } + jj_expentries.add(jj_expentry); + break jj_entries_loop; + } + } + if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[133]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 175; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { + jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; + switch (i) { + case 0: jj_3_1(); break; + case 1: jj_3_2(); break; + case 2: jj_3_3(); break; + case 3: jj_3_4(); break; + case 4: jj_3_5(); break; + case 5: jj_3_6(); break; + case 6: jj_3_7(); break; + case 7: jj_3_8(); break; + case 8: jj_3_9(); break; + case 9: jj_3_10(); break; + case 10: jj_3_11(); break; + case 11: jj_3_12(); break; + case 12: jj_3_13(); break; + case 13: jj_3_14(); break; + case 14: jj_3_15(); break; + case 15: jj_3_16(); break; + case 16: jj_3_17(); break; + case 17: jj_3_18(); break; + case 18: jj_3_19(); break; + case 19: jj_3_20(); break; + case 20: jj_3_21(); break; + case 21: jj_3_22(); break; + case 22: jj_3_23(); break; + case 23: jj_3_24(); break; + case 24: jj_3_25(); break; + case 25: jj_3_26(); break; + case 26: jj_3_27(); break; + case 27: jj_3_28(); break; + case 28: jj_3_29(); break; + case 29: jj_3_30(); break; + case 30: jj_3_31(); break; + case 31: jj_3_32(); break; + case 32: jj_3_33(); break; + case 33: jj_3_34(); break; + case 34: jj_3_35(); break; + case 35: jj_3_36(); break; + case 36: jj_3_37(); break; + case 37: jj_3_38(); break; + case 38: jj_3_39(); break; + case 39: jj_3_40(); break; + case 40: jj_3_41(); break; + case 41: jj_3_42(); break; + case 42: jj_3_43(); break; + case 43: jj_3_44(); break; + case 44: jj_3_45(); break; + case 45: jj_3_46(); break; + case 46: jj_3_47(); break; + } + } + p = p.next; + } while (p != null); + } catch(LookaheadSuccess ls) { } + } + jj_rescan = false; + } + + private void jj_save(int index, int xla) { + JJCalls p = jj_2_rtns[index]; + while (p.gen > jj_gen) { + if (p.next == null) { p = p.next = new JJCalls(); break; } + p = p.next; + } + p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; + } + + static final class JJCalls { + int gen; + Token first; + int arg; + JJCalls next; + } + +} diff --git a/src/com/github/javaparser/ASTParserConstants.java b/src/com/github/javaparser/ASTParserConstants.java new file mode 100644 index 0000000..3692dfc --- /dev/null +++ b/src/com/github/javaparser/ASTParserConstants.java @@ -0,0 +1,414 @@ +/* Generated By:JavaCC: Do not edit this line. ASTParserConstants.java */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; + + +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ +public interface ASTParserConstants { + + /** End of File. */ + int EOF = 0; + /** RegularExpression Id. */ + int SINGLE_LINE_COMMENT = 6; + /** RegularExpression Id. */ + int JAVA_DOC_COMMENT = 9; + /** RegularExpression Id. */ + int MULTI_LINE_COMMENT = 10; + /** RegularExpression Id. */ + int ABSTRACT = 12; + /** RegularExpression Id. */ + int ASSERT = 13; + /** RegularExpression Id. */ + int BOOLEAN = 14; + /** RegularExpression Id. */ + int BREAK = 15; + /** RegularExpression Id. */ + int BYTE = 16; + /** RegularExpression Id. */ + int CASE = 17; + /** RegularExpression Id. */ + int CATCH = 18; + /** RegularExpression Id. */ + int CHAR = 19; + /** RegularExpression Id. */ + int CLASS = 20; + /** RegularExpression Id. */ + int CONST = 21; + /** RegularExpression Id. */ + int CONTINUE = 22; + /** RegularExpression Id. */ + int _DEFAULT = 23; + /** RegularExpression Id. */ + int DO = 24; + /** RegularExpression Id. */ + int DOUBLE = 25; + /** RegularExpression Id. */ + int ELSE = 26; + /** RegularExpression Id. */ + int ENUM = 27; + /** RegularExpression Id. */ + int EXTENDS = 28; + /** RegularExpression Id. */ + int FALSE = 29; + /** RegularExpression Id. */ + int FINAL = 30; + /** RegularExpression Id. */ + int FINALLY = 31; + /** RegularExpression Id. */ + int FLOAT = 32; + /** RegularExpression Id. */ + int FOR = 33; + /** RegularExpression Id. */ + int GOTO = 34; + /** RegularExpression Id. */ + int IF = 35; + /** RegularExpression Id. */ + int IMPLEMENTS = 36; + /** RegularExpression Id. */ + int IMPORT = 37; + /** RegularExpression Id. */ + int INSTANCEOF = 38; + /** RegularExpression Id. */ + int INT = 39; + /** RegularExpression Id. */ + int INTERFACE = 40; + /** RegularExpression Id. */ + int LONG = 41; + /** RegularExpression Id. */ + int NATIVE = 42; + /** RegularExpression Id. */ + int NEW = 43; + /** RegularExpression Id. */ + int NULL = 44; + /** RegularExpression Id. */ + int PACKAGE = 45; + /** RegularExpression Id. */ + int PRIVATE = 46; + /** RegularExpression Id. */ + int PROTECTED = 47; + /** RegularExpression Id. */ + int PUBLIC = 48; + /** RegularExpression Id. */ + int RETURN = 49; + /** RegularExpression Id. */ + int SHORT = 50; + /** RegularExpression Id. */ + int STATIC = 51; + /** RegularExpression Id. */ + int STRICTFP = 52; + /** RegularExpression Id. */ + int SUPER = 53; + /** RegularExpression Id. */ + int SWITCH = 54; + /** RegularExpression Id. */ + int SYNCHRONIZED = 55; + /** RegularExpression Id. */ + int THIS = 56; + /** RegularExpression Id. */ + int THROW = 57; + /** RegularExpression Id. */ + int THROWS = 58; + /** RegularExpression Id. */ + int TRANSIENT = 59; + /** RegularExpression Id. */ + int TRUE = 60; + /** RegularExpression Id. */ + int TRY = 61; + /** RegularExpression Id. */ + int VOID = 62; + /** RegularExpression Id. */ + int VOLATILE = 63; + /** RegularExpression Id. */ + int WHILE = 64; + /** RegularExpression Id. */ + int LONG_LITERAL = 65; + /** RegularExpression Id. */ + int INTEGER_LITERAL = 66; + /** RegularExpression Id. */ + int DECIMAL_LITERAL = 67; + /** RegularExpression Id. */ + int HEX_LITERAL = 68; + /** RegularExpression Id. */ + int OCTAL_LITERAL = 69; + /** RegularExpression Id. */ + int BINARY_LITERAL = 70; + /** RegularExpression Id. */ + int FLOATING_POINT_LITERAL = 71; + /** RegularExpression Id. */ + int DECIMAL_FLOATING_POINT_LITERAL = 72; + /** RegularExpression Id. */ + int DECIMAL_EXPONENT = 73; + /** RegularExpression Id. */ + int HEXADECIMAL_FLOATING_POINT_LITERAL = 74; + /** RegularExpression Id. */ + int HEXADECIMAL_EXPONENT = 75; + /** RegularExpression Id. */ + int CHARACTER_LITERAL = 76; + /** RegularExpression Id. */ + int STRING_LITERAL = 77; + /** RegularExpression Id. */ + int IDENTIFIER = 78; + /** RegularExpression Id. */ + int LETTER = 79; + /** RegularExpression Id. */ + int PART_LETTER = 80; + /** RegularExpression Id. */ + int LPAREN = 81; + /** RegularExpression Id. */ + int RPAREN = 82; + /** RegularExpression Id. */ + int LBRACE = 83; + /** RegularExpression Id. */ + int RBRACE = 84; + /** RegularExpression Id. */ + int LBRACKET = 85; + /** RegularExpression Id. */ + int RBRACKET = 86; + /** RegularExpression Id. */ + int SEMICOLON = 87; + /** RegularExpression Id. */ + int COMMA = 88; + /** RegularExpression Id. */ + int DOT = 89; + /** RegularExpression Id. */ + int AT = 90; + /** RegularExpression Id. */ + int ASSIGN = 91; + /** RegularExpression Id. */ + int LT = 92; + /** RegularExpression Id. */ + int BANG = 93; + /** RegularExpression Id. */ + int TILDE = 94; + /** RegularExpression Id. */ + int HOOK = 95; + /** RegularExpression Id. */ + int COLON = 96; + /** RegularExpression Id. */ + int EQ = 97; + /** RegularExpression Id. */ + int LE = 98; + /** RegularExpression Id. */ + int GE = 99; + /** RegularExpression Id. */ + int NE = 100; + /** RegularExpression Id. */ + int SC_OR = 101; + /** RegularExpression Id. */ + int SC_AND = 102; + /** RegularExpression Id. */ + int INCR = 103; + /** RegularExpression Id. */ + int DECR = 104; + /** RegularExpression Id. */ + int PLUS = 105; + /** RegularExpression Id. */ + int MINUS = 106; + /** RegularExpression Id. */ + int STAR = 107; + /** RegularExpression Id. */ + int SLASH = 108; + /** RegularExpression Id. */ + int BIT_AND = 109; + /** RegularExpression Id. */ + int BIT_OR = 110; + /** RegularExpression Id. */ + int XOR = 111; + /** RegularExpression Id. */ + int REM = 112; + /** RegularExpression Id. */ + int LSHIFT = 113; + /** RegularExpression Id. */ + int PLUSASSIGN = 114; + /** RegularExpression Id. */ + int MINUSASSIGN = 115; + /** RegularExpression Id. */ + int STARASSIGN = 116; + /** RegularExpression Id. */ + int SLASHASSIGN = 117; + /** RegularExpression Id. */ + int ANDASSIGN = 118; + /** RegularExpression Id. */ + int ORASSIGN = 119; + /** RegularExpression Id. */ + int XORASSIGN = 120; + /** RegularExpression Id. */ + int REMASSIGN = 121; + /** RegularExpression Id. */ + int LSHIFTASSIGN = 122; + /** RegularExpression Id. */ + int RSIGNEDSHIFTASSIGN = 123; + /** RegularExpression Id. */ + int RUNSIGNEDSHIFTASSIGN = 124; + /** RegularExpression Id. */ + int ELLIPSIS = 125; + /** RegularExpression Id. */ + int ARROW = 126; + /** RegularExpression Id. */ + int DOUBLECOLON = 127; + /** RegularExpression Id. */ + int RUNSIGNEDSHIFT = 128; + /** RegularExpression Id. */ + int RSIGNEDSHIFT = 129; + /** RegularExpression Id. */ + int GT = 130; + + /** Lexical state. */ + int DEFAULT = 0; + /** Lexical state. */ + int IN_JAVA_DOC_COMMENT = 1; + /** Lexical state. */ + int IN_MULTI_LINE_COMMENT = 2; + + /** Literal token values. */ + String[] tokenImage = { + "", + "\" \"", + "\"\\t\"", + "\"\\n\"", + "\"\\r\"", + "\"\\f\"", + "", + "", + "\"/*\"", + "\"*/\"", + "\"*/\"", + "", + "\"abstract\"", + "\"assert\"", + "\"boolean\"", + "\"break\"", + "\"byte\"", + "\"case\"", + "\"catch\"", + "\"char\"", + "\"class\"", + "\"const\"", + "\"continue\"", + "\"default\"", + "\"do\"", + "\"double\"", + "\"else\"", + "\"enum\"", + "\"extends\"", + "\"false\"", + "\"final\"", + "\"finally\"", + "\"float\"", + "\"for\"", + "\"goto\"", + "\"if\"", + "\"implements\"", + "\"import\"", + "\"instanceof\"", + "\"int\"", + "\"interface\"", + "\"long\"", + "\"native\"", + "\"new\"", + "\"null\"", + "\"package\"", + "\"private\"", + "\"protected\"", + "\"public\"", + "\"return\"", + "\"short\"", + "\"static\"", + "\"strictfp\"", + "\"super\"", + "\"switch\"", + "\"synchronized\"", + "\"this\"", + "\"throw\"", + "\"throws\"", + "\"transient\"", + "\"true\"", + "\"try\"", + "\"void\"", + "\"volatile\"", + "\"while\"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "\"(\"", + "\")\"", + "\"{\"", + "\"}\"", + "\"[\"", + "\"]\"", + "\";\"", + "\",\"", + "\".\"", + "\"@\"", + "\"=\"", + "\"<\"", + "\"!\"", + "\"~\"", + "\"?\"", + "\":\"", + "\"==\"", + "\"<=\"", + "\">=\"", + "\"!=\"", + "\"||\"", + "\"&&\"", + "\"++\"", + "\"--\"", + "\"+\"", + "\"-\"", + "\"*\"", + "\"/\"", + "\"&\"", + "\"|\"", + "\"^\"", + "\"%\"", + "\"<<\"", + "\"+=\"", + "\"-=\"", + "\"*=\"", + "\"/=\"", + "\"&=\"", + "\"|=\"", + "\"^=\"", + "\"%=\"", + "\"<<=\"", + "\">>=\"", + "\">>>=\"", + "\"...\"", + "\"->\"", + "\"::\"", + "\">>>\"", + "\">>\"", + "\">\"", + "\"\\u001a\"", + "\"<>\"", + }; + +} diff --git a/src/com/github/javaparser/ASTParserTokenManager.java b/src/com/github/javaparser/ASTParserTokenManager.java new file mode 100644 index 0000000..8c15764 --- /dev/null +++ b/src/com/github/javaparser/ASTParserTokenManager.java @@ -0,0 +1,2559 @@ +/* Generated By:JavaCC: Do not edit this line. ASTParserTokenManager.java */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; +import java.io.*; +import java.util.*; +import com.github.javaparser.ast.*; +import com.github.javaparser.ast.body.*; +import com.github.javaparser.ast.comments.*; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.*; +import com.github.javaparser.ast.type.*; + +/** Token Manager. */ +public class ASTParserTokenManager implements ASTParserConstants +{ + + /** Debug output. */ + public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ + public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } +private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1, long active2) +{ + switch (pos) + { + case 0: + if ((active0 & 0xfffffffffffff000L) != 0L || (active1 & 0x1L) != 0L) + { + jjmatchedKind = 78; + return 43; + } + if ((active0 & 0x100L) != 0L || (active1 & 0x20100000000000L) != 0L) + return 45; + if ((active1 & 0x2000000002000000L) != 0L) + return 1; + return -1; + case 1: + if ((active0 & 0x803000000L) != 0L) + return 43; + if ((active0 & 0xfffffff7fcfff000L) != 0L || (active1 & 0x1L) != 0L) + { + if (jjmatchedPos != 1) + { + jjmatchedKind = 78; + jjmatchedPos = 1; + } + return 43; + } + if ((active0 & 0x100L) != 0L) + return 50; + return -1; + case 2: + if ((active0 & 0x2000098200000000L) != 0L) + return 43; + if ((active0 & 0xdffff675fefff000L) != 0L || (active1 & 0x1L) != 0L) + { + if (jjmatchedPos != 2) + { + jjmatchedKind = 78; + jjmatchedPos = 2; + } + return 43; + } + return -1; + case 3: + if ((active0 & 0x8effe571f2f4f000L) != 0L || (active1 & 0x1L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 3; + return 43; + } + if ((active0 & 0x510012040c0b0000L) != 0L) + return 43; + return -1; + case 4: + if ((active0 & 0x88dbe57012c07000L) != 0L) + { + if (jjmatchedPos != 4) + { + jjmatchedKind = 78; + jjmatchedPos = 4; + } + return 43; + } + if ((active0 & 0x6240001e0348000L) != 0L || (active1 & 0x1L) != 0L) + return 43; + return -1; + case 5: + if ((active0 & 0x44b042002002000L) != 0L) + return 43; + if ((active0 & 0x8890e15090c05000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 5; + return 43; + } + return -1; + case 6: + if ((active0 & 0x600090804000L) != 0L) + return 43; + if ((active0 & 0x8890815000401000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 6; + return 43; + } + return -1; + case 7: + if ((active0 & 0x880815000000000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 7; + return 43; + } + if ((active0 & 0x8010000000401000L) != 0L) + return 43; + return -1; + case 8: + if ((active0 & 0x800810000000000L) != 0L) + return 43; + if ((active0 & 0x80005000000000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 8; + return 43; + } + return -1; + case 9: + if ((active0 & 0x5000000000L) != 0L) + return 43; + if ((active0 & 0x80000000000000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 9; + return 43; + } + return -1; + case 10: + if ((active0 & 0x80000000000000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 10; + return 43; + } + return -1; + default : + return -1; + } +} +private final int jjStartNfa_0(int pos, long active0, long active1, long active2) +{ + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1, active2), pos + 1); +} +private int jjStopAtPos(int pos, int kind) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; +} +private int jjMoveStringLiteralDfa0_0() +{ + switch(curChar) + { + case 26: + return jjStopAtPos(0, 131); + case 33: + jjmatchedKind = 93; + return jjMoveStringLiteralDfa1_0(0x0L, 0x1000000000L, 0x0L); + case 37: + jjmatchedKind = 112; + return jjMoveStringLiteralDfa1_0(0x0L, 0x200000000000000L, 0x0L); + case 38: + jjmatchedKind = 109; + return jjMoveStringLiteralDfa1_0(0x0L, 0x40004000000000L, 0x0L); + case 40: + return jjStopAtPos(0, 81); + case 41: + return jjStopAtPos(0, 82); + case 42: + jjmatchedKind = 107; + return jjMoveStringLiteralDfa1_0(0x0L, 0x10000000000000L, 0x0L); + case 43: + jjmatchedKind = 105; + return jjMoveStringLiteralDfa1_0(0x0L, 0x4008000000000L, 0x0L); + case 44: + return jjStopAtPos(0, 88); + case 45: + jjmatchedKind = 106; + return jjMoveStringLiteralDfa1_0(0x0L, 0x4008010000000000L, 0x0L); + case 46: + jjmatchedKind = 89; + return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000000000000L, 0x0L); + case 47: + jjmatchedKind = 108; + return jjMoveStringLiteralDfa1_0(0x100L, 0x20000000000000L, 0x0L); + case 58: + jjmatchedKind = 96; + return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000000000000L, 0x0L); + case 59: + return jjStopAtPos(0, 87); + case 60: + jjmatchedKind = 92; + return jjMoveStringLiteralDfa1_0(0x0L, 0x402000400000000L, 0x10L); + case 61: + jjmatchedKind = 91; + return jjMoveStringLiteralDfa1_0(0x0L, 0x200000000L, 0x0L); + case 62: + jjmatchedKind = 130; + return jjMoveStringLiteralDfa1_0(0x0L, 0x1800000800000000L, 0x3L); + case 63: + return jjStopAtPos(0, 95); + case 64: + return jjStopAtPos(0, 90); + case 91: + return jjStopAtPos(0, 85); + case 93: + return jjStopAtPos(0, 86); + case 94: + jjmatchedKind = 111; + return jjMoveStringLiteralDfa1_0(0x0L, 0x100000000000000L, 0x0L); + case 97: + return jjMoveStringLiteralDfa1_0(0x3000L, 0x0L, 0x0L); + case 98: + return jjMoveStringLiteralDfa1_0(0x1c000L, 0x0L, 0x0L); + case 99: + return jjMoveStringLiteralDfa1_0(0x7e0000L, 0x0L, 0x0L); + case 100: + return jjMoveStringLiteralDfa1_0(0x3800000L, 0x0L, 0x0L); + case 101: + return jjMoveStringLiteralDfa1_0(0x1c000000L, 0x0L, 0x0L); + case 102: + return jjMoveStringLiteralDfa1_0(0x3e0000000L, 0x0L, 0x0L); + case 103: + return jjMoveStringLiteralDfa1_0(0x400000000L, 0x0L, 0x0L); + case 105: + return jjMoveStringLiteralDfa1_0(0x1f800000000L, 0x0L, 0x0L); + case 108: + return jjMoveStringLiteralDfa1_0(0x20000000000L, 0x0L, 0x0L); + case 110: + return jjMoveStringLiteralDfa1_0(0x1c0000000000L, 0x0L, 0x0L); + case 112: + return jjMoveStringLiteralDfa1_0(0x1e00000000000L, 0x0L, 0x0L); + case 114: + return jjMoveStringLiteralDfa1_0(0x2000000000000L, 0x0L, 0x0L); + case 115: + return jjMoveStringLiteralDfa1_0(0xfc000000000000L, 0x0L, 0x0L); + case 116: + return jjMoveStringLiteralDfa1_0(0x3f00000000000000L, 0x0L, 0x0L); + case 118: + return jjMoveStringLiteralDfa1_0(0xc000000000000000L, 0x0L, 0x0L); + case 119: + return jjMoveStringLiteralDfa1_0(0x0L, 0x1L, 0x0L); + case 123: + return jjStopAtPos(0, 83); + case 124: + jjmatchedKind = 110; + return jjMoveStringLiteralDfa1_0(0x0L, 0x80002000000000L, 0x0L); + case 125: + return jjStopAtPos(0, 84); + case 126: + return jjStopAtPos(0, 94); + default : + return jjMoveNfa_0(0, 0); + } +} +private int jjMoveStringLiteralDfa1_0(long active0, long active1, long active2) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(0, active0, active1, active2); + return 1; + } + switch(curChar) + { + case 38: + if ((active1 & 0x4000000000L) != 0L) + return jjStopAtPos(1, 102); + break; + case 42: + if ((active0 & 0x100L) != 0L) + return jjStartNfaWithStates_0(1, 8, 50); + break; + case 43: + if ((active1 & 0x8000000000L) != 0L) + return jjStopAtPos(1, 103); + break; + case 45: + if ((active1 & 0x10000000000L) != 0L) + return jjStopAtPos(1, 104); + break; + case 46: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x2000000000000000L, active2, 0L); + case 58: + if ((active1 & 0x8000000000000000L) != 0L) + return jjStopAtPos(1, 127); + break; + case 60: + if ((active1 & 0x2000000000000L) != 0L) + { + jjmatchedKind = 113; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x400000000000000L, active2, 0L); + case 61: + if ((active1 & 0x200000000L) != 0L) + return jjStopAtPos(1, 97); + else if ((active1 & 0x400000000L) != 0L) + return jjStopAtPos(1, 98); + else if ((active1 & 0x800000000L) != 0L) + return jjStopAtPos(1, 99); + else if ((active1 & 0x1000000000L) != 0L) + return jjStopAtPos(1, 100); + else if ((active1 & 0x4000000000000L) != 0L) + return jjStopAtPos(1, 114); + else if ((active1 & 0x8000000000000L) != 0L) + return jjStopAtPos(1, 115); + else if ((active1 & 0x10000000000000L) != 0L) + return jjStopAtPos(1, 116); + else if ((active1 & 0x20000000000000L) != 0L) + return jjStopAtPos(1, 117); + else if ((active1 & 0x40000000000000L) != 0L) + return jjStopAtPos(1, 118); + else if ((active1 & 0x80000000000000L) != 0L) + return jjStopAtPos(1, 119); + else if ((active1 & 0x100000000000000L) != 0L) + return jjStopAtPos(1, 120); + else if ((active1 & 0x200000000000000L) != 0L) + return jjStopAtPos(1, 121); + break; + case 62: + if ((active1 & 0x4000000000000000L) != 0L) + return jjStopAtPos(1, 126); + else if ((active2 & 0x2L) != 0L) + { + jjmatchedKind = 129; + jjmatchedPos = 1; + } + else if ((active2 & 0x10L) != 0L) + return jjStopAtPos(1, 132); + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x1800000000000000L, active2, 0x1L); + case 97: + return jjMoveStringLiteralDfa2_0(active0, 0x240020060000L, active1, 0L, active2, 0L); + case 98: + return jjMoveStringLiteralDfa2_0(active0, 0x1000L, active1, 0L, active2, 0L); + case 101: + return jjMoveStringLiteralDfa2_0(active0, 0x2080000800000L, active1, 0L, active2, 0L); + case 102: + if ((active0 & 0x800000000L) != 0L) + return jjStartNfaWithStates_0(1, 35, 43); + break; + case 104: + return jjMoveStringLiteralDfa2_0(active0, 0x704000000080000L, active1, 0x1L, active2, 0L); + case 105: + return jjMoveStringLiteralDfa2_0(active0, 0xc0000000L, active1, 0L, active2, 0L); + case 108: + return jjMoveStringLiteralDfa2_0(active0, 0x104100000L, active1, 0L, active2, 0L); + case 109: + return jjMoveStringLiteralDfa2_0(active0, 0x3000000000L, active1, 0L, active2, 0L); + case 110: + return jjMoveStringLiteralDfa2_0(active0, 0x1c008000000L, active1, 0L, active2, 0L); + case 111: + if ((active0 & 0x1000000L) != 0L) + { + jjmatchedKind = 24; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0xc000020602604000L, active1, 0L, active2, 0L); + case 114: + return jjMoveStringLiteralDfa2_0(active0, 0x3800c00000008000L, active1, 0L, active2, 0L); + case 115: + return jjMoveStringLiteralDfa2_0(active0, 0x2000L, active1, 0L, active2, 0L); + case 116: + return jjMoveStringLiteralDfa2_0(active0, 0x18000000000000L, active1, 0L, active2, 0L); + case 117: + return jjMoveStringLiteralDfa2_0(active0, 0x21100000000000L, active1, 0L, active2, 0L); + case 119: + return jjMoveStringLiteralDfa2_0(active0, 0x40000000000000L, active1, 0L, active2, 0L); + case 120: + return jjMoveStringLiteralDfa2_0(active0, 0x10000000L, active1, 0L, active2, 0L); + case 121: + return jjMoveStringLiteralDfa2_0(active0, 0x80000000010000L, active1, 0L, active2, 0L); + case 124: + if ((active1 & 0x2000000000L) != 0L) + return jjStopAtPos(1, 101); + break; + default : + break; + } + return jjStartNfa_0(0, active0, active1, active2); +} +private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1, long old2, long active2) +{ + if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) + return jjStartNfa_0(0, old0, old1, old2); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(1, active0, active1, active2); + return 2; + } + switch(curChar) + { + case 46: + if ((active1 & 0x2000000000000000L) != 0L) + return jjStopAtPos(2, 125); + break; + case 61: + if ((active1 & 0x400000000000000L) != 0L) + return jjStopAtPos(2, 122); + else if ((active1 & 0x800000000000000L) != 0L) + return jjStopAtPos(2, 123); + break; + case 62: + if ((active2 & 0x1L) != 0L) + { + jjmatchedKind = 128; + jjmatchedPos = 2; + } + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x1000000000000000L, active2, 0L); + case 97: + return jjMoveStringLiteralDfa3_0(active0, 0x808000000180000L, active1, 0L, active2, 0L); + case 98: + return jjMoveStringLiteralDfa3_0(active0, 0x1000000000000L, active1, 0L, active2, 0L); + case 99: + return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L, active1, 0L, active2, 0L); + case 101: + return jjMoveStringLiteralDfa3_0(active0, 0x8000L, active1, 0L, active2, 0L); + case 102: + return jjMoveStringLiteralDfa3_0(active0, 0x800000L, active1, 0L, active2, 0L); + case 105: + return jjMoveStringLiteralDfa3_0(active0, 0x4140400000000000L, active1, 0x1L, active2, 0L); + case 108: + return jjMoveStringLiteralDfa3_0(active0, 0x8000100020000000L, active1, 0L, active2, 0L); + case 110: + return jjMoveStringLiteralDfa3_0(active0, 0x800200c0600000L, active1, 0L, active2, 0L); + case 111: + return jjMoveStringLiteralDfa3_0(active0, 0x4800100004000L, active1, 0L, active2, 0L); + case 112: + return jjMoveStringLiteralDfa3_0(active0, 0x20003000000000L, active1, 0L, active2, 0L); + case 114: + if ((active0 & 0x200000000L) != 0L) + return jjStartNfaWithStates_0(2, 33, 43); + return jjMoveStringLiteralDfa3_0(active0, 0x610000000000000L, active1, 0L, active2, 0L); + case 115: + return jjMoveStringLiteralDfa3_0(active0, 0x4004023000L, active1, 0L, active2, 0L); + case 116: + if ((active0 & 0x8000000000L) != 0L) + { + jjmatchedKind = 39; + jjmatchedPos = 2; + } + return jjMoveStringLiteralDfa3_0(active0, 0x2050410050000L, active1, 0L, active2, 0L); + case 117: + return jjMoveStringLiteralDfa3_0(active0, 0x100000000a000000L, active1, 0L, active2, 0L); + case 119: + if ((active0 & 0x80000000000L) != 0L) + return jjStartNfaWithStates_0(2, 43, 43); + break; + case 121: + if ((active0 & 0x2000000000000000L) != 0L) + return jjStartNfaWithStates_0(2, 61, 43); + break; + default : + break; + } + return jjStartNfa_0(1, active0, active1, active2); +} +private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1, long old2, long active2) +{ + if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) + return jjStartNfa_0(1, old0, old1, old2); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(2, active0, active1, 0L); + return 3; + } + switch(curChar) + { + case 61: + if ((active1 & 0x1000000000000000L) != 0L) + return jjStopAtPos(3, 124); + break; + case 97: + return jjMoveStringLiteralDfa4_0(active0, 0x80000001c0808000L, active1, 0L); + case 98: + return jjMoveStringLiteralDfa4_0(active0, 0x2000000L, active1, 0L); + case 99: + return jjMoveStringLiteralDfa4_0(active0, 0x80000000040000L, active1, 0L); + case 100: + if ((active0 & 0x4000000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 62, 43); + break; + case 101: + if ((active0 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(3, 16, 43); + else if ((active0 & 0x20000L) != 0L) + return jjStartNfaWithStates_0(3, 17, 43); + else if ((active0 & 0x4000000L) != 0L) + return jjStartNfaWithStates_0(3, 26, 43); + else if ((active0 & 0x1000000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 60, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x20010010002000L, active1, 0L); + case 103: + if ((active0 & 0x20000000000L) != 0L) + return jjStartNfaWithStates_0(3, 41, 43); + break; + case 105: + return jjMoveStringLiteralDfa4_0(active0, 0x10040000000000L, active1, 0L); + case 107: + return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L, active1, 0L); + case 108: + if ((active0 & 0x100000000000L) != 0L) + return jjStartNfaWithStates_0(3, 44, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x1001000004000L, active1, 0x1L); + case 109: + if ((active0 & 0x8000000L) != 0L) + return jjStartNfaWithStates_0(3, 27, 43); + break; + case 110: + return jjMoveStringLiteralDfa4_0(active0, 0x800000000000000L, active1, 0L); + case 111: + if ((active0 & 0x400000000L) != 0L) + return jjStartNfaWithStates_0(3, 34, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x600002000000000L, active1, 0L); + case 114: + if ((active0 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(3, 19, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L, active1, 0L); + case 115: + if ((active0 & 0x100000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 56, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x20300000L, active1, 0L); + case 116: + return jjMoveStringLiteralDfa4_0(active0, 0x48804000401000L, active1, 0L); + case 117: + return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L, active1, 0L); + case 118: + return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(2, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(2, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(3, active0, active1, 0L); + return 4; + } + switch(curChar) + { + case 97: + return jjMoveStringLiteralDfa5_0(active0, 0x604000000000L, active1, 0L); + case 99: + return jjMoveStringLiteralDfa5_0(active0, 0x50000000000000L, active1, 0L); + case 101: + if ((active0 & 0x20000000L) != 0L) + return jjStartNfaWithStates_0(4, 29, 43); + else if ((active1 & 0x1L) != 0L) + return jjStartNfaWithStates_0(4, 64, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x801000004000L, active1, 0L); + case 104: + if ((active0 & 0x40000L) != 0L) + return jjStartNfaWithStates_0(4, 18, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L, active1, 0L); + case 105: + return jjMoveStringLiteralDfa5_0(active0, 0x9000000400000L, active1, 0L); + case 107: + if ((active0 & 0x8000L) != 0L) + return jjStartNfaWithStates_0(4, 15, 43); + break; + case 108: + if ((active0 & 0x40000000L) != 0L) + { + jjmatchedKind = 30; + jjmatchedPos = 4; + } + return jjMoveStringLiteralDfa5_0(active0, 0x82000000L, active1, 0L); + case 110: + return jjMoveStringLiteralDfa5_0(active0, 0x10000000L, active1, 0L); + case 114: + if ((active0 & 0x20000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 53, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x2012000003000L, active1, 0L); + case 115: + if ((active0 & 0x100000L) != 0L) + return jjStartNfaWithStates_0(4, 20, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x800000000000000L, active1, 0L); + case 116: + if ((active0 & 0x200000L) != 0L) + return jjStartNfaWithStates_0(4, 21, 43); + else if ((active0 & 0x100000000L) != 0L) + return jjStartNfaWithStates_0(4, 32, 43); + else if ((active0 & 0x4000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 50, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x8000000000000000L, active1, 0L); + case 117: + return jjMoveStringLiteralDfa5_0(active0, 0x800000L, active1, 0L); + case 118: + return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L, active1, 0L); + case 119: + if ((active0 & 0x200000000000000L) != 0L) + { + jjmatchedKind = 57; + jjmatchedPos = 4; + } + return jjMoveStringLiteralDfa5_0(active0, 0x400000000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(3, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(3, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(4, active0, 0L, 0L); + return 5; + } + switch(curChar) + { + case 97: + return jjMoveStringLiteralDfa6_0(active0, 0x5000L); + case 99: + if ((active0 & 0x1000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 48, 43); + else if ((active0 & 0x8000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 51, 43); + return jjMoveStringLiteralDfa6_0(active0, 0x800000000000L); + case 100: + return jjMoveStringLiteralDfa6_0(active0, 0x10000000L); + case 101: + if ((active0 & 0x2000000L) != 0L) + return jjStartNfaWithStates_0(5, 25, 43); + else if ((active0 & 0x40000000000L) != 0L) + return jjStartNfaWithStates_0(5, 42, 43); + break; + case 102: + return jjMoveStringLiteralDfa6_0(active0, 0x10000000000L); + case 103: + return jjMoveStringLiteralDfa6_0(active0, 0x200000000000L); + case 104: + if ((active0 & 0x40000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 54, 43); + break; + case 105: + return jjMoveStringLiteralDfa6_0(active0, 0x8800000000000000L); + case 108: + return jjMoveStringLiteralDfa6_0(active0, 0x80800000L); + case 109: + return jjMoveStringLiteralDfa6_0(active0, 0x1000000000L); + case 110: + if ((active0 & 0x2000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 49, 43); + return jjMoveStringLiteralDfa6_0(active0, 0x4000400000L); + case 114: + return jjMoveStringLiteralDfa6_0(active0, 0x80000000000000L); + case 115: + if ((active0 & 0x400000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 58, 43); + break; + case 116: + if ((active0 & 0x2000L) != 0L) + return jjStartNfaWithStates_0(5, 13, 43); + else if ((active0 & 0x2000000000L) != 0L) + return jjStartNfaWithStates_0(5, 37, 43); + return jjMoveStringLiteralDfa6_0(active0, 0x10400000000000L); + default : + break; + } + return jjStartNfa_0(4, active0, 0L, 0L); +} +private int jjMoveStringLiteralDfa6_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(4, old0, 0L, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(5, active0, 0L, 0L); + return 6; + } + switch(curChar) + { + case 97: + return jjMoveStringLiteralDfa7_0(active0, 0x10000000000L); + case 99: + return jjMoveStringLiteralDfa7_0(active0, 0x4000001000L); + case 101: + if ((active0 & 0x200000000000L) != 0L) + return jjStartNfaWithStates_0(6, 45, 43); + else if ((active0 & 0x400000000000L) != 0L) + return jjStartNfaWithStates_0(6, 46, 43); + return jjMoveStringLiteralDfa7_0(active0, 0x800001000000000L); + case 102: + return jjMoveStringLiteralDfa7_0(active0, 0x10000000000000L); + case 108: + return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000000L); + case 110: + if ((active0 & 0x4000L) != 0L) + return jjStartNfaWithStates_0(6, 14, 43); + break; + case 111: + return jjMoveStringLiteralDfa7_0(active0, 0x80000000000000L); + case 115: + if ((active0 & 0x10000000L) != 0L) + return jjStartNfaWithStates_0(6, 28, 43); + break; + case 116: + if ((active0 & 0x800000L) != 0L) + return jjStartNfaWithStates_0(6, 23, 43); + return jjMoveStringLiteralDfa7_0(active0, 0x800000000000L); + case 117: + return jjMoveStringLiteralDfa7_0(active0, 0x400000L); + case 121: + if ((active0 & 0x80000000L) != 0L) + return jjStartNfaWithStates_0(6, 31, 43); + break; + default : + break; + } + return jjStartNfa_0(5, active0, 0L, 0L); +} +private int jjMoveStringLiteralDfa7_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(5, old0, 0L, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(6, active0, 0L, 0L); + return 7; + } + switch(curChar) + { + case 99: + return jjMoveStringLiteralDfa8_0(active0, 0x10000000000L); + case 101: + if ((active0 & 0x400000L) != 0L) + return jjStartNfaWithStates_0(7, 22, 43); + else if ((active0 & 0x8000000000000000L) != 0L) + return jjStartNfaWithStates_0(7, 63, 43); + return jjMoveStringLiteralDfa8_0(active0, 0x804000000000L); + case 110: + return jjMoveStringLiteralDfa8_0(active0, 0x880001000000000L); + case 112: + if ((active0 & 0x10000000000000L) != 0L) + return jjStartNfaWithStates_0(7, 52, 43); + break; + case 116: + if ((active0 & 0x1000L) != 0L) + return jjStartNfaWithStates_0(7, 12, 43); + break; + default : + break; + } + return jjStartNfa_0(6, active0, 0L, 0L); +} +private int jjMoveStringLiteralDfa8_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(6, old0, 0L, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(7, active0, 0L, 0L); + return 8; + } + switch(curChar) + { + case 100: + if ((active0 & 0x800000000000L) != 0L) + return jjStartNfaWithStates_0(8, 47, 43); + break; + case 101: + if ((active0 & 0x10000000000L) != 0L) + return jjStartNfaWithStates_0(8, 40, 43); + break; + case 105: + return jjMoveStringLiteralDfa9_0(active0, 0x80000000000000L); + case 111: + return jjMoveStringLiteralDfa9_0(active0, 0x4000000000L); + case 116: + if ((active0 & 0x800000000000000L) != 0L) + return jjStartNfaWithStates_0(8, 59, 43); + return jjMoveStringLiteralDfa9_0(active0, 0x1000000000L); + default : + break; + } + return jjStartNfa_0(7, active0, 0L, 0L); +} +private int jjMoveStringLiteralDfa9_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(7, old0, 0L, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(8, active0, 0L, 0L); + return 9; + } + switch(curChar) + { + case 102: + if ((active0 & 0x4000000000L) != 0L) + return jjStartNfaWithStates_0(9, 38, 43); + break; + case 115: + if ((active0 & 0x1000000000L) != 0L) + return jjStartNfaWithStates_0(9, 36, 43); + break; + case 122: + return jjMoveStringLiteralDfa10_0(active0, 0x80000000000000L); + default : + break; + } + return jjStartNfa_0(8, active0, 0L, 0L); +} +private int jjMoveStringLiteralDfa10_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(8, old0, 0L, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(9, active0, 0L, 0L); + return 10; + } + switch(curChar) + { + case 101: + return jjMoveStringLiteralDfa11_0(active0, 0x80000000000000L); + default : + break; + } + return jjStartNfa_0(9, active0, 0L, 0L); +} +private int jjMoveStringLiteralDfa11_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(9, old0, 0L, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(10, active0, 0L, 0L); + return 11; + } + switch(curChar) + { + case 100: + if ((active0 & 0x80000000000000L) != 0L) + return jjStartNfaWithStates_0(11, 55, 43); + break; + default : + break; + } + return jjStartNfa_0(10, active0, 0L, 0L); +} +private int jjStartNfaWithStates_0(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_0(state, pos + 1); +} +static final long[] jjbitVec0 = { + 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec2 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec3 = { + 0xfff0000000200002L, 0xffffffffffffdfffL, 0xfffff00f7fffffffL, 0x12000000007fffffL +}; +static final long[] jjbitVec4 = { + 0x0L, 0x0L, 0x420043c00000000L, 0xff7fffffff7fffffL +}; +static final long[] jjbitVec5 = { + 0x7fffffffffffffL, 0xffffffffffff0000L, 0xffffffffffffffffL, 0x401f0003ffc3L +}; +static final long[] jjbitVec6 = { + 0x0L, 0x400000000000000L, 0xfffffffbffffd740L, 0xfbfffffffff7fffL +}; +static final long[] jjbitVec7 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffffc03L, 0x33fffffffff7fffL +}; +static final long[] jjbitVec8 = { + 0xfffe00000000ffffL, 0xfffffffe027fffffL, 0xffL, 0x707ffffff0000L +}; +static final long[] jjbitVec9 = { + 0x7fffffe00000000L, 0xfffec000000007ffL, 0xffffffffffffffffL, 0x9c00c060002fffffL +}; +static final long[] jjbitVec10 = { + 0xfffffffd0000L, 0xe000L, 0x2003fffffffffL, 0x0L +}; +static final long[] jjbitVec11 = { + 0x23fffffffffffff0L, 0x3ff010000L, 0x23c5fdfffff99fe0L, 0xf0003b0000000L +}; +static final long[] jjbitVec12 = { + 0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbbfe0L, 0x2000300010000L +}; +static final long[] jjbitVec13 = { + 0x23edfdfffff99fe0L, 0x20003b0000000L, 0x3bfc718d63dc7e8L, 0x200000000000000L +}; +static final long[] jjbitVec14 = { + 0x3effdfffffddfe0L, 0x300000000L, 0x23effdfffffddfe0L, 0x340000000L +}; +static final long[] jjbitVec15 = { + 0x3fffdfffffddfe0L, 0x300000000L, 0x2ffbfffffc7fffe0L, 0x7fL +}; +static final long[] jjbitVec16 = { + 0x800dfffffffffffeL, 0x7fL, 0x200decaefef02596L, 0x3000005fL +}; +static final long[] jjbitVec17 = { + 0x1L, 0x7fffffffeffL, 0xf00L, 0x0L +}; +static final long[] jjbitVec18 = { + 0x6fbffffffffL, 0x3f0000L, 0xffffffff00000000L, 0x1ffffffffff003fL +}; +static final long[] jjbitVec19 = { + 0xffffffffffffffffL, 0xffffffff83ffffffL, 0xffffff07ffffffffL, 0x3ffffffffffffffL +}; +static final long[] jjbitVec20 = { + 0xffffffffffffff7fL, 0xffffffff3d7f3d7fL, 0x7f3d7fffffff3d7fL, 0xffff7fffff7f7f3dL +}; +static final long[] jjbitVec21 = { + 0xffffffff7f3d7fffL, 0x7ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL +}; +static final long[] jjbitVec22 = { + 0xffffffffffffffffL, 0x7f9fffffffffffL, 0xffffffff07fffffeL, 0x1c7ffffffffffL +}; +static final long[] jjbitVec23 = { + 0x3ffff0003dfffL, 0x1dfff0003ffffL, 0xfffffffffffffL, 0x18800000L +}; +static final long[] jjbitVec24 = { + 0xffffffff00000000L, 0xffffffffffffffL, 0x1ffffffffffL, 0x0L +}; +static final long[] jjbitVec25 = { + 0x1fffffffL, 0x1f3fffffff0000L, 0x0L, 0x0L +}; +static final long[] jjbitVec26 = { + 0xffffffffffffffffL, 0xfffffffffffL, 0x0L, 0x0L +}; +static final long[] jjbitVec27 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL +}; +static final long[] jjbitVec28 = { + 0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL +}; +static final long[] jjbitVec29 = { + 0x8000000000000000L, 0x8002000000100001L, 0x3ffff00000000L, 0x0L +}; +static final long[] jjbitVec30 = { + 0xe3fbbd503e2ffc84L, 0xffffffff000003e0L, 0xfL, 0x0L +}; +static final long[] jjbitVec31 = { + 0x1f3e03fe000000e0L, 0xfffffffffffffffeL, 0xfffffffee07fffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec32 = { + 0xfffe1fffffffffe0L, 0xffffffffffffffffL, 0xffffff00007fffL, 0xffff000000000000L +}; +static final long[] jjbitVec33 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffL, 0x0L +}; +static final long[] jjbitVec34 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L +}; +static final long[] jjbitVec35 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0x1fffL, 0x0L +}; +static final long[] jjbitVec36 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L +}; +static final long[] jjbitVec37 = { + 0x6L, 0x0L, 0x0L, 0x0L +}; +static final long[] jjbitVec38 = { + 0xffff3fffffffffffL, 0x7ffffffffffL, 0x0L, 0x0L +}; +static final long[] jjbitVec39 = { + 0x5f7ffdffa0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L +}; +static final long[] jjbitVec40 = { + 0x3fffffffffffffffL, 0xffffffffffff0000L, 0xfffffffffffcffffL, 0x1fff0000000000ffL +}; +static final long[] jjbitVec41 = { + 0x18000000000000L, 0xffdf02000000e000L, 0xffffffffffffffffL, 0x1fffffffffffffffL +}; +static final long[] jjbitVec42 = { + 0x87fffffe00000010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0x631cfcfcfcL +}; +static final long[] jjbitVec43 = { + 0x0L, 0x0L, 0x420243cffffffffL, 0xff7fffffff7fffffL +}; +static final long[] jjbitVec44 = { + 0xffffffffffffffffL, 0x400ffffe0ffffffL, 0xfffffffbffffd740L, 0xfbfffffffff7fffL +}; +static final long[] jjbitVec45 = { + 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffffc7bL, 0x33fffffffff7fffL +}; +static final long[] jjbitVec46 = { + 0xfffe00000000ffffL, 0xfffffffe027fffffL, 0xbbfffffbfffe00ffL, 0x707ffffff0016L +}; +static final long[] jjbitVec47 = { + 0x7fffffe003f000fL, 0xffffc3ff01ffffffL, 0xffffffffffffffffL, 0x9ffffdffbfefffffL +}; +static final long[] jjbitVec48 = { + 0xffffffffffff8000L, 0xe7ffL, 0x3ffffffffffffL, 0x0L +}; +static final long[] jjbitVec49 = { + 0xf3fffffffffffffeL, 0xffcfff1f3fffL, 0xf3c5fdfffff99feeL, 0xfffcfb080399fL +}; +static final long[] jjbitVec50 = { + 0xd36dfdfffff987eeL, 0x1fffc05e003987L, 0xf3edfdfffffbbfeeL, 0x2ffcf00013bbfL +}; +static final long[] jjbitVec51 = { + 0xf3edfdfffff99feeL, 0x2ffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0x200ff8000803dc7L +}; +static final long[] jjbitVec52 = { + 0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xf3effdfffffddfecL, 0xffc340603ddfL +}; +static final long[] jjbitVec53 = { + 0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x2ffbfffffc7fffecL, 0xc0000ff5f847fL +}; +static final long[] jjbitVec54 = { + 0x87fffffffffffffeL, 0x3ff7fffL, 0x3bffecaefef02596L, 0x33ff3f5fL +}; +static final long[] jjbitVec55 = { + 0xc2a003ff03000001L, 0xfffe07fffffffeffL, 0x1ffffffffeff0fdfL, 0x40L +}; +static final long[] jjbitVec56 = { + 0x3c7f6fbffffffffL, 0x3ff03ffL, 0xffffffff00000000L, 0x1ffffffffff003fL +}; +static final long[] jjbitVec57 = { + 0xffffffff7f3d7fffL, 0x3fe0007ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL +}; +static final long[] jjbitVec58 = { + 0x1fffff001fdfffL, 0xddfff000fffffL, 0xffffffffffffffffL, 0x3ff388fffffL +}; +static final long[] jjbitVec59 = { + 0xffffffff03ff3800L, 0xffffffffffffffL, 0x3ffffffffffL, 0x0L +}; +static final long[] jjbitVec60 = { + 0xfff0fff1fffffffL, 0x1f3fffffffffc0L, 0x0L, 0x0L +}; +static final long[] jjbitVec61 = { + 0x80007c000000f000L, 0x8002fc0f00100001L, 0x3ffff00000000L, 0x7e21fff0000L +}; +static final long[] jjbitVec62 = { + 0x1f3efffe000000e0L, 0xfffffffffffffffeL, 0xfffffffee67fffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec63 = { + 0x10000000000006L, 0x0L, 0x0L, 0x0L +}; +static final long[] jjbitVec64 = { + 0x3L, 0x0L, 0x0L, 0x0L +}; +static final long[] jjbitVec65 = { + 0x0L, 0x800000000000000L, 0x0L, 0x0L +}; +static final long[] jjbitVec66 = { + 0x5f7ffdffe0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L +}; +static final long[] jjbitVec67 = { + 0x18000f0000ffffL, 0xffdf02000000e000L, 0xffffffffffffffffL, 0x9fffffffffffffffL +}; +static final long[] jjbitVec68 = { + 0x87fffffe03ff0010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0xe0000631cfcfcfcL +}; +private int jjMoveNfa_0(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 130; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 45: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 50; + else if (curChar == 47) + { + if (kind > 6) + kind = 6; + jjCheckNAddStates(0, 2); + } + break; + case 0: + if ((0x3ff000000000000L & l) != 0L) + { + if (kind > 66) + kind = 66; + jjCheckNAddStates(3, 17); + } + else if (curChar == 47) + jjAddStates(18, 19); + else if (curChar == 36) + { + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + } + else if (curChar == 34) + jjCheckNAddStates(20, 23); + else if (curChar == 39) + jjAddStates(24, 26); + else if (curChar == 46) + jjCheckNAdd(1); + if (curChar == 48) + jjAddStates(27, 34); + break; + case 1: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(35, 38); + break; + case 2: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(2, 3); + break; + case 3: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(39, 41); + break; + case 5: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(6); + break; + case 6: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(42, 44); + break; + case 7: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(7, 8); + break; + case 8: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddTwoStates(6, 9); + break; + case 10: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(45, 48); + break; + case 11: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(49, 53); + break; + case 12: + if (curChar == 39) + jjAddStates(24, 26); + break; + case 13: + if ((0xffffff7fffffdbffL & l) != 0L) + jjCheckNAdd(14); + break; + case 14: + if (curChar == 39 && kind > 76) + kind = 76; + break; + case 16: + if ((0x8400000000L & l) != 0L) + jjCheckNAdd(14); + break; + case 17: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddTwoStates(18, 14); + break; + case 18: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(14); + break; + case 19: + if ((0xf000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 20; + break; + case 20: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(18); + break; + case 22: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 23; + break; + case 23: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 24; + break; + case 24: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 25; + break; + case 25: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAdd(14); + break; + case 27: + if (curChar == 34) + jjCheckNAddStates(20, 23); + break; + case 28: + if ((0xfffffffbffffdbffL & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 30: + if ((0x8400000000L & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 32: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 33; + break; + case 33: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 34; + break; + case 34: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 35; + break; + case 35: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 37: + if (curChar == 34 && kind > 77) + kind = 77; + break; + case 38: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddStates(54, 58); + break; + case 39: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 40: + if ((0xf000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 41; + break; + case 41: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(39); + break; + case 42: + if (curChar != 36) + break; + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + break; + case 43: + if ((0x3ff00100fffc1ffL & l) == 0L) + break; + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + break; + case 44: + if (curChar == 47) + jjAddStates(18, 19); + break; + case 46: + if ((0xffffffffffffdbffL & l) == 0L) + break; + if (kind > 6) + kind = 6; + jjCheckNAddStates(0, 2); + break; + case 47: + if ((0x2400L & l) != 0L && kind > 6) + kind = 6; + break; + case 48: + if (curChar == 10 && kind > 6) + kind = 6; + break; + case 49: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 48; + break; + case 50: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 51; + break; + case 51: + if ((0xffff7fffffffffffL & l) != 0L && kind > 7) + kind = 7; + break; + case 52: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 50; + break; + case 53: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 66) + kind = 66; + jjCheckNAddStates(3, 17); + break; + case 54: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(54, 55); + break; + case 55: + case 98: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAdd(56); + break; + case 57: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(57, 58); + break; + case 58: + case 109: + if ((0x3ff000000000000L & l) != 0L && kind > 66) + kind = 66; + break; + case 59: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(59, 60); + break; + case 60: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(59, 61); + break; + case 61: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(62, 65); + break; + case 63: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(64); + break; + case 64: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(66, 68); + break; + case 65: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(65, 66); + break; + case 66: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(64, 9); + break; + case 67: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(69, 72); + break; + case 68: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(73, 77); + break; + case 69: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(69, 70); + break; + case 70: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(71, 72); + break; + case 71: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(78, 80); + break; + case 73: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(74); + break; + case 74: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(81, 83); + break; + case 75: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(75, 76); + break; + case 76: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddTwoStates(74, 9); + break; + case 77: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(84, 87); + break; + case 78: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(88, 91); + break; + case 79: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(79, 80); + break; + case 80: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(81, 82); + break; + case 81: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(92, 94); + break; + case 82: + if (curChar != 46) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(95, 97); + break; + case 83: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(98, 101); + break; + case 84: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(84, 85); + break; + case 85: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(95, 97); + break; + case 87: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(88); + break; + case 88: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(102, 104); + break; + case 89: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(89, 90); + break; + case 90: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddTwoStates(88, 9); + break; + case 91: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(105, 108); + break; + case 92: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddStates(109, 113); + break; + case 93: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(114, 117); + break; + case 94: + if (curChar == 48) + jjAddStates(27, 34); + break; + case 96: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(118, 120); + break; + case 97: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(97, 98); + break; + case 99: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddStates(121, 123); + break; + case 100: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddTwoStates(100, 101); + break; + case 101: + if ((0xff000000000000L & l) != 0L) + jjCheckNAdd(56); + break; + case 103: + if ((0x3000000000000L & l) != 0L) + jjCheckNAddStates(124, 126); + break; + case 104: + if ((0x3000000000000L & l) != 0L) + jjCheckNAddTwoStates(104, 105); + break; + case 105: + if ((0x3000000000000L & l) != 0L) + jjCheckNAdd(56); + break; + case 107: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 66) + kind = 66; + jjCheckNAddTwoStates(108, 109); + break; + case 108: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(108, 109); + break; + case 110: + if ((0xff000000000000L & l) == 0L) + break; + if (kind > 66) + kind = 66; + jjCheckNAddTwoStates(111, 112); + break; + case 111: + if ((0xff000000000000L & l) != 0L) + jjCheckNAddTwoStates(111, 112); + break; + case 112: + if ((0xff000000000000L & l) != 0L && kind > 66) + kind = 66; + break; + case 114: + if ((0x3000000000000L & l) == 0L) + break; + if (kind > 66) + kind = 66; + jjCheckNAddTwoStates(115, 116); + break; + case 115: + if ((0x3000000000000L & l) != 0L) + jjCheckNAddTwoStates(115, 116); + break; + case 116: + if ((0x3000000000000L & l) != 0L && kind > 66) + kind = 66; + break; + case 118: + if ((0x3ff000000000000L & l) != 0L) + jjAddStates(127, 128); + break; + case 119: + if (curChar == 46) + jjCheckNAdd(120); + break; + case 120: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(120, 121); + break; + case 122: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(123); + break; + case 123: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddTwoStates(123, 9); + break; + case 125: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(129, 131); + break; + case 126: + if (curChar == 46) + jjCheckNAdd(127); + break; + case 128: + if ((0x280000000000L & l) != 0L) + jjCheckNAdd(129); + break; + case 129: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 71) + kind = 71; + jjCheckNAddTwoStates(129, 9); + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + break; + case 2: + if (curChar == 95) + jjAddStates(132, 133); + break; + case 4: + if ((0x2000000020L & l) != 0L) + jjAddStates(134, 135); + break; + case 7: + if (curChar == 95) + jjAddStates(136, 137); + break; + case 9: + if ((0x5000000050L & l) != 0L && kind > 71) + kind = 71; + break; + case 13: + if ((0xffffffffefffffffL & l) != 0L) + jjCheckNAdd(14); + break; + case 15: + if (curChar == 92) + jjAddStates(138, 140); + break; + case 16: + if ((0x14404410000000L & l) != 0L) + jjCheckNAdd(14); + break; + case 21: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 22; + break; + case 22: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 23; + break; + case 23: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 24; + break; + case 24: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 25; + break; + case 25: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAdd(14); + break; + case 26: + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 21; + break; + case 28: + if ((0xffffffffefffffffL & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 29: + if (curChar == 92) + jjAddStates(141, 143); + break; + case 30: + if ((0x14404410000000L & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 31: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 32; + break; + case 32: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 33; + break; + case 33: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 34; + break; + case 34: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 35; + break; + case 35: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(20, 23); + break; + case 36: + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 31; + break; + case 43: + if ((0x87fffffe87fffffeL & l) == 0L) + break; + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + break; + case 46: + if (kind > 6) + kind = 6; + jjAddStates(0, 2); + break; + case 51: + if (kind > 7) + kind = 7; + break; + case 54: + if (curChar == 95) + jjAddStates(144, 145); + break; + case 56: + if ((0x100000001000L & l) != 0L && kind > 65) + kind = 65; + break; + case 57: + if (curChar == 95) + jjAddStates(146, 147); + break; + case 59: + if (curChar == 95) + jjAddStates(148, 149); + break; + case 62: + if ((0x2000000020L & l) != 0L) + jjAddStates(150, 151); + break; + case 65: + if (curChar == 95) + jjAddStates(152, 153); + break; + case 69: + if (curChar == 95) + jjAddStates(154, 155); + break; + case 72: + if ((0x2000000020L & l) != 0L) + jjAddStates(156, 157); + break; + case 75: + if (curChar == 95) + jjAddStates(158, 159); + break; + case 79: + if (curChar == 95) + jjAddStates(160, 161); + break; + case 84: + if (curChar == 95) + jjAddStates(162, 163); + break; + case 86: + if ((0x2000000020L & l) != 0L) + jjAddStates(164, 165); + break; + case 89: + if (curChar == 95) + jjAddStates(166, 167); + break; + case 95: + if ((0x100000001000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 96; + break; + case 96: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(118, 120); + break; + case 97: + if ((0x7e8000007eL & l) != 0L) + jjCheckNAddTwoStates(97, 98); + break; + case 98: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAdd(56); + break; + case 100: + if (curChar == 95) + jjAddStates(168, 169); + break; + case 102: + if ((0x400000004L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 103; + break; + case 104: + if (curChar == 95) + jjAddStates(170, 171); + break; + case 106: + if ((0x100000001000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 107; + break; + case 107: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 66) + kind = 66; + jjCheckNAddTwoStates(108, 109); + break; + case 108: + if ((0x7e8000007eL & l) != 0L) + jjCheckNAddTwoStates(108, 109); + break; + case 109: + if ((0x7e0000007eL & l) != 0L && kind > 66) + kind = 66; + break; + case 111: + if (curChar == 95) + jjAddStates(172, 173); + break; + case 113: + if ((0x400000004L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 114; + break; + case 115: + if (curChar == 95) + jjAddStates(174, 175); + break; + case 117: + if ((0x100000001000000L & l) != 0L) + jjCheckNAddTwoStates(118, 119); + break; + case 118: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddTwoStates(118, 119); + break; + case 120: + if ((0x7e0000007eL & l) != 0L) + jjAddStates(176, 177); + break; + case 121: + if ((0x1000000010000L & l) != 0L) + jjAddStates(178, 179); + break; + case 124: + if ((0x100000001000000L & l) != 0L) + jjCheckNAdd(125); + break; + case 125: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(129, 131); + break; + case 127: + if ((0x1000000010000L & l) != 0L) + jjAddStates(180, 181); + break; + default : break; + } + } while(i != startsAt); + } + else + { + int hiByte = (int)(curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 0: + if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) + break; + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + break; + case 13: + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + jjstateSet[jjnewStateCnt++] = 14; + break; + case 28: + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + jjAddStates(20, 23); + break; + case 43: + if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) + break; + if (kind > 78) + kind = 78; + jjCheckNAdd(43); + break; + case 46: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 6) + kind = 6; + jjAddStates(0, 2); + break; + case 51: + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 7) + kind = 7; + break; + default : break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 130 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private int jjMoveStringLiteralDfa0_2() +{ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_2(0x400L); + default : + return 1; + } +} +private int jjMoveStringLiteralDfa1_2(long active0) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + return 1; + } + switch(curChar) + { + case 47: + if ((active0 & 0x400L) != 0L) + return jjStopAtPos(1, 10); + break; + default : + return 2; + } + return 2; +} +private int jjMoveStringLiteralDfa0_1() +{ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_1(0x200L); + default : + return 1; + } +} +private int jjMoveStringLiteralDfa1_1(long active0) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + return 1; + } + switch(curChar) + { + case 47: + if ((active0 & 0x200L) != 0L) + return jjStopAtPos(1, 9); + break; + default : + return 2; + } + return 2; +} +static final int[] jjnextStates = { + 46, 47, 49, 54, 55, 56, 57, 58, 59, 62, 9, 69, 72, 79, 82, 93, + 78, 68, 45, 52, 28, 29, 36, 37, 13, 15, 26, 95, 99, 102, 106, 110, + 113, 117, 124, 2, 4, 9, 11, 1, 4, 9, 7, 9, 10, 6, 7, 9, + 10, 1, 2, 4, 9, 11, 28, 29, 39, 36, 37, 61, 62, 9, 59, 62, + 9, 68, 65, 9, 67, 64, 65, 9, 67, 61, 59, 62, 9, 68, 69, 72, + 78, 75, 9, 77, 74, 75, 9, 77, 71, 69, 72, 78, 79, 82, 93, 83, + 86, 9, 84, 86, 9, 92, 89, 9, 91, 88, 89, 9, 91, 83, 84, 86, + 9, 92, 81, 79, 82, 93, 97, 98, 56, 100, 101, 56, 104, 105, 56, 118, + 119, 125, 126, 127, 2, 3, 5, 6, 7, 8, 16, 17, 19, 30, 38, 40, + 54, 55, 57, 58, 59, 60, 63, 64, 65, 66, 69, 70, 73, 74, 75, 76, + 79, 80, 84, 85, 87, 88, 89, 90, 100, 101, 104, 105, 111, 112, 115, 116, + 120, 121, 122, 123, 128, 129, +}; +private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) +{ + switch(hiByte) + { + case 0: + return ((jjbitVec2[i2] & l2) != 0L); + default : + if ((jjbitVec0[i1] & l1) != 0L) + return true; + return false; + } +} +private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) +{ + switch(hiByte) + { + case 0: + return ((jjbitVec4[i2] & l2) != 0L); + case 2: + return ((jjbitVec5[i2] & l2) != 0L); + case 3: + return ((jjbitVec6[i2] & l2) != 0L); + case 4: + return ((jjbitVec7[i2] & l2) != 0L); + case 5: + return ((jjbitVec8[i2] & l2) != 0L); + case 6: + return ((jjbitVec9[i2] & l2) != 0L); + case 7: + return ((jjbitVec10[i2] & l2) != 0L); + case 9: + return ((jjbitVec11[i2] & l2) != 0L); + case 10: + return ((jjbitVec12[i2] & l2) != 0L); + case 11: + return ((jjbitVec13[i2] & l2) != 0L); + case 12: + return ((jjbitVec14[i2] & l2) != 0L); + case 13: + return ((jjbitVec15[i2] & l2) != 0L); + case 14: + return ((jjbitVec16[i2] & l2) != 0L); + case 15: + return ((jjbitVec17[i2] & l2) != 0L); + case 16: + return ((jjbitVec18[i2] & l2) != 0L); + case 17: + return ((jjbitVec19[i2] & l2) != 0L); + case 18: + return ((jjbitVec20[i2] & l2) != 0L); + case 19: + return ((jjbitVec21[i2] & l2) != 0L); + case 20: + return ((jjbitVec0[i2] & l2) != 0L); + case 22: + return ((jjbitVec22[i2] & l2) != 0L); + case 23: + return ((jjbitVec23[i2] & l2) != 0L); + case 24: + return ((jjbitVec24[i2] & l2) != 0L); + case 25: + return ((jjbitVec25[i2] & l2) != 0L); + case 29: + return ((jjbitVec26[i2] & l2) != 0L); + case 30: + return ((jjbitVec27[i2] & l2) != 0L); + case 31: + return ((jjbitVec28[i2] & l2) != 0L); + case 32: + return ((jjbitVec29[i2] & l2) != 0L); + case 33: + return ((jjbitVec30[i2] & l2) != 0L); + case 48: + return ((jjbitVec31[i2] & l2) != 0L); + case 49: + return ((jjbitVec32[i2] & l2) != 0L); + case 77: + return ((jjbitVec33[i2] & l2) != 0L); + case 159: + return ((jjbitVec34[i2] & l2) != 0L); + case 164: + return ((jjbitVec35[i2] & l2) != 0L); + case 215: + return ((jjbitVec36[i2] & l2) != 0L); + case 216: + return ((jjbitVec37[i2] & l2) != 0L); + case 250: + return ((jjbitVec38[i2] & l2) != 0L); + case 251: + return ((jjbitVec39[i2] & l2) != 0L); + case 253: + return ((jjbitVec40[i2] & l2) != 0L); + case 254: + return ((jjbitVec41[i2] & l2) != 0L); + case 255: + return ((jjbitVec42[i2] & l2) != 0L); + default : + if ((jjbitVec3[i1] & l1) != 0L) + return true; + return false; + } +} +private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) +{ + switch(hiByte) + { + case 0: + return ((jjbitVec43[i2] & l2) != 0L); + case 2: + return ((jjbitVec5[i2] & l2) != 0L); + case 3: + return ((jjbitVec44[i2] & l2) != 0L); + case 4: + return ((jjbitVec45[i2] & l2) != 0L); + case 5: + return ((jjbitVec46[i2] & l2) != 0L); + case 6: + return ((jjbitVec47[i2] & l2) != 0L); + case 7: + return ((jjbitVec48[i2] & l2) != 0L); + case 9: + return ((jjbitVec49[i2] & l2) != 0L); + case 10: + return ((jjbitVec50[i2] & l2) != 0L); + case 11: + return ((jjbitVec51[i2] & l2) != 0L); + case 12: + return ((jjbitVec52[i2] & l2) != 0L); + case 13: + return ((jjbitVec53[i2] & l2) != 0L); + case 14: + return ((jjbitVec54[i2] & l2) != 0L); + case 15: + return ((jjbitVec55[i2] & l2) != 0L); + case 16: + return ((jjbitVec56[i2] & l2) != 0L); + case 17: + return ((jjbitVec19[i2] & l2) != 0L); + case 18: + return ((jjbitVec20[i2] & l2) != 0L); + case 19: + return ((jjbitVec57[i2] & l2) != 0L); + case 20: + return ((jjbitVec0[i2] & l2) != 0L); + case 22: + return ((jjbitVec22[i2] & l2) != 0L); + case 23: + return ((jjbitVec58[i2] & l2) != 0L); + case 24: + return ((jjbitVec59[i2] & l2) != 0L); + case 25: + return ((jjbitVec60[i2] & l2) != 0L); + case 29: + return ((jjbitVec26[i2] & l2) != 0L); + case 30: + return ((jjbitVec27[i2] & l2) != 0L); + case 31: + return ((jjbitVec28[i2] & l2) != 0L); + case 32: + return ((jjbitVec61[i2] & l2) != 0L); + case 33: + return ((jjbitVec30[i2] & l2) != 0L); + case 48: + return ((jjbitVec62[i2] & l2) != 0L); + case 49: + return ((jjbitVec32[i2] & l2) != 0L); + case 77: + return ((jjbitVec33[i2] & l2) != 0L); + case 159: + return ((jjbitVec34[i2] & l2) != 0L); + case 164: + return ((jjbitVec35[i2] & l2) != 0L); + case 215: + return ((jjbitVec36[i2] & l2) != 0L); + case 216: + return ((jjbitVec63[i2] & l2) != 0L); + case 220: + return ((jjbitVec64[i2] & l2) != 0L); + case 221: + return ((jjbitVec65[i2] & l2) != 0L); + case 250: + return ((jjbitVec38[i2] & l2) != 0L); + case 251: + return ((jjbitVec66[i2] & l2) != 0L); + case 253: + return ((jjbitVec40[i2] & l2) != 0L); + case 254: + return ((jjbitVec67[i2] & l2) != 0L); + case 255: + return ((jjbitVec68[i2] & l2) != 0L); + default : + if ((jjbitVec3[i1] & l1) != 0L) + return true; + return false; + } +} + +/** Token literal values. */ +public static final String[] jjstrLiteralImages = { +"", null, null, null, null, null, null, null, null, null, null, null, +"\141\142\163\164\162\141\143\164", "\141\163\163\145\162\164", "\142\157\157\154\145\141\156", +"\142\162\145\141\153", "\142\171\164\145", "\143\141\163\145", "\143\141\164\143\150", +"\143\150\141\162", "\143\154\141\163\163", "\143\157\156\163\164", +"\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164", "\144\157", "\144\157\165\142\154\145", +"\145\154\163\145", "\145\156\165\155", "\145\170\164\145\156\144\163", "\146\141\154\163\145", +"\146\151\156\141\154", "\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162", +"\147\157\164\157", "\151\146", "\151\155\160\154\145\155\145\156\164\163", +"\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146", "\151\156\164", +"\151\156\164\145\162\146\141\143\145", "\154\157\156\147", "\156\141\164\151\166\145", "\156\145\167", +"\156\165\154\154", "\160\141\143\153\141\147\145", "\160\162\151\166\141\164\145", +"\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143", "\162\145\164\165\162\156", +"\163\150\157\162\164", "\163\164\141\164\151\143", "\163\164\162\151\143\164\146\160", +"\163\165\160\145\162", "\163\167\151\164\143\150", +"\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163", "\164\150\162\157\167", "\164\150\162\157\167\163", +"\164\162\141\156\163\151\145\156\164", "\164\162\165\145", "\164\162\171", "\166\157\151\144", +"\166\157\154\141\164\151\154\145", "\167\150\151\154\145", null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, "\50", "\51", "\173", "\175", "\133", +"\135", "\73", "\54", "\56", "\100", "\75", "\74", "\41", "\176", "\77", "\72", +"\75\75", "\74\75", "\76\75", "\41\75", "\174\174", "\46\46", "\53\53", "\55\55", "\53", +"\55", "\52", "\57", "\46", "\174", "\136", "\45", "\74\74", "\53\75", "\55\75", +"\52\75", "\57\75", "\46\75", "\174\75", "\136\75", "\45\75", "\74\74\75", "\76\76\75", +"\76\76\76\75", "\56\56\56", "\55\76", "\72\72", "\76\76\76", "\76\76", "\76", "\32", +"\74\76", }; + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", + "IN_JAVA_DOC_COMMENT", + "IN_MULTI_LINE_COMMENT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, -1, -1, -1, -1, 1, 2, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, +}; +static final long[] jjtoToken = { + 0xfffffffffffff001L, 0xfffffffffffe7087L, 0x1fL, +}; +static final long[] jjtoSkip = { + 0x67eL, 0x0L, 0x0L, +}; +static final long[] jjtoSpecial = { + 0x640L, 0x0L, 0x0L, +}; +static final long[] jjtoMore = { + 0x980L, 0x0L, 0x0L, +}; +protected JavaCharStream input_stream; +private final int[] jjrounds = new int[130]; +private final int[] jjstateSet = new int[260]; +private final StringBuilder jjimage = new StringBuilder(); +private StringBuilder image = jjimage; +private int jjimageLen; +private int lengthOfMatch; +protected char curChar; +/** Constructor. */ +public ASTParserTokenManager(JavaCharStream stream){ + if (JavaCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + input_stream = stream; +} + +/** Constructor. */ +public ASTParserTokenManager(JavaCharStream stream, int lexState){ + this(stream); + SwitchTo(lexState); +} + +/** Reinitialise parser. */ +public void ReInit(JavaCharStream stream) +{ + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); +} +private void ReInitRounds() +{ + int i; + jjround = 0x80000001; + for (i = 130; i-- > 0;) + jjrounds[i] = 0x80000000; +} + +/** Reinitialise parser. */ +public void ReInit(JavaCharStream stream, int lexState) +{ + ReInit(stream); + SwitchTo(lexState); +} + +/** Switch to specified lex state. */ +public void SwitchTo(int lexState) +{ + if (lexState >= 3 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; +} + +protected Token jjFillToken() +{ + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; + String im = jjstrLiteralImages[jjmatchedKind]; + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = ASTParser.GTToken.newToken(jjmatchedKind, curTokenImage); + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + + return t; +} + +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; + +/** Get the next Token. */ +public Token getNextToken() +{ + Token specialToken = null; + Token matchedToken; + int curPos = 0; + + EOFLoop : + for (;;) + { + try + { + curChar = input_stream.BeginToken(); + } + catch(java.io.IOException e) + { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + return matchedToken; + } + image = jjimage; + image.setLength(0); + jjimageLen = 0; + + for (;;) + { + switch(curLexState) + { + case 0: + try { input_stream.backup(0); + while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) + curChar = input_stream.BeginToken(); + } + catch (java.io.IOException e1) { continue EOFLoop; } + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + break; + case 1: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_1(); + if (jjmatchedPos == 0 && jjmatchedKind > 11) + { + jjmatchedKind = 11; + } + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + if (jjmatchedPos == 0 && jjmatchedKind > 11) + { + jjmatchedKind = 11; + } + break; + } + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + TokenLexicalActions(matchedToken); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + return matchedToken; + } + else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + if (specialToken == null) + specialToken = matchedToken; + else + { + matchedToken.specialToken = specialToken; + specialToken = (specialToken.next = matchedToken); + } + SkipLexicalActions(matchedToken); + } + else + SkipLexicalActions(null); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + continue EOFLoop; + } + MoreLexicalActions(); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + curPos = 0; + jjmatchedKind = 0x7fffffff; + try { + curChar = input_stream.readChar(); + continue; + } + catch (java.io.IOException e1) { } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { input_stream.readChar(); input_stream.backup(1); } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } + } +} + +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + case 7 : + image.append(input_stream.GetSuffix(jjimageLen)); + jjimageLen = 0; + input_stream.backup(1); + break; + default : + break; + } +} +void TokenLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + case 128 : + image.append(jjstrLiteralImages[128]); + lengthOfMatch = jjstrLiteralImages[128].length(); + matchedToken.kind = GT; + ((ASTParser.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; + input_stream.backup(2); + break; + case 129 : + image.append(jjstrLiteralImages[129]); + lengthOfMatch = jjstrLiteralImages[129].length(); + matchedToken.kind = GT; + ((ASTParser.GTToken)matchedToken).realKind = RSIGNEDSHIFT; + input_stream.backup(1); + break; + default : + break; + } +} +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + +private void jjCheckNAddStates(int start, int end) +{ + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); +} + +} diff --git a/src/com/github/javaparser/JavaCharStream.java b/src/com/github/javaparser/JavaCharStream.java new file mode 100644 index 0000000..62a6544 --- /dev/null +++ b/src/com/github/javaparser/JavaCharStream.java @@ -0,0 +1,629 @@ +/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (with java-like unicode escape processing). + */ + +public +class JavaCharStream +{ + /** Whether parser is static. */ + public static final boolean staticFlag = false; + + static final int hexval(char c) throws java.io.IOException { + switch(c) + { + case '0' : + return 0; + case '1' : + return 1; + case '2' : + return 2; + case '3' : + return 3; + case '4' : + return 4; + case '5' : + return 5; + case '6' : + return 6; + case '7' : + return 7; + case '8' : + return 8; + case '9' : + return 9; + + case 'a' : + case 'A' : + return 10; + case 'b' : + case 'B' : + return 11; + case 'c' : + case 'C' : + return 12; + case 'd' : + case 'D' : + return 13; + case 'e' : + case 'E' : + return 14; + case 'f' : + case 'F' : + return 15; + } + + throw new java.io.IOException(); // Should never come here + } + +/** Position in buffer. */ + public int bufpos = -1; + int bufsize; + int available; + int tokenBegin; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] nextCharBuf; + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int nextCharInd = -1; + protected int inBuf = 0; + protected int tabSize = 8; + + protected void setTabSize(int i) { tabSize = i; } + protected int getTabSize(int i) { return tabSize; } + + protected void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + bufpos += (bufsize - tokenBegin); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + bufpos -= tokenBegin; + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + available = (bufsize += 2048); + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + int i; + if (maxNextCharInd == 4096) + maxNextCharInd = nextCharInd = 0; + + try { + if ((i = inputStream.read(nextCharBuf, maxNextCharInd, + 4096 - maxNextCharInd)) == -1) + { + inputStream.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + if (bufpos != 0) + { + --bufpos; + backup(0); + } + else + { + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + throw e; + } + } + + protected char ReadByte() throws java.io.IOException + { + if (++nextCharInd >= maxNextCharInd) + FillBuff(); + + return nextCharBuf[nextCharInd]; + } + +/** @return starting character for token. */ + public char BeginToken() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + tokenBegin = bufpos; + return buffer[bufpos]; + } + + tokenBegin = 0; + bufpos = -1; + + return readChar(); + } + + protected void AdjustBuffSize() + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = 0; + available = tokenBegin; + } + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (tabSize - (column % tabSize)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + +/** Read a character. */ + public char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + char c; + + if (++bufpos == available) + AdjustBuffSize(); + + if ((buffer[bufpos] = c = ReadByte()) == '\\') + { + UpdateLineColumn(c); + + int backSlashCnt = 1; + + for (;;) // Read all the backslashes + { + if (++bufpos == available) + AdjustBuffSize(); + + try + { + if ((buffer[bufpos] = c = ReadByte()) != '\\') + { + UpdateLineColumn(c); + // found a non-backslash char. + if ((c == 'u') && ((backSlashCnt & 1) == 1)) + { + if (--bufpos < 0) + bufpos = bufsize - 1; + + break; + } + + backup(backSlashCnt); + return '\\'; + } + } + catch(java.io.IOException e) + { + // We are returning one backslash so we should only backup (count-1) + if (backSlashCnt > 1) + backup(backSlashCnt-1); + + return '\\'; + } + + UpdateLineColumn(c); + backSlashCnt++; + } + + // Here, we have seen an odd number of backslash's followed by a 'u' + try + { + while ((c = ReadByte()) == 'u') + ++column; + + buffer[bufpos] = c = (char)(hexval(c) << 12 | + hexval(ReadByte()) << 8 | + hexval(ReadByte()) << 4 | + hexval(ReadByte())); + + column += 4; + } + catch(java.io.IOException e) + { + throw new Error("Invalid escape character at line " + line + + " column " + column + "."); + } + + if (backSlashCnt == 1) + return c; + else + { + backup(backSlashCnt - 1); + return '\\'; + } + } + else + { + UpdateLineColumn(c); + return c; + } + } + + @Deprecated + /** + * @deprecated + * @see #getEndColumn + */ + public int getColumn() { + return bufcolumn[bufpos]; + } + + @Deprecated + /** + * @deprecated + * @see #getEndLine + */ + public int getLine() { + return bufline[bufpos]; + } + +/** Get end column. */ + public int getEndColumn() { + return bufcolumn[bufpos]; + } + +/** Get end line. */ + public int getEndLine() { + return bufline[bufpos]; + } + +/** @return column of token start */ + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + +/** @return line number of token start */ + public int getBeginLine() { + return bufline[tokenBegin]; + } + +/** Retreat. */ + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + +/** Constructor. */ + public JavaCharStream(java.io.Reader dstream, + int startline, int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + nextCharBuf = new char[4096]; + } + +/** Constructor. */ + public JavaCharStream(java.io.Reader dstream, + int startline, int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + +/** Constructor. */ + public JavaCharStream(java.io.Reader dstream) + { + this(dstream, 1, 1, 4096); + } +/** Reinitialise. */ + public void ReInit(java.io.Reader dstream, + int startline, int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + nextCharBuf = new char[4096]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + nextCharInd = bufpos = -1; + } + +/** Reinitialise. */ + public void ReInit(java.io.Reader dstream, + int startline, int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + +/** Reinitialise. */ + public void ReInit(java.io.Reader dstream) + { + ReInit(dstream, 1, 1, 4096); + } +/** Constructor. */ + public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + +/** Constructor. */ + public JavaCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + } + +/** Constructor. */ + public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, startline, startcolumn, 4096); + } + +/** Constructor. */ + public JavaCharStream(java.io.InputStream dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + +/** Constructor. */ + public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, 1, 1, 4096); + } + +/** Constructor. */ + public JavaCharStream(java.io.InputStream dstream) + { + this(dstream, 1, 1, 4096); + } + +/** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + +/** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } +/** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, startline, startcolumn, 4096); + } +/** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } +/** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, 1, 1, 4096); + } + +/** Reinitialise. */ + public void ReInit(java.io.InputStream dstream) + { + ReInit(dstream, 1, 1, 4096); + } + + /** @return token image as String */ + public String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + /** @return suffix */ + public char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + /** Set buffers back to null when finished. */ + public void Done() + { + nextCharBuf = null; + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + */ + public void adjustBeginLineColumn(int newLine, int newCol) + { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) + { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) + { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) + { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} +/* JavaCC - OriginalChecksum=5111a95355f2f1cc405246f828703097 (do not edit this line) */ diff --git a/src/com/github/javaparser/JavaParser.java b/src/com/github/javaparser/JavaParser.java new file mode 100644 index 0000000..a1de8be --- /dev/null +++ b/src/com/github/javaparser/JavaParser.java @@ -0,0 +1,450 @@ +/* + * 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.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? +/** + *

+ * This class was generated automatically by javacc, do not edit. + *

+ *

+ * Parse Java 1.5 source code and creates Abstract Syntax Tree classes. + *

+ * + * @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) throws ParseException { + 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) throws ParseException { + 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) + throws ParseException { + 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) + throws ParseException { + 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) + throws ParseException { + 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) throws ParseException { + 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) throws ParseException { + 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) throws ParseException { + 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) throws ParseException { + 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) throws ParseException { + 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 comments = commentsCollection.getAll(); + PositionUtils.sortByBeginPosition(comments); + List 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 children = new LinkedList(); + 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 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 children = node.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + for (Node child : children){ + List commentsInsideChild = new LinkedList(); + 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 attributedComments = new LinkedList(); + 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(); + List childrenAndComments = new LinkedList(); + 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/src/com/github/javaparser/ParseException.java b/src/com/github/javaparser/ParseException.java new file mode 100644 index 0000000..31d07cd --- /dev/null +++ b/src/com/github/javaparser/ParseException.java @@ -0,0 +1,199 @@ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ +/* JavaCCOptions:KEEP_LINE_COL=null */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; + +/** + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. + */ +public class ParseException extends Exception { + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) + { + super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ + + public ParseException() { + super(); + } + + /** Constructor with message. */ + public ParseException(String message) { + super(message); + } + + + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * It uses "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser) the correct error message + * gets displayed. + */ + private static String initialise(Token currentToken, + int[][] expectedTokenSequences, + String[] tokenImage) { + String eol = System.getProperty("line.separator", "\n"); + StringBuffer expected = new StringBuffer(); + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected.append("..."); + } + expected.append(eol).append(" "); + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) retval += " "; + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += " " + tokenImage[tok.kind]; + retval += " \""; + retval += add_escapes(tok.image); + retval += " \""; + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; + retval += "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected.toString(); + return retval; + } + + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); + + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + */ + static String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + +} +/* JavaCC - OriginalChecksum=62ba72b2159703420d5ce7232a0226fb (do not edit this line) */ diff --git a/src/com/github/javaparser/Position.java b/src/com/github/javaparser/Position.java new file mode 100644 index 0000000..522411c --- /dev/null +++ b/src/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/src/com/github/javaparser/PositionUtils.java b/src/com/github/javaparser/PositionUtils.java new file mode 100644 index 0000000..41df817 --- /dev/null +++ b/src/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 void sortByBeginPosition(List nodes){ + sortByBeginPosition(nodes, false); + } + + public static void sortByBeginPosition(List nodes, final boolean ignoringAnnotations){ + Collections.sort(nodes, new Comparator() { + @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 annotations = new LinkedList(); + 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() 0) { + buf.append(arr, 0, numChars); + } + + return buf.toString(); + } + + static Reader stringToReader(String s){ + return new StringReader(s); + } + +} diff --git a/src/com/github/javaparser/Token.java b/src/com/github/javaparser/Token.java new file mode 100644 index 0000000..8aa85f4 --- /dev/null +++ b/src/com/github/javaparser/Token.java @@ -0,0 +1,143 @@ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; + +/** + * Describes the input token stream. + */ + +public class Token implements java.io.Serializable { + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** The line number of the first character of this Token. */ + public int beginLine; + /** The column number of the first character of this Token. */ + public int beginColumn; + /** The line number of the last character of this Token. */ + public int endLine; + /** The column number of the last character of this Token. */ + public int endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * An optional attribute value of the Token. + * Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or + * interpreter. This attribute value is often different from the image. + * Any subclass of Token that actually wants to return a non-null value can + * override this method as appropriate. + */ + public Object getValue() { + return null; + } + + /** + * No-argument constructor + */ + public Token() {} + + /** + * Constructs a new token for the specified Image. + */ + public Token(int kind) + { + this(kind, null); + } + + /** + * Constructs a new token for the specified Image and Kind. + */ + public Token(int kind, String image) + { + this.kind = kind; + this.image = image; + } + + /** + * Returns the image. + */ + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simply add something like : + * + * case MyParserConstants.ID : return new IDToken(ofKind, image); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use sit in your lexical actions. + */ + public static Token newToken(int ofKind, String image) + { + switch(ofKind) + { + default : return new Token(ofKind, image); + } + } + + public static Token newToken(int ofKind) + { + return newToken(ofKind, null); + } + +} +/* JavaCC - OriginalChecksum=a2058282d76ebf324ed236272a3341cb (do not edit this line) */ diff --git a/src/com/github/javaparser/TokenMgrError.java b/src/com/github/javaparser/TokenMgrError.java new file mode 100644 index 0000000..09197e8 --- /dev/null +++ b/src/com/github/javaparser/TokenMgrError.java @@ -0,0 +1,159 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ +/* JavaCCOptions: */ +/* + * + * This file is part of Java 1.8 parser and Abstract Syntax Tree. + * + * Java 1.8 parser and Abstract Syntax Tree is free software: you can redistribute it and/or modify + * it under the terms of 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. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Java 1.8 parser and Abstract Syntax Tree. If not, see . + */ +package com.github.javaparser; + +/** Token Manager Error. */ +public class TokenMgrError extends Error +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occurred. + */ + static final int LEXICAL_ERROR = 0; + + /** + * An attempt was made to create a second instance of a static token manager. + */ + static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their escaped (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexical error + * curLexState : lexical state in which this error occurred + * errorLine : line number when the error occurred + * errorColumn : column number when the error occurred + * errorAfter : prefix that was seen before this error occurred + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + /** No arg constructor. */ + public TokenMgrError() { + } + + /** Constructor with message and reason. */ + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} +/* JavaCC - OriginalChecksum=f06c7e964b5c13a732337c2f3fb4f836 (do not edit this line) */ diff --git a/src/com/github/javaparser/ast/AccessSpecifier.java b/src/com/github/javaparser/ast/AccessSpecifier.java new file mode 100644 index 0000000..5eafdac --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/CompilationUnit.java b/src/com/github/javaparser/ast/CompilationUnit.java new file mode 100644 index 0000000..1363624 --- /dev/null +++ b/src/com/github/javaparser/ast/CompilationUnit.java @@ -0,0 +1,184 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + *

+ * This class represents the entire compilation unit. Each java file denotes a + * compilation unit. + *

+ * The CompilationUnit is constructed following the syntax:
+ *
+ * {@code
+ * CompilationUnit ::=  ( }{@link PackageDeclaration}{@code )?
+ *                      ( }{@link ImportDeclaration}{@code )*
+ *                      ( }{@link TypeDeclaration}{@code )*
+ * }
+ * 
+ * @author Julio Vilmar Gesser + */ +public final class CompilationUnit extends Node { + + private PackageDeclaration pakage; + + private List imports; + + private List types; + + public CompilationUnit() { + } + + public CompilationUnit(PackageDeclaration pakage, List imports, List types) { + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + public CompilationUnit(int beginLine, int beginColumn, int endLine, int endColumn, PackageDeclaration pakage, List imports, List types) { + super(beginLine, beginColumn, endLine, endColumn); + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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.
+ * If there is no comment, null is returned. + * + * @return list with all comments of this compilation unit or + * null + * @see JavadocComment + * @see com.github.javaparser.ast.comments.LineComment + * @see com.github.javaparser.ast.comments.BlockComment + */ + public List getComments() { + return this.getAllContainedComments(); + } + + /** + * Retrieves the list of imports declared in this compilation unit or + * null if there is no import. + * + * @return the list of imports or null if there is no import + */ + public List getImports() { + imports = ensureNotNull(imports); + return imports; + } + + /** + * Retrieves the package declaration of this compilation unit.
+ * If this compilation unit has no package declaration (default package), + * null is returned. + * + * @return the package declaration or null + */ + public PackageDeclaration getPackage() { + return pakage; + } + + /** + * Return the list of types declared in this compilation unit.
+ * If there is no types declared, null is returned. + * + * @return the list of types or null null if there is no type + * @see AnnotationDeclaration + * @see ClassOrInterfaceDeclaration + * @see EmptyTypeDeclaration + * @see EnumDeclaration + */ + public List getTypes() { + types = ensureNotNull(types); + return types; + } + + /** + * Sets the list of comments of this compilation unit. + * + * @param comments + * the list of comments + */ + public void setComments(List comments) { + throw new RuntimeException("Not implemented!"); + } + + /** + * Sets the list of imports of this compilation unit. The list is initially + * null. + * + * @param imports + * the list of imports + */ + public void setImports(List 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 null 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 types) { + this.types = types; + setAsParentNodeOf(this.types); + } +} diff --git a/src/com/github/javaparser/ast/DocumentableNode.java b/src/com/github/javaparser/ast/DocumentableNode.java new file mode 100644 index 0000000..0038831 --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/ImportDeclaration.java b/src/com/github/javaparser/ast/ImportDeclaration.java new file mode 100644 index 0000000..da249e2 --- /dev/null +++ b/src/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; + +/** + *

+ * This class represents a import declaration. Imports are optional for the + * {@link CompilationUnit}. + *

+ * The ImportDeclaration is constructed following the syntax:
+ *
+ * {@code
+ * ImportDeclaration ::= "import" ( "static" )? }{@link NameExpr}{@code ( "." "*" )? ";"
+ * }
+ * 
+ * @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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public
void accept(VoidVisitor 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 true if the import ends with "*", false + * otherwise + */ + public boolean isAsterisk() { + return asterisk; + } + + /** + * Return if the import is static. + * + * @return true if the import is static, false + * otherwise + */ + public boolean isStatic() { + return static_; + } + + /** + * Sets if this import is asterisk. + * + * @param asterisk + * true 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_ + * true if this import is static + */ + public void setStatic(boolean static_) { + this.static_ = static_; + } + +} diff --git a/src/com/github/javaparser/ast/NamedNode.java b/src/com/github/javaparser/ast/NamedNode.java new file mode 100644 index 0000000..7885d71 --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/Node.java b/src/com/github/javaparser/ast/Node.java new file mode 100644 index 0000000..f5f9cb2 --- /dev/null +++ b/src/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 childrenNodes = new LinkedList(); + private List orphanComments = new LinkedList(); + + /** + * 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 + * the type the return value of the visitor + * @param + * 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 accept(GenericVisitor v, A arg); + + /** + * Accept method for visitor support. + * + * @param + * the type the argument passed for the visitor + * @param v + * the visitor implementation + * @param arg + * any value relevant for the visitor + */ + public abstract void accept(VoidVisitor 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 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 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 getAllContainedComments() { + List comments = new LinkedList(); + 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 childNodes) { + if (childNodes != null) { + Iterator 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/src/com/github/javaparser/ast/PackageDeclaration.java b/src/com/github/javaparser/ast/PackageDeclaration.java new file mode 100644 index 0000000..dcb9510 --- /dev/null +++ b/src/com/github/javaparser/ast/PackageDeclaration.java @@ -0,0 +1,121 @@ +/* + * 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.internal.Utils; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + *

+ * This class represents the package declaration. The package declaration is + * optional for the {@link CompilationUnit}. + *

+ * The PackageDeclaration is constructed following the syntax:
+ *
+ * {@code
+ * PackageDeclaration ::= ( }{@link AnnotationExpr}{@code )* "package" }{@link NameExpr}{@code ) ";"
+ * }
+ * 
+ * @author Julio Vilmar Gesser + */ +public final class PackageDeclaration extends Node { + + private List annotations; + + private NameExpr name; + + public PackageDeclaration() { + } + + public PackageDeclaration(NameExpr name) { + setName(name); + } + + public PackageDeclaration(List annotations, NameExpr name) { + setAnnotations(annotations); + setName(name); + } + + public PackageDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List annotations, NameExpr name) { + super(beginLine, beginColumn, endLine, endColumn); + setAnnotations(annotations); + setName(name); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public
void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the list of annotations declared before the package + * declaration. Return null if there are no annotations. + * + * @return list of annotations or null + */ + public List getAnnotations() { + annotations = Utils.ensureNotNull(annotations); + 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 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/src/com/github/javaparser/ast/TreeVisitor.java b/src/com/github/javaparser/ast/TreeVisitor.java new file mode 100644 index 0000000..f3b2672 --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/TypeParameter.java b/src/com/github/javaparser/ast/TypeParameter.java new file mode 100644 index 0000000..81003e2 --- /dev/null +++ b/src/com/github/javaparser/ast/TypeParameter.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; + +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; + +import static com.github.javaparser.ast.internal.Utils.ensureNotNull; + +/** + *

+ * This class represents the declaration of a generics argument. + *

+ * The TypeParameter is constructed following the syntax:
+ *
+ * {@code
+ * TypeParameter ::=  ( "extends" }{@link ClassOrInterfaceType}{@code ( "&" }{@link ClassOrInterfaceType}{@code )* )?
+ * }
+ * 
+ * @author Julio Vilmar Gesser + */ +public final class TypeParameter extends Node implements NamedNode { + + private String name; + + private List annotations; + + private List typeBound; + + public TypeParameter() { + } + + public TypeParameter(final String name, final List typeBound) { + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name, final List typeBound) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(int beginLine, int beginColumn, int endLine, + int endColumn, String name, List typeBound, List annotations) { + this(beginLine, beginColumn, endLine, endColumn, name, typeBound); + setName(name); + setTypeBound(typeBound); + this.annotations = annotations; + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public
void accept(final VoidVisitor 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 null null if there are no type. + * + * @return list of types that this paramente extends or null + */ + public List getTypeBound() { + typeBound = ensureNotNull(typeBound); + 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 typeBound) { + this.typeBound = typeBound; + setAsParentNodeOf(typeBound); + } + + public List getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public void setAnnotations(List annotations) { + this.annotations = annotations; + } +} diff --git a/src/com/github/javaparser/ast/body/AnnotableNode.java b/src/com/github/javaparser/ast/body/AnnotableNode.java new file mode 100644 index 0000000..47c8c4f --- /dev/null +++ b/src/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 getAnnotations(); +} diff --git a/src/com/github/javaparser/ast/body/AnnotationDeclaration.java b/src/com/github/javaparser/ast/body/AnnotationDeclaration.java new file mode 100644 index 0000000..51f2561 --- /dev/null +++ b/src/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 annotations, String name, List members) { + super(annotations, modifiers, name, members); + } + + public AnnotationDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List annotations, String name, List members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java b/src/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java new file mode 100644 index 0000000..a81e6cc --- /dev/null +++ b/src/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 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 annotations, Type type, String name, Expression defaultValue) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/BaseParameter.java b/src/com/github/javaparser/ast/body/BaseParameter.java new file mode 100644 index 0000000..693e846 --- /dev/null +++ b/src/com/github/javaparser/ast/body/BaseParameter.java @@ -0,0 +1,102 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +public abstract class BaseParameter extends Node { + private int modifiers; + + private List 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 annotations, VariableDeclaratorId id) { + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + } + + public BaseParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List annotations, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn); + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + } + + /** + * @return the list returned could be immutable (in that case it will be empty) + */ + public List getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public VariableDeclaratorId getId() { + return id; + } + + /** + * Return the modifiers of this parameter declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + /** + * @param annotations a null value is currently treated as an empty list. This behavior could change + * in the future, so please avoid passing null + */ + public void setAnnotations(List 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/src/com/github/javaparser/ast/body/BodyDeclaration.java b/src/com/github/javaparser/ast/body/BodyDeclaration.java new file mode 100644 index 0000000..ee14528 --- /dev/null +++ b/src/com/github/javaparser/ast/body/BodyDeclaration.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.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.internal.Utils; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class BodyDeclaration extends Node implements AnnotableNode { + + private List annotations; + + public BodyDeclaration() { + } + + public BodyDeclaration(List annotations) { + setAnnotations(annotations); + } + + public BodyDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List annotations) { + super(beginLine, beginColumn, endLine, endColumn); + setAnnotations(annotations); + } + + public final List getAnnotations() { + annotations = Utils.ensureNotNull(annotations); + return annotations; + } + + /** + * + * @param annotations a null value is currently treated as an empty list. This behavior could change + * in the future, so please avoid passing null + */ + public final void setAnnotations(List annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } +} diff --git a/src/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java b/src/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java new file mode 100644 index 0000000..e996485 --- /dev/null +++ b/src/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java @@ -0,0 +1,153 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceDeclaration extends TypeDeclaration implements DocumentableNode { + + private boolean interface_; + + private List typeParameters; + + // Can contain more than one item if this is an interface + private List extendsList; + + private List 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 annotations, final boolean isInterface, final String name, + final List typeParameters, final List extendsList, + final List implementsList, final List 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 annotations, final boolean isInterface, final String name, + final List typeParameters, final List extendsList, + final List implementsList, final List members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getExtends() { + extendsList = ensureNotNull(extendsList); + return extendsList; + } + + public List getImplements() { + implementsList = ensureNotNull(implementsList); + return implementsList; + } + + public List getTypeParameters() { + typeParameters = ensureNotNull(typeParameters); + return typeParameters; + } + + public boolean isInterface() { + return interface_; + } + + /** + * + * @param extendsList a null value is currently treated as an empty list. This behavior could change + * in the future, so please avoid passing null + */ + public void setExtends(final List extendsList) { + this.extendsList = extendsList; + setAsParentNodeOf(this.extendsList); + } + + /** + * + * @param implementsList a null value is currently treated as an empty list. This behavior could change + * in the future, so please avoid passing null + */ + public void setImplements(final List implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + } + + public void setInterface(final boolean interface_) { + this.interface_ = interface_; + } + + /** + * + * @param typeParameters a null value is currently treated as an empty list. This behavior could change + * in the future, so please avoid passing null + */ + public void setTypeParameters(final List 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/src/com/github/javaparser/ast/body/ConstructorDeclaration.java b/src/com/github/javaparser/ast/body/ConstructorDeclaration.java new file mode 100644 index 0000000..28afeb7 --- /dev/null +++ b/src/com/github/javaparser/ast/body/ConstructorDeclaration.java @@ -0,0 +1,235 @@ +/* + * 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 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class ConstructorDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, + NamedNode { + + private int modifiers; + + private List typeParameters; + + private NameExpr name; + + private List parameters; + + private List throws_; + + private BlockStmt block; + + public ConstructorDeclaration() { + } + + public ConstructorDeclaration(int modifiers, String name) { + setModifiers(modifiers); + setName(name); + } + + public ConstructorDeclaration(int modifiers, List annotations, List typeParameters, + String name, List parameters, List 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 annotations, List typeParameters, String name, + List parameters, List throws_, BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBlock(block); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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 getParameters() { + parameters = ensureNotNull(parameters); + return parameters; + } + + public List getThrows() { + throws_ = ensureNotNull(throws_); + return throws_; + } + + public List getTypeParameters() { + typeParameters = ensureNotNull(typeParameters); + 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 parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public void setThrows(List throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + } + + public void setTypeParameters(List 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/src/com/github/javaparser/ast/body/EmptyMemberDeclaration.java b/src/com/github/javaparser/ast/body/EmptyMemberDeclaration.java new file mode 100644 index 0000000..1c19d09 --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/EmptyTypeDeclaration.java b/src/com/github/javaparser/ast/body/EmptyTypeDeclaration.java new file mode 100644 index 0000000..59e8686 --- /dev/null +++ b/src/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 accept(GenericVisitor 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 void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/EnumConstantDeclaration.java b/src/com/github/javaparser/ast/body/EnumConstantDeclaration.java new file mode 100644 index 0000000..074ba7e --- /dev/null +++ b/src/com/github/javaparser/ast/body/EnumConstantDeclaration.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.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; + +import static com.github.javaparser.ast.internal.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumConstantDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode { + + private String name; + + private List args; + + private List classBody; + + public EnumConstantDeclaration() { + } + + public EnumConstantDeclaration(String name) { + setName(name); + } + + public EnumConstantDeclaration(List annotations, String name, List args, List classBody) { + super(annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + public EnumConstantDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List annotations, String name, List args, List classBody) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public List getArgs() { + args = ensureNotNull(args); + return args; + } + + public List getClassBody() { + classBody = ensureNotNull(classBody); + return classBody; + } + + public String getName() { + return name; + } + + public void setArgs(List args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setClassBody(List 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/src/com/github/javaparser/ast/body/EnumDeclaration.java b/src/com/github/javaparser/ast/body/EnumDeclaration.java new file mode 100644 index 0000000..4366630 --- /dev/null +++ b/src/com/github/javaparser/ast/body/EnumDeclaration.java @@ -0,0 +1,105 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumDeclaration extends TypeDeclaration implements DocumentableNode { + + private List implementsList; + + private List entries; + + public EnumDeclaration() { + } + + public EnumDeclaration(int modifiers, String name) { + super(modifiers, name); + } + + public EnumDeclaration(int modifiers, List annotations, String name, List implementsList, List entries, List members) { + super(annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + public EnumDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List annotations, String name, List implementsList, List entries, List members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public List getEntries() { + entries = ensureNotNull(entries); + return entries; + } + + public List getImplements() { + implementsList = ensureNotNull(implementsList); + return implementsList; + } + + public void setEntries(List entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + } + + public void setImplements(List 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/src/com/github/javaparser/ast/body/FieldDeclaration.java b/src/com/github/javaparser/ast/body/FieldDeclaration.java new file mode 100644 index 0000000..dd898fd --- /dev/null +++ b/src/com/github/javaparser/ast/body/FieldDeclaration.java @@ -0,0 +1,132 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldDeclaration extends BodyDeclaration implements DocumentableNode { + + private int modifiers; + + private Type type; + + private List variables; + + public FieldDeclaration() { + } + + public FieldDeclaration(int modifiers, Type type, VariableDeclarator variable) { + setModifiers(modifiers); + setType(type); + List aux = new ArrayList(); + aux.add(variable); + setVariables(aux); + } + + public FieldDeclaration(int modifiers, Type type, List variables) { + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + public FieldDeclaration(int modifiers, List annotations, Type type, List variables) { + super(annotations); + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + public FieldDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List annotations, Type type, List variables) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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 getVariables() { + variables = ensureNotNull(variables); + 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 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/src/com/github/javaparser/ast/body/InitializerDeclaration.java b/src/com/github/javaparser/ast/body/InitializerDeclaration.java new file mode 100644 index 0000000..ea1df9a --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/MethodDeclaration.java b/src/com/github/javaparser/ast/body/MethodDeclaration.java new file mode 100644 index 0000000..4c8f5eb --- /dev/null +++ b/src/com/github/javaparser/ast/body/MethodDeclaration.java @@ -0,0 +1,303 @@ +/* + * 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 static com.github.javaparser.ast.internal.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, NamedNode { + + private int modifiers; + + private List typeParameters; + + private Type type; + + private NameExpr name; + + private List parameters; + + private int arrayCount; + + private List 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 parameters) { + setModifiers(modifiers); + setType(type); + setName(name); + setParameters(parameters); + } + + public MethodDeclaration(final int modifiers, final List annotations, + final List typeParameters, final Type type, final String name, + final List parameters, final int arrayCount, final List 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 annotations, + final List typeParameters, final Type type, final String name, + final List parameters, final int arrayCount, final List 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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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 getParameters() { + parameters = ensureNotNull(parameters); + return parameters; + } + + public List getThrows() { + throws_ = ensureNotNull(throws_); + return throws_; + } + + public Type getType() { + return type; + } + + public List getTypeParameters() { + typeParameters = ensureNotNull(typeParameters); + 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 parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public void setThrows(final List throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setTypeParameters(final List 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/src/com/github/javaparser/ast/body/ModifierSet.java b/src/com/github/javaparser/ast/body/ModifierSet.java new file mode 100644 index 0000000..6981ced --- /dev/null +++ b/src/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.
+ * 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/src/com/github/javaparser/ast/body/MultiTypeParameter.java b/src/com/github/javaparser/ast/body/MultiTypeParameter.java new file mode 100644 index 0000000..8ad20e9 --- /dev/null +++ b/src/com/github/javaparser/ast/body/MultiTypeParameter.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.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; + +import static com.github.javaparser.ast.internal.Utils.ensureNotNull; + +public class MultiTypeParameter extends BaseParameter { + private List types; + + public MultiTypeParameter() {} + + public MultiTypeParameter(int modifiers, List annotations, List types, VariableDeclaratorId id) { + super(modifiers, annotations, id); + this.types = types; + } + + public MultiTypeParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List annotations, List types, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id); + this.types = types; + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public
void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public List getTypes() { + types = ensureNotNull(types); + return types; + } + + public void setTypes(List types) { + this.types = types; + setAsParentNodeOf(types); + } +} diff --git a/src/com/github/javaparser/ast/body/Parameter.java b/src/com/github/javaparser/ast/body/Parameter.java new file mode 100644 index 0000000..6113d70 --- /dev/null +++ b/src/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 annotations, Type type, boolean isVarArgs, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id); + setType(type); + setVarArgs(isVarArgs); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/TypeDeclaration.java b/src/com/github/javaparser/ast/body/TypeDeclaration.java new file mode 100644 index 0000000..d2eb514 --- /dev/null +++ b/src/com/github/javaparser/ast/body/TypeDeclaration.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.body; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; + +import java.util.Collections; +import java.util.List; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class TypeDeclaration extends BodyDeclaration implements NamedNode { + + private NameExpr name; + + private int modifiers; + + private List members; + + public TypeDeclaration() { + } + + public TypeDeclaration(int modifiers, String name) { + setName(name); + setModifiers(modifiers); + } + + public TypeDeclaration(List annotations, + int modifiers, String name, + List members) { + super(annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public TypeDeclaration(int beginLine, int beginColumn, int endLine, + int endColumn, List annotations, + int modifiers, String name, + List members) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public final List getMembers() { + members = ensureNotNull(members); + 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 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/src/com/github/javaparser/ast/body/VariableDeclarator.java b/src/com/github/javaparser/ast/body/VariableDeclarator.java new file mode 100644 index 0000000..1890d9b --- /dev/null +++ b/src/com/github/javaparser/ast/body/VariableDeclarator.java @@ -0,0 +1,89 @@ +/* + * 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); + } + + /** + * Defines the declaration of a variable. + * @param id The identifier for this variable. IE. The variables name. + * @param init What this variable should be initialized to. + * An {@link com.github.javaparser.ast.expr.AssignExpr} is unnecessary as the = operator is already added. + */ + 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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/VariableDeclaratorId.java b/src/com/github/javaparser/ast/body/VariableDeclaratorId.java new file mode 100644 index 0000000..c56bd8e --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/body/WithDeclaration.java b/src/com/github/javaparser/ast/body/WithDeclaration.java new file mode 100644 index 0000000..8f1725c --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/comments/BlockComment.java b/src/com/github/javaparser/ast/comments/BlockComment.java new file mode 100644 index 0000000..299493b --- /dev/null +++ b/src/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; + +/** + *

+ * AST node that represent block comments. + *

+ * 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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public
void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/comments/Comment.java b/src/com/github/javaparser/ast/comments/Comment.java new file mode 100644 index 0000000..135972b --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/comments/CommentsCollection.java b/src/com/github/javaparser/ast/comments/CommentsCollection.java new file mode 100644 index 0000000..ac94c61 --- /dev/null +++ b/src/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 lineComments = new LinkedList(); + private List blockComments = new LinkedList(); + private List javadocComments = new LinkedList(); + + public List getLineComments(){ + return lineComments; + } + + public List getBlockComments(){ + return blockComments; + } + + public List 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 getAll(){ + List comments = new LinkedList(); + 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/src/com/github/javaparser/ast/comments/CommentsParser.java b/src/com/github/javaparser/ast/comments/CommentsParser.java new file mode 100644 index 0000000..3d3a59d --- /dev/null +++ b/src/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(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/src/com/github/javaparser/ast/comments/JavadocComment.java b/src/com/github/javaparser/ast/comments/JavadocComment.java new file mode 100644 index 0000000..a070321 --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/comments/LineComment.java b/src/com/github/javaparser/ast/comments/LineComment.java new file mode 100644 index 0000000..b3df1df --- /dev/null +++ b/src/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; + +/** + *

+ * AST node that represent line comments. + *

+ * 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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public
void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public boolean isLineComment() + { + return true; + } +} diff --git a/src/com/github/javaparser/ast/expr/AnnotationExpr.java b/src/com/github/javaparser/ast/expr/AnnotationExpr.java new file mode 100644 index 0000000..8c65e92 --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/expr/ArrayAccessExpr.java b/src/com/github/javaparser/ast/expr/ArrayAccessExpr.java new file mode 100644 index 0000000..7026d15 --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/ArrayCreationExpr.java b/src/com/github/javaparser/ast/expr/ArrayCreationExpr.java new file mode 100644 index 0000000..f2961e5 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/ArrayCreationExpr.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayCreationExpr extends Expression { + + private Type type; + + private int arrayCount; + + private ArrayInitializerExpr initializer; + + private List dimensions; + + private List> 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 dimensions, int arrayCount) { + setType(type); + setArrayCount(arrayCount); + setDimensions(dimensions); + setInitializer(null); + } + + public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, List dimensions, int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + setDimensions(dimensions); + setInitializer(null); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public List getDimensions() { + dimensions = ensureNotNull(dimensions); + return dimensions; + } + + public ArrayInitializerExpr getInitializer() { + return initializer; + } + + public Type getType() { + return type; + } + + public void setArrayCount(int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setDimensions(List 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> getArraysAnnotations() { + arraysAnnotations = ensureNotNull(arraysAnnotations); + return arraysAnnotations; + } + + public void setArraysAnnotations( + List> arraysAnnotations) { + this.arraysAnnotations = arraysAnnotations; + } +} diff --git a/src/com/github/javaparser/ast/expr/ArrayInitializerExpr.java b/src/com/github/javaparser/ast/expr/ArrayInitializerExpr.java new file mode 100644 index 0000000..0409626 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/ArrayInitializerExpr.java @@ -0,0 +1,69 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayInitializerExpr extends Expression { + + private List values; + + public ArrayInitializerExpr() { + } + + public ArrayInitializerExpr(List values) { + setValues(values); + } + + public ArrayInitializerExpr(int beginLine, int beginColumn, int endLine, int endColumn, List values) { + super(beginLine, beginColumn, endLine, endColumn); + setValues(values); + } + + @Override + public R accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public List getValues() { + values = ensureNotNull(values); + return values; + } + + public void setValues(List values) { + this.values = values; + setAsParentNodeOf(this.values); + } +} diff --git a/src/com/github/javaparser/ast/expr/AssignExpr.java b/src/com/github/javaparser/ast/expr/AssignExpr.java new file mode 100644 index 0000000..b3d508f --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/BinaryExpr.java b/src/com/github/javaparser/ast/expr/BinaryExpr.java new file mode 100644 index 0000000..4ace4be --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/BooleanLiteralExpr.java b/src/com/github/javaparser/ast/expr/BooleanLiteralExpr.java new file mode 100644 index 0000000..e92244a --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } +} diff --git a/src/com/github/javaparser/ast/expr/CastExpr.java b/src/com/github/javaparser/ast/expr/CastExpr.java new file mode 100644 index 0000000..8433869 --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/CharLiteralExpr.java b/src/com/github/javaparser/ast/expr/CharLiteralExpr.java new file mode 100644 index 0000000..061805d --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/expr/ClassExpr.java b/src/com/github/javaparser/ast/expr/ClassExpr.java new file mode 100644 index 0000000..efdbce6 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/ClassExpr.java @@ -0,0 +1,70 @@ +/* + * 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; + +/** + * Defines an expression that accesses the class of a type. + * Example: + * + * Object.class + * + * @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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/ConditionalExpr.java b/src/com/github/javaparser/ast/expr/ConditionalExpr.java new file mode 100644 index 0000000..31db61c --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/DoubleLiteralExpr.java b/src/com/github/javaparser/ast/expr/DoubleLiteralExpr.java new file mode 100644 index 0000000..ce6962d --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/expr/EnclosedExpr.java b/src/com/github/javaparser/ast/expr/EnclosedExpr.java new file mode 100644 index 0000000..72f9de2 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/Expression.java b/src/com/github/javaparser/ast/expr/Expression.java new file mode 100644 index 0000000..8b36d6b --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/expr/FieldAccessExpr.java b/src/com/github/javaparser/ast/expr/FieldAccessExpr.java new file mode 100644 index 0000000..de7d885 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/FieldAccessExpr.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldAccessExpr extends Expression { + + private Expression scope; + + private List 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 typeArgs, final String field) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setTypeArgs(typeArgs); + setField(field); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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 getTypeArgs() { + typeArgs = ensureNotNull(typeArgs); + 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 typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/src/com/github/javaparser/ast/expr/InstanceOfExpr.java b/src/com/github/javaparser/ast/expr/InstanceOfExpr.java new file mode 100644 index 0000000..9a97865 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/IntegerLiteralExpr.java b/src/com/github/javaparser/ast/expr/IntegerLiteralExpr.java new file mode 100644 index 0000000..b326c57 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java b/src/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java new file mode 100644 index 0000000..238b564 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/src/com/github/javaparser/ast/expr/LambdaExpr.java b/src/com/github/javaparser/ast/expr/LambdaExpr.java new file mode 100644 index 0000000..5cc6c00 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/LambdaExpr.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * Lambda expression. + * + * @author Raquel Pau + */ +public class LambdaExpr extends Expression { + + private List parameters; + + private boolean parametersEnclosed; + + private Statement body; + + public LambdaExpr() { + } + + public LambdaExpr(int beginLine, int beginColumn, int endLine, + int endColumn, List parameters, Statement body, + boolean parametersEnclosed) { + + super(beginLine, beginColumn, endLine, endColumn); + setParameters(parameters); + setBody(body); + setParametersEnclosed(parametersEnclosed); + } + + public List getParameters() { + parameters = ensureNotNull(parameters); + return parameters; + } + + public void setParameters(List 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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor v, A arg) { + v.visit(this, arg); + } + + public boolean isParametersEnclosed() { + return parametersEnclosed; + } + + public void setParametersEnclosed(boolean parametersEnclosed) { + this.parametersEnclosed = parametersEnclosed; + } + +} diff --git a/src/com/github/javaparser/ast/expr/LiteralExpr.java b/src/com/github/javaparser/ast/expr/LiteralExpr.java new file mode 100644 index 0000000..7827f78 --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/expr/LongLiteralExpr.java b/src/com/github/javaparser/ast/expr/LongLiteralExpr.java new file mode 100644 index 0000000..15ea255 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java b/src/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java new file mode 100644 index 0000000..f351f7a --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/src/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java b/src/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java new file mode 100644 index 0000000..c1a3545 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/src/com/github/javaparser/ast/expr/MemberValuePair.java b/src/com/github/javaparser/ast/expr/MemberValuePair.java new file mode 100644 index 0000000..e0fa80c --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/MethodCallExpr.java b/src/com/github/javaparser/ast/expr/MethodCallExpr.java new file mode 100644 index 0000000..63c587e --- /dev/null +++ b/src/com/github/javaparser/ast/expr/MethodCallExpr.java @@ -0,0 +1,120 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodCallExpr extends Expression { + + private Expression scope; + + private List typeArgs; + + private NameExpr name; + + private List 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 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 typeArgs, final String name, final List args) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setTypeArgs(typeArgs); + setName(name); + setArgs(args); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getArgs() { + args = ensureNotNull(args); + return args; + } + + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public Expression getScope() { + return scope; + } + + public List getTypeArgs() { + typeArgs = ensureNotNull(typeArgs); + return typeArgs; + } + + public void setArgs(final List 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 typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/src/com/github/javaparser/ast/expr/MethodReferenceExpr.java b/src/com/github/javaparser/ast/expr/MethodReferenceExpr.java new file mode 100644 index 0000000..8fac124 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/MethodReferenceExpr.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * 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 typeParameters; + + private String identifier; + + public MethodReferenceExpr() { + } + + public MethodReferenceExpr(int beginLine, int beginColumn, int endLine, + int endColumn, Expression scope, + List typeParameters, String identifier) { + + super(beginLine, beginColumn, endLine, endColumn); + setIdentifier(identifier); + setScope(scope); + setTypeParameters(typeParameters); + } + + @Override + public R accept(GenericVisitor v, A arg) { + + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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 getTypeParameters() { + typeParameters = ensureNotNull(typeParameters); + return typeParameters; + } + + public void setTypeParameters(List typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + +} diff --git a/src/com/github/javaparser/ast/expr/NameExpr.java b/src/com/github/javaparser/ast/expr/NameExpr.java new file mode 100644 index 0000000..5cdbbbb --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/NormalAnnotationExpr.java b/src/com/github/javaparser/ast/expr/NormalAnnotationExpr.java new file mode 100644 index 0000000..fcd1b90 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/NormalAnnotationExpr.java @@ -0,0 +1,70 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class NormalAnnotationExpr extends AnnotationExpr { + + private List pairs; + + public NormalAnnotationExpr() { + } + + public NormalAnnotationExpr(final NameExpr name, final List pairs) { + setName(name); + setPairs(pairs); + } + + public NormalAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr name, final List pairs) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setPairs(pairs); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getPairs() { + pairs = ensureNotNull(pairs); + return pairs; + } + + public void setPairs(final List pairs) { + this.pairs = pairs; + setAsParentNodeOf(this.pairs); + } +} diff --git a/src/com/github/javaparser/ast/expr/NullLiteralExpr.java b/src/com/github/javaparser/ast/expr/NullLiteralExpr.java new file mode 100644 index 0000000..c7bc177 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/expr/ObjectCreationExpr.java b/src/com/github/javaparser/ast/expr/ObjectCreationExpr.java new file mode 100644 index 0000000..4657a44 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/ObjectCreationExpr.java @@ -0,0 +1,138 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * Defines constructor call expression. + * Example: + * + * new Object() + * + * + * @author Julio Vilmar Gesser + */ +public final class ObjectCreationExpr extends Expression { + + private Expression scope; + + private ClassOrInterfaceType type; + + private List typeArgs; + + private List args; + + // This can be null, to indicate there is no body + private List anonymousClassBody; + + public ObjectCreationExpr() { + } + + /** + * Defines a call to a constructor. + * @param scope may be null + * @param type this is the class that the constructor is being called for. + * @param args Any arguments to pass to the constructor + */ + public ObjectCreationExpr(final Expression scope, final ClassOrInterfaceType type, final List 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 typeArgs, + final List args, final List anonymousBody) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setType(type); + setTypeArgs(typeArgs); + setArgs(args); + setAnonymousClassBody(anonymousBody); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + /** + * This can be null, to indicate there is no body + */ + public List getAnonymousClassBody() { + return anonymousClassBody; + } + + public List getArgs() { + return args; + } + + public Expression getScope() { + return scope; + } + + public ClassOrInterfaceType getType() { + return type; + } + + public List getTypeArgs() { + typeArgs = ensureNotNull(typeArgs); + return typeArgs; + } + + public void setAnonymousClassBody(final List anonymousClassBody) { + this.anonymousClassBody = anonymousClassBody; + setAsParentNodeOf(this.anonymousClassBody); + } + + public void setArgs(final List 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 typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/src/com/github/javaparser/ast/expr/QualifiedNameExpr.java b/src/com/github/javaparser/ast/expr/QualifiedNameExpr.java new file mode 100644 index 0000000..00a65aa --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java b/src/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java new file mode 100644 index 0000000..bd8adb1 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/StringLiteralExpr.java b/src/com/github/javaparser/ast/expr/StringLiteralExpr.java new file mode 100644 index 0000000..6876fa2 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/SuperExpr.java b/src/com/github/javaparser/ast/expr/SuperExpr.java new file mode 100644 index 0000000..791d28b --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/ThisExpr.java b/src/com/github/javaparser/ast/expr/ThisExpr.java new file mode 100644 index 0000000..c269376 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/TypeExpr.java b/src/com/github/javaparser/ast/expr/TypeExpr.java new file mode 100644 index 0000000..636d2c4 --- /dev/null +++ b/src/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 accept(GenericVisitor v, A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(VoidVisitor 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/src/com/github/javaparser/ast/expr/UnaryExpr.java b/src/com/github/javaparser/ast/expr/UnaryExpr.java new file mode 100644 index 0000000..19d9360 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/expr/VariableDeclarationExpr.java b/src/com/github/javaparser/ast/expr/VariableDeclarationExpr.java new file mode 100644 index 0000000..ca03ef3 --- /dev/null +++ b/src/com/github/javaparser/ast/expr/VariableDeclarationExpr.java @@ -0,0 +1,122 @@ +/* + * 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.Collections; +import java.util.List; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclarationExpr extends Expression { + + private int modifiers; + + private List annotations; + + private Type type; + + private List vars; + + public VariableDeclarationExpr() { + } + + public VariableDeclarationExpr(final Type type, final List vars) { + setType(type); + setVars(vars); + } + + public VariableDeclarationExpr(final int modifiers, final Type type, final List 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 annotations, final Type type, + final List vars) { + super(beginLine, beginColumn, endLine, endColumn); + setModifiers(modifiers); + setAnnotations(annotations); + setType(type); + setVars(vars); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getAnnotations() { + annotations = ensureNotNull(annotations); + 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 getVars() { + vars = ensureNotNull(vars); + return vars; + } + + public void setAnnotations(final List 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 vars) { + this.vars = vars; + setAsParentNodeOf(this.vars); + } +} diff --git a/src/com/github/javaparser/ast/internal/Utils.java b/src/com/github/javaparser/ast/internal/Utils.java new file mode 100644 index 0000000..d5e7e4e --- /dev/null +++ b/src/com/github/javaparser/ast/internal/Utils.java @@ -0,0 +1,40 @@ +/* + * 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.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Federico Tomassetti + * @since 3.0.0 + */ +public class Utils { + public static List ensureNotNull(List list) { + return list == null ? new ArrayList() : list; + } + + public static boolean isNullOrEmpty(Collection collection) { + return collection == null || collection.isEmpty(); + } +} diff --git a/src/com/github/javaparser/ast/stmt/AssertStmt.java b/src/com/github/javaparser/ast/stmt/AssertStmt.java new file mode 100644 index 0000000..60f61bc --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/BlockStmt.java b/src/com/github/javaparser/ast/stmt/BlockStmt.java new file mode 100644 index 0000000..74fc41f --- /dev/null +++ b/src/com/github/javaparser/ast/stmt/BlockStmt.java @@ -0,0 +1,70 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class BlockStmt extends Statement { + + private List stmts; + + public BlockStmt() { + } + + public BlockStmt(final List stmts) { + setStmts(stmts); + } + + public BlockStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final List stmts) { + super(beginLine, beginColumn, endLine, endColumn); + setStmts(stmts); + } + + @Override + public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getStmts() { + stmts = ensureNotNull(stmts); + return stmts; + } + + public void setStmts(final List stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + } +} diff --git a/src/com/github/javaparser/ast/stmt/BreakStmt.java b/src/com/github/javaparser/ast/stmt/BreakStmt.java new file mode 100644 index 0000000..1a80f3e --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/CatchClause.java b/src/com/github/javaparser/ast/stmt/CatchClause.java new file mode 100644 index 0000000..3f43e79 --- /dev/null +++ b/src/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 exceptAnnotations, List 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 exceptAnnotations, final List 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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/ContinueStmt.java b/src/com/github/javaparser/ast/stmt/ContinueStmt.java new file mode 100644 index 0000000..81760d0 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/DoStmt.java b/src/com/github/javaparser/ast/stmt/DoStmt.java new file mode 100644 index 0000000..0a6a770 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/EmptyStmt.java b/src/com/github/javaparser/ast/stmt/EmptyStmt.java new file mode 100644 index 0000000..fb16c4d --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java b/src/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java new file mode 100644 index 0000000..a275ab1 --- /dev/null +++ b/src/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class ExplicitConstructorInvocationStmt extends Statement { + + private List typeArgs; + + private boolean isThis; + + private Expression expr; + + private List args; + + public ExplicitConstructorInvocationStmt() { + } + + public ExplicitConstructorInvocationStmt(final boolean isThis, + final Expression expr, final List args) { + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + public ExplicitConstructorInvocationStmt(final int beginLine, + final int beginColumn, final int endLine, final int endColumn, + final List typeArgs, final boolean isThis, + final Expression expr, final List args) { + super(beginLine, beginColumn, endLine, endColumn); + setTypeArgs(typeArgs); + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + @Override + public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getArgs() { + args = ensureNotNull(args); + return args; + } + + public Expression getExpr() { + return expr; + } + + public List getTypeArgs() { + typeArgs = ensureNotNull(typeArgs); + return typeArgs; + } + + public boolean isThis() { + return isThis; + } + + public void setArgs(final List 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 typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/src/com/github/javaparser/ast/stmt/ExpressionStmt.java b/src/com/github/javaparser/ast/stmt/ExpressionStmt.java new file mode 100644 index 0000000..3c441e2 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/ForStmt.java b/src/com/github/javaparser/ast/stmt/ForStmt.java new file mode 100644 index 0000000..cef6f27 --- /dev/null +++ b/src/com/github/javaparser/ast/stmt/ForStmt.java @@ -0,0 +1,114 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForStmt extends Statement { + + private List init; + + private Expression compare; + + private List update; + + private Statement body; + + public ForStmt() { + } + + public ForStmt(final List init, final Expression compare, + final List 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 init, final Expression compare, + final List update, final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + @Override + public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCompare() { + return compare; + } + + public List getInit() { + init = ensureNotNull(init); + return init; + } + + public List getUpdate() { + update = ensureNotNull(update); + 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 init) { + this.init = init; + setAsParentNodeOf(this.init); + } + + public void setUpdate(final List update) { + this.update = update; + setAsParentNodeOf(this.update); + } +} diff --git a/src/com/github/javaparser/ast/stmt/ForeachStmt.java b/src/com/github/javaparser/ast/stmt/ForeachStmt.java new file mode 100644 index 0000000..245622f --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/IfStmt.java b/src/com/github/javaparser/ast/stmt/IfStmt.java new file mode 100644 index 0000000..ccddd90 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/LabeledStmt.java b/src/com/github/javaparser/ast/stmt/LabeledStmt.java new file mode 100644 index 0000000..85d8e7b --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/ReturnStmt.java b/src/com/github/javaparser/ast/stmt/ReturnStmt.java new file mode 100644 index 0000000..3ac6fa6 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/Statement.java b/src/com/github/javaparser/ast/stmt/Statement.java new file mode 100644 index 0000000..30c462d --- /dev/null +++ b/src/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/src/com/github/javaparser/ast/stmt/SwitchEntryStmt.java b/src/com/github/javaparser/ast/stmt/SwitchEntryStmt.java new file mode 100644 index 0000000..853a79e --- /dev/null +++ b/src/com/github/javaparser/ast/stmt/SwitchEntryStmt.java @@ -0,0 +1,85 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchEntryStmt extends Statement { + + private Expression label; + + private List stmts; + + public SwitchEntryStmt() { + } + + public SwitchEntryStmt(final Expression label, final List stmts) { + setLabel(label); + setStmts(stmts); + } + + public SwitchEntryStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression label, + final List stmts) { + super(beginLine, beginColumn, endLine, endColumn); + setLabel(label); + setStmts(stmts); + } + + @Override + public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public Expression getLabel() { + return label; + } + + public List getStmts() { + stmts = ensureNotNull(stmts); + return stmts; + } + + public void setLabel(final Expression label) { + this.label = label; + setAsParentNodeOf(this.label); + } + + public void setStmts(final List stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + } +} diff --git a/src/com/github/javaparser/ast/stmt/SwitchStmt.java b/src/com/github/javaparser/ast/stmt/SwitchStmt.java new file mode 100644 index 0000000..a730b1f --- /dev/null +++ b/src/com/github/javaparser/ast/stmt/SwitchStmt.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchStmt extends Statement { + + private Expression selector; + + private List entries; + + public SwitchStmt() { + } + + public SwitchStmt(final Expression selector, + final List entries) { + setSelector(selector); + setEntries(entries); + } + + public SwitchStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression selector, + final List entries) { + super(beginLine, beginColumn, endLine, endColumn); + setSelector(selector); + setEntries(entries); + } + + @Override + public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getEntries() { + entries = ensureNotNull(entries); + return entries; + } + + public Expression getSelector() { + return selector; + } + + public void setEntries(final List entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + } + + public void setSelector(final Expression selector) { + this.selector = selector; + setAsParentNodeOf(this.selector); + } +} diff --git a/src/com/github/javaparser/ast/stmt/SynchronizedStmt.java b/src/com/github/javaparser/ast/stmt/SynchronizedStmt.java new file mode 100644 index 0000000..e91fc0b --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/ThrowStmt.java b/src/com/github/javaparser/ast/stmt/ThrowStmt.java new file mode 100644 index 0000000..48283b1 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/TryStmt.java b/src/com/github/javaparser/ast/stmt/TryStmt.java new file mode 100644 index 0000000..f6a709a --- /dev/null +++ b/src/com/github/javaparser/ast/stmt/TryStmt.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.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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class TryStmt extends Statement { + + private List resources; + + private BlockStmt tryBlock; + + private List catchs; + + private BlockStmt finallyBlock; + + public TryStmt() { + } + + public TryStmt(final BlockStmt tryBlock, final List 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 resources, + final BlockStmt tryBlock, final List catchs, final BlockStmt finallyBlock) { + super(beginLine, beginColumn, endLine, endColumn); + setResources(resources); + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + @Override + public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + public List getCatchs() { + catchs = ensureNotNull(catchs); + return catchs; + } + + public BlockStmt getFinallyBlock() { + return finallyBlock; + } + + public BlockStmt getTryBlock() { + return tryBlock; + } + + public List getResources() { + resources = ensureNotNull(resources); + return resources; + } + + public void setCatchs(final List 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 resources) { + this.resources = resources; + setAsParentNodeOf(this.resources); + } +} diff --git a/src/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java b/src/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java new file mode 100644 index 0000000..79b507a --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/stmt/WhileStmt.java b/src/com/github/javaparser/ast/stmt/WhileStmt.java new file mode 100644 index 0000000..51b2a1a --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/type/ClassOrInterfaceType.java b/src/com/github/javaparser/ast/type/ClassOrInterfaceType.java new file mode 100644 index 0000000..ceeedfd --- /dev/null +++ b/src/com/github/javaparser/ast/type/ClassOrInterfaceType.java @@ -0,0 +1,114 @@ +/* + * 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.NamedNode; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceType extends Type implements NamedNode { + + private ClassOrInterfaceType scope; + + private String name; + + private List 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 typeArgs) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setName(name); + setTypeArgs(typeArgs); + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + + @Override + public String getName() { + return name; + } + + public ClassOrInterfaceType getScope() { + return scope; + } + + public List getTypeArgs() { + typeArgs = ensureNotNull(typeArgs); + 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); + } + + /** + * Allows you to set the generic arguments + * @param typeArgs The list of types of the generics + */ + public void setTypeArgs(final List typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } + +} diff --git a/src/com/github/javaparser/ast/type/PrimitiveType.java b/src/com/github/javaparser/ast/type/PrimitiveType.java new file mode 100644 index 0000000..561a896 --- /dev/null +++ b/src/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 unboxMap = new HashMap(); + 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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/type/ReferenceType.java b/src/com/github/javaparser/ast/type/ReferenceType.java new file mode 100644 index 0000000..9141395 --- /dev/null +++ b/src/com/github/javaparser/ast/type/ReferenceType.java @@ -0,0 +1,128 @@ +/* + * 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; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class ReferenceType extends Type { + + private Type type; + + private int arrayCount; + + private List> 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 annotations, + List> arraysAnnotations) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setType(type); + setArrayCount(arrayCount); + this.arraysAnnotations = arraysAnnotations; + } + + @Override public R accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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); + } + + /** + *

Arrays annotations are annotations on the arrays modifiers of the type. + * Consider this example:

+ * + *

+	 * {@code
+	 * int @Ann1 [] @Ann2 [] array;
+	 * }

+ * + *

in this this method will return a list with the annotation expressions

@Ann1
+ * and
@Ann2

+ * + *

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. + *

+ * + *

This property is guaranteed to hold:

{@code getArraysAnnotations().size() == getArrayCount()}
+ * If a certain array modifier has no annotation the corresponding entry of arraysAnnotations will be null

+ */ + public List> getArraysAnnotations() { + arraysAnnotations = ensureNotNull(arraysAnnotations); + return arraysAnnotations; + } + + /** + * For a description of the arrayAnnotations field refer to {@link #getArraysAnnotations()} + */ + public void setArraysAnnotations(List> arraysAnnotations) { + this.arraysAnnotations = arraysAnnotations; + } +} diff --git a/src/com/github/javaparser/ast/type/Type.java b/src/com/github/javaparser/ast/type/Type.java new file mode 100644 index 0000000..fc9dbae --- /dev/null +++ b/src/com/github/javaparser/ast/type/Type.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.type; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +import static com.github.javaparser.ast.internal.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Type extends Node { + + private List annotations; + + public Type() { + } + + public Type(List 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 annotations) { + super(beginLine, beginColumn, endLine, endColumn); + this.annotations = annotations; + } + + public List getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public void setAnnotations(List annotations) { + this.annotations = annotations; + } + +} diff --git a/src/com/github/javaparser/ast/type/UnknownType.java b/src/com/github/javaparser/ast/type/UnknownType.java new file mode 100644 index 0000000..af6d4d9 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override + public
void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } +} diff --git a/src/com/github/javaparser/ast/type/VoidType.java b/src/com/github/javaparser/ast/type/VoidType.java new file mode 100644 index 0000000..5dacbe1 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/src/com/github/javaparser/ast/type/WildcardType.java b/src/com/github/javaparser/ast/type/WildcardType.java new file mode 100644 index 0000000..8016ed7 --- /dev/null +++ b/src/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 accept(final GenericVisitor v, final A arg) { + return v.visit(this, arg); + } + + @Override public void accept(final VoidVisitor 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/src/com/github/javaparser/ast/visitor/CloneVisitor.java b/src/com/github/javaparser/ast/visitor/CloneVisitor.java new file mode 100644 index 0000000..3d8d299 --- /dev/null +++ b/src/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 { + + @Override + public Node visit(CompilationUnit _n, Object _arg) { + PackageDeclaration package_ = cloneNodes(_n.getPackage(), _arg); + List imports = visit(_n.getImports(), _arg); + List 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 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 typeBound = visit(_n.getTypeBound(), _arg); + + List 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 annotations = visit(_n.getAnnotations(), _arg); + List typeParameters = visit(_n.getTypeParameters(), _arg); + List extendsList = visit(_n.getExtends(), _arg); + List implementsList = visit(_n.getImplements(), _arg); + List 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 annotations = visit(_n.getAnnotations(), _arg); + List implementsList = visit(_n.getImplements(), _arg); + List entries = visit(_n.getEntries(), _arg); + List 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 annotations = visit(_n.getAnnotations(), _arg); + List args = visit(_n.getArgs(), _arg); + List 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 annotations = visit(_n.getAnnotations(), _arg); + List 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 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 annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List 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 annotations = visit(_n.getAnnotations(), _arg); + List typeParameters = visit(_n.getTypeParameters(), _arg); + List parameters = visit(_n.getParameters(), _arg); + List 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 annotations = visit(_n.getAnnotations(), _arg); + List typeParameters = visit(_n.getTypeParameters(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List parameters = visit(_n.getParameters(), _arg); + List 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 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 annotations = visit(_n.getAnnotations(), _arg); + List 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 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 ann = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List> arraysAnnotations = _n.getArraysAnnotations(); + List> _arraysAnnotations = null; + if(arraysAnnotations != null){ + _arraysAnnotations = new LinkedList>(); + for(List 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 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> arraysAnnotations = _n.getArraysAnnotations(); + List> _arraysAnnotations = null; + if(arraysAnnotations != null){ + _arraysAnnotations = new LinkedList>(); + for(List 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 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 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 typeArgs = visit(_n.getTypeArgs(), _arg); + List 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 typeArgs = visit(_n.getTypeArgs(), _arg); + List args = visit(_n.getArgs(), _arg); + List 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 annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List 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 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 typeArgs = visit(_n.getTypeArgs(), _arg); + Expression expr = cloneNodes(_n.getExpr(), _arg); + List 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 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 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 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 init = visit(_n.getInit(), _arg); + Expression compare = cloneNodes(_n.getCompare(), _arg); + List 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 resources = visit(_n.getResources(),_arg); + BlockStmt tryBlock = cloneNodes(_n.getTryBlock(), _arg); + List 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 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 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 List visit(List _nodes, Object _arg) { + if (_nodes == null) + return null; + List r = new ArrayList(_nodes.size()); + for (T n : _nodes) { + T rN = cloneNodes(n, _arg); + if (rN != null) + r.add(rN); + } + return r; + } + + protected 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/src/com/github/javaparser/ast/visitor/DumpVisitor.java b/src/com/github/javaparser/ast/visitor/DumpVisitor.java new file mode 100644 index 0000000..b821e89 --- /dev/null +++ b/src/com/github/javaparser/ast/visitor/DumpVisitor.java @@ -0,0 +1,1671 @@ +/* + * 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 class DumpVisitor implements VoidVisitor { + + private boolean printComments; + + public DumpVisitor() { + this(true); + } + + public DumpVisitor(boolean printComments) { + this.printComments = printComments; + } + + protected static class SourcePrinter { + + private final String indentation; + + protected SourcePrinter(final String indentation) { + this.indentation = indentation; + } + + 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(indentation); + } + } + + 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 = createSourcePrinter(); + + protected SourcePrinter createSourcePrinter() { + return 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 members, final Object arg) { + for (final BodyDeclaration member : members) { + printer.printLn(); + member.accept(this, arg); + printer.printLn(); + } + } + + private void printMemberAnnotations(final List annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.printLn(); + } + } + } + + private void printAnnotations(final List annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.print(" "); + } + } + } + + private void printTypeArgs(final List args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator 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 args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator 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 args, final Object arg) { + printer.print("("); + if (!isNullOrEmpty(args)) { + for (final Iterator 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 (!isNullOrEmpty(n.getImports())) { + for (final ImportDeclaration i : n.getImports()) { + i.accept(this, arg); + } + printer.printLn(); + } + + if (!isNullOrEmpty(n.getTypes())) { + for (final Iterator 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 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 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 (!isNullOrEmpty(n.getTypeBound())) { + printer.print(" extends "); + for (final Iterator 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 (!isNullOrEmpty(n.getAnnotations())) { + 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 (!isNullOrEmpty(n.getAnnotations())) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + n.getType().accept(this, arg); + List> arraysAnnotations = n.getArraysAnnotations(); + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + List annotations = arraysAnnotations.get(i); + if (!isNullOrEmpty(annotations)) { + 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 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 (!isNullOrEmpty(n.getValues())) { + printer.print(" "); + for (final Iterator 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> arraysAnnotations = n.getArraysAnnotations(); + if (!isNullOrEmpty(n.getDimensions())) { + int j = 0; + for (final Expression dim : n.getDimensions()) { + + if (arraysAnnotations != null && j < arraysAnnotations.size()) { + List annotations = arraysAnnotations.get(j); + if (!isNullOrEmpty(annotations)) { + 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 annotations = arraysAnnotations.get(i); + if (!isNullOrEmpty(annotations)) { + 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 annotations = arraysAnnotations.get(i); + if (!isNullOrEmpty(annotations)) { + 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 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 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 (!isNullOrEmpty(n.getTypeParameters())) { + printer.print(" "); + } + + n.getType().accept(this, arg); + printer.print(" "); + printer.print(n.getName()); + + printer.print("("); + if (!isNullOrEmpty(n.getParameters())) { + for (final Iterator 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 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 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 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 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 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 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 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 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 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 parameters = n.getParameters(); + boolean printPar = false; + printPar = n.isParametersEnclosed(); + + if (printPar) { + printer.print("("); + } + if (parameters != null) { + for (Iterator 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 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 everything = new LinkedList(); + everything.addAll(parent.getChildrenNodes()); + sortByBeginPosition(everything); + int positionOfTheChild = -1; + for (int i=0;i=0 && positionOfPreviousChild==-1;i--){ + if (!(everything.get(i) instanceof Comment)) positionOfPreviousChild = i; + } + for (int i=positionOfPreviousChild+1;i everything = new LinkedList(); + everything.addAll(node.getChildrenNodes()); + sortByBeginPosition(everything); + if (everything.size()==0) { + return; + } + + int commentsAtEnd = 0; + boolean findingComments = true; + while (findingComments && commentsAtEnd { + + 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 boolean nodesEquals(final List nodes1, final List 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 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 n1types = n1.getTypes().iterator(); + Iterator 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> n1a = n1.getArraysAnnotations(); + List> n2a = n2.getArraysAnnotations(); + + if (n1a !=null && n2a!= null) { + if(n1a.size() != n2a.size()){ + return Boolean.FALSE; + } + else{ + int i = 0; + for(List 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> n1a = n1.getArraysAnnotations(); + List> n2a = n2.getArraysAnnotations(); + + if (n1a !=null && n2a!= null) { + if(n1a.size() != n2a.size()){ + return Boolean.FALSE; + } + else{ + int i = 0; + for(List 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/src/com/github/javaparser/ast/visitor/GenericVisitor.java b/src/com/github/javaparser/ast/visitor/GenericVisitor.java new file mode 100644 index 0000000..58fbf6d --- /dev/null +++ b/src/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 { + + //- 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/src/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java b/src/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java new file mode 100644 index 0000000..eac9cab --- /dev/null +++ b/src/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 implements GenericVisitor { + + @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/src/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java b/src/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java new file mode 100644 index 0000000..3d23cea --- /dev/null +++ b/src/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 implements GenericVisitor { + + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 types = new LinkedList(); + 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 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 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 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 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 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 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 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/src/com/github/javaparser/ast/visitor/VoidVisitor.java b/src/com/github/javaparser/ast/visitor/VoidVisitor.java new file mode 100644 index 0000000..b85bd55 --- /dev/null +++ b/src/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 { + + //- 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/src/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java b/src/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java new file mode 100644 index 0000000..ddad12f --- /dev/null +++ b/src/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 implements VoidVisitor { + + @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); + } + } +}