diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-04 08:21:35 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-04 08:21:35 +0000 |
commit | b4c1397d5df9370f6358d4f8e9efd27e0f67dec1 (patch) | |
tree | 6789ec288d344cf5fd5d057bcf1efc9545b1af28 /javaparser-symbol-solver-testing/src/test/test_sourcecode | |
parent | 92d661a1d239131fb5c1e019a8f2ac7584d2d3f6 (diff) | |
parent | 1afe9e0652b9b53edade5aa276162abe27b32a67 (diff) | |
download | platform_external_javaparser-b4c1397d5df9370f6358d4f8e9efd27e0f67dec1.tar.gz platform_external_javaparser-b4c1397d5df9370f6358d4f8e9efd27e0f67dec1.tar.bz2 platform_external_javaparser-b4c1397d5df9370f6358d4f8e9efd27e0f67dec1.zip |
Snap for 4632767 from 1afe9e0652b9b53edade5aa276162abe27b32a67 to pi-releaseandroid-wear-9.0.0_r9android-wear-9.0.0_r8android-wear-9.0.0_r7android-wear-9.0.0_r6android-wear-9.0.0_r5android-wear-9.0.0_r4android-wear-9.0.0_r3android-wear-9.0.0_r23android-wear-9.0.0_r22android-wear-9.0.0_r21android-wear-9.0.0_r20android-wear-9.0.0_r2android-wear-9.0.0_r19android-wear-9.0.0_r18android-wear-9.0.0_r17android-wear-9.0.0_r16android-wear-9.0.0_r15android-wear-9.0.0_r14android-wear-9.0.0_r13android-wear-9.0.0_r12android-wear-9.0.0_r11android-wear-9.0.0_r10android-wear-9.0.0_r1android-vts-9.0_r9android-vts-9.0_r8android-vts-9.0_r7android-vts-9.0_r6android-vts-9.0_r5android-vts-9.0_r4android-vts-9.0_r14android-vts-9.0_r13android-vts-9.0_r12android-vts-9.0_r11android-vts-9.0_r10android-cts-9.0_r9android-cts-9.0_r8android-cts-9.0_r7android-cts-9.0_r6android-cts-9.0_r5android-cts-9.0_r4android-cts-9.0_r3android-cts-9.0_r2android-cts-9.0_r13android-cts-9.0_r12android-cts-9.0_r11android-cts-9.0_r10android-cts-9.0_r1android-9.0.0_r9android-9.0.0_r8android-9.0.0_r7android-9.0.0_r60android-9.0.0_r6android-9.0.0_r59android-9.0.0_r58android-9.0.0_r57android-9.0.0_r56android-9.0.0_r55android-9.0.0_r54android-9.0.0_r53android-9.0.0_r52android-9.0.0_r51android-9.0.0_r50android-9.0.0_r5android-9.0.0_r49android-9.0.0_r48android-9.0.0_r3android-9.0.0_r2android-9.0.0_r18android-9.0.0_r17android-9.0.0_r10android-9.0.0_r1security-pi-releasepie-vts-releasepie-security-releasepie-s2-releasepie-release-2pie-releasepie-r2-s2-releasepie-r2-s1-releasepie-r2-releasepie-platform-releasepie-gsipie-cuttlefish-testingpie-cts-release
Change-Id: Ibe65883e94ed5a7272dff3f100393987a1cf3da2
Diffstat (limited to 'javaparser-symbol-solver-testing/src/test/test_sourcecode')
278 files changed, 66593 insertions, 0 deletions
diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/CommentsInserter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/CommentsInserter.java new file mode 100644 index 000000000..eee450d20 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/CommentsInserter.java @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.comments.Comment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.utils.PositionUtils; + +import java.util.*; + +import static com.github.javaparser.ast.Node.NODE_BY_BEGIN_POSITION; + +/** + * Assigns comments to nodes of the AST. + * + * @author Sebastian Kuerten + * @author Júlio Vilmar Gesser + */ +class CommentsInserter { + private final ParserConfiguration configuration; + + CommentsInserter(ParserConfiguration configuration) { + this.configuration = configuration; + } + + /** + * Comments are attributed to the thing they comment and are removed from + * the comments. + */ + private void insertComments(CompilationUnit cu, TreeSet<Comment> comments) { + if (comments.isEmpty()) + 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<Node> children = cu.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + Comment firstComment = comments.iterator().next(); + if (cu.getPackage() != null + && (children.isEmpty() || PositionUtils.areInOrder( + firstComment, children.get(0)))) { + cu.setComment(firstComment); + comments.remove(firstComment); + } + } + + /** + * This method try to attributes the nodes received to child of the node. It + * returns the node that were not attributed. + */ + void insertComments(Node node, TreeSet<Comment> commentsToAttribute) { + if (commentsToAttribute.isEmpty()) + return; + + if(node instanceof CompilationUnit){ + insertComments((CompilationUnit)node, commentsToAttribute); + } + + // the comments can: + // 1) Inside one of the child, then it is the child that have to + // associate them + // 2) If they are not inside a child they could be preceeding nothing, a + // comment or a child + // if they preceed a child they are assigned to it, otherweise they + // remain "orphans" + + List<Node> children = node.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + for (Node child : children) { + TreeSet<Comment> commentsInsideChild = new TreeSet<>(NODE_BY_BEGIN_POSITION); + for (Comment c : commentsToAttribute) { + if (PositionUtils.nodeContains(child, c, + configuration.doNotConsiderAnnotationsAsNodeStartForCodeAttribution)) { + commentsInsideChild.add(c); + } + } + commentsToAttribute.removeAll(commentsInsideChild); + insertComments(child, commentsInsideChild); + } + + /* I can attribute in line comments to elements preceeding them, if + there is something contained in their line */ + List<Comment> attributedComments = new LinkedList<>(); + for (Comment comment : commentsToAttribute) { + if (comment.isLineComment()) { + for (Node child : children) { + if (child.getEnd().line == comment.getBegin().line + && 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<Node> childrenAndComments = new LinkedList<>(); + childrenAndComments.addAll(children); + childrenAndComments.addAll(commentsToAttribute); + PositionUtils.sortByBeginPosition(childrenAndComments, + configuration.doNotConsiderAnnotationsAsNodeStartForCodeAttribution); + + for (Node thing : childrenAndComments) { + if (thing instanceof Comment) { + previousComment = (Comment) thing; + if (!previousComment.isOrphan()) { + previousComment = null; + } + } else { + if (previousComment != null && !thing.hasComment()) { + if (!configuration.doNotAssignCommentsPrecedingEmptyLines + || !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 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.getBegin().line == lineComment.getBegin().line + && !node.hasComment()) { + if(!(node instanceof Comment)) { + node.setComment(lineComment); + } + return true; + } else { + // try with all the children, sorted by reverse position (so the + // first one is the nearest to the comment + List<Node> children = new LinkedList<Node>(); + children.addAll(node.getChildrenNodes()); + PositionUtils.sortByBeginPosition(children); + Collections.reverse(children); + + for (Node child : children) { + if (attributeLineCommentToNodeOrChild(child, lineComment)) { + return true; + } + } + + return false; + } + } + + private boolean thereAreLinesBetween(Node a, Node b) { + if (!PositionUtils.areInOrder(a, b)) { + return thereAreLinesBetween(b, a); + } + int endOfA = a.getEnd().line; + return b.getBegin().line > (endOfA + 1); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/JavaParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/JavaParser.java new file mode 100644 index 000000000..7fdc77f21 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/JavaParser.java @@ -0,0 +1,318 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.ImportDeclaration; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.comments.CommentsCollection; +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.*; +import java.nio.charset.Charset; +import java.nio.file.Path; +import java.util.Optional; + +import static com.github.javaparser.ParseStart.*; +import static com.github.javaparser.Providers.UTF8; +import static com.github.javaparser.Providers.provider; + +/** + * Parse Java source code and creates Abstract Syntax Trees. + * + * @author Júlio Vilmar Gesser + */ +public final class JavaParser { + private final CommentsInserter commentsInserter; + + private ASTParser astParser = null; + + /** + * Instantiate the parser with default configuration. Note that parsing can also be done with the static methods on this class. + * Creating an instance will reduce setup time between parsing files. + */ + public JavaParser() { + this(new ParserConfiguration()); + } + + /** + * Instantiate the parser. Note that parsing can also be done with the static methods on this class. + * Creating an instance will reduce setup time between parsing files. + */ + public JavaParser(ParserConfiguration configuration) { + commentsInserter = new CommentsInserter(configuration); + } + + private ASTParser getParserForProvider(Provider provider) { + if (astParser == null) { + astParser = new ASTParser(provider); + } else { + astParser.ReInit(provider); + } + return astParser; + } + + /** + * Parses source code. + * It takes the source code from a Provider. + * The start indicates what can be found in the source code (compilation unit, block, import...) + * + * @param start refer to the constants in ParseStart to see what can be parsed. + * @param provider refer to Providers to see how you can read source. + * @param <N> the subclass of Node that is the result of parsing in the start. + * @return the parse result, a collection of encountered problems, and some extra data. + */ + public <N extends Node> ParseResult<N> parse(ParseStart<N> start, Provider provider) { + try { + final ASTParser parser = getParserForProvider(provider); + N resultNode = start.parse(parser); + final CommentsCollection comments = astParser.getCommentsCollection(); + commentsInserter.insertComments(resultNode, comments.copy().getComments()); + + return new ParseResult<>(Optional.of(resultNode), parser.problems, Optional.of(astParser.getTokens()), Optional.of(astParser.getCommentsCollection())); + } catch (ParseException e) { + return new ParseResult<>(e); + } catch (TokenMgrException e) { + return new ParseResult<>(e); + } finally { + try { + provider.close(); + } catch (IOException e) { + // Since we're done parsing and have our result, we don't care about any errors. + } + } + } + + /** + * 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 ParseProblemException if the source code has parser errors + */ + public static CompilationUnit parse(final InputStream in, Charset encoding) { + return simplifiedParse(COMPILATION_UNIT, provider(in, encoding)); + } + + /** + * Parses the Java code contained in the {@link InputStream} and returns a + * {@link CompilationUnit} that represents it.<br> + * Note: Uses UTF-8 encoding + * + * @param in {@link InputStream} containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseProblemException if the source code has parser errors + */ + public static CompilationUnit parse(final InputStream in) { + return parse(in, UTF8); + } + + /** + * 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 ParseProblemException if the source code has parser errors + * @throws FileNotFoundException the file was not found + */ + public static CompilationUnit parse(final File file, final Charset encoding) throws FileNotFoundException { + return simplifiedParse(COMPILATION_UNIT, provider(file, encoding)); + } + + /** + * Parses the Java code contained in a {@link File} and returns a + * {@link CompilationUnit} that represents it.<br> + * Note: Uses UTF-8 encoding + * + * @param file {@link File} containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseProblemException if the source code has parser errors + * @throws FileNotFoundException the file was not found + */ + public static CompilationUnit parse(final File file) throws FileNotFoundException { + return simplifiedParse(COMPILATION_UNIT, provider(file)); + } + + /** + * Parses the Java code contained in a file and returns a + * {@link CompilationUnit} that represents it. + * + * @param path path to a file containing Java source code + * @param encoding encoding of the source code + * @return CompilationUnit representing the Java source code + * @throws IOException the path could not be accessed + * @throws ParseProblemException if the source code has parser errors + */ + public static CompilationUnit parse(final Path path, final Charset encoding) throws IOException { + return simplifiedParse(COMPILATION_UNIT, provider(path, encoding)); + } + + /** + * Parses the Java code contained in a file and returns a + * {@link CompilationUnit} that represents it.<br> + * Note: Uses UTF-8 encoding + * + * @param path path to a file containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseProblemException if the source code has parser errors + * @throws IOException the path could not be accessed + */ + public static CompilationUnit parse(final Path path) throws IOException { + return simplifiedParse(COMPILATION_UNIT, provider(path)); + } + + /** + * Parses Java code from a Reader and returns a + * {@link CompilationUnit} that represents it.<br> + * + * @param reader the reader containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseProblemException if the source code has parser errors + */ + public static CompilationUnit parse(final Reader reader) { + return simplifiedParse(COMPILATION_UNIT, provider(reader)); + } + + /** + * Parses the Java code contained in code and returns a + * {@link CompilationUnit} that represents it. + * + * @param code Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseProblemException if the source code has parser errors + */ + public static CompilationUnit parse(String code) { + return simplifiedParse(COMPILATION_UNIT, provider(code)); + } + + /** + * 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 ParseProblemException if the source code has parser errors + */ + public static BlockStmt parseBlock(final String blockStatement) { + return simplifiedParse(BLOCK, provider(blockStatement)); + } + + /** + * 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 ParseProblemException if the source code has parser errors + */ + public static Statement parseStatement(final String statement) { + return simplifiedParse(STATEMENT, provider(statement)); + } + + private static <T extends Node> T simplifiedParse(ParseStart<T> context, Provider provider) { + ParseResult<T> result = new JavaParser(new ParserConfiguration()).parse(context, provider); + if (result.isSuccessful()) { + return result.getResult().get(); + } + throw new ParseProblemException(result.getProblems()); + } + + /** + * 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 ParseProblemException if the source code has parser errors + */ + public static ImportDeclaration parseImport(final String importDeclaration) { + return simplifiedParse(IMPORT_DECLARATION, provider(importDeclaration)); + } + + /** + * 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 ParseProblemException if the source code has parser errors + */ + public static Expression parseExpression(final String expression) { + return simplifiedParse(EXPRESSION, provider(expression)); + } + + /** + * 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 ParseProblemException if the source code has parser errors + */ + public static AnnotationExpr parseAnnotation(final String annotation) { + return simplifiedParse(ANNOTATION, provider(annotation)); + } + + /** + * Parses the Java annotation 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 ParseProblemException if the source code has parser errors + */ + public static BodyDeclaration<?> parseAnnotationBodyDeclaration(final String body) { + return simplifiedParse(ANNOTATION_BODY, provider(body)); + } + + /** + * Parses a Java class body declaration(e.g fields or methods) and returns a + * {@link BodyDeclaration} that represents it. + * + * @param body the body of a class + * @return BodyDeclaration representing the Java class body + * @throws ParseProblemException if the source code has parser errors + */ + public static BodyDeclaration<?> parseClassBodyDeclaration(String body) { + return simplifiedParse(CLASS_BODY, provider(body)); + } + + /** + * Parses a Java interface body declaration(e.g fields or methods) and returns a + * {@link BodyDeclaration} that represents it. + * + * @param body the body of an interface + * @return BodyDeclaration representing the Java interface body + * @throws ParseProblemException if the source code has parser errors + */ + public static BodyDeclaration parseInterfaceBodyDeclaration(String body) { + return simplifiedParse(INTERFACE_BODY, provider(body)); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/PackageLocalClasses.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/PackageLocalClasses.java new file mode 100644 index 000000000..90a33f5ba --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/PackageLocalClasses.java @@ -0,0 +1,4 @@ +package com.github.javaparser; + +class FooClass {} +class BarClass {}
\ No newline at end of file diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseProblemException.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseProblemException.java new file mode 100644 index 000000000..f6a029886 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseProblemException.java @@ -0,0 +1,40 @@ +package com.github.javaparser; + +import java.util.List; +import java.util.Optional; + +import static com.github.javaparser.utils.Utils.assertNotNull; +import static java.util.Collections.singletonList; + +import static com.github.javaparser.utils.Utils.EOL; + +/** + * Thrown when parsing problems occur during parsing with the static methods on JavaParser. + */ +public class ParseProblemException extends RuntimeException { + /** + * The problems that were encountered during parsing + */ + private final List<Problem> problems; + + ParseProblemException(List<Problem> problems) { + super(createMessage(assertNotNull(problems))); + this.problems = problems; + } + + ParseProblemException(Throwable throwable) { + this(singletonList(new Problem(throwable.getMessage(), Optional.empty(), Optional.of(throwable)))); + } + + private static String createMessage(List<Problem> problems) { + StringBuilder message = new StringBuilder(); + for(Problem problem: problems){ + message.append(problem.toString()).append(EOL); + } + return message.toString(); + } + + public List<Problem> getProblems() { + return problems; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseResult.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseResult.java new file mode 100644 index 000000000..88e400525 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseResult.java @@ -0,0 +1,88 @@ +package com.github.javaparser; + +import com.github.javaparser.ast.comments.CommentsCollection; + +import java.util.List; +import java.util.Optional; + +import static com.github.javaparser.utils.Utils.assertNotNull; +import static java.util.Collections.singletonList; + +import static com.github.javaparser.utils.Utils.EOL; + +/** + * The results given when parsing with an instance of JavaParser. + */ +public class ParseResult<T> { + private final Optional<T> result; + private final List<Problem> problems; + private final Optional<List<Token>> tokens; + private final Optional<CommentsCollection> commentsCollection; + + /** + * General constructor. + * @param result the AST, or empty if it wasn't created. + * @param problems a list of encountered parsing problems. + * @param tokens the complete list of tokens that were parsed, or empty if parsing failed completely. + */ + ParseResult(Optional<T> result, List<Problem> problems, Optional<List<Token>> tokens, Optional<CommentsCollection> commentsCollection) { + this.commentsCollection = assertNotNull(commentsCollection); + this.result = assertNotNull(result); + this.problems = assertNotNull(problems); + this.tokens = assertNotNull(tokens); + } + + /** + * Used when parsing failed completely with an exception. + */ + ParseResult(Throwable throwable) { + this(Optional.empty(), singletonList(new Problem(throwable.getMessage(), Optional.empty(), Optional.of(throwable))), Optional.empty(), Optional.empty()); + } + + /** + * @return if parsing was successful, meaning no errors of any kind were encountered. + */ + public boolean isSuccessful() { + return problems.isEmpty() && result.isPresent(); + } + + /** + * @return the list of encountered parsing problems. Empty when no problems were encountered. + */ + public List<Problem> getProblems() { + return problems; + } + + /** + * @return the complete list of tokens that were parsed, or empty if parsing failed completely. + */ + public Optional<List<Token>> getTokens() { + return tokens; + } + + /** + * @return the complete collection of comments encountered while parsing. + */ + public Optional<CommentsCollection> getCommentsCollection() { + return commentsCollection; + } + + /** + * @return the AST of the parsed source code, or empty if parsing failed completely. + */ + public Optional<T> getResult() { + return result; + } + + @Override + public String toString() { + if (isSuccessful()) { + return "Parsing successful"; + } + StringBuilder message = new StringBuilder("Parsing failed:").append(EOL); + for (Problem problem : problems) { + message.append(problem.toString()).append(EOL); + } + return message.toString(); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseStart.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseStart.java new file mode 100644 index 000000000..f94a66282 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParseStart.java @@ -0,0 +1,32 @@ +package com.github.javaparser; + +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +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; + +/** + * The start production for JavaParser. + * Tells JavaParser what piece of Java code it can expect. + * For example, + * COMPILATION_UNIT indicates a complete Java file, + * and CLASS_BODY would indicate the part of a class that is within { and }. + * @see JavaParser#parse(ParseStart, Provider) + */ +@FunctionalInterface +public interface ParseStart<R> { + ParseStart<CompilationUnit> COMPILATION_UNIT = ASTParser::CompilationUnit; + ParseStart<BlockStmt> BLOCK = ASTParser::Block; + ParseStart<Statement> STATEMENT = ASTParser::BlockStatement; + ParseStart<ImportDeclaration> IMPORT_DECLARATION= ASTParser::ImportDeclaration; + ParseStart<Expression> EXPRESSION = ASTParser::Expression; + ParseStart<AnnotationExpr> ANNOTATION = ASTParser::Annotation; + ParseStart<BodyDeclaration<?>> ANNOTATION_BODY = ASTParser::AnnotationBodyDeclaration; + ParseStart<BodyDeclaration<?>> CLASS_BODY = p -> p.ClassOrInterfaceBodyDeclaration(false); + ParseStart<BodyDeclaration<?>> INTERFACE_BODY = p -> p.ClassOrInterfaceBodyDeclaration(true); + + R parse(ASTParser parser) throws ParseException; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParserConfiguration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParserConfiguration.java new file mode 100644 index 000000000..0b165b6e2 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ParserConfiguration.java @@ -0,0 +1,6 @@ +package com.github.javaparser; + +public class ParserConfiguration { + public boolean doNotAssignCommentsPrecedingEmptyLines = true; + public boolean doNotConsiderAnnotationsAsNodeStartForCodeAttribution = false; +}
\ No newline at end of file diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Position.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Position.java new file mode 100644 index 000000000..312824445 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Position.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.assertNotNull; + +/** + * A position in a source file. Lines and columns start counting at 1. + */ +public class Position implements Comparable<Position> { + public final int line; + public final 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); + + /** + * The first position in the file + */ + public static final Position HOME = new Position(1, 1); + public static final Position UNKNOWN = new Position(0, 0); + + public Position(int line, int column) { + if (line < Node.ABSOLUTE_END_LINE) { + throw new IllegalArgumentException("Can't position at line " + line); + } + if (column < -1) { + throw new IllegalArgumentException("Can't position at column " + column); + } + this.line = line; + this.column = column; + } + + /** + * Convenient factory method. + */ + public static Position pos(int line, int column) { + return new Position(line, column); + } + + public Position withColumn(int column) { + return new Position(this.line, column); + } + + public Position withLine(int line) { + return new Position(line, this.column); + } + + /** + * Check if the position is usable. Does not know what it is pointing at, so it can't check if the position is after the end of the source. + */ + public boolean valid() { + return line > 0 && column > 0; + } + + public boolean invalid() { + return !valid(); + } + + public Position orIfInvalid(Position anotherPosition) { + if (valid()) { + return this; + } + return anotherPosition; + } + + public boolean isAfter(Position position) { + assertNotNull(position); + if (position.line == Node.ABSOLUTE_BEGIN_LINE) return true; + if (line > position.line) { + return true; + } else if (line == position.line) { + return column > position.column; + } + return false; + + } + + public boolean isBefore(Position position) { + assertNotNull(position); + if (position.line == Node.ABSOLUTE_END_LINE) return true; + if (line < position.line) { + return true; + } else if (line == position.line) { + return column < position.column; + } + return false; + } + + @Override + public int compareTo(Position o) { + assertNotNull(o); + if (isBefore(o)) { + return -1; + } + if (isAfter(o)) { + return 1; + } + return 0; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Position position = (Position) o; + + return line == position.line && column == position.column; + } + + @Override + public int hashCode() { + return 31 * line + column; + } + + @Override + public String toString() { + return "(line " + line + ",col " + column + ")"; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Problem.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Problem.java new file mode 100644 index 000000000..7e45cc987 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Problem.java @@ -0,0 +1,39 @@ +package com.github.javaparser; + +import java.util.Optional; + +import static com.github.javaparser.utils.Utils.assertNotNull; + +/** + * A problem that was encountered during parsing. + */ +public class Problem { + private final String message; + private final Optional<Range> range; + private final Optional<Throwable> cause; + + Problem(String message, Optional<Range> range, Optional<Throwable> cause) { + this.message = assertNotNull(message); + this.range = assertNotNull(range); + this.cause = assertNotNull(cause); + } + + @Override + public String toString() { + StringBuilder str = new StringBuilder(message); + range.ifPresent(r -> str.append(" ").append(r)); + return str.toString(); + } + + public String getMessage() { + return message; + } + + public Optional<Range> getRange() { + return range; + } + + public Optional<Throwable> getCause() { + return cause; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Providers.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Providers.java new file mode 100644 index 000000000..b5e731c09 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Providers.java @@ -0,0 +1,61 @@ +package com.github.javaparser; + +import java.io.*; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; + +import static com.github.javaparser.utils.Utils.assertNotNull; + +/** + * Factory for providers of source code for JavaParser. + * Providers that have no parameter for encoding but need it will use UTF-8. + */ +public final class Providers { + public static final Charset UTF8 = Charset.forName("utf-8"); + + private Providers() { + } + + public static Provider provider(Reader reader) { + return new StreamProvider(assertNotNull(reader)); + } + + public static Provider provider(InputStream input, Charset encoding) { + assertNotNull(input); + assertNotNull(encoding); + try { + return new StreamProvider(input, encoding.name()); + } catch (IOException e) { + // The only one that is thrown is UnsupportedCharacterEncodingException, + // and that's a fundamental problem, so runtime exception. + throw new RuntimeException(e); + } + } + + public static Provider provider(InputStream input) { + return provider(input, UTF8); + } + + public static Provider provider(File file, Charset encoding) throws FileNotFoundException { + return provider(new FileInputStream(assertNotNull(file)), assertNotNull(encoding)); + } + + public static Provider provider(File file) throws FileNotFoundException { + return provider(assertNotNull(file), UTF8); + } + + public static Provider provider(Path path, Charset encoding) throws IOException { + return provider(Files.newInputStream(assertNotNull(path)), assertNotNull(encoding)); + } + + public static Provider provider(Path path) throws IOException { + return provider(assertNotNull(path), UTF8); + } + + public static Provider provider(String source) { + return new StringProvider(assertNotNull(source)); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Range.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Range.java new file mode 100644 index 000000000..68e364aed --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/Range.java @@ -0,0 +1,89 @@ +package com.github.javaparser; + +import static com.github.javaparser.Position.pos; + +/** + * A range of characters in a source file, from "begin" to "end", including the characters at "begin" and "end". + */ +public class Range { + public static final Range UNKNOWN = range(Position.UNKNOWN, Position.UNKNOWN); + + public final Position begin; + public final Position end; + + public Range(Position begin, Position end) { + if (begin == null) { + throw new IllegalArgumentException("begin can't be null"); + } + if (end == null) { + throw new IllegalArgumentException("end can't be null"); + } + this.begin = begin; + this.end = end; + } + + public static Range range(Position begin, Position end) { + return new Range(begin, end); + } + + public static Range range(int beginLine, int beginColumn, int endLine, int endColumn) { + return new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)); + } + + public Range withBeginColumn(int column) { + return range(begin.withColumn(column), end); + } + + public Range withBeginLine(int line) { + return range(begin.withLine(line), end); + } + + public Range withEndColumn(int column) { + return range(begin, end.withColumn(column)); + } + + public Range withEndLine(int line) { + return range(begin, end.withLine(line)); + } + + public Range withBegin(Position begin) { + return range(begin, this.end); + } + + public Range withEnd(Position end) { + return range(this.begin, end); + } + + public boolean contains(Range other) { + return begin.isBefore(other.begin) && end.isAfter(other.end); + } + + public boolean isBefore(Position position) { + return end.isBefore(position); + } + + public boolean isAfter(Position position) { + return begin.isAfter(position); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Range range = (Range) o; + + return begin.equals(range.begin) && end.equals(range.end); + + } + + @Override + public int hashCode() { + return 31 * begin.hashCode() + end.hashCode(); + } + + @Override + public String toString() { + return begin+"-"+end; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/AccessSpecifier.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/AccessSpecifier.java new file mode 100644 index 000000000..f23f8631d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/AccessSpecifier.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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; + + AccessSpecifier(String codeRepresentation) { + this.codeRepresenation = codeRepresentation; + } + + public String getCodeRepresenation(){ + return this.codeRepresenation; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ArrayBracketPair.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ArrayBracketPair.java new file mode 100644 index 000000000..cca0b8761 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ArrayBracketPair.java @@ -0,0 +1,44 @@ +package com.github.javaparser.ast; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * In, for example, <code>int[] a[];</code> there are two ArrayBracketPair objects, + * one for the [] after int, one for the [] after a. + */ +public class ArrayBracketPair extends Node implements NodeWithAnnotations<ArrayBracketPair> { + private List<AnnotationExpr> annotations; + + public ArrayBracketPair(Range range, List<AnnotationExpr> annotations) { + super(range); + setAnnotations(annotations); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<AnnotationExpr> getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public ArrayBracketPair setAnnotations(List<AnnotationExpr> annotations) { + setAsParentNodeOf(annotations); + this.annotations = annotations; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ArrayCreationLevel.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ArrayCreationLevel.java new file mode 100644 index 000000000..2edc68c2a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ArrayCreationLevel.java @@ -0,0 +1,56 @@ +package com.github.javaparser.ast; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * In <code>new int[1][2];</code> there are two ArrayCreationLevel objects, + * the first one contains the expression "1", + * the second the expression "2". + */ +public class ArrayCreationLevel extends Node implements NodeWithAnnotations<ArrayCreationLevel> { + private Expression dimension; + private List<AnnotationExpr> annotations; + + public ArrayCreationLevel(Range range, Expression dimension, List<AnnotationExpr> annotations) { + super(range); + setDimension(dimension); + setAnnotations(annotations); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public void setDimension(Expression dimension) { + this.dimension = dimension; + setAsParentNodeOf(dimension); + } + + public Expression getDimension() { + return dimension; + } + + public List<AnnotationExpr> getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public ArrayCreationLevel setAnnotations(List<AnnotationExpr> annotations) { + setAsParentNodeOf(annotations); + this.annotations = annotations; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java new file mode 100644 index 000000000..2f30777de --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java @@ -0,0 +1,413 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.ast.expr.NameExpr.*; +import static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; + +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.utils.ClassUtils; +import com.github.javaparser.Range; +import com.github.javaparser.ast.body.*; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.utils.ClassUtils; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * <p> + * This class represents the entire compilation unit. Each java file denotes a + * compilation unit. + * </p> + * The CompilationUnit is constructed following the syntax:<br> + * + * <pre> + * {@code + * CompilationUnit ::= ( }{@link PackageDeclaration}{@code )? + * ( }{@link ImportDeclaration}{@code )* + * ( }{@link TypeDeclaration}{@code )* + * } + * </pre> + * + * @author Julio Vilmar Gesser + */ +public final class CompilationUnit extends Node { + + private PackageDeclaration pakage; + + private List<ImportDeclaration> imports; + + private List<TypeDeclaration<?>> types; + + public CompilationUnit() { + } + + public CompilationUnit(PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration<?>> types) { + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + public CompilationUnit(Range range, PackageDeclaration pakage, List<ImportDeclaration> imports, + List<TypeDeclaration<?>> types) { + super(range); + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return a list containing all comments declared in this compilation unit. + * Including javadocs, line comments and block comments of all types, + * inner-classes and other members.<br> + * If there is no comment, <code>null</code> is returned. + * + * @return list with all comments of this compilation unit or + * <code>null</code> + * @see JavadocComment + * @see com.github.javaparser.ast.comments.LineComment + * @see com.github.javaparser.ast.comments.BlockComment + */ + public List<Comment> getComments() { + return this.getAllContainedComments(); + } + + /** + * Retrieves the list of imports declared in this compilation unit or + * <code>null</code> if there is no import. + * + * @return the list of imports or <code>null</code> if there is no import + */ + public List<ImportDeclaration> getImports() { + imports = ensureNotNull(imports); + return imports; + } + + /** + * Retrieves the package declaration of this compilation unit.<br> + * If this compilation unit has no package declaration (default package), + * <code>null</code> is returned. + * + * @return the package declaration or <code>null</code> + */ + public PackageDeclaration getPackage() { + return pakage; + } + + /** + * Return the list of types declared in this compilation unit.<br> + * If there is no types declared, <code>null</code> is returned. + * + * @return the list of types or <code>null</code> null if there is no type + * @see AnnotationDeclaration + * @see ClassOrInterfaceDeclaration + * @see EmptyTypeDeclaration + * @see EnumDeclaration + */ + public List<TypeDeclaration<?>> getTypes() { + types = ensureNotNull(types); + return types; + } + + /** + * Sets the list of comments of this compilation unit. + * + * @param comments + * the list of comments + */ + public CompilationUnit setComments(List<Comment> comments) { + throw new RuntimeException("Not implemented!"); + } + + /** + * Sets the list of imports of this compilation unit. The list is initially + * <code>null</code>. + * + * @param imports + * the list of imports + */ + public CompilationUnit setImports(List<ImportDeclaration> imports) { + this.imports = imports; + setAsParentNodeOf(this.imports); + return this; + } + + /** + * Sets or clear the package declarations of this compilation unit. + * + * @param pakage + * the pakage declaration to set or <code>null</code> to default + * package + */ + public CompilationUnit setPackage(PackageDeclaration pakage) { + this.pakage = pakage; + setAsParentNodeOf(this.pakage); + return this; + } + + /** + * Sets the list of types declared in this compilation unit. + * + * @param types + * the lis of types + */ + public CompilationUnit setTypes(List<TypeDeclaration<?>> types) { + this.types = types; + setAsParentNodeOf(this.types); + return this; + } + + /** + * sets the package declaration of this compilation unit + * + * @param name the name of the package + * @return this, the {@link CompilationUnit} + */ + public CompilationUnit setPackageName(String name) { + setPackage(new PackageDeclaration(name(name))); + return this; + } + + /** + * Add an import to the list of {@link ImportDeclaration} of this compilation unit<br> + * shorthand for {@link #addImport(String, boolean, boolean)} with name,false,false + * + * @param name the import name + * @return this, the {@link CompilationUnit} + */ + public CompilationUnit addImport(String name) { + return addImport(name, false, false); + } + + /** + * Add an import to the list of {@link ImportDeclaration} of this compilation unit<br> + * shorthand for {@link #addImport(String)} with clazz.getName() + * + * @param clazz the class to import + * @return this, the {@link CompilationUnit} + */ + public CompilationUnit addImport(Class<?> clazz) { + if (ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.getName().startsWith("java.lang")) + return this; + else if (clazz.isArray() && !ClassUtils.isPrimitiveOrWrapper(clazz.getComponentType()) + && !clazz.getComponentType().getName().startsWith("java.lang")) + return addImport(clazz.getComponentType().getName()); + return addImport(clazz.getName()); + } + + /** + * Add an import to the list of {@link ImportDeclaration} of this compilation unit<br> + * <b>This method check if no import with the same name is already in the list</b> + * + * @param name the import name + * @param isStatic is it an "import static" + * @param isAsterisk does the import end with ".*" + * @return this, the {@link CompilationUnit} + */ + public CompilationUnit addImport(String name, boolean isStatic, boolean isAsterisk) { + if (getImports().stream().anyMatch(i -> i.getName().toString().equals(name))) + return this; + else { + ImportDeclaration importDeclaration = new ImportDeclaration(name(name), isStatic, + isAsterisk); + getImports().add(importDeclaration); + importDeclaration.setParentNode(this); + return this; + } + } + + /** + * Add a public class to the types of this compilation unit + * + * @param name the class name + * @return the newly created class + */ + public ClassOrInterfaceDeclaration addClass(String name) { + return addClass(name, Modifier.PUBLIC); + } + + /** + * Add a class to the types of this compilation unit + * + * @param name the class name + * @param modifiers the modifiers (like Modifier.PUBLIC) + * @return the newly created class + */ + public ClassOrInterfaceDeclaration addClass(String name, Modifier... modifiers) { + ClassOrInterfaceDeclaration classOrInterfaceDeclaration = new ClassOrInterfaceDeclaration( + Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))), + false, name); + getTypes().add(classOrInterfaceDeclaration); + classOrInterfaceDeclaration.setParentNode(this); + return classOrInterfaceDeclaration; + } + + /** + * Add a public interface class to the types of this compilation unit + * + * @param name the interface name + * @return the newly created class + */ + public ClassOrInterfaceDeclaration addInterface(String name) { + return addInterface(name, Modifier.PUBLIC); + } + + /** + * Add an interface to the types of this compilation unit + * + * @param name the interface name + * @param modifiers the modifiers (like Modifier.PUBLIC) + * @return the newly created class + */ + public ClassOrInterfaceDeclaration addInterface(String name, Modifier... modifiers) { + ClassOrInterfaceDeclaration classOrInterfaceDeclaration = new ClassOrInterfaceDeclaration( + Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))), + true, name); + getTypes().add(classOrInterfaceDeclaration); + classOrInterfaceDeclaration.setParentNode(this); + return classOrInterfaceDeclaration; + } + + /** + * Add a public enum to the types of this compilation unit + * + * @param name the enum name + * @return the newly created class + */ + public EnumDeclaration addEnum(String name) { + return addEnum(name, Modifier.PUBLIC); + } + + /** + * Add an enum to the types of this compilation unit + * + * @param name the enum name + * @param modifiers the modifiers (like Modifier.PUBLIC) + * @return the newly created class + */ + public EnumDeclaration addEnum(String name, Modifier... modifiers) { + EnumDeclaration enumDeclaration = new EnumDeclaration(Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))), name); + getTypes().add(enumDeclaration); + enumDeclaration.setParentNode(this); + return enumDeclaration; + } + + /** + * Add a public annotation declaration to the types of this compilation unit + * + * @param name the annotation name + * @return the newly created class + */ + public AnnotationDeclaration addAnnotationDeclaration(String name) { + return addAnnotationDeclaration(name, Modifier.PUBLIC); + } + + /** + * Add an annotation declaration to the types of this compilation unit + * + * @param name the annotation name + * @param modifiers the modifiers (like Modifier.PUBLIC) + * @return the newly created class + */ + public AnnotationDeclaration addAnnotationDeclaration(String name, Modifier... modifiers) { + AnnotationDeclaration annotationDeclaration = new AnnotationDeclaration(Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class))), name); + getTypes().add(annotationDeclaration); + annotationDeclaration.setParentNode(this); + return annotationDeclaration; + } + + /** + * Try to get a class by its name + * + * @param className the class name (case-sensitive) + * @return null if not found, the class otherwise + */ + public ClassOrInterfaceDeclaration getClassByName(String className) { + return (ClassOrInterfaceDeclaration) getTypes().stream().filter(type -> type.getName().equals(className) + && type instanceof ClassOrInterfaceDeclaration && !((ClassOrInterfaceDeclaration) type).isInterface()) + .findFirst().orElse(null); + } + + /** + * Try to get an interface by its name + * + * @param interfaceName the interface name (case-sensitive) + * @return null if not found, the interface otherwise + */ + public ClassOrInterfaceDeclaration getInterfaceByName(String interfaceName) { + return (ClassOrInterfaceDeclaration) getTypes().stream().filter(type -> type.getName().equals(interfaceName) + && type instanceof ClassOrInterfaceDeclaration && ((ClassOrInterfaceDeclaration) type).isInterface()) + .findFirst().orElse(null); + } + + /** + * Try to get an enum by its name + * + * @param enumName the enum name (case-sensitive) + * @return null if not found, the enum otherwise + */ + public EnumDeclaration getEnumByName(String enumName) { + return (EnumDeclaration) getTypes().stream().filter(type -> type.getName().equals(enumName) + && type instanceof EnumDeclaration) + .findFirst().orElse(null); + } + + /** + * Try to get an annotation by its name + * + * @param annotationName the annotation name (case-sensitive) + * @return null if not found, the annotation otherwise + */ + public AnnotationDeclaration getAnnotationDeclarationByName(String annotationName) { + return (AnnotationDeclaration) getTypes().stream().filter(type -> type.getName().equals(annotationName) + && type instanceof AnnotationDeclaration) + .findFirst().orElse(null); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Example.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Example.java new file mode 100644 index 000000000..70cf2cd91 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Example.java @@ -0,0 +1,31 @@ +package com.github.javaparser.ast; + +import com.github.javaparser.JavaParser; +import com.github.javaparser.ParseException; +import com.github.javaparser.ast.CompilationUnit; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; + +/** + * Created by federico on 07/01/16. + */ +public class Example { + + public static void main(String[] args) throws UnsupportedEncodingException, ParseException { + String code = "interface A {\n" + + " default Comparator<T> thenComparing(Comparator<? super T> other) {\n" + + " Objects.requireNonNull(other);\n" + + " return (Comparator<T> & Serializable) (c1, c2) -> { // this is the defaulting line\n" + + " int res = compare(c1, c2);\n" + + " return (res != 0) ? res : other.compare(c1, c2);\n" + + " };\n" + + " }\n" + + "}"; + InputStream stream = new ByteArrayInputStream(code.getBytes("UTF-8")); + CompilationUnit cu = JavaParser.parse(stream); + + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ImportDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ImportDeclaration.java new file mode 100644 index 000000000..863c8d364 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/ImportDeclaration.java @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * This class represents a import declaration or an empty import declaration. Imports are optional for the + * {@link CompilationUnit}. + * </p> + * The ImportDeclaration is constructed following the syntax:<br> + * <pre> + * {@code + * ImportDeclaration ::= "import" ( "static" )? }{@link NameExpr}{@code ( "." "*" )? ";" + * } + * </pre> + * An enmpty import declaration is simply a semicolon among the import declarations. + * @author Julio Vilmar Gesser + */ +public final class ImportDeclaration extends Node { + + private NameExpr name; + private boolean static_; + private boolean asterisk; + private boolean isEmptyImportDeclaration; + + private ImportDeclaration() { + this.isEmptyImportDeclaration = true; + static_ = false; + asterisk = false; + } + + private ImportDeclaration(Range range) { + super(range); + this.isEmptyImportDeclaration = true; + static_ = false; + asterisk = false; + } + + /** + * Create an empty import declaration without specifying its position. + */ + public static ImportDeclaration createEmptyDeclaration(){ + return new ImportDeclaration(); + } + + /** + * Create an empty import declaration specifying its position. + */ + public static ImportDeclaration createEmptyDeclaration(Range range){ + return new ImportDeclaration(range); + } + + public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk) { + setAsterisk(isAsterisk); + setName(name); + setStatic(isStatic); + this.isEmptyImportDeclaration = false; + } + + public ImportDeclaration(Range range, NameExpr name, boolean isStatic, boolean isAsterisk) { + super(range); + setAsterisk(isAsterisk); + setName(name); + setStatic(isStatic); + this.isEmptyImportDeclaration = false; + } + + /** + * Is this an empty import declaration or a normal import declaration? + */ + public boolean isEmptyImportDeclaration(){ + return this.isEmptyImportDeclaration; + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the name of the import. + * + * @return the name of the import + * @throws UnsupportedOperationException when invoked on an empty import declaration + */ + public NameExpr getName() { + if (isEmptyImportDeclaration) { + throw new UnsupportedOperationException("Empty import declarations have no name"); + } + return name; + } + + /** + * Return if the import ends with "*". + * + * @return <code>true</code> if the import ends with "*", <code>false</code> + * otherwise + */ + public boolean isAsterisk() { + return asterisk; + } + + /** + * Return if the import is static. + * + * @return <code>true</code> if the import is static, <code>false</code> + * otherwise + */ + public boolean isStatic() { + return static_; + } + + /** + * Sets if this import is asterisk. + * + * @param asterisk + * <code>true</code> if this import is asterisk + * @throws UnsupportedOperationException when setting true on an empty import declaration + */ + public ImportDeclaration setAsterisk(boolean asterisk) { + if (isEmptyImportDeclaration && asterisk) { + throw new UnsupportedOperationException("Empty import cannot have asterisk"); + } + this.asterisk = asterisk; + return this; + } + + /** + * Sets the name this import. + * + * @param name + * the name to set + * @throws UnsupportedOperationException when invoked on an empty import declaration + */ + public ImportDeclaration setName(NameExpr name) { + if (isEmptyImportDeclaration) { + throw new UnsupportedOperationException("Empty import cannot have name"); + } + this.name = name; + setAsParentNodeOf(this.name); + return this; + } + + /** + * Sets if this import is static. + * + * @param static_ + * <code>true</code> if this import is static + * @throws UnsupportedOperationException when setting true on an empty import declaration + */ + public ImportDeclaration setStatic(boolean static_) { + if (isEmptyImportDeclaration && static_) { + throw new UnsupportedOperationException("Empty import cannot be static"); + } + this.static_ = static_; + return this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Modifier.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Modifier.java new file mode 100644 index 000000000..3f5a50b45 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Modifier.java @@ -0,0 +1,46 @@ +package com.github.javaparser.ast; + +import java.util.EnumSet; + +public enum Modifier { + PUBLIC("public"), + PROTECTED("protected"), + PRIVATE("private"), + ABSTRACT("abstract"), + STATIC("static"), + FINAL("final"), + TRANSIENT("transient"), + VOLATILE("volatile"), + SYNCHRONIZED("synchronized"), + NATIVE("native"), + STRICTFP("strictfp"); + + String lib; + + private Modifier(String lib) { + this.lib = lib; + } + + /** + * @return the lib + */ + public String getLib() { + return lib; + } + + public EnumSet<Modifier> toEnumSet() { + return EnumSet.of(this); + } + + public static AccessSpecifier getAccessSpecifier(EnumSet<Modifier> modifiers) { + if (modifiers.contains(Modifier.PUBLIC)) { + return AccessSpecifier.PUBLIC; + } else if (modifiers.contains(Modifier.PROTECTED)) { + return AccessSpecifier.PROTECTED; + } else if (modifiers.contains(Modifier.PRIVATE)) { + return AccessSpecifier.PRIVATE; + } else { + return AccessSpecifier.DEFAULT; + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Node.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Node.java new file mode 100644 index 000000000..f2bae43b1 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/Node.java @@ -0,0 +1,396 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Position; +import com.github.javaparser.Range; +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.visitor.*; + +import java.util.*; + +/** + * 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 { + /** + * This can be used to sort nodes on position. + */ + public static Comparator<Node> NODE_BY_BEGIN_POSITION = (a, b) -> a.getBegin().compareTo(b.getBegin()); + + private Range range; + + private Node parentNode; + + private List<Node> childrenNodes = new LinkedList<>(); + private List<Comment> orphanComments = new LinkedList<>(); + + private IdentityHashMap<UserDataKey<?>, Object> userData = null; + + private Comment comment; + + public Node() { + this(Range.UNKNOWN); + } + + public Node(Range range) { + this.range = range; + } + + /** + * Accept method for visitor support. + * + * @param <R> + * the type the return value of the visitor + * @param <A> + * the type the argument passed to the visitor + * @param v + * the visitor implementation + * @param arg + * the argument passed to the visitor + * @return the result of the visit + */ + public abstract <R, A> R accept(GenericVisitor<R, A> v, A arg); + + /** + * Accept method for visitor support. + * + * @param <A> + * the type the argument passed for the visitor + * @param v + * the visitor implementation + * @param arg + * any value relevant for the visitor + */ + public abstract <A> void accept(VoidVisitor<A> v, A arg); + + /** + * This is a comment associated with this node. + * + * @return comment property + */ + public final Comment getComment() { + return comment; + } + + /** + * The begin position of this node in the source file. + */ + public Position getBegin() { + return range.begin; + } + + /** + * The end position of this node in the source file. + */ + public Position getEnd() { + return range.end; + } + + /** + * Sets the begin position of this node in the source file. + */ + public Node setBegin(Position begin) { + range = range.withBegin(begin); + return this; + } + + /** + * Sets the end position of this node in the source file. + */ + public Node setEnd(Position end) { + range = range.withEnd(end); + return this; + } + + /** + * @return the range of characters in the source code that this node covers. + */ + public Range getRange() { + return range; + } + + /** + * @param range the range of characters in the source code that this node covers. + */ + public Node setRange(Range range) { + this.range = range; + return this; + } + + /** + * Use this to store additional information to this node. + * + * @param comment to be set + */ + public final Node 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); + } + return this; + } + + + + /** + * Use this to store additional information to this node. + * + * @param comment to be set + */ + public final Node setLineComment(String comment) { + return setComment(new LineComment(comment)); + } + + /** + * Use this to store additional information to this node. + * + * @param comment to be set + */ + public final Node setBlockComment(String comment) { + return setComment(new BlockComment(comment)); + } + + /** + * 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; + } + + @SuppressWarnings("unchecked") + public <T> T getParentNodeOfType(Class<T> classType) { + Node parent = parentNode; + while (parent != null) { + if (classType.isAssignableFrom(parent.getClass())) + return (T) parent; + parent = parent.parentNode; + } + return null; + } + + public List<Node> getChildrenNodes() { + return childrenNodes; + } + + public boolean contains(Node other) { + return range.contains(other.range); + } + + 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 comment preceeds a statement, the one immediately preceding it + * it is associated with the statements, while the others are orphans. + * + * @return all comments that cannot be attributed to a concept + */ + public List<Comment> getOrphanComments() { + return orphanComments; + } + + /** + * This is the list of Comment which are contained in the Node either because + * they are properly associated to one of its children or because they are floating + * around inside the Node + * + * @return all Comments within the node as a list + */ + public List<Comment> getAllContainedComments() { + List<Comment> comments = new LinkedList<>(); + comments.addAll(getOrphanComments()); + + for (Node child : getChildrenNodes()) { + if (child.getComment() != null) { + comments.add(child.getComment()); + } + comments.addAll(child.getAllContainedComments()); + } + + return comments; + } + + /** + * Assign a new parent to this node, removing it + * from the list of children of the previous parent, if any. + * + * @param parentNode node to be set as parent + */ + public void setParentNode(Node parentNode) { + // remove from old parent, if any + if (this.parentNode != null) { + this.parentNode.childrenNodes.remove(this); + } + this.parentNode = parentNode; + // add to new parent, if any + if (this.parentNode != null) { + this.parentNode.childrenNodes.add(this); + } + } + + protected void setAsParentNodeOf(List<? extends Node> childNodes) { + if (childNodes != null) { + for (Node current : childNodes) { + 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(Position position) { + return range.isAfter(position); + } + + public boolean isPositionedBefore(Position position) { + return range.isBefore(position); + } + + public boolean hasComment() { + return comment != null; + } + + public void tryAddImportToParentCompilationUnit(Class<?> clazz) { + CompilationUnit parentNode = getParentNodeOfType(CompilationUnit.class); + if (parentNode != null) { + parentNode.addImport(clazz); + } + } + + /** + * Recursively finds all nodes of a certain type. + * + * @param clazz the type of node to find. + */ + public <N extends Node> List<N> getNodesByType(Class<N> clazz) { + List<N> nodes = new ArrayList<>(); + for (Node child : getChildrenNodes()) { + if (clazz.isInstance(child)) { + nodes.add(clazz.cast(child)); + } + nodes.addAll(child.getNodesByType(clazz)); + } + return nodes; + } + + /** + * Gets user data for this component using the given key. + * + * @param <M> + * The type of the user data. + * + * @param key + * The key for the data + * @return The user data or null of no user data was found for the given key + * @see UserDataKey + */ + public <M> M getUserData(final UserDataKey<M> key) { + if (userData == null) { + return null; + } + return (M) userData.get(key); + } + + /** + * Sets user data for this component using the given key. + * For information on creating UserDataKey, see {@link UserDataKey}. + * + * @param <M> + * The type of user data + * + * @param key + * The singleton key for the user data + * @param object + * The user data object + * @throws IllegalArgumentException + * @see UserDataKey + */ + public <M> void setUserData(UserDataKey<M> key, M object) { + if (userData == null) { + userData = new IdentityHashMap<>(); + } + userData.put(key, object); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/PackageDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/PackageDeclaration.java new file mode 100644 index 000000000..4252ad4e9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/PackageDeclaration.java @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.utils.Utils; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the package declaration. The package declaration is + * optional for the {@link CompilationUnit}. + * </p> + * The PackageDeclaration is constructed following the syntax:<br> + * <pre> + * {@code + * PackageDeclaration ::= ( }{@link AnnotationExpr}{@code )* "package" }{@link NameExpr}{@code ) ";" + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class PackageDeclaration extends Node implements NodeWithAnnotations<PackageDeclaration> { + + private List<AnnotationExpr> annotations; + + private NameExpr name; + + public PackageDeclaration() { + } + + public PackageDeclaration(NameExpr name) { + setName(name); + } + + public PackageDeclaration(List<AnnotationExpr> annotations, NameExpr name) { + setAnnotations(annotations); + setName(name); + } + + public PackageDeclaration(Range range, List<AnnotationExpr> annotations, NameExpr name) { + super(range); + setAnnotations(annotations); + setName(name); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the list of annotations declared before the package + * declaration. Return <code>null</code> if there are no annotations. + * + * @return list of annotations or <code>null</code> + */ + public List<AnnotationExpr> getAnnotations() { + annotations = Utils.ensureNotNull(annotations); + return annotations; + } + + /** + * Return the name expression of the package. + * + * @return the name of the package + */ + public NameExpr getName() { + return name; + } + + /** + * Get full package name. + */ + public String getPackageName() { + return name.toString(); + } + + /** + * @param annotations + * the annotations to set + */ + public PackageDeclaration setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + return this; + } + + /** + * Sets the name of this package declaration. + * + * @param name + * the name to set + */ + public PackageDeclaration setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + return this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/UserDataKey.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/UserDataKey.java new file mode 100644 index 000000000..4d7caa2e2 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/UserDataKey.java @@ -0,0 +1,39 @@ +package com.github.javaparser.ast; + +/** + * A key to a piece of user data associated with a {@link Node} at runtime. + * The key contains type information that can be used to check the + * type of any user data value for the key when the value is set. UserDataKey is abstract in order to + * force the creation of a subtype. That subtype is used to test for identity when looking for the + * user data because actual object identity would suffer from problems under serialization. + * So, the correct way to declare a UserDataKey is like this: + * + * <pre> + * <code> + * public static final UserDataKey<Role> ROLE = new UserDataKey<Role>() { }; + * </code> + * </pre> + * + * This code was taken from the <a href="http://wicket.apache.org/">Wicket project</a>. + * + * @param <T> + * The type of the object which is stored + * + * @see Node#getUserData(UserDataKey) + */ +public abstract class UserDataKey<T> { + @Override + public int hashCode() + { + return getClass().hashCode(); + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + return obj != null && getClass().equals(obj.getClass()); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/AnnotationDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/AnnotationDeclaration.java new file mode 100644 index 000000000..74d84e822 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/AnnotationDeclaration.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import java.util.List; + +import java.util.EnumSet; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class AnnotationDeclaration extends TypeDeclaration<AnnotationDeclaration> { + + public AnnotationDeclaration() { + } + + public AnnotationDeclaration(EnumSet<Modifier> modifiers, String name) { + super(modifiers, name); + } + + public AnnotationDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name, + List<BodyDeclaration<?>> members) { + super(annotations, modifiers, name, members); + } + + public AnnotationDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name, + List<BodyDeclaration<?>> members) { + super(range, annotations, modifiers, name, members); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java new file mode 100644 index 000000000..66b9dc3a3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Modifier; +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.nodeTypes.NodeWithJavaDoc; +import com.github.javaparser.ast.nodeTypes.NodeWithModifiers; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.EnumSet; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class AnnotationMemberDeclaration extends BodyDeclaration<AnnotationMemberDeclaration> + implements NodeWithJavaDoc<AnnotationMemberDeclaration>, NodeWithName<AnnotationMemberDeclaration>, + NodeWithType<AnnotationMemberDeclaration>, NodeWithModifiers<AnnotationMemberDeclaration> { + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private Type type; + + private String name; + + private Expression defaultValue; + + public AnnotationMemberDeclaration() { + } + + public AnnotationMemberDeclaration(EnumSet<Modifier> modifiers, Type type, String name, Expression defaultValue) { + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + public AnnotationMemberDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type, String name, + Expression defaultValue) { + super(annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + public AnnotationMemberDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type type, + String name, Expression defaultValue) { + super(range, annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getDefaultValue() { + return defaultValue; + } + + /** + * Return the modifiers of this member declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public EnumSet<Modifier> getModifiers() { + return modifiers; + } + + @Override + public String getName() { + return name; + } + + @Override + public Type getType() { + return type; + } + + public AnnotationMemberDeclaration setDefaultValue(Expression defaultValue) { + this.defaultValue = defaultValue; + setAsParentNodeOf(defaultValue); + return this; + } + + @Override + public AnnotationMemberDeclaration setModifiers(EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return this; + } + + @Override + public AnnotationMemberDeclaration setName(String name) { + this.name = name; + return this; + } + + @Override + public AnnotationMemberDeclaration setType(Type type) { + this.type = type; + setAsParentNodeOf(type); + return this; + } + + @Override + public JavadocComment getJavaDoc() { + if (getComment() instanceof JavadocComment) { + return (JavadocComment) getComment(); + } + return null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/BodyDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/BodyDeclaration.java new file mode 100644 index 000000000..9055d96a5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/BodyDeclaration.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.utils.Utils; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class BodyDeclaration<T> extends Node implements NodeWithAnnotations<T> { + + private List<AnnotationExpr> annotations; + + public BodyDeclaration() { + } + + public BodyDeclaration(List<AnnotationExpr> annotations) { + setAnnotations(annotations); + } + + public BodyDeclaration(Range range, List<AnnotationExpr> annotations) { + super(range); + setAnnotations(annotations); + } + + @Override + public final List<AnnotationExpr> 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 + */ + @SuppressWarnings("unchecked") + @Override + public final T setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + return (T) this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java new file mode 100644 index 000000000..4120d4a71 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.type.TypeParameter; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithExtends; +import com.github.javaparser.ast.nodeTypes.NodeWithImplements; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.EnumSet; +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceDeclaration extends TypeDeclaration<ClassOrInterfaceDeclaration> + implements NodeWithImplements<ClassOrInterfaceDeclaration>, NodeWithExtends<ClassOrInterfaceDeclaration> { + + private boolean interface_; + + private List<TypeParameter> typeParameters; + + // Can contain more than one item if this is an interface + private List<ClassOrInterfaceType> extendsList; + + private List<ClassOrInterfaceType> implementsList; + + public ClassOrInterfaceDeclaration() { + } + + public ClassOrInterfaceDeclaration(final EnumSet<Modifier> modifiers, final boolean isInterface, + final String name) { + super(modifiers, name); + setInterface(isInterface); + } + + public ClassOrInterfaceDeclaration(final EnumSet<Modifier> modifiers, + final List<AnnotationExpr> annotations, final boolean isInterface, + final String name, + final List<TypeParameter> typeParameters, + final List<ClassOrInterfaceType> extendsList, + final List<ClassOrInterfaceType> implementsList, + final List<BodyDeclaration<?>> members) { + super(annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + public ClassOrInterfaceDeclaration(Range range, final EnumSet<Modifier> modifiers, + final List<AnnotationExpr> annotations, final boolean isInterface, + final String name, + final List<TypeParameter> typeParameters, + final List<ClassOrInterfaceType> extendsList, + final List<ClassOrInterfaceType> implementsList, + final List<BodyDeclaration<?>> members) { + super(range, annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<ClassOrInterfaceType> getExtends() { + extendsList = ensureNotNull(extendsList); + return extendsList; + } + + @Override + public List<ClassOrInterfaceType> getImplements() { + implementsList = ensureNotNull(implementsList); + return implementsList; + } + + public List<TypeParameter> 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 + * @return + */ + @Override + public ClassOrInterfaceDeclaration setExtends(final List<ClassOrInterfaceType> extendsList) { + this.extendsList = extendsList; + setAsParentNodeOf(this.extendsList); + return this; + } + + /** + * + * @param implementsList a null value is currently treated as an empty list. This behavior could change + * in the future, so please avoid passing null + */ + @Override + public ClassOrInterfaceDeclaration setImplements(final List<ClassOrInterfaceType> implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + return this; + } + + public ClassOrInterfaceDeclaration setInterface(final boolean interface_) { + this.interface_ = interface_; + return this; + } + + /** + * + * @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 ClassOrInterfaceDeclaration setTypeParameters(final List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + return this; + } + + + + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/ConstructorDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/ConstructorDeclaration.java new file mode 100644 index 000000000..4a9cd2a2a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/ConstructorDeclaration.java @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.AccessSpecifier; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.type.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.nodeTypes.*; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.ReferenceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.EnumSet; +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ConstructorDeclaration extends BodyDeclaration<ConstructorDeclaration> + implements NodeWithJavaDoc<ConstructorDeclaration>, NodeWithDeclaration, + NodeWithName<ConstructorDeclaration>, NodeWithModifiers<ConstructorDeclaration>, + NodeWithParameters<ConstructorDeclaration>, NodeWithThrowable<ConstructorDeclaration>, + NodeWithBlockStmt<ConstructorDeclaration> { + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private List<TypeParameter> typeParameters; + + private NameExpr name; + + private List<Parameter> parameters; + + private List<ReferenceType> throws_; + + private BlockStmt body; + + public ConstructorDeclaration() { + } + + public ConstructorDeclaration(EnumSet<Modifier> modifiers, String name) { + setModifiers(modifiers); + setName(name); + } + + public ConstructorDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, + List<TypeParameter> typeParameters, + String name, List<Parameter> parameters, List<ReferenceType> throws_, + BlockStmt block) { + super(annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBody(block); + } + + public ConstructorDeclaration(Range range, EnumSet<Modifier> modifiers, + List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name, + List<Parameter> parameters, List<ReferenceType> throws_, BlockStmt block) { + super(range, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBody(block); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return the modifiers of this member declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public EnumSet<Modifier> getModifiers() { + return modifiers; + } + + @Override + public String getName() { + return name == null ? null : name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + @Override + public List<Parameter> getParameters() { + parameters = ensureNotNull(parameters); + return parameters; + } + + @Override + public List<ReferenceType> getThrows() { + throws_ = ensureNotNull(throws_); + return throws_; + } + + public List<TypeParameter> getTypeParameters() { + typeParameters = ensureNotNull(typeParameters); + return typeParameters; + } + + @Override + public ConstructorDeclaration setModifiers(EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return this; + } + + @Override + public ConstructorDeclaration setName(String name) { + setNameExpr(new NameExpr(name)); + return this; + } + + public ConstructorDeclaration setNameExpr(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + return this; + } + + @Override + public ConstructorDeclaration setParameters(List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + return this; + } + + @Override + public ConstructorDeclaration setThrows(List<ReferenceType> throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + return this; + } + + public ConstructorDeclaration setTypeParameters(List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + return this; + } + + /** + * The declaration returned has this schema: + * + * [accessSpecifier] className ([paramType [paramName]]) + * [throws exceptionsList] + */ + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, + boolean includingParameterName) { + StringBuilder sb = new StringBuilder(); + if (includingModifiers) { + AccessSpecifier accessSpecifier = Modifier.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.getElementType().toStringWithoutComments()); + } + } + sb.append(")"); + if (includingThrows) { + boolean firstThrow = true; + for (ReferenceType 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 JavadocComment getJavaDoc() { + if (getComment() instanceof JavadocComment) { + return (JavadocComment) getComment(); + } + return null; + } + + @Override + public BlockStmt getBody() { + return body; + } + + @Override + public ConstructorDeclaration setBody(BlockStmt body) { + this.body = body; + setAsParentNodeOf(body); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EmptyMemberDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EmptyMemberDeclaration.java new file mode 100644 index 000000000..102eb7aa4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EmptyMemberDeclaration.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyMemberDeclaration extends BodyDeclaration<EmptyMemberDeclaration> + implements NodeWithJavaDoc<EmptyMemberDeclaration> { + + public EmptyMemberDeclaration() { + super(null); + } + + public EmptyMemberDeclaration(Range range) { + super(range, null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public JavadocComment getJavaDoc() { + if(getComment() instanceof JavadocComment){ + return (JavadocComment) getComment(); + } + return null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EmptyTypeDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EmptyTypeDeclaration.java new file mode 100644 index 000000000..3a774de99 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EmptyTypeDeclaration.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.EnumSet; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyTypeDeclaration extends TypeDeclaration<EmptyTypeDeclaration> { + + public EmptyTypeDeclaration() { + super(null, EnumSet.noneOf(Modifier.class), null, null); + } + + public EmptyTypeDeclaration(Range range) { + super(range, null, EnumSet.noneOf(Modifier.class), null, null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EnumConstantDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EnumConstantDeclaration.java new file mode 100644 index 000000000..646f6c287 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EnumConstantDeclaration.java @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.ast.expr.NameExpr.*; +import static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.List; + +import com.github.javaparser.Range; +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.expr.NameExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumConstantDeclaration extends BodyDeclaration<EnumConstantDeclaration> + implements NodeWithJavaDoc<EnumConstantDeclaration>, NodeWithName<EnumConstantDeclaration> { + + private String name; + + private List<Expression> args; + + private List<BodyDeclaration<?>> classBody; + + public EnumConstantDeclaration() { + } + + public EnumConstantDeclaration(String name) { + setName(name); + } + + public EnumConstantDeclaration(List<AnnotationExpr> annotations, String name, List<Expression> args, + List<BodyDeclaration<?>> classBody) { + super(annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + public EnumConstantDeclaration(Range range, List<AnnotationExpr> annotations, String name, List<Expression> args, + List<BodyDeclaration<?>> classBody) { + super(range, annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + args = ensureNotNull(args); + return args; + } + + public List<BodyDeclaration<?>> getClassBody() { + classBody = ensureNotNull(classBody); + return classBody; + } + + @Override + public String getName() { + return name; + } + + public EnumConstantDeclaration setArgs(List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + return this; + } + + public EnumConstantDeclaration setClassBody(List<BodyDeclaration<?>> classBody) { + this.classBody = classBody; + setAsParentNodeOf(this.classBody); + return this; + } + + @Override + public EnumConstantDeclaration setName(String name) { + this.name = name; + return this; + } + + @Override + public JavadocComment getJavaDoc() { + if(getComment() instanceof JavadocComment){ + return (JavadocComment) getComment(); + } + return null; + } + + public EnumConstantDeclaration addArgument(String valueExpr) { + getArgs().add(name(valueExpr)); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EnumDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EnumDeclaration.java new file mode 100644 index 000000000..0ad3089b6 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/EnumDeclaration.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.EnumSet; +import java.util.List; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithImplements; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumDeclaration extends TypeDeclaration<EnumDeclaration> + implements NodeWithImplements<EnumDeclaration> { + + private List<ClassOrInterfaceType> implementsList; + + private List<EnumConstantDeclaration> entries; + + public EnumDeclaration() { + } + + public EnumDeclaration(EnumSet<Modifier> modifiers, String name) { + super(modifiers, name); + } + + public EnumDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name, + List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, + List<BodyDeclaration<?>> members) { + super(annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + public EnumDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, String name, + List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, + List<BodyDeclaration<?>> members) { + super(range, annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<EnumConstantDeclaration> getEntries() { + entries = ensureNotNull(entries); + return entries; + } + + @Override + public List<ClassOrInterfaceType> getImplements() { + implementsList = ensureNotNull(implementsList); + return implementsList; + } + + public EnumDeclaration setEntries(List<EnumConstantDeclaration> entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + return this; + } + + @Override + public EnumDeclaration setImplements(List<ClassOrInterfaceType> implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + return this; + } + + + + public EnumConstantDeclaration addEnumConstant(String name) { + EnumConstantDeclaration enumConstant = new EnumConstantDeclaration(name); + getEntries().add(enumConstant); + enumConstant.setParentNode(this); + return enumConstant; + } + + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/FieldDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/FieldDeclaration.java new file mode 100644 index 000000000..aa04a5230 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/FieldDeclaration.java @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.ast.expr.NameExpr.*; +import static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.AssignExpr.Operator; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.nodeTypes.*; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import static com.github.javaparser.ast.Modifier.PUBLIC; +import static com.github.javaparser.ast.type.VoidType.VOID_TYPE; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldDeclaration extends BodyDeclaration<FieldDeclaration> implements + NodeWithJavaDoc<FieldDeclaration>, + NodeWithElementType<FieldDeclaration>, + NodeWithModifiers<FieldDeclaration>, + NodeWithVariables<FieldDeclaration> { + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private Type elementType; + + private List<VariableDeclarator> variables; + + private List<ArrayBracketPair> arrayBracketPairsAfterElementType; + + public FieldDeclaration() { + } + + public FieldDeclaration(EnumSet<Modifier> modifiers, Type elementType, VariableDeclarator variable) { + setModifiers(modifiers); + setElementType(elementType); + List<VariableDeclarator> aux = new ArrayList<>(); + aux.add(variable); + setVariables(aux); + } + + public FieldDeclaration(EnumSet<Modifier> modifiers, Type elementType, List<VariableDeclarator> variables) { + setModifiers(modifiers); + setElementType(elementType); + setVariables(variables); + } + + public FieldDeclaration(EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type elementType, List<ArrayBracketPair> arrayBracketPairsAfterElementType, + List<VariableDeclarator> variables) { + super(annotations); + setModifiers(modifiers); + setElementType(elementType); + setVariables(variables); + setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType); + } + + public FieldDeclaration(Range range, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations, Type elementType, + List<VariableDeclarator> variables, List<ArrayBracketPair> arrayBracketPairsAfterElementType) { + super(range, annotations); + setModifiers(modifiers); + setElementType(elementType); + setVariables(variables); + setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType); + } + + /** + * Creates a {@link FieldDeclaration}. + * + * @param modifiers + * modifiers + * @param type + * type + * @param variable + * variable declarator + * @return instance of {@link FieldDeclaration} + */ + public static FieldDeclaration create(EnumSet<Modifier> modifiers, Type type, + VariableDeclarator variable) { + List<VariableDeclarator> variables = new ArrayList<>(); + variables.add(variable); + return new FieldDeclaration(modifiers, type, variables); + } + + /** + * Creates a {@link FieldDeclaration}. + * + * @param modifiers + * modifiers + * @param type + * type + * @param name + * field name + * @return instance of {@link FieldDeclaration} + */ + public static FieldDeclaration create(EnumSet<Modifier> modifiers, Type type, String name) { + VariableDeclaratorId id = new VariableDeclaratorId(name); + VariableDeclarator variable = new VariableDeclarator(id); + return create(modifiers, type, variable); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return the modifiers of this member declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public EnumSet<Modifier> getModifiers() { + return modifiers; + } + + @Override + public List<VariableDeclarator> getVariables() { + variables = ensureNotNull(variables); + return variables; + } + + @Override + public FieldDeclaration setModifiers(EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return this; + } + + @Override + public FieldDeclaration setVariables(List<VariableDeclarator> variables) { + this.variables = variables; + setAsParentNodeOf(this.variables); + return this; + } + + @Override + public JavadocComment getJavaDoc() { + if (getComment() instanceof JavadocComment) { + return (JavadocComment) getComment(); + } + return null; + } + + /** + * Create a getter for this field, <b>will only work if this field declares only 1 identifier and if this field is + * already added to a ClassOrInterfaceDeclaration</b> + * + * @return the {@link MethodDeclaration} created + * @throws IllegalStateException if there is more than 1 variable identifier or if this field isn't attached to a + * class or enum + */ + public MethodDeclaration createGetter() { + if (getVariables().size() != 1) + throw new IllegalStateException("You can use this only when the field declares only 1 variable name"); + ClassOrInterfaceDeclaration parentClass = getParentNodeOfType(ClassOrInterfaceDeclaration.class); + EnumDeclaration parentEnum = getParentNodeOfType(EnumDeclaration.class); + if ((parentClass == null && parentEnum == null) || (parentClass != null && parentClass.isInterface())) + throw new IllegalStateException( + "You can use this only when the field is attached to a class or an enum"); + + VariableDeclarator variable = getVariables().get(0); + String fieldName = variable.getId().getName(); + String fieldNameUpper = fieldName.toUpperCase().substring(0, 1) + fieldName.substring(1, fieldName.length()); + final MethodDeclaration getter; + if (parentClass != null) + getter = parentClass.addMethod("get" + fieldNameUpper, PUBLIC); + else + getter = parentEnum.addMethod("get" + fieldNameUpper, PUBLIC); + getter.setType(variable.getType()); + BlockStmt blockStmt = new BlockStmt(); + getter.setBody(blockStmt); + blockStmt.addStatement(new ReturnStmt(name(fieldName))); + return getter; + } + + /** + * Create a setter for this field, <b>will only work if this field declares only 1 identifier and if this field is + * already added to a ClassOrInterfaceDeclaration</b> + * + * @return the {@link MethodDeclaration} created + * @throws IllegalStateException if there is more than 1 variable identifier or if this field isn't attached to a + * class or enum + */ + public MethodDeclaration createSetter() { + if (getVariables().size() != 1) + throw new IllegalStateException("You can use this only when the field declares only 1 variable name"); + ClassOrInterfaceDeclaration parentClass = getParentNodeOfType(ClassOrInterfaceDeclaration.class); + EnumDeclaration parentEnum = getParentNodeOfType(EnumDeclaration.class); + if ((parentClass == null && parentEnum == null) || (parentClass != null && parentClass.isInterface())) + throw new IllegalStateException( + "You can use this only when the field is attached to a class or an enum"); + + VariableDeclarator variable = getVariables().get(0); + String fieldName = variable.getId().getName(); + String fieldNameUpper = fieldName.toUpperCase().substring(0, 1) + fieldName.substring(1, fieldName.length()); + + final MethodDeclaration setter; + if (parentClass != null) + setter = parentClass.addMethod("set" + fieldNameUpper, PUBLIC); + else + setter = parentEnum.addMethod("set" + fieldNameUpper, PUBLIC); + setter.setType(VOID_TYPE); + setter.getParameters().add(new Parameter(variable.getType(), new VariableDeclaratorId(fieldName))); + BlockStmt blockStmt2 = new BlockStmt(); + setter.setBody(blockStmt2); + blockStmt2.addStatement(new AssignExpr(new NameExpr("this." + fieldName), new NameExpr(fieldName), Operator.assign)); + return setter; + } + + + @Override + public Type getElementType() { + return elementType; + } + + @Override + public FieldDeclaration setElementType(final Type elementType) { + this.elementType = elementType; + setAsParentNodeOf(this.elementType); + return this; + } + + /** + * @return the array brackets in this position: <code>class C { int[] abc; }</code> + */ + public List<ArrayBracketPair> getArrayBracketPairsAfterElementType() { + arrayBracketPairsAfterElementType = ensureNotNull(arrayBracketPairsAfterElementType); + return arrayBracketPairsAfterElementType; + } + + @Override + public FieldDeclaration setArrayBracketPairsAfterElementType(List<ArrayBracketPair> arrayBracketPairsAfterType) { + this.arrayBracketPairsAfterElementType = arrayBracketPairsAfterType; + setAsParentNodeOf(arrayBracketPairsAfterType); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/InitializerDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/InitializerDeclaration.java new file mode 100644 index 000000000..adb893f03 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/InitializerDeclaration.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.nodeTypes.NodeWithJavaDoc; +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<InitializerDeclaration> + implements NodeWithJavaDoc<InitializerDeclaration> { + + private boolean isStatic; + + private BlockStmt block; + + public InitializerDeclaration() { + } + + public InitializerDeclaration(boolean isStatic, BlockStmt block) { + super(null); + setStatic(isStatic); + setBlock(block); + } + + public InitializerDeclaration(Range range, boolean isStatic, BlockStmt block) { + super(range, null); + setStatic(isStatic); + setBlock(block); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + public boolean isStatic() { + return isStatic; + } + + public InitializerDeclaration setBlock(BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + return this; + } + + public InitializerDeclaration setStatic(boolean isStatic) { + this.isStatic = isStatic; + return this; + } + + @Override + public JavadocComment getJavaDoc() { + if(getComment() instanceof JavadocComment){ + return (JavadocComment) getComment(); + } + return null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/MethodDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/MethodDeclaration.java new file mode 100644 index 000000000..a89103a3b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/MethodDeclaration.java @@ -0,0 +1,399 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.ast.type.ArrayType.*; +import static com.github.javaparser.ast.type.ArrayType.wrapInArrayTypes; +import static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.EnumSet; +import java.util.List; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.AccessSpecifier; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.nodeTypes.*; +import com.github.javaparser.ast.type.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.nodeTypes.*; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.ReferenceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.utils.Pair; + +import java.util.EnumSet; +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodDeclaration extends BodyDeclaration<MethodDeclaration> implements + NodeWithJavaDoc<MethodDeclaration>, + NodeWithDeclaration, + NodeWithName<MethodDeclaration>, + NodeWithType<MethodDeclaration>, + NodeWithElementType<MethodDeclaration>, + NodeWithModifiers<MethodDeclaration>, + NodeWithParameters<MethodDeclaration>, + NodeWithThrowable<MethodDeclaration>, + NodeWithBlockStmt<MethodDeclaration> { + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private List<TypeParameter> typeParameters; + + private Type elementType; + + private NameExpr name; + + private List<Parameter> parameters; + + private List<ReferenceType> throws_; + + private BlockStmt body; + + private boolean isDefault = false; + + private List<ArrayBracketPair> arrayBracketPairsAfterType; + + private List<ArrayBracketPair> arrayBracketPairsAfterParameterList; + + public MethodDeclaration() { + } + + public MethodDeclaration(final EnumSet<Modifier> modifiers, final Type elementType, final String name) { + setModifiers(modifiers); + setElementType(elementType); + setName(name); + } + + public MethodDeclaration(final EnumSet<Modifier> modifiers, final Type elementType, final String name, + final List<Parameter> parameters) { + setModifiers(modifiers); + setElementType(elementType); + setName(name); + setParameters(parameters); + } + + public MethodDeclaration(final EnumSet<Modifier> modifiers, + final List<AnnotationExpr> annotations, + final List<TypeParameter> typeParameters, + final Type elementType, + final List<ArrayBracketPair> arrayBracketPairsAfterElementType, + final String name, + final List<Parameter> parameters, + final List<ArrayBracketPair> arrayBracketPairsAfterParameterList, + final List<ReferenceType> throws_, + final BlockStmt body) { + super(annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setElementType(elementType); + setName(name); + setParameters(parameters); + setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType); + setArrayBracketPairsAfterParameterList(arrayBracketPairsAfterParameterList); + setThrows(throws_); + setBody(body); + } + + public MethodDeclaration(Range range, + final EnumSet<Modifier> modifiers, + final List<AnnotationExpr> annotations, + final List<TypeParameter> typeParameters, + final Type elementType, + final List<ArrayBracketPair> arrayBracketPairsAfterElementType, + final NameExpr nameExpr, + final List<Parameter> parameters, + final List<ArrayBracketPair> arrayBracketPairsAfterParameterList, + final List<ReferenceType> throws_, + final BlockStmt body) { + super(range, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setElementType(elementType); + setNameExpr(nameExpr); + setParameters(parameters); + setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType); + setArrayBracketPairsAfterParameterList(arrayBracketPairsAfterParameterList); + setThrows(throws_); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public BlockStmt getBody() { + return body; + } + + /** + * Return the modifiers of this member declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public EnumSet<Modifier> getModifiers() { + return modifiers; + } + + @Override + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + @Override + public List<Parameter> getParameters() { + parameters = ensureNotNull(parameters); + return parameters; + } + + @Override + public List<ReferenceType> getThrows() { + throws_ = ensureNotNull(throws_); + return throws_; + } + + @Override + public Type getType() { + return wrapInArrayTypes(getElementType(), + getArrayBracketPairsAfterElementType(), + getArrayBracketPairsAfterParameterList()); + } + + @Override + public Type getElementType() { + return elementType; + } + + public List<TypeParameter> getTypeParameters() { + typeParameters = ensureNotNull(typeParameters); + return typeParameters; + } + + @Override + public MethodDeclaration setBody(final BlockStmt body) { + this.body = body; + setAsParentNodeOf(this.body); + return this; + } + + @Override + public MethodDeclaration setModifiers(final EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return this; + } + + @Override + public MethodDeclaration setName(final String name) { + setNameExpr(new NameExpr(name)); + return this; + } + + public MethodDeclaration setNameExpr(final NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + return this; + } + + @Override + public MethodDeclaration setParameters(final List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + return this; + } + + @Override + public MethodDeclaration setThrows(final List<ReferenceType> throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + return this; + } + + @Override + public MethodDeclaration setType(final Type type) { + Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type); + setElementType(typeListPair.a); + setArrayBracketPairsAfterElementType(typeListPair.b); + setArrayBracketPairsAfterParameterList(null); + return this; + } + + @Override + public MethodDeclaration setElementType(final Type elementType) { + this.elementType = elementType; + setAsParentNodeOf(this.elementType); + return this; + } + + public MethodDeclaration setTypeParameters(final List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(typeParameters); + return this; + } + + public boolean isDefault() { + return isDefault; + } + + public MethodDeclaration setDefault(boolean isDefault) { + this.isDefault = isDefault; + return this; + } + + @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) { + StringBuilder sb = new StringBuilder(); + if (includingModifiers) { + AccessSpecifier accessSpecifier = Modifier.getAccessSpecifier(getModifiers()); + sb.append(accessSpecifier.getCodeRepresenation()); + sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " "); + if (getModifiers().contains(Modifier.STATIC)) { + sb.append("static "); + } + if (getModifiers().contains(Modifier.ABSTRACT)) { + sb.append("abstract "); + } + if (getModifiers().contains(Modifier.FINAL)) { + sb.append("final "); + } + if (getModifiers().contains(Modifier.NATIVE)) { + sb.append("native "); + } + if (getModifiers().contains(Modifier.SYNCHRONIZED)) { + sb.append("synchronized "); + } + } + // TODO verify it does not print comments connected to the type + sb.append(getElementType().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.getElementType().toStringWithoutComments()); + if (param.isVarArgs()) { + sb.append("..."); + } + } + } + sb.append(")"); + if (includingThrows) { + boolean firstThrow = true; + for (ReferenceType thr : getThrows()) { + if (firstThrow) { + firstThrow = false; + sb.append(" throws "); + } else { + sb.append(", "); + } + sb.append(thr.toStringWithoutComments()); + } + } + return sb.toString(); + } + + @Override + public JavadocComment getJavaDoc() { + if (getComment() instanceof JavadocComment) { + return (JavadocComment) getComment(); + } + return null; + } + + /** + * @return the array brackets in this position: <code>class C { int[] abc; }</code> + */ + public List<ArrayBracketPair> getArrayBracketPairsAfterElementType() { + arrayBracketPairsAfterType = ensureNotNull(arrayBracketPairsAfterType); + return arrayBracketPairsAfterType; + } + + @Override + public MethodDeclaration setArrayBracketPairsAfterElementType(List<ArrayBracketPair> arrayBracketPairsAfterType) { + this.arrayBracketPairsAfterType = arrayBracketPairsAfterType; + setAsParentNodeOf(arrayBracketPairsAfterType); + return this; + } + + /** + * @return the array brackets in this position: <code>int abc()[] {...}</code> + */ + public List<ArrayBracketPair> getArrayBracketPairsAfterParameterList() { + arrayBracketPairsAfterParameterList = ensureNotNull(arrayBracketPairsAfterParameterList); + return arrayBracketPairsAfterParameterList; + } + + public MethodDeclaration setArrayBracketPairsAfterParameterList(List<ArrayBracketPair> arrayBracketPairsAfterParameterList) { + this.arrayBracketPairsAfterParameterList = arrayBracketPairsAfterParameterList; + setAsParentNodeOf(arrayBracketPairsAfterParameterList); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/Parameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/Parameter.java new file mode 100644 index 000000000..d66b39a00 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/Parameter.java @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.*; +import com.github.javaparser.ast.type.ArrayType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.utils.Pair; + +import static com.github.javaparser.ast.type.ArrayType.wrapInArrayTypes; +import java.util.EnumSet; +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class Parameter extends Node implements + NodeWithType<Parameter>, + NodeWithElementType<Parameter>, + NodeWithAnnotations<Parameter>, + NodeWithName<Parameter>, + NodeWithModifiers<Parameter> { + + private Type elementType; + + private boolean isVarArgs; + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private List<AnnotationExpr> annotations; + + private VariableDeclaratorId id; + + private List<ArrayBracketPair> arrayBracketPairsAfterType; + + public Parameter() { + } + + public Parameter(Type elementType, VariableDeclaratorId id) { + setId(id); + setElementType(elementType); + } + + /** + * Creates a new {@link Parameter}. + * + * @param elementType + * type of the parameter + * @param name + * name of the parameter + * @return instance of {@link Parameter} + */ + public static Parameter create(Type elementType, String name) { + return new Parameter(elementType, new VariableDeclaratorId(name)); + } + + public Parameter(EnumSet<Modifier> modifiers, Type elementType, VariableDeclaratorId id) { + setModifiers(modifiers); + setId(id); + setElementType(elementType); + } + + public Parameter(final Range range, + EnumSet<Modifier> modifiers, + List<AnnotationExpr> annotations, + Type elementType, + List<ArrayBracketPair> arrayBracketPairsAfterElementType, + boolean isVarArgs, + VariableDeclaratorId id) { + super(range); + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + setElementType(elementType); + setVarArgs(isVarArgs); + setArrayBracketPairsAfterElementType(arrayBracketPairsAfterElementType); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public Type getType() { + return wrapInArrayTypes(elementType, + getArrayBracketPairsAfterElementType(), + getId().getArrayBracketPairsAfterId()); + } + + public boolean isVarArgs() { + return isVarArgs; + } + + @Override + public Parameter setType(Type type) { + Pair<Type, List<ArrayBracketPair>> unwrapped = ArrayType.unwrapArrayTypes(type); + setElementType(unwrapped.a); + setArrayBracketPairsAfterElementType(unwrapped.b); + getId().setArrayBracketPairsAfterId(null); + return this; + } + + public Parameter setVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + return this; + } + /** + * @return the list returned could be immutable (in that case it will be empty) + */ + @Override + public List<AnnotationExpr> getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public VariableDeclaratorId getId() { + return id; + } + + @Override + public String getName() { + return getId().getName(); + } + + @SuppressWarnings("unchecked") + @Override + public Parameter setName(String name) { + if (id != null) + id.setName(name); + else + id = new VariableDeclaratorId(name); + return this; + } + + /** + * Return the modifiers of this parameter declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public EnumSet<Modifier> 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 + */ + @Override + @SuppressWarnings("unchecked") + public Parameter setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + return this; + } + + public void setId(VariableDeclaratorId id) { + this.id = id; + setAsParentNodeOf(this.id); + } + + @Override + @SuppressWarnings("unchecked") + public Parameter setModifiers(EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return this; + } + + @Override + public Type getElementType() { + return elementType; + } + + @Override + public Parameter setElementType(final Type elementType) { + this.elementType = elementType; + setAsParentNodeOf(this.elementType); + return this; + } + + public List<ArrayBracketPair> getArrayBracketPairsAfterElementType() { + arrayBracketPairsAfterType = ensureNotNull(arrayBracketPairsAfterType); + return arrayBracketPairsAfterType; + } + + @Override + public Parameter setArrayBracketPairsAfterElementType(List<ArrayBracketPair> arrayBracketPairsAfterType) { + this.arrayBracketPairsAfterType = arrayBracketPairsAfterType; + setAsParentNodeOf(arrayBracketPairsAfterType); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/TypeDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/TypeDeclaration.java new file mode 100644 index 000000000..829d37c26 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/TypeDeclaration.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull; +import static com.github.javaparser.utils.Utils.isNullOrEmpty; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.Modifier; +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.nodeTypes.NodeWithJavaDoc; +import com.github.javaparser.ast.nodeTypes.NodeWithMembers; +import com.github.javaparser.ast.nodeTypes.NodeWithModifiers; +import com.github.javaparser.ast.nodeTypes.NodeWithName; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class TypeDeclaration<T> extends BodyDeclaration<T> + implements NodeWithName<T>, NodeWithJavaDoc<T>, NodeWithModifiers<T>, NodeWithMembers<T> { + + private NameExpr name; + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private List<BodyDeclaration<?>> members; + + public TypeDeclaration() { + } + + public TypeDeclaration(EnumSet<Modifier> modifiers, String name) { + setName(name); + setModifiers(modifiers); + } + + public TypeDeclaration(List<AnnotationExpr> annotations, + EnumSet<Modifier> modifiers, String name, + List<BodyDeclaration<?>> members) { + super(annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public TypeDeclaration(Range range, List<AnnotationExpr> annotations, + EnumSet<Modifier> modifiers, String name, + List<BodyDeclaration<?>> members) { + super(range, annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + /** + * Adds the given declaration to the specified type. The list of members + * will be initialized if it is <code>null</code>. + * + * @param decl + * member declaration + */ + public TypeDeclaration<T> addMember(BodyDeclaration<?> decl) { + List<BodyDeclaration<?>> members = getMembers(); + if (isNullOrEmpty(members)) { + members = new ArrayList<>(); + setMembers(members); + } + members.add(decl); + decl.setParentNode(this); + return this; + } + + @Override + public List<BodyDeclaration<?>> getMembers() { + members = ensureNotNull(members); + return members; + } + + /** + * Return the modifiers of this type declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public final EnumSet<Modifier> getModifiers() { + return modifiers; + } + + @Override + public final String getName() { + return name.getName(); + } + + @SuppressWarnings("unchecked") + @Override + public T setMembers(List<BodyDeclaration<?>> members) { + this.members = members; + setAsParentNodeOf(this.members); + return (T) this; + } + + @SuppressWarnings("unchecked") + @Override + public T setModifiers(EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return (T) this; + } + + @Override + @SuppressWarnings("unchecked") + public T setName(String name) { + setNameExpr(new NameExpr(name)); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T setNameExpr(NameExpr nameExpr) { + this.name = nameExpr; + setAsParentNodeOf(this.name); + return (T) this; + } + + public final NameExpr getNameExpr() { + return name; + } + + @Override + public JavadocComment getJavaDoc() { + if(getComment() instanceof JavadocComment){ + return (JavadocComment) getComment(); + } + return null; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/VariableDeclarator.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/VariableDeclarator.java new file mode 100644 index 000000000..ff78d6e68 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/VariableDeclarator.java @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithElementType; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +import com.github.javaparser.ast.type.ArrayType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.utils.Pair; + +import java.util.List; + +import static com.github.javaparser.ast.type.ArrayType.wrapInArrayTypes; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclarator extends Node implements + NodeWithType<VariableDeclarator> { + + private VariableDeclaratorId id; + + private Expression init; + + public VariableDeclarator() { + } + + public VariableDeclarator(VariableDeclaratorId id) { + setId(id); + } + + public VariableDeclarator(String variableName) { + setId(new VariableDeclaratorId(variableName)); + } + + /** + * 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 <code>=</code> operator is + * already added. + */ + public VariableDeclarator(VariableDeclaratorId id, Expression init) { + setId(id); + setInit(init); + } + + public VariableDeclarator(String variableName, Expression init) { + setId(new VariableDeclaratorId(variableName)); + setInit(init); + } + + public VariableDeclarator(Range range, VariableDeclaratorId id, Expression init) { + super(range); + setId(id); + setInit(init); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public VariableDeclaratorId getId() { + return id; + } + + public Expression getInit() { + return init; + } + + public VariableDeclarator setId(VariableDeclaratorId id) { + this.id = id; + setAsParentNodeOf(this.id); + return this; + } + + public VariableDeclarator setInit(Expression init) { + this.init = init; + setAsParentNodeOf(this.init); + return this; + } + + /** + * Will create a {@link NameExpr} with the init param + */ + public VariableDeclarator setInit(String init) { + this.init = new NameExpr(init); + setAsParentNodeOf(this.init); + return this; + } + + + @Override + public Type getType() { + NodeWithElementType<?> elementType = getParentNodeOfType(NodeWithElementType.class); + + return wrapInArrayTypes(elementType.getElementType(), + elementType.getArrayBracketPairsAfterElementType(), + getId().getArrayBracketPairsAfterId()); + } + + @Override + public VariableDeclarator setType(Type type) { + Pair<Type, List<ArrayBracketPair>> unwrapped = ArrayType.unwrapArrayTypes(type); + NodeWithElementType<?> nodeWithElementType = getParentNodeOfType(NodeWithElementType.class); + if (nodeWithElementType == null) { + throw new IllegalStateException("Cannot set type without a parent"); + } + nodeWithElementType.setElementType(unwrapped.a); + nodeWithElementType.setArrayBracketPairsAfterElementType(null); + getId().setArrayBracketPairsAfterId(unwrapped.b); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/VariableDeclaratorId.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/VariableDeclaratorId.java new file mode 100644 index 000000000..b6dccc2aa --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/body/VariableDeclaratorId.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclaratorId extends Node implements NodeWithName<VariableDeclaratorId> { + + private String name; + + private List<ArrayBracketPair> arrayBracketPairsAfterId; + + public VariableDeclaratorId() { + } + + public VariableDeclaratorId(String name) { + setName(name); + } + + public VariableDeclaratorId(Range range, String name, List<ArrayBracketPair> arrayBracketPairsAfterId) { + super(range); + setName(name); + setArrayBracketPairsAfterId(arrayBracketPairsAfterId); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public String getName() { + return name; + } + + @Override + public VariableDeclaratorId setName(String name) { + this.name = name; + return this; + } + + public List<ArrayBracketPair> getArrayBracketPairsAfterId() { + arrayBracketPairsAfterId = ensureNotNull(arrayBracketPairsAfterId); + return arrayBracketPairsAfterId; + } + + public VariableDeclaratorId setArrayBracketPairsAfterId(List<ArrayBracketPair> arrayBracketPairsAfterId) { + this.arrayBracketPairsAfterId = arrayBracketPairsAfterId; + setAsParentNodeOf(arrayBracketPairsAfterId); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/BlockComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/BlockComment.java new file mode 100644 index 000000000..77157d595 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/BlockComment.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * AST node that represent block comments. + * </p> + * Block comments can has multi lines and are delimited by "/*" and + * "*/". + * + * @author Julio Vilmar Gesser + */ +public final class BlockComment extends Comment { + + public BlockComment() { + } + + public BlockComment(String content) { + super(content); + } + + public BlockComment(Range range, String content) { + super(range, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/Comment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/Comment.java new file mode 100644 index 000000000..9da994ec4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/Comment.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, String content) { + super(range); + 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 Comment setContent(String content) { + this.content = content; + return this; + } + + 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 Comment setCommentedNode(Node commentedNode) + { + if (commentedNode==null) { + this.commentedNode = null; + return this; + } + if (commentedNode==this) { + throw new IllegalArgumentException(); + } + if (commentedNode instanceof Comment) { + throw new IllegalArgumentException(); + } + this.commentedNode = commentedNode; + return this; + } + + public boolean isOrphan() + { + return this.commentedNode == null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/CommentsCollection.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/CommentsCollection.java new file mode 100644 index 000000000..d02c7a5f0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/CommentsCollection.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Collection; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import static com.github.javaparser.ast.Node.NODE_BY_BEGIN_POSITION; + +/** + * The comments contained in a certain parsed piece of source code. + */ +public class CommentsCollection { + private final TreeSet<Comment> comments = new TreeSet<>(NODE_BY_BEGIN_POSITION); + + public CommentsCollection() { + } + + public CommentsCollection(Collection<Comment> commentsToCopy) { + comments.addAll(commentsToCopy); + } + + public Set<LineComment> getLineComments() { + return comments.stream() + .filter(comment -> comment instanceof LineComment) + .map(comment -> (LineComment) comment) + .collect(Collectors.toCollection(() -> new TreeSet<>(NODE_BY_BEGIN_POSITION))); + } + + public Set<BlockComment> getBlockComments() { + return comments.stream() + .filter(comment -> comment instanceof BlockComment) + .map(comment -> (BlockComment) comment) + .collect(Collectors.toCollection(() -> new TreeSet<>(NODE_BY_BEGIN_POSITION))); + } + + public Set<JavadocComment> getJavadocComments() { + return comments.stream() + .filter(comment -> comment instanceof JavadocComment) + .map(comment -> (JavadocComment) comment) + .collect(Collectors.toCollection(() -> new TreeSet<>(NODE_BY_BEGIN_POSITION))); + } + + public void addComment(Comment comment) { + comments.add(comment); + } + + public boolean contains(Comment comment) { + for (Comment c : getComments()) { + // we tolerate a difference of one element in the end column: + // it depends how \r and \n are calculated... + if (c.getBegin().line == comment.getBegin().line && + c.getBegin().column == comment.getBegin().column && + c.getEnd().line == comment.getEnd().line && + Math.abs(c.getEnd().column - comment.getEnd().column) < 2) { + return true; + } + } + return false; + } + + public TreeSet<Comment> getComments() { + return comments; + } + + public int size() { + return comments.size(); + } + + public CommentsCollection minus(CommentsCollection other) { + CommentsCollection result = new CommentsCollection(); + result.comments.addAll( + comments.stream() + .filter(comment -> !other.contains(comment)) + .collect(Collectors.toList())); + return result; + } + + public CommentsCollection copy() { + return new CommentsCollection(comments); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/JavadocComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/JavadocComment.java new file mode 100644 index 000000000..18b77af28 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/JavadocComment.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, String content) { + super(range, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/LineComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/LineComment.java new file mode 100644 index 000000000..56b8054d3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/comments/LineComment.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * AST node that represent line comments. + * </p> + * Line comments are started with "//" and finish at the end of the line ("\n"). + * + * @author Julio Vilmar Gesser + */ +public final class LineComment extends Comment { + + public LineComment() { + } + + public LineComment(String content) { + super(content); + } + + public LineComment(Range range, String content) { + super(range, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public boolean isLineComment() + { + return true; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/AnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/AnnotationExpr.java new file mode 100644 index 000000000..a1cad1cdb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/AnnotationExpr.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class AnnotationExpr extends Expression { + + protected NameExpr name; + + public AnnotationExpr() {} + + public AnnotationExpr(Range range) { + super(range); + } + + public NameExpr getName() { + return name; + } + + public AnnotationExpr setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(name); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayAccessExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayAccessExpr.java new file mode 100644 index 000000000..b461ea87b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayAccessExpr.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, Expression name, Expression index) { + super(range); + setName(name); + setIndex(index); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getIndex() { + return index; + } + + public Expression getName() { + return name; + } + + public ArrayAccessExpr setIndex(Expression index) { + this.index = index; + setAsParentNodeOf(this.index); + return this; + } + + public ArrayAccessExpr setName(Expression name) { + this.name = name; + setAsParentNodeOf(this.name); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayCreationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayCreationExpr.java new file mode 100644 index 000000000..79d55a56c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayCreationExpr.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +import com.github.javaparser.ast.ArrayCreationLevel; +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.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayCreationExpr extends Expression implements NodeWithType<ArrayCreationExpr> { + + private List<ArrayCreationLevel> levels; + + private Type type; + + private ArrayInitializerExpr initializer; + + public ArrayCreationExpr() { + } + + public ArrayCreationExpr(Type type, List<ArrayCreationLevel> levels, ArrayInitializerExpr initializer) { + setLevels(levels); + setType(type); + setInitializer(initializer); + } + + public ArrayCreationExpr(Range range, Type type, List<ArrayCreationLevel> levels, ArrayInitializerExpr initializer) { + super(range); + setLevels(levels); + setType(type); + setInitializer(initializer); + } + + public ArrayCreationExpr(Type type) { + setType(type); + setInitializer(null); + } + + public ArrayCreationExpr(Range range, Type type) { + super(range); + setType(type); + setInitializer(null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public ArrayInitializerExpr getInitializer() { + return initializer; + } + + @Override + public Type getType() { + return type; + } + + public ArrayCreationExpr setInitializer(ArrayInitializerExpr initializer) { + this.initializer = initializer; + setAsParentNodeOf(this.initializer); + return this; + } + + @Override + public ArrayCreationExpr setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + return this; + } + + public List<ArrayCreationLevel> getLevels() { + levels = ensureNotNull(levels); + return levels; + } + + public ArrayCreationExpr setLevels(List<ArrayCreationLevel> levels) { + this.levels = levels; + setAsParentNodeOf(levels); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayInitializerExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayInitializerExpr.java new file mode 100644 index 000000000..67c10739b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ArrayInitializerExpr.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayInitializerExpr extends Expression { + + private List<Expression> values; + + public ArrayInitializerExpr() { + } + + public ArrayInitializerExpr(List<Expression> values) { + setValues(values); + } + + public ArrayInitializerExpr(Range range, List<Expression> values) { + super(range); + setValues(values); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Expression> getValues() { + values = ensureNotNull(values); + return values; + } + + public ArrayInitializerExpr setValues(List<Expression> values) { + this.values = values; + setAsParentNodeOf(this.values); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/AssignExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/AssignExpr.java new file mode 100644 index 000000000..cf16c6fff --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/AssignExpr.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 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(Range range, Expression target, Expression value, Operator op) { + super(range); + setTarget(target); + setValue(value); + setOperator(op); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Operator getOperator() { + return op; + } + + public Expression getTarget() { + return target; + } + + public Expression getValue() { + return value; + } + + public AssignExpr setOperator(Operator op) { + this.op = op; + return this; + } + + public AssignExpr setTarget(Expression target) { + this.target = target; + setAsParentNodeOf(this.target); + return this; + } + + public AssignExpr setValue(Expression value) { + this.value = value; + setAsParentNodeOf(this.value); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/BinaryExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/BinaryExpr.java new file mode 100644 index 000000000..83675c8c4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/BinaryExpr.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 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(Range range, Expression left, Expression right, Operator op) { + super(range); + setLeft(left); + setRight(right); + setOperator(op); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getLeft() { + return left; + } + + public Operator getOperator() { + return op; + } + + public Expression getRight() { + return right; + } + + public BinaryExpr setLeft(Expression left) { + this.left = left; + setAsParentNodeOf(this.left); + return this; + } + + public BinaryExpr setOperator(Operator op) { + this.op = op; + return this; + } + + public BinaryExpr setRight(Expression right) { + this.right = right; + setAsParentNodeOf(this.right); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/BooleanLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/BooleanLiteralExpr.java new file mode 100644 index 000000000..a42c8c722 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/BooleanLiteralExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, boolean value) { + super(range); + setValue(value); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean getValue() { + return value; + } + + public BooleanLiteralExpr setValue(boolean value) { + this.value = value; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/CastExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/CastExpr.java new file mode 100644 index 000000000..d2a54bc08 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/CastExpr.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +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 implements NodeWithType<CastExpr> { + + private Type type; + + private Expression expr; + + public CastExpr() { + } + + public CastExpr(Type type, Expression expr) { + setType(type); + setExpr(expr); + } + + public CastExpr(Range range, Type type, Expression expr) { + super(range); + setType(type); + setExpr(expr); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + @Override + public Type getType() { + return type; + } + + public CastExpr setExpr(Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } + + @Override + public CastExpr setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/CharLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/CharLiteralExpr.java new file mode 100644 index 000000000..e799e887c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/CharLiteralExpr.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.utils.Utils; +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(Range range, String value) { + super(range, value); + } + + /** + * Utility method that creates a new StringLiteralExpr. Escapes EOL characters. + */ + public static CharLiteralExpr escape(String string) { + return new CharLiteralExpr(Utils.escapeEndOfLines(string)); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ClassExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ClassExpr.java new file mode 100644 index 000000000..a6dc9058d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ClassExpr.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +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: + * <code> + * Object.class + * </code> + * @author Julio Vilmar Gesser + */ +public final class ClassExpr extends Expression implements NodeWithType<ClassExpr> { + + private Type type; + + public ClassExpr() { + } + + public ClassExpr(Type type) { + setType(type); + } + + public ClassExpr(Range range, Type type) { + super(range); + setType(type); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public Type getType() { + return type; + } + + @Override + public ClassExpr setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ConditionalExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ConditionalExpr.java new file mode 100644 index 000000000..4dd4c4b0f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ConditionalExpr.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, Expression condition, Expression thenExpr, Expression elseExpr) { + super(range); + setCondition(condition); + setThenExpr(thenExpr); + setElseExpr(elseExpr); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getCondition() { + return condition; + } + + public Expression getElseExpr() { + return elseExpr; + } + + public Expression getThenExpr() { + return thenExpr; + } + + public ConditionalExpr setCondition(Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + return this; + } + + public ConditionalExpr setElseExpr(Expression elseExpr) { + this.elseExpr = elseExpr; + setAsParentNodeOf(this.elseExpr); + return this; + } + + public ConditionalExpr setThenExpr(Expression thenExpr) { + this.thenExpr = thenExpr; + setAsParentNodeOf(this.thenExpr); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/DoubleLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/DoubleLiteralExpr.java new file mode 100644 index 000000000..b78923851 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/DoubleLiteralExpr.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final String value) { + super(range, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/EnclosedExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/EnclosedExpr.java new file mode 100644 index 000000000..a7c40febc --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/EnclosedExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final Expression inner) { + super(range); + setInner(inner); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getInner() { + return inner; + } + + public EnclosedExpr setInner(final Expression inner) { + this.inner = inner; + setAsParentNodeOf(this.inner); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/Expression.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/Expression.java new file mode 100644 index 000000000..f9745646f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/Expression.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Node; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Expression extends Node { + + public Expression() { + } + + public Expression(Range range) { + super(range); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/FieldAccessExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/FieldAccessExpr.java new file mode 100644 index 000000000..0a4badf5c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/FieldAccessExpr.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithTypeArguments; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldAccessExpr extends Expression implements NodeWithTypeArguments<FieldAccessExpr> { + + private Expression scope; + + private List<Type<?>> typeArguments; + + private NameExpr field; + + public FieldAccessExpr() { + } + + public FieldAccessExpr(final Expression scope, final String field) { + setScope(scope); + setField(field); + } + + public FieldAccessExpr(final Range range, final Expression scope, final List<Type<?>> typeArguments, final String field) { + super(range); + setScope(scope); + setTypeArguments(typeArguments); + setField(field); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getField() { + return field.getName(); + } + + public NameExpr getFieldExpr() { + return field; + } + + public Expression getScope() { + return scope; + } + + public FieldAccessExpr setField(final String field) { + setFieldExpr(new NameExpr(field)); + return this; + } + + public FieldAccessExpr setFieldExpr(NameExpr field) { + this.field = field; + setAsParentNodeOf(this.field); + return this; + } + + public FieldAccessExpr setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + return this; + } + + + @Override + public List<Type<?>> getTypeArguments() { + return typeArguments; + } + + @Override + public FieldAccessExpr setTypeArguments(final List<Type<?>> types) { + this.typeArguments = types; + setAsParentNodeOf(this.typeArguments); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/InstanceOfExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/InstanceOfExpr.java new file mode 100644 index 000000000..ffc248ce6 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/InstanceOfExpr.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +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 implements NodeWithType<InstanceOfExpr> { + + private Expression expr; + + private Type type; + + public InstanceOfExpr() { + } + + public InstanceOfExpr(final Expression expr, final Type type) { + setExpr(expr); + setType(type); + } + + public InstanceOfExpr(final Range range, final Expression expr, final Type type) { + super(range); + setExpr(expr); + setType(type); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + @Override + public Type getType() { + return type; + } + + public InstanceOfExpr setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } + + @Override + public InstanceOfExpr setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/IntegerLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/IntegerLiteralExpr.java new file mode 100644 index 000000000..91f5dec77 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/IntegerLiteralExpr.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final String value) { + super(range, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final boolean isMinValue() { + return value != null && // + value.length() == 10 && // + value.equals(UNSIGNED_MIN_VALUE); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java new file mode 100644 index 000000000..2665aafe3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range) { + super(range, MIN_VALUE); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LambdaExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LambdaExpr.java new file mode 100644 index 000000000..4db1b0dfb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LambdaExpr.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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.utils.Utils.*; + +/** + * Lambda expression. + * + * @author Raquel Pau + */ +public class LambdaExpr extends Expression { + + private List<Parameter> parameters; + + private boolean parametersEnclosed; + + private Statement body; + + public LambdaExpr() { + } + + public LambdaExpr(Range range, List<Parameter> parameters, Statement body, + boolean parametersEnclosed) { + + super(range); + setParameters(parameters); + setBody(body); + setParametersEnclosed(parametersEnclosed); + } + + public List<Parameter> getParameters() { + parameters = ensureNotNull(parameters); + return parameters; + } + + public LambdaExpr setParameters(List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + return this; + } + + public Statement getBody() { + return body; + } + + public LambdaExpr setBody(Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + return this; + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean isParametersEnclosed() { + return parametersEnclosed; + } + + public LambdaExpr setParametersEnclosed(boolean parametersEnclosed) { + this.parametersEnclosed = parametersEnclosed; + return this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LiteralExpr.java new file mode 100644 index 000000000..9cafefdc4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LiteralExpr.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class LiteralExpr extends Expression { + + public LiteralExpr() { + } + + public LiteralExpr(Range range) { + super(range); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LongLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LongLiteralExpr.java new file mode 100644 index 000000000..0e2e8f299 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LongLiteralExpr.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final String value) { + super(range, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final boolean isMinValue() { + return value != null && // + value.length() == 20 && // + value.startsWith(UNSIGNED_MIN_VALUE) && // + (value.charAt(19) == 'L' || value.charAt(19) == 'l'); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java new file mode 100644 index 000000000..d46145a4a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range) { + super(range, MIN_VALUE); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java new file mode 100644 index 000000000..1a117ff97 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final NameExpr name) { + super(range); + setName(name); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MemberValuePair.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MemberValuePair.java new file mode 100644 index 000000000..f87af5dbb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MemberValuePair.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +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 NodeWithName<MemberValuePair> { + + private String name; + + private Expression value; + + public MemberValuePair() { + } + + public MemberValuePair(final String name, final Expression value) { + setName(name); + setValue(value); + } + + public MemberValuePair(final Range range, final String name, final Expression value) { + super(range); + setName(name); + setValue(value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public String getName() { + return name; + } + + public Expression getValue() { + return value; + } + + @Override + public MemberValuePair setName(final String name) { + this.name = name; + return this; + } + + public MemberValuePair setValue(final Expression value) { + this.value = value; + setAsParentNodeOf(this.value); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MethodCallExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MethodCallExpr.java new file mode 100644 index 000000000..98a246455 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MethodCallExpr.java @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithTypeArguments; +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.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodCallExpr extends Expression implements NodeWithTypeArguments<MethodCallExpr> { + + private Expression scope; + + private List<Type<?>> typeArguments; + + private NameExpr name; + + private List<Expression> args; + + public MethodCallExpr() { + } + + public MethodCallExpr(final Expression scope, final String name) { + setScope(scope); + setName(name); + } + + public MethodCallExpr(final Expression scope, final String name, final List<Expression> args) { + setScope(scope); + setName(name); + setArgs(args); + } + + public MethodCallExpr(final Range range, final Expression scope, final List<Type<?>> typeArguments, final String name, final List<Expression> args) { + super(range); + setScope(scope); + setTypeArguments(typeArguments); + setName(name); + setArgs(args); + } + + /** + * Adds the given argument to the method call. + * + * @param arg + * argument value + */ + public MethodCallExpr addArgument(Expression arg) { + getArgs().add(arg); + arg.setParentNode(this); + return this; + } + + public void addArgument(String arg) { + addArgument(new NameExpr(arg)); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + args = ensureNotNull(args); + return args; + } + + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public Expression getScope() { + return scope; + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public MethodCallExpr setName(final String name) { + setNameExpr(new NameExpr(name)); + return this; + } + + public MethodCallExpr setNameExpr(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + return this; + } + + public MethodCallExpr setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + return this; + } + + @Override + public List<Type<?>> getTypeArguments() { + return typeArguments; + } + + @Override + public MethodCallExpr setTypeArguments(final List<Type<?>> types) { + this.typeArguments = types; + setAsParentNodeOf(this.typeArguments); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MethodReferenceExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MethodReferenceExpr.java new file mode 100644 index 000000000..d048ca16a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/MethodReferenceExpr.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithTypeArguments; +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.utils.Utils.ensureNotNull; + +/** + * 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 implements NodeWithTypeArguments<MethodReferenceExpr> { + + private Expression scope; + + private List<Type<?>> typeArguments; + + private String identifier; + + public MethodReferenceExpr() { + } + + public MethodReferenceExpr(Range range, Expression scope, + List<Type<?>> typeArguments, String identifier) { + super(range); + setIdentifier(identifier); + setScope(scope); + setTypeArguments(typeArguments); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getScope() { + return scope; + } + + public MethodReferenceExpr setScope(Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + return this; + } + + @Override + public List<Type<?>> getTypeArguments() { + return typeArguments; + } + + @Override + public MethodReferenceExpr setTypeArguments(final List<Type<?>> types) { + this.typeArguments = types; + setAsParentNodeOf(this.typeArguments); + return this; + } + + public String getIdentifier() { + return identifier; + } + + public MethodReferenceExpr setIdentifier(String identifier) { + this.identifier = identifier; + return this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NameExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NameExpr.java new file mode 100644 index 000000000..331fa2af3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NameExpr.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class NameExpr extends Expression implements NodeWithName<NameExpr> { + + private String name; + + public NameExpr() { + } + + public NameExpr(final String name) { + this.name = name; + } + + public NameExpr(Range range, final String name) { + super(range); + this.name = name; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public final String getName() { + return name; + } + + @Override + public NameExpr setName(final String name) { + this.name = name; + return this; + } + + + /** + * Creates a new {@link NameExpr} from a qualified name.<br> + * The qualified name can contains "." (dot) characters. + * + * @param qualifiedName + * qualified name + * @return instanceof {@link NameExpr} + */ + public static NameExpr name(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; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NormalAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NormalAnnotationExpr.java new file mode 100644 index 000000000..502b11dbd --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NormalAnnotationExpr.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.ast.expr.NameExpr.*; +import static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.List; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class NormalAnnotationExpr extends AnnotationExpr { + + private List<MemberValuePair> pairs; + + public NormalAnnotationExpr() { + } + + public NormalAnnotationExpr(final NameExpr name, final List<MemberValuePair> pairs) { + setName(name); + setPairs(pairs); + } + + public NormalAnnotationExpr(final Range range, final NameExpr name, final List<MemberValuePair> pairs) { + super(range); + setName(name); + setPairs(pairs); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<MemberValuePair> getPairs() { + pairs = ensureNotNull(pairs); + return pairs; + } + + public NormalAnnotationExpr setPairs(final List<MemberValuePair> pairs) { + this.pairs = pairs; + setAsParentNodeOf(this.pairs); + return this; + } + + /** + * adds a pair to this annotation + * + * @return this, the {@link NormalAnnotationExpr} + */ + public NormalAnnotationExpr addPair(String key, String value) { + return addPair(key, name(value)); + } + + /** + * adds a pair to this annotation + * + * @return this, the {@link NormalAnnotationExpr} + */ + public NormalAnnotationExpr addPair(String key, NameExpr value) { + MemberValuePair memberValuePair = new MemberValuePair(key, value); + getPairs().add(memberValuePair); + memberValuePair.setParentNode(this); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NullLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NullLiteralExpr.java new file mode 100644 index 000000000..cb0a92b83 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/NullLiteralExpr.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range) { + super(range); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ObjectCreationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ObjectCreationExpr.java new file mode 100644 index 000000000..4d06ff8db --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ObjectCreationExpr.java @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.nodeTypes.NodeWithTypeArguments; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +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.ArrayList; +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * Defines constructor call expression. + * Example: + * <code> + * new Object() + * </code> + * + * @author Julio Vilmar Gesser + */ +public final class ObjectCreationExpr extends Expression implements + NodeWithTypeArguments<ObjectCreationExpr>, + NodeWithType<ObjectCreationExpr> { + + private Expression scope; + + private ClassOrInterfaceType type; + + private List<Type<?>> typeArguments; + + private List<Expression> args; + + // This can be null, to indicate there is no body + private List<BodyDeclaration<?>> 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<Expression> args) { + setScope(scope); + setType(type); + setArgs(args); + } + + public ObjectCreationExpr(final Range range, + final Expression scope, final ClassOrInterfaceType type, final List<Type<?>> typeArguments, + final List<Expression> args, final List<BodyDeclaration<?>> anonymousBody) { + super(range); + setScope(scope); + setType(type); + setTypeArguments(typeArguments); + setArgs(args); + setAnonymousClassBody(anonymousBody); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + /** + * This can be null, to indicate there is no body + */ + public List<BodyDeclaration<?>> getAnonymousClassBody() { + return anonymousClassBody; + } + + public void addAnonymousClassBody(BodyDeclaration<?> body) { + if (anonymousClassBody == null) + anonymousClassBody = new ArrayList<>(); + anonymousClassBody.add(body); + body.setParentNode(this); + } + + public List<Expression> getArgs() { + args = ensureNotNull(args); + return args; + } + + public Expression getScope() { + return scope; + } + + @Override + public ClassOrInterfaceType getType() { + return type; + } + + public ObjectCreationExpr setAnonymousClassBody(final List<BodyDeclaration<?>> anonymousClassBody) { + this.anonymousClassBody = anonymousClassBody; + setAsParentNodeOf(this.anonymousClassBody); + return this; + } + + public ObjectCreationExpr setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + return this; + } + + public ObjectCreationExpr setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + return this; + } + + @Override + public ObjectCreationExpr setType(final Type<?> type) { + if (!(type instanceof ClassOrInterfaceType))// needed so we can use NodeWithType + throw new RuntimeException("You can only add ClassOrInterfaceType to an ObjectCreationExpr"); + this.type = (ClassOrInterfaceType) type; + setAsParentNodeOf(this.type); + return this; + } + + @Override + public List<Type<?>> getTypeArguments() { + return typeArguments; + } + + @Override + public ObjectCreationExpr setTypeArguments(final List<Type<?>> types) { + this.typeArguments = types; + setAsParentNodeOf(this.typeArguments); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/QualifiedNameExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/QualifiedNameExpr.java new file mode 100644 index 000000000..dd906310d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/QualifiedNameExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final NameExpr scope, final String name) { + super(range, name); + setQualifier(scope); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public NameExpr getQualifier() { + return qualifier; + } + + public QualifiedNameExpr setQualifier(final NameExpr qualifier) { + this.qualifier = qualifier; + setAsParentNodeOf(this.qualifier); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java new file mode 100644 index 000000000..bd6692c83 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final NameExpr name, final Expression memberValue) { + super(range); + setName(name); + setMemberValue(memberValue); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getMemberValue() { + return memberValue; + } + + public SingleMemberAnnotationExpr setMemberValue(final Expression memberValue) { + this.memberValue = memberValue; + setAsParentNodeOf(this.memberValue); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/StringLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/StringLiteralExpr.java new file mode 100644 index 000000000..f66a594da --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/StringLiteralExpr.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.utils.Utils; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * Java® Language Specification 3.10.5 String Literals + * @author Julio Vilmar Gesser + */ +public class StringLiteralExpr extends LiteralExpr { + + protected String value; + + public StringLiteralExpr() { + this.value = ""; + } + + public StringLiteralExpr(final String value) { + if (value.contains("\n") || value.contains("\r")) { + throw new IllegalArgumentException("Illegal literal expression: newlines (line feed or carriage return) have to be escaped"); + } + this.value = value; + } + + /** + * Utility method that creates a new StringLiteralExpr. Escapes EOL characters. + */ + public static StringLiteralExpr escape(String string) { + return new StringLiteralExpr(Utils.escapeEndOfLines(string)); + } + + public StringLiteralExpr(final Range range, final String value) { + super(range); + this.value = value; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final String getValue() { + return value; + } + + public final StringLiteralExpr setValue(final String value) { + this.value = value; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/SuperExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/SuperExpr.java new file mode 100644 index 000000000..3f5e1866c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/SuperExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final Expression classExpr) { + super(range); + setClassExpr(classExpr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getClassExpr() { + return classExpr; + } + + public SuperExpr setClassExpr(final Expression classExpr) { + this.classExpr = classExpr; + setAsParentNodeOf(this.classExpr); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ThisExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ThisExpr.java new file mode 100644 index 000000000..117fed53d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/ThisExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final Expression classExpr) { + super(range); + setClassExpr(classExpr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getClassExpr() { + return classExpr; + } + + public ThisExpr setClassExpr(final Expression classExpr) { + this.classExpr = classExpr; + setAsParentNodeOf(this.classExpr); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/TypeExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/TypeExpr.java new file mode 100644 index 000000000..28b14e19f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/TypeExpr.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithType; +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 implements NodeWithType<TypeExpr> { + + private Type<?> type; + + public TypeExpr(){} + + public TypeExpr(Range range, Type<?> type) { + super(range); + setType(type); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public Type<?> getType() { + return type; + } + + @Override + public TypeExpr setType(Type<?> type) { + this.type = type; + setAsParentNodeOf(this.type); + return this; + } + + + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/UnaryExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/UnaryExpr.java new file mode 100644 index 000000000..eef9101ee --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/UnaryExpr.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 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 Range range, final Expression expr, final Operator op) { + super(range); + setExpr(expr); + setOperator(op); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Operator getOperator() { + return op; + } + + public UnaryExpr setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } + + public UnaryExpr setOperator(final Operator op) { + this.op = op; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/VariableDeclarationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/VariableDeclarationExpr.java new file mode 100644 index 000000000..5bb0f6299 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr/VariableDeclarationExpr.java @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull; +import static java.util.Collections.*; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.nodeTypes.NodeWithElementType; +import com.github.javaparser.ast.nodeTypes.NodeWithModifiers; +import com.github.javaparser.ast.nodeTypes.NodeWithVariables; +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 VariableDeclarationExpr extends Expression implements + NodeWithElementType<VariableDeclarationExpr>, + NodeWithModifiers<VariableDeclarationExpr>, + NodeWithAnnotations<VariableDeclarationExpr>, + NodeWithVariables<VariableDeclarationExpr> { + + private EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + + private List<AnnotationExpr> annotations; + + private Type elementType; + + private List<VariableDeclarator> variables; + + private List<ArrayBracketPair> arrayBracketPairsAfterType; + + public VariableDeclarationExpr() { + } + + public VariableDeclarationExpr(final Type elementType, String variableName) { + setElementType(elementType); + setVariables(singletonList(new VariableDeclarator(variableName))); + } + + public VariableDeclarationExpr(final Type elementType, VariableDeclarator var) { + setElementType(elementType); + setVariables(singletonList(var)); + } + + public VariableDeclarationExpr(final Type elementType, String variableName, Modifier... modifiers) { + setElementType(elementType); + setVariables(singletonList(new VariableDeclarator(variableName))); + setModifiers(Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class)))); + } + + public VariableDeclarationExpr(final Type elementType, VariableDeclarator var, Modifier... modifiers) { + setElementType(elementType); + setVariables(singletonList(var)); + setModifiers(Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class)))); + } + + public VariableDeclarationExpr(final Type elementType, final List<VariableDeclarator> variables) { + setElementType(elementType); + setVariables(variables); + } + + public VariableDeclarationExpr(final EnumSet<Modifier> modifiers, final Type elementType, + final List<VariableDeclarator> variables) { + setModifiers(modifiers); + setElementType(elementType); + setVariables(variables); + } + + public VariableDeclarationExpr(final Range range, + final EnumSet<Modifier> modifiers, final List<AnnotationExpr> annotations, + final Type elementType, + final List<VariableDeclarator> variables, + final List<ArrayBracketPair> arrayBracketPairsAfterType) { + super(range); + setModifiers(modifiers); + setAnnotations(annotations); + setElementType(elementType); + setVariables(variables); + setArrayBracketPairsAfterElementType(arrayBracketPairsAfterType); + } + + /** + * Creates a {@link VariableDeclarationExpr}. + * + * @return instance of {@link VariableDeclarationExpr} + */ + public static VariableDeclarationExpr create(Type type, String name) { + return new VariableDeclarationExpr(type, name); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public List<AnnotationExpr> getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + /** + * Return the modifiers of this variable declaration. + * + * @see Modifier + * @return modifiers + */ + @Override + public EnumSet<Modifier> getModifiers() { + return modifiers; + } + + @Override + public Type getElementType() { + return elementType; + } + + @Override + public List<VariableDeclarator> getVariables() { + variables = ensureNotNull(variables); + return variables; + } + + @Override + public VariableDeclarationExpr setAnnotations(final List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + return this; + } + + @Override + public VariableDeclarationExpr setModifiers(final EnumSet<Modifier> modifiers) { + this.modifiers = modifiers; + return this; + } + + @Override + public VariableDeclarationExpr setElementType(final Type elementType) { + this.elementType = elementType; + setAsParentNodeOf(this.elementType); + return this; + } + + @Override + public VariableDeclarationExpr setVariables(final List<VariableDeclarator> variables) { + this.variables = variables; + setAsParentNodeOf(this.variables); + return this; + } + + public List<ArrayBracketPair> getArrayBracketPairsAfterElementType() { + arrayBracketPairsAfterType = ensureNotNull(arrayBracketPairsAfterType); + return arrayBracketPairsAfterType; + } + + @Override + public VariableDeclarationExpr setArrayBracketPairsAfterElementType(List<ArrayBracketPair> arrayBracketPairsAfterType) { + this.arrayBracketPairsAfterType = arrayBracketPairsAfterType; + setAsParentNodeOf(arrayBracketPairsAfterType); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithAnnotations.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithAnnotations.java new file mode 100644 index 000000000..71ff7179b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithAnnotations.java @@ -0,0 +1,167 @@ +/* + * 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.nodeTypes; + +import java.lang.annotation.Annotation; +import java.util.List; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.MarkerAnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.NormalAnnotationExpr; +import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr; + +import static com.github.javaparser.ast.expr.NameExpr.*; + +/** + * An element which can be the target of annotations. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public interface NodeWithAnnotations<T> { + List<AnnotationExpr> getAnnotations(); + + T setAnnotations(List<AnnotationExpr> annotations); + + /** + * Annotates this + * + * @param name the name of the annotation + * @return the {@link NormalAnnotationExpr} added + */ + public default NormalAnnotationExpr addAnnotation(String name) { + NormalAnnotationExpr normalAnnotationExpr = new NormalAnnotationExpr( + name(name), null); + getAnnotations().add(normalAnnotationExpr); + normalAnnotationExpr.setParentNode((Node) this); + return normalAnnotationExpr; + } + + /** + * Annotates this and automatically add the import + * + * @param clazz the class of the annotation + * @return the {@link NormalAnnotationExpr} added + */ + public default NormalAnnotationExpr addAnnotation(Class<? extends Annotation> clazz) { + ((Node) this).tryAddImportToParentCompilationUnit(clazz); + return addAnnotation(clazz.getSimpleName()); + } + + /** + * Annotates this with a marker annotation + * + * @param name the name of the annotation + * @return this + */ + @SuppressWarnings("unchecked") + public default T addMarkerAnnotation(String name) { + MarkerAnnotationExpr markerAnnotationExpr = new MarkerAnnotationExpr( + name(name)); + getAnnotations().add(markerAnnotationExpr); + markerAnnotationExpr.setParentNode((Node) this); + return (T) this; + } + + /** + * Annotates this with a marker annotation and automatically add the import + * + * @param clazz the class of the annotation + * @return this + */ + public default T addMarkerAnnotation(Class<? extends Annotation> clazz) { + ((Node) this).tryAddImportToParentCompilationUnit(clazz); + return addMarkerAnnotation(clazz.getSimpleName()); + } + + /** + * Annotates this with a single member annotation + * + * @param name the name of the annotation + * @param value the value, don't forget to add \"\" for a string value + * @return this + */ + @SuppressWarnings("unchecked") + public default T addSingleMemberAnnotation(String name, String value) { + SingleMemberAnnotationExpr singleMemberAnnotationExpr = new SingleMemberAnnotationExpr( + name(name), name(value)); + getAnnotations().add(singleMemberAnnotationExpr); + singleMemberAnnotationExpr.setParentNode((Node) this); + return (T) this; + } + + /** + * Annotates this with a single member annotation and automatically add the import + * + * @param clazz the class of the annotation + * @param value the value, don't forget to add \"\" for a string value + * @return this + */ + public default T addSingleMemberAnnotation(Class<? extends Annotation> clazz, + String value) { + ((Node) this).tryAddImportToParentCompilationUnit(clazz); + return addSingleMemberAnnotation(clazz.getSimpleName(), value); + } + + /** + * Check whether an annotation with this name is present on this element + * + * @param annotationName the name of the annotation + * @return true if found, false if not + */ + public default boolean isAnnotationPresent(String annotationName) { + return getAnnotations().stream().anyMatch(a -> a.getName().getName().equals(annotationName)); + } + + /** + * Check whether an annotation with this class is present on this element + * + * @param annotationClass the class of the annotation + * @return true if found, false if not + */ + public default boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) { + return isAnnotationPresent(annotationClass.getSimpleName()); + } + + /** + * Try to find an annotation by its name + * + * @param annotationName the name of the annotation + * @return null if not found, the annotation otherwise + */ + public default AnnotationExpr getAnnotationByName(String annotationName) { + return getAnnotations().stream().filter(a -> a.getName().getName().equals(annotationName)).findFirst() + .orElse(null); + } + + /** + * Try to find an annotation by its class + * + * @param annotationClass the class of the annotation + * @return null if not found, the annotation otherwise + */ + public default AnnotationExpr getAnnotationByClass(Class<? extends Annotation> annotationClass) { + return getAnnotationByName(annotationClass.getSimpleName()); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithBlockStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithBlockStmt.java new file mode 100644 index 000000000..381318b66 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithBlockStmt.java @@ -0,0 +1,18 @@ +package com.github.javaparser.ast.nodeTypes; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.stmt.BlockStmt; + +public interface NodeWithBlockStmt<T> { + BlockStmt getBody(); + + T setBody(BlockStmt block); + + default BlockStmt createBody() { + BlockStmt block = new BlockStmt(); + setBody(block); + block.setParentNode((Node) this); + + return block; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithBody.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithBody.java new file mode 100644 index 000000000..2adfe8664 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithBody.java @@ -0,0 +1,18 @@ +package com.github.javaparser.ast.nodeTypes; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.Statement; + +public interface NodeWithBody<T> { + public Statement getBody(); + + public T setBody(final Statement body); + + public default BlockStmt createBlockStatementAsBody() { + BlockStmt b = new BlockStmt(); + b.setParentNode((Node) this); + setBody(b); + return b; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithDeclaration.java new file mode 100644 index 000000000..875d28de0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithDeclaration.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.nodeTypes; + +/** + * Element with a declaration representable as a String. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public interface NodeWithDeclaration { + + /** + * As {@link NodeWithDeclaration#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 NodeWithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including + * the parameters with both type and name. + * @param includingModifiers flag to include the modifiers (if present) in the string produced + * @param includingThrows flag to include the throws clause (if present) in the string produced + * @return String representation of declaration based on parameter flags + */ + String getDeclarationAsString(boolean includingModifiers, boolean includingThrows); + + /** + * A simple representation of the element declaration. + * It should fit one string. + * @param includingModifiers flag to include the modifiers (if present) in the string produced + * @param includingThrows flag to include the throws clause (if present) in the string produced + * @param includingParameterName flag to include the parameter name (while the parameter type is always included) in the string produced + * @return String representation of declaration based on parameter flags + */ + String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithElementType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithElementType.java new file mode 100644 index 000000000..21a41bad8 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithElementType.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.nodeTypes; + +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.Type; + +import java.util.List; + +/** + * A node having an element type. + * In most cases, the element type is simply the type. + * In case of arrays, the element type is the type that is inside the deepest nesting: + * for int[][][], the element type is int. + * + * The main reason for this interface is to permit users to manipulate homogeneously all nodes with getElementType/setElementType + * methods + */ +public interface NodeWithElementType<T> { + /** + * @return the element type + */ + Type<?> getElementType(); + + /** + * @param elementType the element elementType + * @return this + */ + T setElementType(Type<?> elementType); + + List<ArrayBracketPair> getArrayBracketPairsAfterElementType(); + + T setArrayBracketPairsAfterElementType(List<ArrayBracketPair> arrayBracketPairsAfterType); + + /** + * Sets this type to this class and try to import it to the {@link CompilationUnit} if needed + * + * @param typeClass the type + * @return this + */ + default T setElementType(Class<?> typeClass) { + ((Node) this).tryAddImportToParentCompilationUnit(typeClass); + return setElementType(new ClassOrInterfaceType(typeClass.getSimpleName())); + } + + default T setElementType(final String type) { + ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(type); + return setElementType(classOrInterfaceType); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithExtends.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithExtends.java new file mode 100644 index 000000000..083fc01b1 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithExtends.java @@ -0,0 +1,37 @@ +package com.github.javaparser.ast.nodeTypes; + +import java.util.List; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.type.ClassOrInterfaceType; + +public interface NodeWithExtends<T> { + public List<ClassOrInterfaceType> getExtends(); + + public T setExtends(final List<ClassOrInterfaceType> extendsList); + + /** + * Add an extends to this and automatically add the import + * + * @param clazz the class to extand from + * @return this + */ + public default T addExtends(Class<?> clazz) { + ((Node) this).tryAddImportToParentCompilationUnit(clazz); + return addExtends(clazz.getSimpleName()); + } + + /** + * Add an extends to this + * + * @param name the name of the type to extends from + * @return this + */ + @SuppressWarnings("unchecked") + public default T addExtends(String name) { + ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(name); + getExtends().add(classOrInterfaceType); + classOrInterfaceType.setParentNode((Node) this); + return (T) this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithImplements.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithImplements.java new file mode 100644 index 000000000..3f5192587 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithImplements.java @@ -0,0 +1,37 @@ +package com.github.javaparser.ast.nodeTypes; + +import java.util.List; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.type.ClassOrInterfaceType; + +public interface NodeWithImplements<T> { + public List<ClassOrInterfaceType> getImplements(); + + public T setImplements(List<ClassOrInterfaceType> implementsList); + + /** + * Add an implements to this + * + * @param name the name of the type to extends from + * @return this + */ + @SuppressWarnings("unchecked") + public default T addImplements(String name) { + ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(name); + getImplements().add(classOrInterfaceType); + classOrInterfaceType.setParentNode((Node) this); + return (T) this; + } + + /** + * Add an implements to this and automatically add the import + * + * @param clazz the type to implements from + * @return this + */ + public default T addImplements(Class<?> clazz) { + ((Node) this).tryAddImportToParentCompilationUnit(clazz); + return addImplements(clazz.getSimpleName()); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithJavaDoc.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithJavaDoc.java new file mode 100644 index 000000000..b00cffa5d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithJavaDoc.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.nodeTypes; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.comments.JavadocComment; + +/** + * Node which can be documented through a Javadoc comment. + */ +public interface NodeWithJavaDoc<T> { + /** + * Gets the JavaDoc for this node. You can set the JavaDoc by calling setComment with a JavadocComment. + * + * @return The JavaDoc for this node if it exists, null if it doesn't. + */ + JavadocComment getJavaDoc(); + + /** + * Use this to store additional information to this node. + * + * @param comment to be set + */ + @SuppressWarnings("unchecked") + public default T setJavaDocComment(String comment) { + ((Node) this).setComment(new JavadocComment(comment)); + return (T) this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithMembers.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithMembers.java new file mode 100644 index 000000000..827e5edee --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithMembers.java @@ -0,0 +1,284 @@ +package com.github.javaparser.ast.nodeTypes; + +import static com.github.javaparser.ast.type.VoidType.VOID_TYPE; +import static java.util.Collections.unmodifiableList; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toSet; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.List; +import java.util.stream.Stream; + +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +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.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.Type; + +/** + * A node having members. + * + * The main reason for this interface is to permit users to manipulate homogeneously all nodes with a getMembers + * method. + * + */ +public interface NodeWithMembers<T> { + List<BodyDeclaration<?>> getMembers(); + + T setMembers(List<BodyDeclaration<?>> members); + + /** + * Add a field to this and automatically add the import of the type if needed + * + * @param typeClass the type of the field + * @param name the name of the field + * @param modifiers the modifiers like {@link Modifier#PUBLIC} + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addField(Class<?> typeClass, String name, Modifier... modifiers) { + ((Node) this).tryAddImportToParentCompilationUnit(typeClass); + return addField(typeClass.getSimpleName(), name, modifiers); + } + + /** + * Add a field to this + * + * @param type the type of the field + * @param name the name of the field + * @param modifiers the modifiers like {@link Modifier#PUBLIC} + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addField(String type, String name, Modifier... modifiers) { + return addField(new ClassOrInterfaceType(type), name, modifiers); + } + + /** + * Add a field to this + * + * @param type the type of the field + * @param name the name of the field + * @param modifiers the modifiers like {@link Modifier#PUBLIC} + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addField(Type<?> type, String name, Modifier... modifiers) { + FieldDeclaration fieldDeclaration = new FieldDeclaration(); + fieldDeclaration.setParentNode((Node) this); + VariableDeclarator variable = new VariableDeclarator(new VariableDeclaratorId(name)); + fieldDeclaration.getVariables().add(variable); + variable.setParentNode(fieldDeclaration); + fieldDeclaration.setModifiers(Arrays.stream(modifiers) + .collect(toCollection(() -> EnumSet.noneOf(Modifier.class)))); + variable.setType(type); + getMembers().add(fieldDeclaration); + return fieldDeclaration; + } + + /** + * Add a private field to this + * + * @param typeClass the type of the field + * @param name the name of the field + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addPrivateField(Class<?> typeClass, String name) { + return addField(typeClass, name, Modifier.PRIVATE); + } + + /** + * Add a private field to this and automatically add the import of the type if + * needed + * + * @param type the type of the field + * @param name the name of the field + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addPrivateField(String type, String name) { + return addField(type, name, Modifier.PRIVATE); + } + + /** + * Add a public field to this + * + * @param typeClass the type of the field + * @param name the name of the field + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addPublicField(Class<?> typeClass, String name) { + return addField(typeClass, name, Modifier.PUBLIC); + } + + /** + * Add a public field to this and automatically add the import of the type if + * needed + * + * @param type the type of the field + * @param name the name of the field + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addPublicField(String type, String name) { + return addField(type, name, Modifier.PUBLIC); + } + + /** + * Add a protected field to this + * + * @param typeClass the type of the field + * @param name the name of the field + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addProtectedField(Class<?> typeClass, String name) { + return addField(typeClass, name, Modifier.PROTECTED); + } + + /** + * Add a protected field to this and automatically add the import of the type + * if needed + * + * @param type the type of the field + * @param name the name of the field + * @return the {@link FieldDeclaration} created + */ + default FieldDeclaration addProtectedField(String type, String name) { + return addField(type, name, Modifier.PROTECTED); + } + + /** + * Adds a methods with void return by default to this + * + * @param methodName the method name + * @param modifiers the modifiers like {@link Modifier#PUBLIC} + * @return the {@link MethodDeclaration} created + */ + default MethodDeclaration addMethod(String methodName, Modifier... modifiers) { + MethodDeclaration methodDeclaration = new MethodDeclaration(); + methodDeclaration.setName(methodName); + methodDeclaration.setType(VOID_TYPE); + methodDeclaration.setModifiers(Arrays.stream(modifiers) + .collect(toCollection(() -> EnumSet.noneOf(Modifier.class)))); + getMembers().add(methodDeclaration); + methodDeclaration.setParentNode((Node) this); + return methodDeclaration; + } + + /** + * Adds a constructor to this + * + * @param modifiers the modifiers like {@link Modifier#PUBLIC} + * @return the {@link MethodDeclaration} created + */ + default ConstructorDeclaration addCtor(Modifier... modifiers) { + ConstructorDeclaration constructorDeclaration = new ConstructorDeclaration(); + constructorDeclaration.setModifiers(Arrays.stream(modifiers) + .collect(toCollection(() -> EnumSet.noneOf(Modifier.class)))); + constructorDeclaration.setName(((TypeDeclaration<?>) this).getName()); + getMembers().add(constructorDeclaration); + constructorDeclaration.setParentNode((Node) this); + return constructorDeclaration; + } + + default BlockStmt addInitializer() { + BlockStmt block = new BlockStmt(); + InitializerDeclaration initializerDeclaration = new InitializerDeclaration(false, block); + getMembers().add(initializerDeclaration); + initializerDeclaration.setParentNode((Node) this); + return block; + } + + default BlockStmt addStaticInitializer() { + BlockStmt block = new BlockStmt(); + InitializerDeclaration initializerDeclaration = new InitializerDeclaration(true, block); + getMembers().add(initializerDeclaration); + initializerDeclaration.setParentNode((Node) this); + return block; + } + + /** + * Try to find a {@link MethodDeclaration} by its name + * + * @param name the name of the method + * @return the methods found (multiple in case of polymorphism) + */ + default List<MethodDeclaration> getMethodsByName(String name) { + return getMembers().stream() + .filter(m -> m instanceof MethodDeclaration && ((MethodDeclaration) m).getName().equals(name)) + .map(m -> (MethodDeclaration) m).collect(toList()); + } + + /** + * Find all methods in the members of this node. + * + * @return the methods found. This list is immutable. + */ + default List<MethodDeclaration> getMethods() { + return unmodifiableList(getMembers().stream() + .filter(m -> m instanceof MethodDeclaration) + .map(m -> (MethodDeclaration) m) + .collect(toList())); + } + + /** + * Try to find a {@link MethodDeclaration} by its parameters types + * + * @param paramTypes the types of parameters like "Map<Integer,String>","int" to match<br> + * void foo(Map<Integer,String> myMap,int number) + * @return the methods found (multiple in case of polymorphism) + */ + default List<MethodDeclaration> getMethodsByParameterTypes(String... paramTypes) { + return getMembers().stream() + .filter(m -> m instanceof MethodDeclaration + && ((MethodDeclaration) m).getParameters().stream().map(p -> p.getType().toString()) + .collect(toSet()).equals(Stream.of(paramTypes).collect(toSet()))) + .map(m -> (MethodDeclaration) m).collect(toList()); + } + + /** + * Try to find a {@link MethodDeclaration} by its parameters types + * + * @param paramTypes the types of parameters like "Map<Integer,String>","int" to match<br> + * void foo(Map<Integer,String> myMap,int number) + * @return the methods found (multiple in case of polymorphism) + */ + default List<MethodDeclaration> getMethodsByParameterTypes(Class<?>... paramTypes) { + return getMembers().stream() + .filter(m -> m instanceof MethodDeclaration + && ((MethodDeclaration) m).getParameters().stream().map(p -> p.getType().toString()) + .collect(toSet()) + .equals(Stream.of(paramTypes).map(Class::getSimpleName).collect(toSet()))) + .map(m -> (MethodDeclaration) m).collect(toList()); + } + + /** + * Try to find a {@link FieldDeclaration} by its name + * + * @param name the name of the field + * @return null if not found, the FieldDeclaration otherwise + */ + default FieldDeclaration getFieldByName(String name) { + return (FieldDeclaration) getMembers().stream() + .filter(m -> m instanceof FieldDeclaration && ((FieldDeclaration) m).getVariables().stream() + .anyMatch(var -> var.getId().getName().equals(name))) + .findFirst().orElse(null); + } + + /** + * Find all fields in the members of this node. + * + * @return the fields found. This list is immutable. + */ + default List<FieldDeclaration> getFields() { + return unmodifiableList(getMembers().stream() + .filter(m -> m instanceof FieldDeclaration ) + .map(m -> (FieldDeclaration) m) + .collect(toList())); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithModifiers.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithModifiers.java new file mode 100644 index 000000000..6a1959ecf --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithModifiers.java @@ -0,0 +1,73 @@ +package com.github.javaparser.ast.nodeTypes; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.stream.Collectors; + +import com.github.javaparser.ast.Modifier; + +/** + * A Node with Modifiers. + */ +public interface NodeWithModifiers<T> { + /** + * Return the modifiers of this variable declaration. + * + * @see Modifier + * @return modifiers + */ + EnumSet<Modifier> getModifiers(); + + T setModifiers(EnumSet<Modifier> modifiers); + + @SuppressWarnings("unchecked") + default T addModifier(Modifier... modifiers) { + getModifiers().addAll(Arrays.stream(modifiers) + .collect(Collectors.toCollection(() -> EnumSet.noneOf(Modifier.class)))); + return (T) this; + } + + default boolean isStatic() { + return getModifiers().contains(Modifier.STATIC); + } + + default boolean isAbstract() { + return getModifiers().contains(Modifier.ABSTRACT); + } + + default boolean isFinal() { + return getModifiers().contains(Modifier.FINAL); + } + + default boolean isNative() { + return getModifiers().contains(Modifier.NATIVE); + } + + default boolean isPrivate() { + return getModifiers().contains(Modifier.PRIVATE); + } + + default boolean isProtected() { + return getModifiers().contains(Modifier.PROTECTED); + } + + default boolean isPublic() { + return getModifiers().contains(Modifier.PUBLIC); + } + + default boolean isStrictfp() { + return getModifiers().contains(Modifier.STRICTFP); + } + + default boolean isSynchronized() { + return getModifiers().contains(Modifier.SYNCHRONIZED); + } + + default boolean isTransient() { + return getModifiers().contains(Modifier.TRANSIENT); + } + + default boolean isVolatile() { + return getModifiers().contains(Modifier.VOLATILE); + } +}
\ No newline at end of file diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithName.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithName.java new file mode 100644 index 000000000..edcff5cff --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithName.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.nodeTypes; + +/** + * 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 NodeWithName<T> { + String getName(); + + T setName(String name); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java new file mode 100644 index 000000000..fb8697f3c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithParameters.java @@ -0,0 +1,100 @@ +package com.github.javaparser.ast.nodeTypes; + +import java.util.List; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.Type; + +public interface NodeWithParameters<T> { + List<Parameter> getParameters(); + + T setParameters(List<Parameter> parameters); + + default T addParameter(Type type, String name) { + return addParameter(new Parameter(type, new VariableDeclaratorId(name))); + } + + default T addParameter(Class<?> paramClass, String name) { + ((Node) this).tryAddImportToParentCompilationUnit(paramClass); + return addParameter(new ClassOrInterfaceType(paramClass.getSimpleName()), name); + } + + /** + * Remember to import the class in the compilation unit yourself + * + * @param className the name of the class, ex : org.test.Foo or Foo if you added manually the import + * @param name the name of the parameter + */ + default T addParameter(String className, String name) { + return addParameter(new ClassOrInterfaceType(className), name); + } + + @SuppressWarnings("unchecked") + default T addParameter(Parameter parameter) { + getParameters().add(parameter); + parameter.setParentNode((Node) this); + return (T) this; + } + + default Parameter addAndGetParameter(Type type, String name) { + return addAndGetParameter(new Parameter(type, new VariableDeclaratorId(name))); + } + + default Parameter addAndGetParameter(Class<?> paramClass, String name) { + ((Node) this).tryAddImportToParentCompilationUnit(paramClass); + return addAndGetParameter(new ClassOrInterfaceType(paramClass.getSimpleName()), name); + } + + /** + * Remember to import the class in the compilation unit yourself + * + * @param className the name of the class, ex : org.test.Foo or Foo if you added manually the import + * @param name the name of the parameter + * @return the {@link Parameter} created + */ + default Parameter addAndGetParameter(String className, String name) { + return addAndGetParameter(new ClassOrInterfaceType(className), name); + } + + default Parameter addAndGetParameter(Parameter parameter) { + getParameters().add(parameter); + parameter.setParentNode((Node) this); + return parameter; + } + + /** + * Try to find a {@link Parameter} by its name + * + * @param name the name of the param + * @return null if not found, the param found otherwise + */ + default Parameter getParamByName(String name) { + return getParameters().stream() + .filter(p -> p.getName().equals(name)).findFirst().orElse(null); + } + + /** + * Try to find a {@link Parameter} by its type + * + * @param type the type of the param + * @return null if not found, the param found otherwise + */ + default Parameter getParamByType(String type) { + return getParameters().stream() + .filter(p -> p.getType().toString().equals(type)).findFirst().orElse(null); + } + + /** + * Try to find a {@link Parameter} by its type + * + * @param type the type of the param <b>take care about generics, it wont work</b> + * @return null if not found, the param found otherwise + */ + default Parameter getParamByType(Class<?> type) { + return getParameters().stream() + .filter(p -> p.getType().toString().equals(type.getSimpleName())).findFirst().orElse(null); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithStatements.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithStatements.java new file mode 100644 index 000000000..b6c895efb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithStatements.java @@ -0,0 +1,46 @@ +package com.github.javaparser.ast.nodeTypes; + +import java.util.List; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.Statement; + +public interface NodeWithStatements<T> { + public List<Statement> getStmts(); + + public T setStmts(final List<Statement> stmts); + + @SuppressWarnings("unchecked") + public default T addStatement(Statement statement) { + getStmts().add(statement); + statement.setParentNode((Node) this); + return (T) this; + } + + @SuppressWarnings("unchecked") + public default T addStatement(int index, final Statement statement) { + getStmts().add(index, statement); + statement.setParentNode((Node) this); + return (T) this; + } + + public default T addStatement(Expression expr) { + ExpressionStmt statement = new ExpressionStmt(expr); + expr.setParentNode(statement); + return addStatement(statement); + } + + public default T addStatement(String statement) { + return addStatement(new NameExpr(statement)); + } + + public default T addStatement(int index, final Expression expr) { + Statement stmt = new ExpressionStmt(expr); + expr.setParentNode(stmt); + return addStatement(index, stmt); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithThrowable.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithThrowable.java new file mode 100644 index 000000000..beee9e727 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithThrowable.java @@ -0,0 +1,57 @@ +package com.github.javaparser.ast.nodeTypes; + +import java.util.List; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.ReferenceType; + +public interface NodeWithThrowable<T> { + T setThrows(List<ReferenceType> throws_); + + List<ReferenceType> getThrows(); + + /** + * Adds this type to the throws clause + * + * @param throwType the exception type + * @return this + */ + @SuppressWarnings("unchecked") + default T addThrows(ReferenceType throwType) { + getThrows().add(throwType); + throwType.setParentNode((Node) this); + return (T) this; + } + + /** + * Adds this class to the throws clause + * + * @param clazz the exception class + * @return this + */ + default T addThrows(Class<? extends Throwable> clazz) { + ((Node) this).tryAddImportToParentCompilationUnit(clazz); + return addThrows(new ClassOrInterfaceType(clazz.getSimpleName())); + } + + /** + * Check whether this elements throws this exception class + * + * @param clazz the class of the exception + * @return true if found in throws clause, false if not + */ + public default boolean isThrows(Class<? extends Throwable> clazz) { + return isThrows(clazz.getSimpleName()); + } + + /** + * Check whether this elements throws this exception class + * + * @param throwableName the class of the exception + * @return true if found in throws clause, false if not + */ + public default boolean isThrows(String throwableName) { + return getThrows().stream().anyMatch(t -> t.toString().equals(throwableName)); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithType.java new file mode 100644 index 000000000..fc183b20b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithType.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.nodeTypes; + +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.Type; + +/** + * A node having a type. + * + * The main reason for this interface is to permit users to manipulate homogeneously all nodes with getType/setType + * methods + * + * @since 2.3.1 + */ +public interface NodeWithType<T> { + /** + * Gets the type + * + * @return the type + */ + Type<?> getType(); + + /** + * Sets the type + * + * @param type the type + * @return this + */ + T setType(Type<?> type); + + /** + * Sets this type to this class and try to import it to the {@link CompilationUnit} if needed + * + * @param typeClass the type + * @return this + */ + default T setType(Class<?> typeClass) { + ((Node) this).tryAddImportToParentCompilationUnit(typeClass); + return setType(new ClassOrInterfaceType(typeClass.getSimpleName())); + } + + default T setType(final String type) { + ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(type); + return setType(classOrInterfaceType); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithTypeArguments.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithTypeArguments.java new file mode 100644 index 000000000..3ce27971e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithTypeArguments.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.nodeTypes; + +import com.github.javaparser.ast.type.Type; + +import java.util.*; + +import static com.github.javaparser.utils.Utils.arrayToList; + +/** + * A node that can have type arguments. + * <pre> + * new X(); --> typeArguments == null + * new X<>(); --> typeArguments.types = [], typeArguments.diamondOperator=true + * new X<C,D>(); --> typeArguments.types = [C,D], typeArguments.diamondOperator=false + * </pre> + */ +public interface NodeWithTypeArguments<T> { + /** + * @return the types that can be found in the type arguments: <String, Integer>. + */ + List<Type<?>> getTypeArguments(); + + /** + * Allows you to set the generic arguments + * @param typeArguments The list of types of the generics + */ + T setTypeArguments(List<Type<?>> typeArguments); + + /** + * @return whether the type arguments look like <>. + */ + default boolean isUsingDiamondOperator() { + if(getTypeArguments()==null){ + return false; + } + return getTypeArguments().isEmpty(); + } + + /** + * Sets the type arguments to <>. + */ + default T setDiamondOperator() { + final List<Type<?>> empty = new LinkedList<>(); + setTypeArguments(empty); + return (T) this; + } + + /** + * Removes all type arguments, including the surrounding <>. + */ + default T removeTypeArguments() { + setTypeArguments((List<Type<?>>) null); + return (T) this; + } + + default T setTypeArguments(Type<?>... typeArguments) { + setTypeArguments(arrayToList(typeArguments)); + return (T) this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithVariables.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithVariables.java new file mode 100644 index 000000000..2c6702ac4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/nodeTypes/NodeWithVariables.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.nodeTypes; + +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; + +import java.util.List; + +/** + * A node which has a list of variables. + */ +public interface NodeWithVariables<T> { + List<VariableDeclarator> getVariables(); + + T setVariables(List<VariableDeclarator> variables); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/AssertStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/AssertStmt.java new file mode 100644 index 000000000..85a34a847 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/AssertStmt.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final Expression check, final Expression msg) { + super(range); + + setCheck(check); + setMessage(msg); + + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getCheck() { + return check; + } + + public Expression getMessage() { + return msg; + } + + public AssertStmt setCheck(final Expression check) { + this.check = check; + setAsParentNodeOf(this.check); + return this; + } + + public AssertStmt setMessage(final Expression msg) { + this.msg = msg; + setAsParentNodeOf(this.msg); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/BlockStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/BlockStmt.java new file mode 100644 index 000000000..31cbfa391 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/BlockStmt.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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 static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.List; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithStatements; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BlockStmt extends Statement implements NodeWithStatements<BlockStmt> { + + private List<Statement> stmts; + + public BlockStmt() { + } + + public BlockStmt(final List<Statement> stmts) { + setStmts(stmts); + } + + public BlockStmt(final Range range, final List<Statement> stmts) { + super(range); + setStmts(stmts); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public List<Statement> getStmts() { + stmts = ensureNotNull(stmts); + return stmts; + } + + @Override + public BlockStmt setStmts(final List<Statement> stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + return this; + } + + + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/BreakStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/BreakStmt.java new file mode 100644 index 000000000..04c39fb9f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/BreakStmt.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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 Range range, final String id) { + super(range); + this.id = id; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getId() { + return id; + } + + public BreakStmt setId(final String id) { + this.id = id; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/CatchClause.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/CatchClause.java new file mode 100644 index 000000000..a1f300544 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/CatchClause.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt; +import com.github.javaparser.ast.type.ReferenceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.EnumSet; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class CatchClause extends Node implements NodeWithBlockStmt<CatchClause> { + + private Parameter param; + + private BlockStmt catchBlock; + + public CatchClause() { + } + + public CatchClause(final Parameter param, final BlockStmt catchBlock) { + setParam(param); + setBody(catchBlock); + } + + public CatchClause(final Range range, + final EnumSet<Modifier> exceptModifier, + final List<AnnotationExpr> exceptAnnotations, + final Type exceptType, + final VariableDeclaratorId exceptId, + final BlockStmt catchBlock) { + super(range); + setParam(new Parameter(range, exceptModifier, exceptAnnotations, exceptType, null, false, exceptId)); + setBody(catchBlock); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + /** + * Use {@link #getBody()} instead + */ + @Deprecated + public BlockStmt getCatchBlock() { + return catchBlock; + } + + /** + * Note that the type of the Parameter can be a UnionType. In this case, any annotations found at the start of the catch(@X A a |...) + * are found directly in the Parameter. Annotations that are on the second or later type - catch(A a | @X B b ...) are found on those types. + */ + public Parameter getParam() { + return param; + } + + /** + * Use {@link #setBody(BlockStmt)} instead + * + * @param catchBlock + */ + @Deprecated + public CatchClause setCatchBlock(final BlockStmt catchBlock) { + this.catchBlock = catchBlock; + setAsParentNodeOf(this.catchBlock); + return this; + } + + public CatchClause setParam(final Parameter param) { + this.param = param; + setAsParentNodeOf(this.param); + return this; + } + + @Override + public BlockStmt getBody() { + return catchBlock; + } + + @Override + public CatchClause setBody(BlockStmt block) { + this.catchBlock = block; + setAsParentNodeOf(this.catchBlock); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ContinueStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ContinueStmt.java new file mode 100644 index 000000000..4ba7faa7b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ContinueStmt.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, final String id) { + super(range); + this.id = id; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getId() { + return id; + } + + public ContinueStmt setId(final String id) { + this.id = id; + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/DoStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/DoStmt.java new file mode 100644 index 000000000..8f293ecab --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/DoStmt.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithBody; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class DoStmt extends Statement implements NodeWithBody<DoStmt> { + + private Statement body; + + private Expression condition; + + public DoStmt() { + } + + public DoStmt(final Statement body, final Expression condition) { + setBody(body); + setCondition(condition); + } + + public DoStmt(Range range, final Statement body, final Expression condition) { + super(range); + setBody(body); + setCondition(condition); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public Statement getBody() { + return body; + } + + public Expression getCondition() { + return condition; + } + + @Override + public DoStmt setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + return this; + } + + public DoStmt setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/EmptyStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/EmptyStmt.java new file mode 100644 index 000000000..00709806d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/EmptyStmt.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range) { + super(range); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java new file mode 100644 index 000000000..e29205b84 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithTypeArguments; +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.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ExplicitConstructorInvocationStmt extends Statement implements NodeWithTypeArguments<ExplicitConstructorInvocationStmt> { + + private List<Type<?>> typeArguments; + + private boolean isThis; + + private Expression expr; + + private List<Expression> args; + + public ExplicitConstructorInvocationStmt() { + } + + public ExplicitConstructorInvocationStmt(final boolean isThis, + final Expression expr, final List<Expression> args) { + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + public ExplicitConstructorInvocationStmt(Range range, + final List<Type<?>> typeArguments, final boolean isThis, + final Expression expr, final List<Expression> args) { + super(range); + setTypeArguments(typeArguments); + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + args = ensureNotNull(args); + return args; + } + + public Expression getExpr() { + return expr; + } + + public boolean isThis() { + return isThis; + } + + public ExplicitConstructorInvocationStmt setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + return this; + } + + public ExplicitConstructorInvocationStmt setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } + + public ExplicitConstructorInvocationStmt setThis(final boolean isThis) { + this.isThis = isThis; + return this; + } + + @Override + public List<Type<?>> getTypeArguments() { + return typeArguments; + } + + @Override + public ExplicitConstructorInvocationStmt setTypeArguments(final List<Type<?>> types) { + this.typeArguments = types; + setAsParentNodeOf(this.typeArguments); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ExpressionStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ExpressionStmt.java new file mode 100644 index 000000000..72d8a2e94 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ExpressionStmt.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, + final Expression expr) { + super(range); + setExpression(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpression() { + return expr; + } + + public ExpressionStmt setExpression(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ForStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ForStmt.java new file mode 100644 index 000000000..52baddb7b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ForStmt.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithBody; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForStmt extends Statement implements NodeWithBody<ForStmt> { + + private List<Expression> init; + + private Expression compare; + + private List<Expression> update; + + private Statement body; + + public ForStmt() { + } + + public ForStmt(final List<Expression> init, final Expression compare, + final List<Expression> update, final Statement body) { + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + public ForStmt(Range range, + final List<Expression> init, final Expression compare, + final List<Expression> update, final Statement body) { + super(range); + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public Statement getBody() { + return body; + } + + public Expression getCompare() { + return compare; + } + + public List<Expression> getInit() { + init = ensureNotNull(init); + return init; + } + + public List<Expression> getUpdate() { + update = ensureNotNull(update); + return update; + } + + @Override + public ForStmt setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + return this; + } + + public ForStmt setCompare(final Expression compare) { + this.compare = compare; + setAsParentNodeOf(this.compare); + return this; + } + + public ForStmt setInit(final List<Expression> init) { + this.init = init; + setAsParentNodeOf(this.init); + return this; + } + + public ForStmt setUpdate(final List<Expression> update) { + this.update = update; + setAsParentNodeOf(this.update); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ForeachStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ForeachStmt.java new file mode 100644 index 000000000..3a94572b0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ForeachStmt.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithBody; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForeachStmt extends Statement implements NodeWithBody<ForeachStmt> { + + 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(Range range, + final VariableDeclarationExpr var, final Expression iterable, + final Statement body) { + super(range); + setVariable(var); + setIterable(iterable); + setBody(body); + } + + /** + * Will create a {@link NameExpr} with the iterable param + * + * @param var + * @param iterable + * @param body + */ + public ForeachStmt(VariableDeclarationExpr var, String iterable, BlockStmt body) { + setVariable(var); + setIterable(new NameExpr(iterable)); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public Statement getBody() { + return body; + } + + public Expression getIterable() { + return iterable; + } + + public VariableDeclarationExpr getVariable() { + return var; + } + + @Override + public ForeachStmt setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + return this; + } + + public ForeachStmt setIterable(final Expression iterable) { + this.iterable = iterable; + setAsParentNodeOf(this.iterable); + return this; + } + + public ForeachStmt setVariable(final VariableDeclarationExpr var) { + this.var = var; + setAsParentNodeOf(this.var); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/IfStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/IfStmt.java new file mode 100644 index 000000000..ace3ec8a5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/IfStmt.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, + final Expression condition, final Statement thenStmt, final Statement elseStmt) { + super(range); + setCondition(condition); + setThenStmt(thenStmt); + setElseStmt(elseStmt); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getCondition() { + return condition; + } + + public Statement getElseStmt() { + return elseStmt; + } + + public Statement getThenStmt() { + return thenStmt; + } + + public IfStmt setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + return this; + } + + public IfStmt setElseStmt(final Statement elseStmt) { + this.elseStmt = elseStmt; + setAsParentNodeOf(this.elseStmt); + return this; + } + + public IfStmt setThenStmt(final Statement thenStmt) { + this.thenStmt = thenStmt; + setAsParentNodeOf(this.thenStmt); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/LabeledStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/LabeledStmt.java new file mode 100644 index 000000000..ded1ad8d8 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/LabeledStmt.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, final String label, final Statement stmt) { + super(range); + setLabel(label); + setStmt(stmt); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getLabel() { + return label; + } + + public Statement getStmt() { + return stmt; + } + + public LabeledStmt setLabel(final String label) { + this.label = label; + return this; + } + + public LabeledStmt setStmt(final Statement stmt) { + this.stmt = stmt; + setAsParentNodeOf(this.stmt); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ReturnStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ReturnStmt.java new file mode 100644 index 000000000..6ce31d0bf --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ReturnStmt.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.NameExpr; +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(Range range, final Expression expr) { + super(range); + setExpr(expr); + } + + /** + * Will create a NameExpr with the string param + * + * @param expr + */ + public ReturnStmt(String expr) { + setExpr(new NameExpr(expr)); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public ReturnStmt setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/Statement.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/Statement.java new file mode 100644 index 000000000..eacfcc416 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/Statement.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Node; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Statement extends Node { + + public Statement() { + } + + public Statement(final Range range) { + super(range); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SwitchEntryStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SwitchEntryStmt.java new file mode 100644 index 000000000..e17e20e94 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SwitchEntryStmt.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithStatements; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchEntryStmt extends Statement implements NodeWithStatements<SwitchEntryStmt> { + + private Expression label; + + private List<Statement> stmts; + + public SwitchEntryStmt() { + } + + public SwitchEntryStmt(final Expression label, final List<Statement> stmts) { + setLabel(label); + setStmts(stmts); + } + + public SwitchEntryStmt(Range range, final Expression label, + final List<Statement> stmts) { + super(range); + setLabel(label); + setStmts(stmts); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getLabel() { + return label; + } + + @Override + public List<Statement> getStmts() { + stmts = ensureNotNull(stmts); + return stmts; + } + + public SwitchEntryStmt setLabel(final Expression label) { + this.label = label; + setAsParentNodeOf(this.label); + return this; + } + + @Override + public SwitchEntryStmt setStmts(final List<Statement> stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SwitchStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SwitchStmt.java new file mode 100644 index 000000000..c909394b2 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SwitchStmt.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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.utils.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchStmt extends Statement { + + private Expression selector; + + private List<SwitchEntryStmt> entries; + + public SwitchStmt() { + } + + public SwitchStmt(final Expression selector, + final List<SwitchEntryStmt> entries) { + setSelector(selector); + setEntries(entries); + } + + public SwitchStmt(Range range, final Expression selector, + final List<SwitchEntryStmt> entries) { + super(range); + setSelector(selector); + setEntries(entries); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<SwitchEntryStmt> getEntries() { + entries = ensureNotNull(entries); + return entries; + } + + public Expression getSelector() { + return selector; + } + + public SwitchStmt setEntries(final List<SwitchEntryStmt> entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + return this; + } + + public SwitchStmt setSelector(final Expression selector) { + this.selector = selector; + setAsParentNodeOf(this.selector); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SynchronizedStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SynchronizedStmt.java new file mode 100644 index 000000000..1a9d2db5d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/SynchronizedStmt.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SynchronizedStmt extends Statement implements NodeWithBlockStmt<SynchronizedStmt> { + + private Expression expr; + + private BlockStmt block; + + public SynchronizedStmt() { + } + + public SynchronizedStmt(final Expression expr, final BlockStmt block) { + setExpr(expr); + setBlock(block); + } + + public SynchronizedStmt(Range range, final Expression expr, + final BlockStmt block) { + super(range); + setExpr(expr); + setBlock(block); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + /** + * @deprecated use {@link #getBody()} + * @return + */ + @Deprecated + public BlockStmt getBlock() { + return block; + } + + public Expression getExpr() { + return expr; + } + + /** + * @deprecated Use {@link #setBody(BlockStmt)} instead + * @param block + */ + @Deprecated + public SynchronizedStmt setBlock(final BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + return this; + } + + public SynchronizedStmt setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } + + @Override + public BlockStmt getBody() { + return block; + } + + @Override + public SynchronizedStmt setBody(BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ThrowStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ThrowStmt.java new file mode 100644 index 000000000..180fdd04c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/ThrowStmt.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, final Expression expr) { + super(range); + setExpr(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public ThrowStmt setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/TryStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/TryStmt.java new file mode 100644 index 000000000..4688454b4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/TryStmt.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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.utils.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public final class TryStmt extends Statement { + + private List<VariableDeclarationExpr> resources; + + private BlockStmt tryBlock; + + private List<CatchClause> catchs; + + private BlockStmt finallyBlock; + + public TryStmt() { + } + + public TryStmt(final BlockStmt tryBlock, final List<CatchClause> catchs, + final BlockStmt finallyBlock) { + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + public TryStmt(Range range, List<VariableDeclarationExpr> resources, + final BlockStmt tryBlock, final List<CatchClause> catchs, final BlockStmt finallyBlock) { + super(range); + setResources(resources); + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<CatchClause> getCatchs() { + catchs = ensureNotNull(catchs); + return catchs; + } + + public BlockStmt getFinallyBlock() { + return finallyBlock; + } + + public BlockStmt getTryBlock() { + return tryBlock; + } + + public List<VariableDeclarationExpr> getResources() { + resources = ensureNotNull(resources); + return resources; + } + + public TryStmt setCatchs(final List<CatchClause> catchs) { + this.catchs = catchs; + setAsParentNodeOf(this.catchs); + return this; + } + + public TryStmt setFinallyBlock(final BlockStmt finallyBlock) { + this.finallyBlock = finallyBlock; + setAsParentNodeOf(this.finallyBlock); + return this; + } + + public TryStmt setTryBlock(final BlockStmt tryBlock) { + this.tryBlock = tryBlock; + setAsParentNodeOf(this.tryBlock); + return this; + } + + public TryStmt setResources(List<VariableDeclarationExpr> resources) { + this.resources = resources; + setAsParentNodeOf(this.resources); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java new file mode 100644 index 000000000..a9f83bf78 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +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(Range range, final TypeDeclaration typeDecl) { + super(range); + setTypeDeclaration(typeDecl); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public TypeDeclaration getTypeDeclaration() { + return typeDecl; + } + + public TypeDeclarationStmt setTypeDeclaration(final TypeDeclaration typeDecl) { + this.typeDecl = typeDecl; + setAsParentNodeOf(this.typeDecl); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/WhileStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/WhileStmt.java new file mode 100644 index 000000000..b843494a4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/stmt/WhileStmt.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.nodeTypes.NodeWithBody; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class WhileStmt extends Statement implements NodeWithBody<WhileStmt> { + + private Expression condition; + + private Statement body; + + public WhileStmt() { + } + + public WhileStmt(final Expression condition, final Statement body) { + setCondition(condition); + setBody(body); + } + + public WhileStmt(Range range, final Expression condition, final Statement body) { + super(range); + setCondition(condition); + setBody(body); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public Statement getBody() { + return body; + } + + public Expression getCondition() { + return condition; + } + + @Override + public WhileStmt setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + return this; + } + + public WhileStmt setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ArrayType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ArrayType.java new file mode 100644 index 000000000..babf2a5d7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ArrayType.java @@ -0,0 +1,86 @@ +package com.github.javaparser.ast.type; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.ArrayBracketPair; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.utils.Pair; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * To indicate that a type is an array, it gets wrapped in an ArrayType for every array level it has. + * So, int[][] becomes ArrayType(ArrayType(int)). + */ +public class ArrayType extends ReferenceType<ArrayType> implements NodeWithAnnotations<ArrayType> { + private Type componentType; + + public ArrayType(Type componentType, List<AnnotationExpr> annotations) { + setComponentType(componentType); + setAnnotations(annotations); + } + + public ArrayType(Range range, Type componentType, List<AnnotationExpr> annotations) { + super(range); + setComponentType(componentType); + setAnnotations(annotations); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Type getComponentType() { + return componentType; + } + + public ArrayType setComponentType(final Type type) { + this.componentType = type; + setAsParentNodeOf(this.componentType); + return this; + } + + /** + * Takes lists of arrayBracketPairs, assumes the lists are ordered left to right and the pairs are ordered left to right, mirroring the actual code. + * The type gets wrapped in ArrayTypes so that the outermost ArrayType corresponds to the rightmost ArrayBracketPair. + */ + @SafeVarargs + public static Type wrapInArrayTypes(Type type, List<ArrayBracketPair>... arrayBracketPairLists) { + for (int i = arrayBracketPairLists.length - 1; i >= 0; i--) { + final List<ArrayBracketPair> arrayBracketPairList = arrayBracketPairLists[i]; + if (arrayBracketPairList != null) { + for (int j = arrayBracketPairList.size() - 1; j >= 0; j--) { + type = new ArrayType(type, arrayBracketPairList.get(j).getAnnotations()); + } + } + } + return type; + } + + /** + * Takes a type that may be an ArrayType. Unwraps ArrayTypes until the element type is found. + * + * @return a pair of the element type, and the unwrapped ArrayTypes, if any. + */ + public static Pair<Type, List<ArrayBracketPair>> unwrapArrayTypes(Type type) { + final List<ArrayBracketPair> arrayBracketPairs = new ArrayList<>(); + while (type instanceof ArrayType) { + ArrayType arrayType = (ArrayType) type; + arrayBracketPairs.add(new ArrayBracketPair(Range.UNKNOWN, arrayType.getAnnotations())); + type = arrayType.getComponentType(); + } + return new Pair<>(type, arrayBracketPairs); + } + + public static ArrayType arrayOf(Type type, AnnotationExpr... annotations) { + return new ArrayType(type, Arrays.asList(annotations)); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ClassOrInterfaceType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ClassOrInterfaceType.java new file mode 100644 index 000000000..ac308940d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ClassOrInterfaceType.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.nodeTypes.NodeWithTypeArguments; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceType extends ReferenceType<ClassOrInterfaceType> implements + NodeWithName<ClassOrInterfaceType>, + NodeWithAnnotations<ClassOrInterfaceType>, + NodeWithTypeArguments<ClassOrInterfaceType> { + + private ClassOrInterfaceType scope; + + private String name; + + private List<Type<?>> typeArguments; + + public ClassOrInterfaceType() { + } + + public ClassOrInterfaceType(final String name) { + setName(name); + } + + public ClassOrInterfaceType(final ClassOrInterfaceType scope, final String name) { + setScope(scope); + setName(name); + } + + public ClassOrInterfaceType(final Range range, final ClassOrInterfaceType scope, final String name, final List<Type<?>> typeArguments) { + super(range); + setScope(scope); + setName(name); + setTypeArguments(typeArguments); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public String getName() { + return name; + } + + public ClassOrInterfaceType getScope() { + return scope; + } + + 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)); + } + + @Override + public ClassOrInterfaceType setName(final String name) { + this.name = name; + return this; + } + + public ClassOrInterfaceType setScope(final ClassOrInterfaceType scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + return this; + } + + @Override + public List<Type<?>> getTypeArguments() { + return typeArguments; + } + + @Override + public ClassOrInterfaceType setTypeArguments(final List<Type<?>> types) { + this.typeArguments = types; + setAsParentNodeOf(this.typeArguments); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/IntersectionType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/IntersectionType.java new file mode 100644 index 000000000..029d46537 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/IntersectionType.java @@ -0,0 +1,60 @@ +package com.github.javaparser.ast.type; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * Represents a set of types. A given value of this type has to be assignable to at all of the element types. + * As of Java 8 it is used in casts or while expressing bounds for generic types. + * + * For example: + * public class A>T extends Serializable & Cloneable< { } + * + * Or: + * void foo((Serializable & Cloneable)myObject); + * + * @since 3.0.0 + */ +public class IntersectionType extends Type<IntersectionType> implements NodeWithAnnotations<IntersectionType> { + + private List<ReferenceType> elements; + + public IntersectionType(Range range, List<ReferenceType> elements) { + super(range); + setElements(elements); + } + + public IntersectionType(List<ReferenceType> elements) { + super(); + setElements(elements); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<ReferenceType> getElements() { + return elements; + } + + public IntersectionType setElements(List<ReferenceType> elements) { + if (this.elements != null) { + for (ReferenceType element : elements){ + element.setParentNode(null); + } + } + this.elements = elements; + setAsParentNodeOf(this.elements); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/PrimitiveType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/PrimitiveType.java new file mode 100644 index 000000000..29299a425 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/PrimitiveType.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +import java.util.HashMap; + +/** + * @author Julio Vilmar Gesser + */ +public final class PrimitiveType extends Type<PrimitiveType> implements NodeWithAnnotations<PrimitiveType> { + + 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 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); + } + + Primitive(String nameOfBoxedType) { + this.nameOfBoxedType = nameOfBoxedType; + } + } + + static final HashMap<String, Primitive> 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(Range range, final Primitive type) { + super(range); + setType(type); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Primitive getType() { + return type; + } + + public ClassOrInterfaceType toBoxedType() { + return type.toBoxedType(); + } + + public PrimitiveType setType(final Primitive type) { + this.type = type; + return this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ReferenceType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ReferenceType.java new file mode 100644 index 000000000..1a4666b4f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/ReferenceType.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class ReferenceType<T extends ReferenceType> extends Type<T> { + + public ReferenceType() { + } + + public ReferenceType(final Range range) { + super(range); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/Type.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/Type.java new file mode 100644 index 000000000..6c043557a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/Type.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.*; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Type<T extends Type> extends Node { + + private List<AnnotationExpr> annotations; + + public Type() { + } + + public Type(List<AnnotationExpr> annotation){ + this.annotations = annotation; + } + + public Type(Range range) { + super(range); + } + + public Type(Range range, List<AnnotationExpr> annotations) { + super(range); + setAnnotations(annotations); + } + + public List<AnnotationExpr> getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public T setAnnotations(List<AnnotationExpr> annotations) { + setAsParentNodeOf(annotations); + this.annotations = annotations; + return (T) this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/TypeParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/TypeParameter.java new file mode 100644 index 000000000..bfec9c936 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/TypeParameter.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +import static com.github.javaparser.utils.Utils.ensureNotNull; + +/** + * <p> + * This class represents the declaration of a generics argument. + * </p> + * The TypeParameter is constructed following the syntax:<br> + * <pre> + * {@code + * TypeParameter ::= <IDENTIFIER> ( "extends" }{@link ClassOrInterfaceType}{@code ( "&" }{@link ClassOrInterfaceType}{@code )* )? + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class TypeParameter extends ReferenceType<TypeParameter> implements NodeWithName<TypeParameter> { + + private String name; + + private List<AnnotationExpr> annotations; + + private List<ClassOrInterfaceType> typeBound; + + public TypeParameter() { + } + + public TypeParameter(final String name, final List<ClassOrInterfaceType> typeBound) { + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(Range range, final String name, final List<ClassOrInterfaceType> typeBound) { + super(range); + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(Range range, String name, List<ClassOrInterfaceType> typeBound, List<AnnotationExpr> annotations) { + this(range, name, typeBound); + setTypeBound(typeBound); + setAnnotations(annotations); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + /** + * Return the name of the paramenter. + * + * @return the name of the paramenter + */ + @Override + public String getName() { + return name; + } + + /** + * Return the list of {@link ClassOrInterfaceType} that this parameter + * extends. Return <code>null</code> null if there are no type. + * + * @return list of types that this paramente extends or <code>null</code> + */ + public List<ClassOrInterfaceType> getTypeBound() { + typeBound = ensureNotNull(typeBound); + return typeBound; + } + + /** + * Sets the name of this type parameter. + * + * @param name + * the name to set + */ + @Override + public TypeParameter setName(final String name) { + this.name = name; + return this; + } + + /** + * Sets the list o types. + * + * @param typeBound + * the typeBound to set + */ + public TypeParameter setTypeBound(final List<ClassOrInterfaceType> typeBound) { + this.typeBound = typeBound; + setAsParentNodeOf(typeBound); + return this; + } + + public List<AnnotationExpr> getAnnotations() { + annotations = ensureNotNull(annotations); + return annotations; + } + + public TypeParameter setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + return this; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/UnionType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/UnionType.java new file mode 100644 index 000000000..74894af0f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/UnionType.java @@ -0,0 +1,52 @@ +package com.github.javaparser.ast.type; + +import com.github.javaparser.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * Represents a set of types. A given value of this type has to be assignable to at least one of the element types. + * As of Java 8 it is only used in catch clauses. + */ +public class UnionType extends Type<UnionType> implements NodeWithAnnotations<UnionType> { + + private List<ReferenceType> elements; + + public UnionType(Range range, List<ReferenceType> elements) { + super(range); + setElements(elements); + } + + public UnionType(List<ReferenceType> elements) { + super(); + setElements(elements); + } + + public List<ReferenceType> getElements() { + return elements; + } + + public UnionType setElements(List<ReferenceType> elements) { + if (this.elements != null) { + for (ReferenceType element : elements){ + element.setParentNode(null); + } + } + this.elements = elements; + setAsParentNodeOf(this.elements); + return this; + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/UnknownType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/UnknownType.java new file mode 100644 index 000000000..b76c5962c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/UnknownType.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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; + +/** + * 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<UnknownType> { + + public UnknownType() { + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + @Override + public List<AnnotationExpr> getAnnotations() { + throw new IllegalStateException("Inferred lambda types cannot be annotated."); + } + + @Override + public UnknownType setAnnotations(List<AnnotationExpr> annotations) { + throw new IllegalStateException("Inferred lambda types cannot be annotated."); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/VoidType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/VoidType.java new file mode 100644 index 000000000..d5f7273cb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/VoidType.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VoidType extends Type<VoidType> implements NodeWithAnnotations<VoidType> { + + public static final VoidType VOID_TYPE = new VoidType(); + + public VoidType() { + } + + public VoidType(Range range) { + super(range); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/WildcardType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/WildcardType.java new file mode 100644 index 000000000..d1e49bc0b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/type/WildcardType.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Range; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class WildcardType extends Type<WildcardType> implements NodeWithAnnotations<WildcardType> { + + 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 Range range, + final ReferenceType ext, final ReferenceType sup) { + super(range); + setExtends(ext); + setSuper(sup); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public ReferenceType getExtends() { + return ext; + } + + public ReferenceType getSuper() { + return sup; + } + + public WildcardType setExtends(final ReferenceType ext) { + this.ext = ext; + setAsParentNodeOf(this.ext); + return this; + } + + public WildcardType setSuper(final ReferenceType sup) { + this.sup = sup; + setAsParentNodeOf(this.sup); + return this; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/CloneVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/CloneVisitor.java new file mode 100644 index 000000000..33ca0e02a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/CloneVisitor.java @@ -0,0 +1,1296 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.List; + +import com.github.javaparser.ast.*; +import com.github.javaparser.ast.type.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.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.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.*; + +public class CloneVisitor implements GenericVisitor<Node, Object> { + + @Override + public Node visit(CompilationUnit _n, Object _arg) { + PackageDeclaration package_ = cloneNodes(_n.getPackage(), _arg); + List<ImportDeclaration> imports = visit(_n.getImports(), _arg); + List<TypeDeclaration<?>> types = visit(_n.getTypes(), _arg); + + return new CompilationUnit( + _n.getRange(), + package_, imports, types + ); + } + + @Override + public Node visit(PackageDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + PackageDeclaration r = new PackageDeclaration( + _n.getRange(), + 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.getRange(), + name, _n.isStatic(), _n.isAsterisk() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TypeParameter _n, Object _arg) { + List<ClassOrInterfaceType> typeBound = visit(_n.getTypeBound(), _arg); + + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + TypeParameter r = new TypeParameter(_n.getRange(), + _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.getRange(), _n.getContent()); + } + + @Override + public Node visit(BlockComment _n, Object _arg) { + return new BlockComment(_n.getRange(), _n.getContent()); + } + + @Override + public Node visit(ClassOrInterfaceDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + List<ClassOrInterfaceType> extendsList = visit(_n.getExtends(), _arg); + List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg); + List<BodyDeclaration<?>> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassOrInterfaceDeclaration r = new ClassOrInterfaceDeclaration( + _n.getRange(), + _n.getModifiers(), annotations, _n.isInterface(), _n.getName(), typeParameters, extendsList, implementsList, members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnumDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg); + List<EnumConstantDeclaration> entries = visit(_n.getEntries(), _arg); + List<BodyDeclaration<?>> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnumDeclaration r = new EnumDeclaration( + _n.getRange(), + _n.getModifiers(), annotations, _n.getName(), implementsList, entries, members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyTypeDeclaration _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyTypeDeclaration r = new EmptyTypeDeclaration( + _n.getRange() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnumConstantDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + List<BodyDeclaration<?>> classBody = visit(_n.getClassBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnumConstantDeclaration r = new EnumConstantDeclaration( + _n.getRange(), + annotations, _n.getName(), args, classBody + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AnnotationDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<BodyDeclaration<?>> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AnnotationDeclaration r = new AnnotationDeclaration( + _n.getRange(), + _n.getModifiers(), annotations, _n.getName(), members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AnnotationMemberDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type<?> type_ = cloneNodes(_n.getType(), _arg); + Expression defaultValue = cloneNodes(_n.getDefaultValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AnnotationMemberDeclaration r = new AnnotationMemberDeclaration( + _n.getRange(), + _n.getModifiers(), annotations, type_, _n.getName(), defaultValue + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(FieldDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations_ = visit(_n.getAnnotations(), _arg); + Type<?> elementType_ = cloneNodes(_n.getElementType(), _arg); + List<VariableDeclarator> variables_ = visit(_n.getVariables(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + List<ArrayBracketPair> arrayBracketPairsAfterType_ = visit(_n.getArrayBracketPairsAfterElementType(), _arg); + + FieldDeclaration r = new FieldDeclaration( + _n.getRange(), + _n.getModifiers(), + annotations_, + elementType_, + variables_, + arrayBracketPairsAfterType_ + + ); + 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.getRange(), + id, init + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclaratorId _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + List<ArrayBracketPair> arrayBracketPairsAfterId_ = visit(_n.getArrayBracketPairsAfterId(), _arg); + + VariableDeclaratorId r = new VariableDeclaratorId( + _n.getRange(), + _n.getName(), + arrayBracketPairsAfterId_ + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ConstructorDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + List<Parameter> parameters = visit(_n.getParameters(), _arg); + List<ReferenceType> throws_ = visit(_n.getThrows(), _arg); + BlockStmt block = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ConstructorDeclaration r = new ConstructorDeclaration( + _n.getRange(), + _n.getModifiers(), annotations, typeParameters, _n.getName(), parameters, throws_, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MethodDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations_ = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters_ = visit(_n.getTypeParameters(), _arg); + Type<?> type_ = cloneNodes(_n.getElementType(), _arg); + NameExpr nameExpr_ = cloneNodes(_n.getNameExpr(), _arg); + List<Parameter> parameters_ = visit(_n.getParameters(), _arg); + List<ReferenceType> throws_ = visit(_n.getThrows(), _arg); + BlockStmt block_ = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + List<ArrayBracketPair> arrayBracketPairsAfterElementType_ = visit(_n.getArrayBracketPairsAfterElementType(), _arg); + List<ArrayBracketPair> arrayBracketPairsAfterParameterList_ = visit(_n.getArrayBracketPairsAfterParameterList(), _arg); + + MethodDeclaration r = new MethodDeclaration( + _n.getRange(), + _n.getModifiers(), + annotations_, + typeParameters_, + type_, + arrayBracketPairsAfterElementType_, + nameExpr_, + parameters_, + arrayBracketPairsAfterParameterList_, + throws_, + block_ + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(Parameter _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type<?> type_ = cloneNodes(_n.getElementType(), _arg); + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + List<ArrayBracketPair> arrayBracketPairsAfterType_ = visit(_n.getArrayBracketPairsAfterElementType(), _arg); + + Parameter r = new Parameter( + _n.getRange(), + _n.getModifiers(), + annotations, + type_, + arrayBracketPairsAfterType_, + _n.isVarArgs(), + id + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyMemberDeclaration _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyMemberDeclaration r = new EmptyMemberDeclaration( + _n.getRange() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(InitializerDeclaration _n, Object _arg) { + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + InitializerDeclaration r = new InitializerDeclaration( + _n.getRange(), + _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.getRange(), + _n.getContent() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ClassOrInterfaceType _n, Object _arg) { + ClassOrInterfaceType scope = cloneNodes(_n.getScope(), _arg); + List<Type<?>> typeArguments_ = visit(_n.getTypeArguments(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassOrInterfaceType r = new ClassOrInterfaceType( + _n.getRange(), + scope, + _n.getName(), + _n.getTypeArguments() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(PrimitiveType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + + PrimitiveType r = new PrimitiveType( + _n.getRange(), + _n.getType() + ); + r.setComment(comment); + r.setAnnotations(annotations); + return r; + } + + @Override + public Node visit(ArrayType _n, Object _arg) { + List<AnnotationExpr> ann = visit(_n.getAnnotations(), _arg); + Type<?> type_ = cloneNodes(_n.getComponentType(), _arg); + + ArrayType r = new ArrayType(_n.getRange(), type_, ann); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayCreationLevel _n, Object _arg) { + List<AnnotationExpr> ann = visit(_n.getAnnotations(), _arg); + Expression dimension_ = cloneNodes(_n.getDimension(), _arg); + + ArrayCreationLevel r = new ArrayCreationLevel(_n.getRange(), dimension_, ann); + + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IntersectionType _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<ReferenceType> elements = visit(_n.getElements(), _arg); + + IntersectionType r = new IntersectionType(_n.getRange(), elements); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + r.setAnnotations(annotations); + return r; + } + + @Override + public Node visit(UnionType _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<ReferenceType> elements = visit(_n.getElements(), _arg); + + UnionType r = new UnionType(_n.getRange(), + elements); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + r.setAnnotations(annotations); + return r; + } + + @Override + public Node visit(VoidType _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + VoidType r = new VoidType(_n.getRange()); + r.setAnnotations(annotations); + r.setComment(comment); + return r; + } + + @Override + public Node visit(WildcardType _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + ReferenceType ext = cloneNodes(_n.getExtends(), _arg); + ReferenceType sup = cloneNodes(_n.getSuper(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + WildcardType r = new WildcardType( + _n.getRange(), + ext, sup + ); + r.setComment(comment); + r.setAnnotations(annotations); + 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.getRange(), + name, index + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayCreationExpr _n, Object _arg) { + Type<?> type_ = cloneNodes(_n.getType(), _arg); + List<ArrayCreationLevel> levels_ = visit(_n.getLevels(), _arg); + ArrayInitializerExpr initializer_ = cloneNodes(_n.getInitializer(), _arg); + + ArrayCreationExpr r = new ArrayCreationExpr(_n.getRange(), type_, levels_, initializer_); + + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayInitializerExpr _n, Object _arg) { + List<Expression> values = visit(_n.getValues(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ArrayInitializerExpr r = new ArrayInitializerExpr( + _n.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + inner + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(FieldAccessExpr _n, Object _arg) { + Expression scope_ = cloneNodes(_n.getScope(), _arg); + List<Type<?>> typeArguments_ = visit(_n.getTypeArguments(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + FieldAccessExpr r = new FieldAccessExpr( + _n.getRange(), + scope_, + typeArguments_, + _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.getRange(), + 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.getRange(), + _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.getRange(), + _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.getRange(), + _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.getRange()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LongLiteralMinValueExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + LongLiteralMinValueExpr r = new LongLiteralMinValueExpr(_n.getRange()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CharLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + CharLiteralExpr r = new CharLiteralExpr( + _n.getRange(), + _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.getRange(), + _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.getRange(), + _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.getRange()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MethodCallExpr _n, Object _arg) { + Expression scope_ = cloneNodes(_n.getScope(), _arg); + List<Type<?>> typeArguments_ = visit(_n.getTypeArguments(), _arg); + List<Expression> args_ = visit(_n.getArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MethodCallExpr r = new MethodCallExpr( + _n.getRange(), + scope_, + typeArguments_, + _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.getRange(), + _n.getName() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ObjectCreationExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + ClassOrInterfaceType type_ = cloneNodes(_n.getType(), _arg); + List<Type<?>> typeArgs = visit(_n.getTypeArguments(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + List<BodyDeclaration<?>> anonymousBody = visit(_n.getAnonymousClassBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ObjectCreationExpr r = new ObjectCreationExpr( + _n.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + expr, _n.getOperator() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclarationExpr _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type<?> type_ = cloneNodes(_n.getElementType(), _arg); + List<VariableDeclarator> vars = visit(_n.getVariables(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + List<ArrayBracketPair> arrayBracketPairsAfterType_ = visit(_n.getArrayBracketPairsAfterElementType(), _arg); + + VariableDeclarationExpr r = new VariableDeclarationExpr( + _n.getRange(), + _n.getModifiers(), + annotations, + type_, + vars, + arrayBracketPairsAfterType_ + ); + 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.getRange(), + 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.getRange(), + name, memberValue + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NormalAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + List<MemberValuePair> pairs = visit(_n.getPairs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + NormalAnnotationExpr r = new NormalAnnotationExpr( + _n.getRange(), + 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.getRange(), + _n.getName(), value + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ExplicitConstructorInvocationStmt _n, Object _arg) { + List<Type<?>> typeArguments_ = visit(_n.getTypeArguments(), _arg); + Expression expr_ = cloneNodes(_n.getExpr(), _arg); + List<Expression> args_ = visit(_n.getArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ExplicitConstructorInvocationStmt r = new ExplicitConstructorInvocationStmt( + _n.getRange(), + typeArguments_, + _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.getRange(), + 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.getRange(), + check, message + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BlockStmt _n, Object _arg) { + List<Statement> stmts = visit(_n.getStmts(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + BlockStmt r = new BlockStmt( + _n.getRange(), + 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.getRange(), + _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.getRange()); + 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.getRange(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SwitchStmt _n, Object _arg) { + Expression selector = cloneNodes(_n.getSelector(), _arg); + List<SwitchEntryStmt> entries = visit(_n.getEntries(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SwitchStmt r = new SwitchStmt( + _n.getRange(), + selector, entries + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SwitchEntryStmt _n, Object _arg) { + Expression label = cloneNodes(_n.getLabel(), _arg); + List<Statement> stmts = visit(_n.getStmts(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SwitchEntryStmt r = new SwitchEntryStmt( + _n.getRange(), + 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.getRange(), + _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.getRange(), + 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.getRange(), + 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.getRange(), + 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.getRange(), + _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.getRange(), + 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.getRange(), + var, iterable, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ForStmt _n, Object _arg) { + List<Expression> init = visit(_n.getInit(), _arg); + Expression compare = cloneNodes(_n.getCompare(), _arg); + List<Expression> update = visit(_n.getUpdate(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ForStmt r = new ForStmt( + _n.getRange(), + 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.getRange(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SynchronizedStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + BlockStmt block = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SynchronizedStmt r = new SynchronizedStmt( + _n.getRange(), + expr, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TryStmt _n, Object _arg) { + List<VariableDeclarationExpr> resources = visit(_n.getResources(),_arg); + BlockStmt tryBlock = cloneNodes(_n.getTryBlock(), _arg); + List<CatchClause> catchs = visit(_n.getCatchs(), _arg); + BlockStmt finallyBlock = cloneNodes(_n.getFinallyBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + TryStmt r = new TryStmt( + _n.getRange(), + resources, tryBlock, catchs, finallyBlock + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CatchClause _n, Object _arg) { + Parameter param = cloneNodes(_n.getParam(), _arg); + BlockStmt catchBlock = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + CatchClause r = new CatchClause( + _n.getRange(), + param.getModifiers(), param.getAnnotations(), param.getElementType(), param.getId(), catchBlock + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LambdaExpr _n, Object _arg) { + + List<Parameter> lambdaParameters = visit(_n.getParameters(), _arg); + + Statement body = cloneNodes(_n.getBody(), _arg); + + return new LambdaExpr(_n.getRange(), lambdaParameters, body, + _n.isParametersEnclosed()); + } + + @Override + public Node visit(MethodReferenceExpr _n, Object arg) { + + Expression scope = cloneNodes(_n.getScope(), arg); + + return new MethodReferenceExpr(_n.getRange(), scope, + _n.getTypeArguments(), _n.getIdentifier()); + } + + @Override + public Node visit(TypeExpr n, Object arg) { + + Type<?> t = cloneNodes(n.getType(), arg); + + return new TypeExpr(n.getRange(), t); + } + + @Override + public Node visit(ArrayBracketPair _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + + return new ArrayBracketPair(_n.getRange(), annotations); + } + + public <T extends Node> List<T> visit(List<T> _nodes, Object _arg) { + if (_nodes == null) + return null; + List<T> r = new ArrayList<>(_nodes.size()); + for (T n : _nodes) { + T rN = cloneNodes(n, _arg); + if (rN != null) + r.add(rN); + } + return r; + } + + @SuppressWarnings("unchecked") + protected <T extends Node> T cloneNodes(T _node, Object _arg) { + if (_node == null) + return null; + Node r = _node.accept(this, _arg); + if (r == null) + return null; + return (T) r; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/DumpVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/DumpVisitor.java new file mode 100644 index 000000000..569f39516 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/DumpVisitor.java @@ -0,0 +1,1644 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.*; +import com.github.javaparser.ast.body.*; +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.nodeTypes.NodeWithTypeArguments; +import com.github.javaparser.ast.stmt.*; +import com.github.javaparser.ast.type.*; + +import java.util.EnumSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +import static com.github.javaparser.utils.PositionUtils.sortByBeginPosition; +import static com.github.javaparser.utils.Utils.EOL; +import static com.github.javaparser.utils.Utils.isNullOrEmpty; + +/** + * Dumps the AST to formatted Java source code. + * + * @author Julio Vilmar Gesser + */ +public class DumpVisitor implements VoidVisitor<Object> { + + private boolean printComments; + + public DumpVisitor() { + this(true); + } + + public DumpVisitor(boolean printComments) { + this.printComments = printComments; + } + + public static class SourcePrinter { + + private final String indentation; + + public 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(EOL); + 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 EnumSet<Modifier> modifiers) { + if (modifiers.size() > 0) + printer.print(modifiers.stream().map(Modifier::getLib).collect(Collectors.joining(" ")) + " "); + } + + private void printMembers(final List<BodyDeclaration<?>> members, final Object arg) { + for (final BodyDeclaration<?> member : members) { + printer.printLn(); + member.accept(this, arg); + printer.printLn(); + } + } + + private void printMemberAnnotations(final List<AnnotationExpr> annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.printLn(); + } + } + } + + private void printAnnotations(final List<AnnotationExpr> annotations, boolean prefixWithASpace, final Object arg) { + if (!isNullOrEmpty(annotations)) { + if(prefixWithASpace){ + printer.print(" "); + } + for (AnnotationExpr annotation : annotations) { + annotation.accept(this, arg); + printer.print(" "); + } + } + } + + private void printTypeArgs(final NodeWithTypeArguments<?> nodeWithTypeArguments, final Object arg) { + List<Type<?>> typeArguments = nodeWithTypeArguments.getTypeArguments(); + if (!isNullOrEmpty(typeArguments)) { + printer.print("<"); + for (final Iterator<Type<?>> i = typeArguments.iterator(); i.hasNext(); ) { + final Type<?> t = i.next(); + t.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + } + + private void printTypeParameters(final List<TypeParameter> args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator<TypeParameter> i = args.iterator(); i.hasNext(); ) { + final TypeParameter t = i.next(); + t.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + } + + private void printArguments(final List<Expression> args, final Object arg) { + printer.print("("); + if (!isNullOrEmpty(args)) { + for (final Iterator<Expression> i = args.iterator(); i.hasNext(); ) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + } + + private void 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<TypeDeclaration<?>> i = n.getTypes().iterator(); i.hasNext(); ) { + i.next().accept(this, arg); + printer.printLn(); + if (i.hasNext()) { + printer.printLn(); + } + } + } + + printOrphanCommentsEnding(n); + } + + @Override + public void visit(final PackageDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), false, 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); + if (!n.isEmptyImportDeclaration()) { + 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); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + if (n.isInterface()) { + printer.print("interface "); + } else { + printer.print("class "); + } + + printer.print(n.getName()); + + printTypeParameters(n.getTypeParameters(), arg); + + if (!isNullOrEmpty(n.getExtends())) { + printer.print(" extends "); + for (final Iterator<ClassOrInterfaceType> i = n.getExtends().iterator(); i.hasNext(); ) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + if (!isNullOrEmpty(n.getImplements())) { + printer.print(" implements "); + for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + printer.printLn(" {"); + printer.indent(); + if (!isNullOrEmpty(n.getMembers())) { + printMembers(n.getMembers(), arg); + } + + printOrphanCommentsEnding(n); + + printer.unindent(); + printer.print("}"); + } + + @Override + public void visit(final EmptyTypeDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + 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.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + + printer.print(n.getName()); + + if (n.isUsingDiamondOperator()) { + printer.print("<>"); + } else { + printTypeArgs(n, arg); + } + } + + @Override + public void visit(final TypeParameter n, final Object arg) { + printJavaComment(n.getComment(), arg); + 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<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext(); ) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(" & "); + } + } + } + } + + @Override + public void visit(final PrimitiveType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), true, arg); + 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 ArrayType n, final Object arg) { + final List<ArrayType> arrayTypeBuffer = new LinkedList<>(); + Type type = n; + while (type instanceof ArrayType) { + final ArrayType arrayType = (ArrayType) type; + arrayTypeBuffer.add(arrayType); + type = arrayType.getComponentType(); + } + + type.accept(this, arg); + for (ArrayType arrayType : arrayTypeBuffer) { + printAnnotations(arrayType.getAnnotations(), true, arg); + printer.print("[]"); + } + } + + @Override + public void visit(final ArrayCreationLevel n, final Object arg) { + printAnnotations(n.getAnnotations(), true, arg); + printer.print("["); + if (n.getDimension() != null) { + n.getDimension().accept(this, arg); + } + printer.print("]"); + } + + @Override + public void visit(final IntersectionType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), false, arg); + boolean isFirst = true; + for (ReferenceType element : n.getElements()) { + element.accept(this, arg); + if (isFirst) { + isFirst = false; + } else { + printer.print(" & "); + } + } + } + + @Override public void visit(final UnionType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), true, arg); + boolean isFirst = true; + for (ReferenceType element : n.getElements()) { + if (isFirst) { + isFirst = false; + } else { + printer.print(" | "); + } + element.accept(this, arg); + } + } + + + @Override + public void visit(final WildcardType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), false, 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); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + n.getElementType().accept(this, arg); + for(ArrayBracketPair pair: n.getArrayBracketPairsAfterElementType()){ + pair.accept(this, arg); + } + + printer.print(" "); + for (final Iterator<VariableDeclarator> i = n.getVariables().iterator(); i.hasNext(); ) { + final VariableDeclarator var = i.next(); + var.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + + printer.print(";"); + } + + @Override + public void visit(final VariableDeclarator n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getId().accept(this, arg); + if (n.getInit() != null) { + printer.print(" = "); + n.getInit().accept(this, arg); + } + } + + @Override + public void visit(final VariableDeclaratorId n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + for(ArrayBracketPair pair: n.getArrayBracketPairsAfterId()){ + pair.accept(this, arg); + } + } + + @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<Expression> i = n.getValues().iterator(); i.hasNext(); ) { + final Expression expr = i.next(); + expr.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(" "); + } + printer.print("}"); + } + + @Override + public void visit(final VoidType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), false, 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); + for (ArrayCreationLevel level : n.getLevels()) { + level.accept(this, arg); + } + if (n.getInitializer() != null) { + 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, 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, arg); + if (!isNullOrEmpty(n.getTypeArguments())) { + 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); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printTypeParameters(n.getTypeParameters(), arg); + if (!n.getTypeParameters().isEmpty()) { + printer.print(" "); + } + printer.print(n.getName()); + + printer.print("("); + if (!n.getParameters().isEmpty()) { + for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext(); ) { + final Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + + if (!isNullOrEmpty(n.getThrows())) { + printer.print(" throws "); + for (final Iterator<ReferenceType> i = n.getThrows().iterator(); i.hasNext(); ) { + final ReferenceType name = i.next(); + name.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(" "); + n.getBody().accept(this, arg); + } + + @Override + public void visit(final MethodDeclaration n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + + printJavaComment(n.getComment(), 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.getElementType().accept(this, arg); + for(ArrayBracketPair pair: n.getArrayBracketPairsAfterElementType()){ + pair.accept(this, arg); + } + printer.print(" "); + printer.print(n.getName()); + + printer.print("("); + if (!isNullOrEmpty(n.getParameters())) { + for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext(); ) { + final Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + + for(ArrayBracketPair pair: n.getArrayBracketPairsAfterParameterList()){ + pair.accept(this, arg); + } + + if (!isNullOrEmpty(n.getThrows())) { + printer.print(" throws "); + for (final Iterator<ReferenceType> i = n.getThrows().iterator(); i.hasNext(); ) { + final ReferenceType 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(), false, arg); + printModifiers(n.getModifiers()); + if (n.getElementType() != null) { + n.getElementType().accept(this, arg); + } + for(ArrayBracketPair pair: n.getArrayBracketPairsAfterElementType()){ + pair.accept(this, arg); + } + if (n.isVarArgs()) { + printer.print("..."); + } + 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, arg); + printer.print("this"); + } else { + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + printer.print("."); + } + printTypeArgs(n, 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(), false, arg); + printModifiers(n.getModifiers()); + + n.getElementType().accept(this, arg); + for(ArrayBracketPair pair: n.getArrayBracketPairsAfterElementType()){ + pair.accept(this, arg); + } + printer.print(" "); + + for (final Iterator<VariableDeclarator> i = n.getVariables().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); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printer.print("enum "); + printer.print(n.getName()); + + if (!n.getImplements().isEmpty()) { + printer.print(" implements "); + for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + printer.printLn(" {"); + printer.indent(); + if (n.getEntries() != null) { + printer.printLn(); + for (final Iterator<EnumConstantDeclaration> i = n.getEntries().iterator(); i.hasNext(); ) { + final EnumConstantDeclaration e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (!n.getMembers().isEmpty()) { + printer.printLn(";"); + printMembers(n.getMembers(), arg); + } else { + if (!n.getEntries().isEmpty()) { + printer.printLn(); + } + } + printer.unindent(); + printer.print("}"); + } + + @Override + public void visit(final EnumConstantDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printer.print(n.getName()); + + if (!n.getArgs().isEmpty()) { + printArguments(n.getArgs(), arg); + } + + if (!n.getClassBody().isEmpty()) { + 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); + printer.print(";"); + } + + @Override + public void visit(final InitializerDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.isStatic()) { + printer.print("static "); + } + n.getBlock().accept(this, arg); + } + + @Override + public void visit(final IfStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("if ("); + n.getCondition().accept(this, arg); + final boolean thenBlock = n.getThenStmt() instanceof BlockStmt; + if (thenBlock) // block statement should start on the same line + printer.print(") "); + else { + printer.printLn(")"); + printer.indent(); + } + n.getThenStmt().accept(this, arg); + if (!thenBlock) + printer.unindent(); + if (n.getElseStmt() != null) { + if (thenBlock) + printer.print(" "); + else + printer.printLn(); + final boolean elseIf = n.getElseStmt() instanceof IfStmt; + final boolean elseBlock = n.getElseStmt() instanceof BlockStmt; + if (elseIf || elseBlock) // put chained if and start of block statement on a same level + printer.print("else "); + else { + printer.printLn("else"); + printer.indent(); + } + n.getElseStmt().accept(this, arg); + if (!(elseIf || elseBlock)) + printer.unindent(); + } + } + + @Override + public void visit(final WhileStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("while ("); + n.getCondition().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override + public void visit(final ContinueStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("continue"); + if (n.getId() != null) { + printer.print(" "); + printer.print(n.getId()); + } + printer.print(";"); + } + + @Override + public void visit(final DoStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("do "); + n.getBody().accept(this, arg); + printer.print(" while ("); + n.getCondition().accept(this, arg); + printer.print(");"); + } + + @Override + public void visit(final ForeachStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("for ("); + n.getVariable().accept(this, arg); + printer.print(" : "); + n.getIterable().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override + public void visit(final ForStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("for ("); + if (n.getInit() != null) { + for (final Iterator<Expression> i = n.getInit().iterator(); i.hasNext(); ) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print("; "); + if (n.getCompare() != null) { + n.getCompare().accept(this, arg); + } + printer.print("; "); + if (n.getUpdate() != null) { + for (final Iterator<Expression> i = n.getUpdate().iterator(); i.hasNext(); ) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override + public void visit(final ThrowStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("throw "); + n.getExpr().accept(this, arg); + printer.print(";"); + } + + @Override + public void visit(final SynchronizedStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("synchronized ("); + n.getExpr().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override + public void visit(final TryStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("try "); + if (!n.getResources().isEmpty()) { + printer.print("("); + Iterator<VariableDeclarationExpr> resources = n.getResources().iterator(); + boolean first = true; + while (resources.hasNext()) { + visit(resources.next(), arg); + if (resources.hasNext()) { + printer.print(";"); + printer.printLn(); + if (first) { + printer.indent(); + } + } + first = false; + } + if (n.getResources().size() > 1) { + printer.unindent(); + } + printer.print(") "); + } + n.getTryBlock().accept(this, arg); + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + c.accept(this, arg); + } + } + if (n.getFinallyBlock() != null) { + printer.print(" finally "); + n.getFinallyBlock().accept(this, arg); + } + } + + @Override + public void visit(final CatchClause n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(" catch ("); + n.getParam().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + + } + + @Override + public void visit(final AnnotationDeclaration n, final Object arg) { + printJavaComment(n.getComment(), 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); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + n.getType().accept(this, arg); + printer.print(" "); + printer.print(n.getName()); + printer.print("()"); + if (n.getDefaultValue() != null) { + printer.print(" default "); + n.getDefaultValue().accept(this, arg); + } + printer.print(";"); + } + + @Override + public void visit(final MarkerAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + } + + @Override + public void visit(final SingleMemberAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + printer.print("("); + n.getMemberValue().accept(this, arg); + printer.print(")"); + } + + @Override + public void visit(final NormalAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + printer.print("("); + if (n.getPairs() != null) { + for (final Iterator<MemberValuePair> i = n.getPairs().iterator(); i.hasNext(); ) { + final MemberValuePair m = i.next(); + m.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + } + + @Override + public void visit(final MemberValuePair n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + printer.print(" = "); + n.getValue().accept(this, arg); + } + + @Override + public void visit(final LineComment n, final Object arg) { + if (!this.printComments) { + return; + } + printer.print("//"); + String tmp = n.getContent(); + tmp = tmp.replace('\r', ' '); + tmp = tmp.replace('\n', ' '); + printer.printLn(tmp); + } + + @Override + public void visit(final BlockComment n, final Object arg) { + if (!this.printComments) { + return; + } + printer.print("/*"); + printer.print(n.getContent()); + printer.printLn("*/"); + } + + @Override + public void visit(LambdaExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + + final List<Parameter> parameters = n.getParameters(); + final boolean printPar = n.isParametersEnclosed(); + + if (printPar) { + printer.print("("); + } + if (parameters != null) { + for (Iterator<Parameter> i = parameters.iterator(); i.hasNext(); ) { + Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (printPar) { + printer.print(")"); + } + + printer.print(" -> "); + final 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("::"); + printTypeArgs(n, arg); + 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); + } + } + + @Override + public void visit(ArrayBracketPair arrayBracketPair, Object arg) { + printAnnotations(arrayBracketPair.getAnnotations(), true, arg); + printer.print("[]"); + } + + private void printOrphanCommentsBeforeThisChildNode(final Node node) { + if (node instanceof Comment) return; + + Node parent = node.getParentNode(); + if (parent == null) return; + List<Node> everything = new LinkedList<>(); + everything.addAll(parent.getChildrenNodes()); + sortByBeginPosition(everything); + int positionOfTheChild = -1; + for (int i = 0; i < everything.size(); i++) { + if (everything.get(i) == node) positionOfTheChild = i; + } + if (positionOfTheChild == -1) throw new RuntimeException("My index not found!!! " + node); + int positionOfPreviousChild = -1; + for (int i = positionOfTheChild - 1; i >= 0 && positionOfPreviousChild == -1; i--) { + if (!(everything.get(i) instanceof Comment)) positionOfPreviousChild = i; + } + for (int i = positionOfPreviousChild + 1; i < positionOfTheChild; i++) { + Node nodeToPrint = everything.get(i); + if (!(nodeToPrint instanceof Comment)) + throw new RuntimeException("Expected comment, instead " + nodeToPrint.getClass() + ". Position of previous child: " + positionOfPreviousChild + ", position of child " + positionOfTheChild); + nodeToPrint.accept(this, null); + } + } + + + private void printOrphanCommentsEnding(final Node node) { + List<Node> everything = new LinkedList<>(); + everything.addAll(node.getChildrenNodes()); + sortByBeginPosition(everything); + if (everything.isEmpty()) { + return; + } + + int commentsAtEnd = 0; + boolean findingComments = true; + while (findingComments && commentsAtEnd < everything.size()) { + Node last = everything.get(everything.size() - 1 - commentsAtEnd); + findingComments = (last instanceof Comment); + if (findingComments) { + commentsAtEnd++; + } + } + for (int i = 0; i < commentsAtEnd; i++) { + everything.get(everything.size() - commentsAtEnd + i).accept(this, null); + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/EqualsVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/EqualsVisitor.java new file mode 100644 index 000000000..e10184ce9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/EqualsVisitor.java @@ -0,0 +1,1514 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.List; + +import com.github.javaparser.ast.*; +import com.github.javaparser.ast.type.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.body.MethodDeclaration; +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.comments.BlockComment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.comments.LineComment; +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.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.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 class EqualsVisitor implements GenericVisitor<Boolean, Node> { + + private static final EqualsVisitor SINGLETON = new EqualsVisitor(); + + public static boolean equals(final Node n1, final Node n2) { + return SINGLETON.nodeEquals(n1, n2); + } + + private EqualsVisitor() { + // hide constructor + } + + /** + * Check for equality that can be applied to each kind of node, + * to not repeat it in every method we store that here. + */ + private boolean commonNodeEquality(Node n1, Node n2) { + if (!nodeEquals(n1.getComment(), n2.getComment())) { + return false; + } + return nodesEquals(n1.getOrphanComments(), n2.getOrphanComments()); + } + + private <T extends Node> boolean nodesEquals(final List<T> nodes1, final List<T> nodes2) { + if (nodes1 == null) { + return nodes2 == null; + } else if (nodes2 == null) { + return false; + } + if (nodes1.size() != nodes2.size()) { + return false; + } + for (int i = 0; i < nodes1.size(); i++) { + if (!nodeEquals(nodes1.get(i), nodes2.get(i))) { + return false; + } + } + return true; + } + + private <T extends Node> boolean nodeEquals(final T n1, final T n2) { + if (n1 == n2) { + return true; + } + if (n1 == null || n2 == null) { + return false; + } + if (n1.getClass() != n2.getClass()) { + return false; + } + if (!commonNodeEquality(n1, n2)){ + return false; + } + return n1.accept(this, n2); + } + + private boolean objEquals(final Object n1, final Object n2) { + if (n1 == n2) { + return true; + } + if (n1 == null || 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 false; + } + + if (!nodesEquals(n1.getImports(), n2.getImports())) { + return false; + } + + if (!nodesEquals(n1.getTypes(), n2.getTypes())) { + return false; + } + + if (!nodesEquals(n1.getComments(), n2.getComments())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final PackageDeclaration n1, final Node arg) { + final PackageDeclaration n2 = (PackageDeclaration) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ImportDeclaration n1, final Node arg) { + final ImportDeclaration n2 = (ImportDeclaration) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final TypeParameter n1, final Node arg) { + final TypeParameter n2 = (TypeParameter) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getTypeBound(), n2.getTypeBound())) { + return false; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + return true; + } + + @Override public Boolean visit(final LineComment n1, final Node arg) { + final LineComment n2 = (LineComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return false; + } + + if (!objEquals(n1.getBegin().line, n2.getBegin().line)) { + return false; + } + + return true; + } + + @Override public Boolean visit(final BlockComment n1, final Node arg) { + final BlockComment n2 = (BlockComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return false; + } + + if (!objEquals(n1.getBegin().line, n2.getBegin().line)) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ClassOrInterfaceDeclaration n1, final Node arg) { + final ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (n1.isInterface() != n2.isInterface()) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return false; + } + + if (!nodesEquals(n1.getExtends(), n2.getExtends())) { + return false; + } + + if (!nodesEquals(n1.getImplements(), n2.getImplements())) { + return false; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final EnumDeclaration n1, final Node arg) { + final EnumDeclaration n2 = (EnumDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodesEquals(n1.getImplements(), n2.getImplements())) { + return false; + } + + if (!nodesEquals(n1.getEntries(), n2.getEntries())) { + return false; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final EmptyTypeDeclaration n1, final Node arg) { + return 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 false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return false; + } + + if (!nodesEquals(n1.getClassBody(), n2.getClassBody())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final AnnotationDeclaration n1, final Node arg) { + final AnnotationDeclaration n2 = (AnnotationDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final AnnotationMemberDeclaration n1, final Node arg) { + final AnnotationMemberDeclaration n2 = (AnnotationMemberDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodeEquals(n1.getDefaultValue(), n2.getDefaultValue())) { + return false; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final FieldDeclaration n1, final Node arg) { + final FieldDeclaration n2 = (FieldDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodeEquals(n1.getElementType(), n2.getElementType())) { + return false; + } + + if (!nodesEquals(n1.getVariables(), n2.getVariables())) { + return false; + } + + if(!nodesEquals(n1.getArrayBracketPairsAfterElementType(), n2.getArrayBracketPairsAfterElementType())){ + return false; + } + + return true; + } + + @Override public Boolean visit(final VariableDeclarator n1, final Node arg) { + final VariableDeclarator n2 = (VariableDeclarator) arg; + + if (!nodeEquals(n1.getId(), n2.getId())) { + return false; + } + + if (!nodeEquals(n1.getInit(), n2.getInit())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final VariableDeclaratorId n1, final Node arg) { + final VariableDeclaratorId n2 = (VariableDeclaratorId) arg; + + if(!nodesEquals(n1.getArrayBracketPairsAfterId(), n2.getArrayBracketPairsAfterId())){ + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ConstructorDeclaration n1, final Node arg) { + final ConstructorDeclaration n2 = (ConstructorDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return false; + } + + if (!nodesEquals(n1.getThrows(), n2.getThrows())) { + return false; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final MethodDeclaration n1, final Node arg) { + final MethodDeclaration n2 = (MethodDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if(!nodesEquals(n1.getArrayBracketPairsAfterElementType(), n2.getArrayBracketPairsAfterElementType())){ + return false; + } + + if(!nodesEquals(n1.getArrayBracketPairsAfterParameterList(), n2.getArrayBracketPairsAfterParameterList())){ + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodeEquals(n1.getElementType(), n2.getElementType())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return false; + } + + if (!nodesEquals(n1.getThrows(), n2.getThrows())) { + return false; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return false; + } + if(n1.isDefault() != n2.isDefault()){ + return false; + } + return true; + } + + @Override public Boolean visit(final Parameter n1, final Node arg) { + final Parameter n2 = (Parameter) arg; + if (!nodeEquals(n1.getElementType(), n2.getElementType())) { + return false; + } + + if(!nodesEquals(n1.getArrayBracketPairsAfterElementType(), n2.getArrayBracketPairsAfterElementType())){ + return false; + } + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!nodeEquals(n1.getId(), n2.getId())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final EmptyMemberDeclaration n1, final Node arg) { + return true; + } + + @Override public Boolean visit(final InitializerDeclaration n1, final Node arg) { + final InitializerDeclaration n2 = (InitializerDeclaration) arg; + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final JavadocComment n1, final Node arg) { + final JavadocComment n2 = (JavadocComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ClassOrInterfaceType n1, final Node arg) { + final ClassOrInterfaceType n2 = (ClassOrInterfaceType) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return false; + } + + if (!nodesEquals(n1.getTypeArguments(), n2.getTypeArguments())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final PrimitiveType n1, final Node arg) { + final PrimitiveType n2 = (PrimitiveType) arg; + + if (n1.getType() != n2.getType()) { + return false; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + return true; + } + + @Override + public Boolean visit(ArrayType n1, Node arg) { + final ArrayType n2 = (ArrayType) arg; + + if (!nodeEquals(n1.getComponentType(), n2.getComponentType())) { + return false; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + return true; + } + + @Override + public Boolean visit(ArrayCreationLevel n1, Node arg) { + final ArrayCreationLevel n2 = (ArrayCreationLevel) arg; + + if (!nodeEquals(n1.getDimension(), n2.getDimension())) { + return false; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + return true; + } + + @Override public Boolean visit(final IntersectionType n1, final Node arg) { + final IntersectionType n2 = (IntersectionType) arg; + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + List<ReferenceType> n1Elements = n1.getElements(); + List<ReferenceType> n2Elements = n2.getElements(); + + if (n1Elements !=null && n2Elements != null) { + if(n1Elements.size() != n2Elements.size()){ + return false; + } + else{ + int i = 0; + for(ReferenceType aux: n1Elements){ + if(aux.accept(this, n2Elements.get(i))) { + return false; + } + i++; + } + } + } else if (n1Elements != n2Elements){ + return false; + } + return true; + } + + @Override public Boolean visit(final UnionType n1, final Node arg) { + final UnionType n2 = (UnionType) arg; + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + List<ReferenceType> n1Elements = n1.getElements(); + List<ReferenceType> n2Elements = n2.getElements(); + + if (n1Elements !=null && n2Elements != null) { + if(n1Elements.size() != n2Elements.size()){ + return false; + } + else{ + int i = 0; + for(ReferenceType aux: n1Elements){ + if(aux.accept(this, n2Elements.get(i))) { + return false; + } + i++; + } + } + } else if (n1Elements != n2Elements){ + return false; + } + return true; + } + + @Override + public Boolean visit(VoidType n1, Node arg) { + VoidType n2 = (VoidType) arg; + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + return true; + } + + @Override public Boolean visit(final WildcardType n1, final Node arg) { + final WildcardType n2 = (WildcardType) arg; + + if (!nodeEquals(n1.getExtends(), n2.getExtends())) { + return false; + } + + if (!nodeEquals(n1.getSuper(), n2.getSuper())) { + return false; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + return true; + } + + @Override public Boolean visit(final UnknownType n1, final Node arg) { + return true; + } + + @Override public Boolean visit(final ArrayAccessExpr n1, final Node arg) { + final ArrayAccessExpr n2 = (ArrayAccessExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodeEquals(n1.getIndex(), n2.getIndex())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ArrayCreationExpr n1, final Node arg) { + final ArrayCreationExpr n2 = (ArrayCreationExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return false; + } + + if (!nodesEquals(n1.getLevels(), n2.getLevels())) { + return false; + } + + if (!nodeEquals(n1.getInitializer(), n2.getInitializer())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ArrayInitializerExpr n1, final Node arg) { + final ArrayInitializerExpr n2 = (ArrayInitializerExpr) arg; + + if (!nodesEquals(n1.getValues(), n2.getValues())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final AssignExpr n1, final Node arg) { + final AssignExpr n2 = (AssignExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return false; + } + + if (!nodeEquals(n1.getTarget(), n2.getTarget())) { + return false; + } + + if (!nodeEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final BinaryExpr n1, final Node arg) { + final BinaryExpr n2 = (BinaryExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return false; + } + + if (!nodeEquals(n1.getLeft(), n2.getLeft())) { + return false; + } + + if (!nodeEquals(n1.getRight(), n2.getRight())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final CastExpr n1, final Node arg) { + final CastExpr n2 = (CastExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return false; + } + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ClassExpr n1, final Node arg) { + final ClassExpr n2 = (ClassExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ConditionalExpr n1, final Node arg) { + final ConditionalExpr n2 = (ConditionalExpr) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return false; + } + + if (!nodeEquals(n1.getThenExpr(), n2.getThenExpr())) { + return false; + } + + if (!nodeEquals(n1.getElseExpr(), n2.getElseExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final EnclosedExpr n1, final Node arg) { + final EnclosedExpr n2 = (EnclosedExpr) arg; + + if (!nodeEquals(n1.getInner(), n2.getInner())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final FieldAccessExpr n1, final Node arg) { + final FieldAccessExpr n2 = (FieldAccessExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return false; + } + + if (!objEquals(n1.getField(), n2.getField())) { + return false; + } + + if (!nodesEquals(n1.getTypeArguments(), n2.getTypeArguments())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final InstanceOfExpr n1, final Node arg) { + final InstanceOfExpr n2 = (InstanceOfExpr) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final StringLiteralExpr n1, final Node arg) { + final StringLiteralExpr n2 = (StringLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final IntegerLiteralExpr n1, final Node arg) { + final IntegerLiteralExpr n2 = (IntegerLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final LongLiteralExpr n1, final Node arg) { + final LongLiteralExpr n2 = (LongLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final IntegerLiteralMinValueExpr n1, final Node arg) { + final IntegerLiteralMinValueExpr n2 = (IntegerLiteralMinValueExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final LongLiteralMinValueExpr n1, final Node arg) { + final LongLiteralMinValueExpr n2 = (LongLiteralMinValueExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final CharLiteralExpr n1, final Node arg) { + final CharLiteralExpr n2 = (CharLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final DoubleLiteralExpr n1, final Node arg) { + final DoubleLiteralExpr n2 = (DoubleLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final BooleanLiteralExpr n1, final Node arg) { + final BooleanLiteralExpr n2 = (BooleanLiteralExpr) arg; + + if (n1.getValue() != n2.getValue()) { + return false; + } + + return true; + } + + @Override public Boolean visit(final NullLiteralExpr n1, final Node arg) { + return true; + } + + @Override public Boolean visit(final MethodCallExpr n1, final Node arg) { + final MethodCallExpr n2 = (MethodCallExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return false; + } + + if (!nodesEquals(n1.getTypeArguments(), n2.getTypeArguments())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final NameExpr n1, final Node arg) { + final NameExpr n2 = (NameExpr) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ObjectCreationExpr n1, final Node arg) { + final ObjectCreationExpr n2 = (ObjectCreationExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return false; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return false; + } + + if (!nodesEquals(n1.getAnonymousClassBody(), n2.getAnonymousClassBody())) { + return false; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return false; + } + + if (!nodesEquals(n1.getTypeArguments(), n2.getTypeArguments())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final QualifiedNameExpr n1, final Node arg) { + final QualifiedNameExpr n2 = (QualifiedNameExpr) arg; + + if (!nodeEquals(n1.getQualifier(), n2.getQualifier())) { + return false; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ThisExpr n1, final Node arg) { + final ThisExpr n2 = (ThisExpr) arg; + + if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final SuperExpr n1, final Node arg) { + final SuperExpr n2 = (SuperExpr) arg; + + if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final UnaryExpr n1, final Node arg) { + final UnaryExpr n2 = (UnaryExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return false; + } + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final VariableDeclarationExpr n1, final Node arg) { + final VariableDeclarationExpr n2 = (VariableDeclarationExpr) arg; + + if (!n1.getModifiers().equals(n2.getModifiers())) { + return false; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + if (!nodeEquals(n1.getElementType(), n2.getElementType())) { + return false; + } + + if (!nodesEquals(n1.getVariables(), n2.getVariables())) { + return false; + } + + if(!nodesEquals(n1.getArrayBracketPairsAfterElementType(), n2.getArrayBracketPairsAfterElementType())){ + return false; + } + + return true; + } + + @Override public Boolean visit(final MarkerAnnotationExpr n1, final Node arg) { + final MarkerAnnotationExpr n2 = (MarkerAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final SingleMemberAnnotationExpr n1, final Node arg) { + final SingleMemberAnnotationExpr n2 = (SingleMemberAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodeEquals(n1.getMemberValue(), n2.getMemberValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final NormalAnnotationExpr n1, final Node arg) { + final NormalAnnotationExpr n2 = (NormalAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodesEquals(n1.getPairs(), n2.getPairs())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final MemberValuePair n1, final Node arg) { + final MemberValuePair n2 = (MemberValuePair) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return false; + } + + if (!nodeEquals(n1.getValue(), n2.getValue())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ExplicitConstructorInvocationStmt n1, final Node arg) { + final ExplicitConstructorInvocationStmt n2 = (ExplicitConstructorInvocationStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return false; + } + + if (!nodesEquals(n1.getTypeArguments(), n2.getTypeArguments())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final TypeDeclarationStmt n1, final Node arg) { + final TypeDeclarationStmt n2 = (TypeDeclarationStmt) arg; + + if (!nodeEquals(n1.getTypeDeclaration(), n2.getTypeDeclaration())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final AssertStmt n1, final Node arg) { + final AssertStmt n2 = (AssertStmt) arg; + + if (!nodeEquals(n1.getCheck(), n2.getCheck())) { + return false; + } + + if (!nodeEquals(n1.getMessage(), n2.getMessage())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final BlockStmt n1, final Node arg) { + final BlockStmt n2 = (BlockStmt) arg; + + if (!nodesEquals(n1.getStmts(), n2.getStmts())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final LabeledStmt n1, final Node arg) { + final LabeledStmt n2 = (LabeledStmt) arg; + + if (!nodeEquals(n1.getStmt(), n2.getStmt())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final EmptyStmt n1, final Node arg) { + return true; + } + + @Override public Boolean visit(final ExpressionStmt n1, final Node arg) { + final ExpressionStmt n2 = (ExpressionStmt) arg; + + if (!nodeEquals(n1.getExpression(), n2.getExpression())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final SwitchStmt n1, final Node arg) { + final SwitchStmt n2 = (SwitchStmt) arg; + + if (!nodeEquals(n1.getSelector(), n2.getSelector())) { + return false; + } + + if (!nodesEquals(n1.getEntries(), n2.getEntries())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final SwitchEntryStmt n1, final Node arg) { + final SwitchEntryStmt n2 = (SwitchEntryStmt) arg; + + if (!nodeEquals(n1.getLabel(), n2.getLabel())) { + return false; + } + + if (!nodesEquals(n1.getStmts(), n2.getStmts())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final BreakStmt n1, final Node arg) { + final BreakStmt n2 = (BreakStmt) arg; + + if (!objEquals(n1.getId(), n2.getId())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ReturnStmt n1, final Node arg) { + final ReturnStmt n2 = (ReturnStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final IfStmt n1, final Node arg) { + final IfStmt n2 = (IfStmt) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return false; + } + + if (!nodeEquals(n1.getThenStmt(), n2.getThenStmt())) { + return false; + } + + if (!nodeEquals(n1.getElseStmt(), n2.getElseStmt())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final WhileStmt n1, final Node arg) { + final WhileStmt n2 = (WhileStmt) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ContinueStmt n1, final Node arg) { + final ContinueStmt n2 = (ContinueStmt) arg; + + if (!objEquals(n1.getId(), n2.getId())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final DoStmt n1, final Node arg) { + final DoStmt n2 = (DoStmt) arg; + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ForeachStmt n1, final Node arg) { + final ForeachStmt n2 = (ForeachStmt) arg; + + if (!nodeEquals(n1.getVariable(), n2.getVariable())) { + return false; + } + + if (!nodeEquals(n1.getIterable(), n2.getIterable())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ForStmt n1, final Node arg) { + final ForStmt n2 = (ForStmt) arg; + + if (!nodesEquals(n1.getInit(), n2.getInit())) { + return false; + } + + if (!nodeEquals(n1.getCompare(), n2.getCompare())) { + return false; + } + + if (!nodesEquals(n1.getUpdate(), n2.getUpdate())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final ThrowStmt n1, final Node arg) { + final ThrowStmt n2 = (ThrowStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final SynchronizedStmt n1, final Node arg) { + final SynchronizedStmt n2 = (SynchronizedStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final TryStmt n1, final Node arg) { + final TryStmt n2 = (TryStmt) arg; + + if (!nodeEquals(n1.getTryBlock(), n2.getTryBlock())) { + return false; + } + + if (!nodesEquals(n1.getCatchs(), n2.getCatchs())) { + return false; + } + + if(!nodesEquals(n1.getResources(), n2.getResources())) { + return false; + } + + if (!nodeEquals(n1.getFinallyBlock(), n2.getFinallyBlock())) { + return false; + } + + return true; + } + + @Override public Boolean visit(final CatchClause n1, final Node arg) { + final CatchClause n2 = (CatchClause) arg; + + if (!nodeEquals(n1.getParam(), n2.getParam())) { + return false; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + + return true; + } + + @Override + public Boolean visit(LambdaExpr n1, Node arg) { + LambdaExpr n2 = (LambdaExpr) arg; + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return false; + } + if(n1.isParametersEnclosed() != n2.isParametersEnclosed()){ + return false; + } + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return false; + } + return true; + } + + @Override + public Boolean visit(MethodReferenceExpr n1, Node arg) { + MethodReferenceExpr n2 = (MethodReferenceExpr) arg; + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return false; + } + if (!nodesEquals(n1.getTypeArguments(), n2.getTypeArguments())) { + return false; + } + if (!objEquals(n1.getIdentifier(), n2.getIdentifier())) { + return false; + } + return true; + } + + @Override + public Boolean visit(TypeExpr n, Node arg) { + TypeExpr n2 = (TypeExpr) arg; + if (!nodeEquals(n.getType(), n2.getType())) { + return false; + } + return true; + } + + @Override + public Boolean visit(ArrayBracketPair n1, Node arg) { + ArrayBracketPair n2 = (ArrayBracketPair) arg; + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return false; + } + + return true; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/GenericVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/GenericVisitor.java new file mode 100644 index 000000000..9f4e9bc7f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/GenericVisitor.java @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.*; +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.type.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.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * A visitor that has a return value. + * + * @author Julio Vilmar Gesser + */ +public interface GenericVisitor<R, A> { + + //- Compilation Unit ---------------------------------- + + R visit(CompilationUnit n, A arg); + + R visit(PackageDeclaration n, A arg); + + R visit(ImportDeclaration n, A arg); + + R visit(TypeParameter n, A arg); + + R visit(LineComment n, A arg); + + R visit(BlockComment n, A arg); + + //- Body ---------------------------------------------- + + R visit(ClassOrInterfaceDeclaration n, A arg); + + R visit(EnumDeclaration n, A arg); + + R visit(EmptyTypeDeclaration n, A arg); + + R visit(EnumConstantDeclaration n, A arg); + + R visit(AnnotationDeclaration n, A arg); + + R visit(AnnotationMemberDeclaration n, A arg); + + R visit(FieldDeclaration n, A arg); + + R visit(VariableDeclarator n, A arg); + + R visit(VariableDeclaratorId n, A arg); + + R visit(ConstructorDeclaration n, A arg); + + R visit(MethodDeclaration n, A arg); + + R visit(Parameter n, A arg); + + R visit(EmptyMemberDeclaration n, A arg); + + R visit(InitializerDeclaration n, A arg); + + R visit(JavadocComment n, A arg); + + //- Type ---------------------------------------------- + + R visit(ClassOrInterfaceType n, A arg); + + R visit(PrimitiveType n, A arg); + + R visit(ArrayType n, A arg); + + R visit(ArrayCreationLevel n, A arg); + + R visit(IntersectionType n, A arg); + + R visit(UnionType n, A arg); + + R visit(VoidType n, A arg); + + R visit(WildcardType n, A arg); + + R visit(UnknownType n, A arg); + + //- Expression ---------------------------------------- + + R visit(ArrayAccessExpr n, A arg); + + R visit(ArrayCreationExpr n, A arg); + + R visit(ArrayInitializerExpr n, A arg); + + R visit(AssignExpr n, A arg); + + R visit(BinaryExpr n, A arg); + + R visit(CastExpr n, A arg); + + R visit(ClassExpr n, A arg); + + R visit(ConditionalExpr n, A arg); + + R visit(EnclosedExpr n, A arg); + + R visit(FieldAccessExpr n, A arg); + + R visit(InstanceOfExpr n, A arg); + + R visit(StringLiteralExpr n, A arg); + + R visit(IntegerLiteralExpr n, A arg); + + R visit(LongLiteralExpr n, A arg); + + R visit(IntegerLiteralMinValueExpr n, A arg); + + R visit(LongLiteralMinValueExpr n, A arg); + + R visit(CharLiteralExpr n, A arg); + + R visit(DoubleLiteralExpr n, A arg); + + R visit(BooleanLiteralExpr n, A arg); + + R visit(NullLiteralExpr n, A arg); + + R visit(MethodCallExpr n, A arg); + + R visit(NameExpr n, A arg); + + R visit(ObjectCreationExpr n, A arg); + + R visit(QualifiedNameExpr n, A arg); + + R visit(ThisExpr n, A arg); + + R visit(SuperExpr n, A arg); + + R visit(UnaryExpr n, A arg); + + R visit(VariableDeclarationExpr n, A arg); + + R visit(MarkerAnnotationExpr n, A arg); + + R visit(SingleMemberAnnotationExpr n, A arg); + + R visit(NormalAnnotationExpr n, A arg); + + R visit(MemberValuePair n, A arg); + + //- Statements ---------------------------------------- + + R visit(ExplicitConstructorInvocationStmt n, A arg); + + R visit(TypeDeclarationStmt n, A arg); + + R visit(AssertStmt n, A arg); + + R visit(BlockStmt n, A arg); + + R visit(LabeledStmt n, A arg); + + R visit(EmptyStmt n, A arg); + + R visit(ExpressionStmt n, A arg); + + R visit(SwitchStmt n, A arg); + + R visit(SwitchEntryStmt n, A arg); + + R visit(BreakStmt n, A arg); + + R visit(ReturnStmt n, A arg); + + R visit(IfStmt n, A arg); + + R visit(WhileStmt n, A arg); + + R visit(ContinueStmt n, A arg); + + R visit(DoStmt n, A arg); + + R visit(ForeachStmt n, A arg); + + R visit(ForStmt n, A arg); + + R visit(ThrowStmt n, A arg); + + R visit(SynchronizedStmt n, A arg); + + R visit(TryStmt n, A arg); + + R visit(CatchClause n, A arg); + + R visit(LambdaExpr n, A arg); + + R visit(MethodReferenceExpr n, A arg); + + R visit(TypeExpr n, A arg); + + R visit(ArrayBracketPair arrayBracketPair, A arg); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java new file mode 100644 index 000000000..af01fdffb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java @@ -0,0 +1,1677 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.*; +import com.github.javaparser.ast.body.*; +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.*; +import com.github.javaparser.ast.type.*; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class GenericVisitorAdapter<R, A> implements GenericVisitor<R, A> { + + @Override + public R visit(final AnnotationDeclaration n, final A arg) { + visitComment(n, arg); + 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) { + visitComment(n, 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; + } + } + 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) { + visitComment(n, 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) { + visitComment(n, arg); + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + for(ArrayCreationLevel level: n.getLevels()){ + R result = level.accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getInitializer() != null) { + R result = n.getInitializer().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ArrayInitializerExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final BreakStmt n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final CastExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + { + R result = n.getParam().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 CharLiteralExpr n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final ClassExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + 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) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArguments() != null) { + for (Type<?> type : n.getTypeArguments()) { + R result = type.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final CompilationUnit n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + 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 ReferenceType name : n.getThrows()) { + { + R result = name.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 ContinueStmt n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final DoStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final EmptyMemberDeclaration n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final EmptyStmt n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final EmptyTypeDeclaration n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final EnclosedExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + 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) { + visitComment(n, arg); + 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) { + visitComment(n, arg); + if (!n.isThis() && n.getExpr() != null) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArguments() != null) { + for (Type<?> type : n.getTypeArguments()) { + R result = type.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) { + visitComment(n, 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) { + visitComment(n, arg); + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + { + if (n.getTypeArguments() != null) { + for (Type<?> type : n.getTypeArguments()) { + R result = type.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final FieldDeclaration n, final A arg) { + visitComment(n, 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.getElementType().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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final InstanceOfExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final IntegerLiteralMinValueExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final LongLiteralMinValueExpr n, final A arg) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final MarkerAnnotationExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArguments() != null) { + for (Type<?> type : n.getTypeArguments()) { + R result = type.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) { + visitComment(n, arg); + 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.getElementType().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 ReferenceType 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final NormalAnnotationExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final ObjectCreationExpr n, final A arg) { + visitComment(n, arg); + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArguments() != null) { + for (Type<?> type : n.getTypeArguments()) { + R result = type.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) { + visitComment(n, 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) { + visitComment(n, 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.getElementType().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) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final QualifiedNameExpr n, final A arg) { + visitComment(n, arg); + { + R result = n.getQualifier().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(ArrayType n, A arg) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getComponentType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(ArrayCreationLevel n, A arg) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + { + if(n.getDimension()!=null) { + R result = n.getDimension().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final IntersectionType n, final A arg) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + { + for (ReferenceType element : n.getElements()) { + R result = element.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final UnionType n, final A arg) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + { + for (ReferenceType element : n.getElements()) { + R result = element.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ReturnStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final SuperExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + { + if (n.getExpr() != null) { + R result = n.getExpr().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 ThisExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final VariableDeclarationExpr n, final A arg) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getElementType().accept(this, arg); + if (result != null) { + return result; + } + } + for (final VariableDeclarator v : n.getVariables()) { + { + R result = v.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final VariableDeclarator n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + return null; + } + + @Override + public R visit(final VoidType n, final A arg) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final WhileStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + for (final AnnotationExpr a : n.getAnnotations()) { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + 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) { + visitComment(n, arg); + if (n.getParameters() != null) { + for (final Parameter a : n.getParameters()) { + R result = a.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(MethodReferenceExpr n, A arg) { + visitComment(n, arg); + { + if (n.getTypeArguments() != null) { + for (Type<?> type : n.getTypeArguments()) { + R result = type.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getScope() != null) { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(TypeExpr n, A arg){ + visitComment(n, arg); + if (n.getType() != null) { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(ArrayBracketPair n, A arg) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + 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; + } + + private void visitComment(Node n, A arg) { + if(n.getComment()!=null){ + Comment result = (Comment) n.getComment().accept(this, arg); + if(result!=null){ + n.setComment(result); + } + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java new file mode 100644 index 000000000..78b0e2931 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java @@ -0,0 +1,1149 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.List; + +import com.github.javaparser.ast.*; +import com.github.javaparser.ast.type.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.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.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.nodeTypes.NodeWithAnnotations; +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.type.*; +import com.github.javaparser.ast.stmt.WhileStmt; + +/** + * 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 class ModifierVisitorAdapter<A> implements GenericVisitor<Node, A> { + + private void removeNulls(final List<?> list) { + for (int i = list.size() - 1; i >= 0; i--) { + if (list.get(i) == null) { + list.remove(i); + } + } + } + + @Override public Node visit(final AnnotationDeclaration n, final A arg) { + visitAnnotations(n, arg); + visitComment(n, arg); + final List<BodyDeclaration<?>> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration<?>) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + private void visitAnnotations(NodeWithAnnotations<?> n, A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + } + + @Override public Node visit(final AnnotationMemberDeclaration n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + if (n.getDefaultValue() != null) { + n.setDefaultValue((Expression) n.getDefaultValue().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ArrayAccessExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + n.setType((Type) n.getType().accept(this, arg)); + + final List<ArrayCreationLevel> values = n.getLevels(); + for (int i = 0; i < values.size(); i++) { + values.set(i, (ArrayCreationLevel) values.get(i).accept(this, arg)); + } + removeNulls(values); + + if (n.getInitializer() != null) { + n.setInitializer((ArrayInitializerExpr) n.getInitializer().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ArrayInitializerExpr n, final A arg) { + visitComment(n, arg); + if (n.getValues() != null) { + final List<Expression> values = n.getValues(); + if (values != null) { + for (int i = 0; i < values.size(); i++) { + values.set(i, (Expression) values.get(i).accept(this, arg)); + } + removeNulls(values); + } + } + return n; + } + + @Override public Node visit(final AssertStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + final Expression target = (Expression) n.getTarget().accept(this, arg); + if (target == null) { + return null; + } + n.setTarget(target); + + final Expression value = (Expression) n.getValue().accept(this, arg); + if (value == null) { + return null; + } + n.setValue(value); + + return n; + } + + @Override public Node visit(final BinaryExpr n, final A arg) { + visitComment(n, arg); + final Expression left = (Expression) n.getLeft().accept(this, arg); + final Expression right = (Expression) n.getRight().accept(this, arg); + if (left == null) { + return right; + } + if (right == null) { + return left; + } + n.setLeft(left); + n.setRight(right); + return n; + } + + @Override public Node visit(final BlockStmt n, final A arg) { + visitComment(n, arg); + final List<Statement> stmts = n.getStmts(); + if (stmts != null) { + for (int i = 0; i < stmts.size(); i++) { + stmts.set(i, (Statement) stmts.get(i).accept(this, arg)); + } + removeNulls(stmts); + } + return n; + } + + @Override public Node visit(final BooleanLiteralExpr n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final BreakStmt n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final CastExpr n, final A arg) { + visitComment(n, arg); + final Type type = (Type) n.getType().accept(this, arg); + final Expression expr = (Expression) n.getExpr().accept(this, arg); + if (type == null) { + return expr; + } + if (expr == null) { + return null; + } + n.setType(type); + n.setExpr(expr); + return n; + } + + @Override public Node visit(final CatchClause n, final A arg) { + visitComment(n, arg); + n.setParam((Parameter)n.getParam().accept(this, arg)); + n.setBody((BlockStmt) n.getBody().accept(this, arg)); + return n; + + } + + @Override public Node visit(final CharLiteralExpr n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final ClassExpr n, final A arg) { + visitComment(n, arg); + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final ClassOrInterfaceDeclaration n, final A arg) { + visitAnnotations(n, arg); + visitComment(n, arg); + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + final List<ClassOrInterfaceType> extendz = n.getExtends(); + if (extendz != null) { + for (int i = 0; i < extendz.size(); i++) { + extendz.set(i, (ClassOrInterfaceType) extendz.get(i).accept(this, arg)); + } + removeNulls(extendz); + } + final List<ClassOrInterfaceType> implementz = n.getImplements(); + if (implementz != null) { + for (int i = 0; i < implementz.size(); i++) { + implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg)); + } + removeNulls(implementz); + } + final List<BodyDeclaration<?>> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration<?>) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final ClassOrInterfaceType n, final A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + if (n.getScope() != null) { + n.setScope((ClassOrInterfaceType) n.getScope().accept(this, arg)); + } + final List<Type<?>> typeArguments = n.getTypeArguments(); + if (typeArguments != null) { + for (int i = 0; i < typeArguments.size(); i++) { + typeArguments.set(i, (Type<?>) typeArguments.get(i).accept(this, arg)); + } + removeNulls(typeArguments); + } + return n; + } + + @Override public Node visit(final CompilationUnit n, final A arg) { + visitComment(n, arg); + if (n.getPackage() != null) { + n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg)); + } + final List<ImportDeclaration> imports = n.getImports(); + if (imports != null) { + for (int i = 0; i < imports.size(); i++) { + imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg)); + } + removeNulls(imports); + } + final List<TypeDeclaration<?>> types = n.getTypes(); + if (types != null) { + for (int i = 0; i < types.size(); i++) { + types.set(i, (TypeDeclaration<?>) types.get(i).accept(this, arg)); + } + removeNulls(types); + } + return n; + } + + @Override public Node visit(final ConditionalExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + final List<Parameter> parameters = n.getParameters(); + if (parameters != null) { + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + } + final List<ReferenceType> throwz = n.getThrows(); + if (throwz != null) { + for (int i = 0; i < throwz.size(); i++) { + throwz.set(i, (ReferenceType) throwz.get(i).accept(this, arg)); + } + removeNulls(throwz); + } + n.setBody((BlockStmt) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final ContinueStmt n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final DoStmt n, final A arg) { + visitComment(n, arg); + final Statement body = (Statement) n.getBody().accept(this, arg); + if (body == null) { + return null; + } + n.setBody(body); + + final Expression condition = (Expression) n.getCondition().accept(this, arg); + if (condition == null) { + return null; + } + n.setCondition(condition); + + return n; + } + + @Override public Node visit(final DoubleLiteralExpr n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final EmptyMemberDeclaration n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final EmptyStmt n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final EmptyTypeDeclaration n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final EnclosedExpr n, final A arg) { + visitComment(n, arg); + n.setInner((Expression) n.getInner().accept(this, arg)); + return n; + } + + @Override public Node visit(final EnumConstantDeclaration n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + final List<BodyDeclaration<?>> classBody = n.getClassBody(); + if (classBody != null) { + for (int i = 0; i < classBody.size(); i++) { + classBody.set(i, (BodyDeclaration<?>) classBody.get(i).accept(this, arg)); + } + removeNulls(classBody); + } + return n; + } + + @Override public Node visit(final EnumDeclaration n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<ClassOrInterfaceType> implementz = n.getImplements(); + if (implementz != null) { + for (int i = 0; i < implementz.size(); i++) { + implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg)); + } + removeNulls(implementz); + } + final List<EnumConstantDeclaration> entries = n.getEntries(); + if (entries != null) { + for (int i = 0; i < entries.size(); i++) { + entries.set(i, (EnumConstantDeclaration) entries.get(i).accept(this, arg)); + } + removeNulls(entries); + } + final List<BodyDeclaration<?>> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration<?>) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final ExplicitConstructorInvocationStmt n, final A arg) { + visitComment(n, arg); + if (!n.isThis() && n.getExpr() != null) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + } + final List<Type<?>> typeArguments = n.getTypeArguments(); + if (typeArguments != null) { + for (int i = 0; i < typeArguments.size(); i++) { + typeArguments.set(i, (Type<?>) typeArguments.get(i).accept(this, arg)); + } + removeNulls(typeArguments); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + return n; + } + + @Override public Node visit(final ExpressionStmt n, final A arg) { + visitComment(n, arg); + final Expression expr = (Expression) n.getExpression().accept(this, arg); + if (expr == null) { + return null; + } + n.setExpression(expr); + return n; + } + + @Override public Node visit(final FieldAccessExpr n, final A arg) { + visitComment(n, arg); + final Expression scope = (Expression) n.getScope().accept(this, arg); + if (scope == null) { + return null; + } + n.setScope(scope); + return n; + } + + @Override public Node visit(final FieldDeclaration n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setElementType((Type) n.getElementType().accept(this, arg)); + final List<VariableDeclarator> variables = n.getVariables(); + for (int i = 0; i < variables.size(); i++) { + variables.set(i, (VariableDeclarator) variables.get(i).accept(this, arg)); + } + removeNulls(variables); + return n; + } + + @Override public Node visit(final ForeachStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + final List<Expression> init = n.getInit(); + if (init != null) { + for (int i = 0; i < init.size(); i++) { + init.set(i, (Expression) init.get(i).accept(this, arg)); + } + removeNulls(init); + } + if (n.getCompare() != null) { + n.setCompare((Expression) n.getCompare().accept(this, arg)); + } + final List<Expression> update = n.getUpdate(); + if (update != null) { + for (int i = 0; i < update.size(); i++) { + update.set(i, (Expression) update.get(i).accept(this, arg)); + } + removeNulls(update); + } + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final IfStmt n, final A arg) { + visitComment(n, arg); + final Expression condition = (Expression) + n.getCondition().accept(this, arg); + if (condition == null) { + return null; + } + n.setCondition(condition); + final Statement thenStmt = (Statement) n.getThenStmt().accept(this, arg); + if (thenStmt == null) { + // Remove the entire statement if the then-clause was removed. + // DumpVisitor, used for toString, has no null check for the + // then-clause. + return null; + } + n.setThenStmt(thenStmt); + if (n.getElseStmt() != null) { + n.setElseStmt((Statement) n.getElseStmt().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ImportDeclaration n, final A arg) { + visitComment(n, arg); + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final InitializerDeclaration n, final A arg) { + visitComment(n, arg); + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final InstanceOfExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final IntegerLiteralMinValueExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + n.setStmt((Statement) n.getStmt().accept(this, arg)); + return n; + } + + @Override public Node visit(final LongLiteralExpr n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final LongLiteralMinValueExpr n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final MarkerAnnotationExpr n, final A arg) { + visitComment(n, arg); + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final MemberValuePair n, final A arg) { + visitComment(n, arg); + n.setValue((Expression) n.getValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final MethodCallExpr n, final A arg) { + visitComment(n, arg); + if (n.getScope() != null) { + n.setScope((Expression) n.getScope().accept(this, arg)); + } + final List<Type<?>> typeArguments = n.getTypeArguments(); + if (typeArguments != null) { + for (int i = 0; i < typeArguments.size(); i++) { + typeArguments.set(i, (Type<?>) typeArguments.get(i).accept(this, arg)); + } + removeNulls(typeArguments); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + return n; + } + + @Override public Node visit(final MethodDeclaration n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + n.setElementType((Type) n.getElementType().accept(this, arg)); + final List<Parameter> parameters = n.getParameters(); + if (parameters != null) { + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + } + final List<ReferenceType> throwz = n.getThrows(); + if (throwz != null) { + for (int i = 0; i < throwz.size(); i++) { + throwz.set(i, (ReferenceType) 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) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final NormalAnnotationExpr n, final A arg) { + visitComment(n, arg); + n.setName((NameExpr) n.getName().accept(this, arg)); + final List<MemberValuePair> pairs = n.getPairs(); + if (pairs != null) { + for (int i = 0; i < pairs.size(); i++) { + pairs.set(i, (MemberValuePair) pairs.get(i).accept(this, arg)); + } + removeNulls(pairs); + } + return n; + } + + @Override public Node visit(final NullLiteralExpr n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final ObjectCreationExpr n, final A arg) { + visitComment(n, arg); + if (n.getScope() != null) { + n.setScope((Expression) n.getScope().accept(this, arg)); + } + final List<Type<?>> typeArguments = n.getTypeArguments(); + if (typeArguments != null) { + for (int i = 0; i < typeArguments.size(); i++) { + typeArguments.set(i, (Type<?>) typeArguments.get(i).accept(this, arg)); + } + removeNulls(typeArguments); + } + n.setType((ClassOrInterfaceType) n.getType().accept(this, arg)); + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + final List<BodyDeclaration<?>> anonymousClassBody = n.getAnonymousClassBody(); + if (anonymousClassBody != null) { + for (int i = 0; i < anonymousClassBody.size(); i++) { + anonymousClassBody.set(i, (BodyDeclaration<?>) anonymousClassBody.get(i).accept(this, arg)); + } + removeNulls(anonymousClassBody); + } + return n; + } + + @Override public Node visit(final PackageDeclaration n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final Parameter n, final A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + n.setId((VariableDeclaratorId) n.getId().accept(this, arg)); + n.setElementType((Type) n.getElementType().accept(this, arg)); + return n; + } + + @Override public Node visit(final PrimitiveType n, final A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + return n; + } + + @Override public Node visit(final QualifiedNameExpr n, final A arg) { + visitComment(n, arg); + n.setQualifier((NameExpr) n.getQualifier().accept(this, arg)); + return n; + } + + @Override + public Node visit(ArrayType n, A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + n.setComponentType((Type) n.getComponentType().accept(this, arg)); + return n; + } + + @Override + public Node visit(ArrayCreationLevel n, A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + if(n.getDimension()!=null) { + n.setDimension((Expression) n.getDimension().accept(this, arg)); + } + return n; + } + + @Override + public Node visit(final IntersectionType n, final A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + final List<ReferenceType> elements = n.getElements(); + if (elements != null) { + for (int i = 0; i < elements.size(); i++) { + elements.set(i, (ReferenceType) elements.get(i).accept(this, arg)); + } + removeNulls(elements); + } + return n; + } + + @Override + public Node visit(final UnionType n, final A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + final List<ReferenceType> elements = n.getElements(); + if (elements != null) { + for (int i = 0; i < elements.size(); i++) { + elements.set(i, (ReferenceType) elements.get(i).accept(this, arg)); + } + removeNulls(elements); + } + return n; + } + + @Override public Node visit(final ReturnStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, 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) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final SuperExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + if (n.getLabel() != null) { + n.setLabel((Expression) n.getLabel().accept(this, arg)); + } + final List<Statement> stmts = n.getStmts(); + if (stmts != null) { + for (int i = 0; i < stmts.size(); i++) { + stmts.set(i, (Statement) stmts.get(i).accept(this, arg)); + } + removeNulls(stmts); + } + return n; + } + + @Override public Node visit(final SwitchStmt n, final A arg) { + visitComment(n, arg); + n.setSelector((Expression) n.getSelector().accept(this, arg)); + final List<SwitchEntryStmt> entries = n.getEntries(); + if (entries != null) { + for (int i = 0; i < entries.size(); i++) { + entries.set(i, (SwitchEntryStmt) entries.get(i).accept(this, arg)); + } + removeNulls(entries); + } + return n; + + } + + @Override public Node visit(final SynchronizedStmt n, final A arg) { + visitComment(n, arg); + n.setExpr((Expression) n.getExpr().accept(this, arg)); + n.setBody((BlockStmt) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final ThisExpr n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final TryStmt n, final A arg) { + visitComment(n, arg); + final List<VariableDeclarationExpr> types = n.getResources(); + for (int i = 0; i < types.size(); i++) { + n.getResources().set(i, + (VariableDeclarationExpr) n.getResources().get(i).accept(this, arg)); + } + n.setTryBlock((BlockStmt) n.getTryBlock().accept(this, arg)); + final List<CatchClause> catchs = n.getCatchs(); + if (catchs != null) { + for (int i = 0; i < catchs.size(); i++) { + catchs.set(i, (CatchClause) catchs.get(i).accept(this, arg)); + } + removeNulls(catchs); + } + if (n.getFinallyBlock() != null) { + n.setFinallyBlock((BlockStmt) n.getFinallyBlock().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final TypeDeclarationStmt n, final A arg) { + visitComment(n, arg); + n.setTypeDeclaration((TypeDeclaration<?>) n.getTypeDeclaration().accept(this, arg)); + return n; + } + + @Override public Node visit(final TypeParameter n, final A arg) { + visitComment(n, arg); + final List<ClassOrInterfaceType> typeBound = n.getTypeBound(); + if (typeBound != null) { + for (int i = 0; i < typeBound.size(); i++) { + typeBound.set(i, (ClassOrInterfaceType) typeBound.get(i).accept(this, arg)); + } + removeNulls(typeBound); + } + return n; + } + + @Override public Node visit(final UnaryExpr n, final A arg) { + visitComment(n, arg); + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final UnknownType n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final VariableDeclarationExpr n, final A arg) { + visitComment(n, arg); + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + + final Type type = (Type) n.getElementType().accept(this, arg); + if (type == null) { + return null; + } + n.setElementType(type); + + final List<VariableDeclarator> vars = n.getVariables(); + for (int i = 0; i < vars.size();) { + final VariableDeclarator decl = (VariableDeclarator) + vars.get(i).accept(this, arg); + if (decl == null) { + vars.remove(i); + } else { + vars.set(i++, decl); + } + } + if (vars.isEmpty()) { + return null; + } + + return n; + } + + @Override public Node visit(final VariableDeclarator n, final A arg) { + visitComment(n, arg); + final VariableDeclaratorId id = (VariableDeclaratorId) + n.getId().accept(this, arg); + if (id == null) { + return null; + } + n.setId(id); + if (n.getInit() != null) { + n.setInit((Expression) n.getInit().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final VariableDeclaratorId n, final A arg) { + visitComment(n, arg); + return n; + } + + @Override public Node visit(final VoidType n, final A arg) { + visitComment(n, arg); + visitAnnotations(n, arg); + return n; + } + + @Override public Node visit(final WhileStmt n, final A arg) { + visitComment(n, 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) { + visitComment(n, arg); + visitAnnotations(n, 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) { + visitComment(n, arg); + final List<Parameter> parameters = n.getParameters(); + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + if (n.getBody() != null) { + n.setBody((Statement) n.getBody().accept(this, arg)); + } + return n; + } + + @Override + public Node visit(final MethodReferenceExpr n, final A arg) { + visitComment(n, arg); + final List<Type<?>> types = n.getTypeArguments(); + for (int i = 0; i < types.size(); i++) { + n.getTypeArguments().set(i, + (Type<?>) n.getTypeArguments().get(i).accept(this, arg)); + } + if (n.getScope() != null) { + n.setScope((Expression)n.getScope().accept(this, arg)); + } + return n; + } + + @Override + public Node visit(final TypeExpr n, final A arg) { + visitComment(n, arg); + if (n.getType() != null) { + n.setType((Type<?>) n.getType().accept(this, arg)); + } + return n; + } + + @Override + public Node visit(ArrayBracketPair n, A arg) { + visitAnnotations(n, 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; + } + + private void visitComment(Node n, final A arg) { + if (n != null && n.getComment() != null) { + n.setComment((Comment) n.getComment().accept(this, arg)); + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/TreeVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/TreeVisitor.java new file mode 100644 index 000000000..c1b7eaee6 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/TreeVisitor.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.Node; + +/** + * Iterate over all the nodes in (a part of) the AST. + */ +public abstract class TreeVisitor { + + /** + * https://en.wikipedia.org/wiki/Depth-first_search + * + * @param node the start node, and the first one that is passed to process(node). + */ + public void visitDepthFirst(Node node) { + process(node); + for (Node child : node.getChildrenNodes()) { + visitDepthFirst(child); + } + } + + public abstract void process(Node node); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/VoidVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/VoidVisitor.java new file mode 100644 index 000000000..ec1d0f6a6 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/VoidVisitor.java @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.*; +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.type.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.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * A visitor that does not return anything. + * + * @author Julio Vilmar Gesser + */ +public interface VoidVisitor<A> { + + //- Compilation Unit ---------------------------------- + + void visit(CompilationUnit n, A arg); + + void visit(PackageDeclaration n, A arg); + + void visit(ImportDeclaration n, A arg); + + void visit(TypeParameter n, A arg); + + void visit(LineComment n, A arg); + + void visit(BlockComment n, A arg); + + //- Body ---------------------------------------------- + + void visit(ClassOrInterfaceDeclaration n, A arg); + + void visit(EnumDeclaration n, A arg); + + void visit(EmptyTypeDeclaration n, A arg); + + void visit(EnumConstantDeclaration n, A arg); + + void visit(AnnotationDeclaration n, A arg); + + void visit(AnnotationMemberDeclaration n, A arg); + + void visit(FieldDeclaration n, A arg); + + void visit(VariableDeclarator n, A arg); + + void visit(VariableDeclaratorId n, A arg); + + void visit(ConstructorDeclaration n, A arg); + + void visit(MethodDeclaration n, A arg); + + void visit(Parameter n, A arg); + + void visit(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(ArrayType n, A arg); + + void visit(ArrayCreationLevel n, A arg); + + void visit(IntersectionType n, A arg); + + void visit(UnionType 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); + + void visit(ArrayBracketPair arrayBracketPair, A arg); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java new file mode 100644 index 000000000..cab3ef496 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java @@ -0,0 +1,806 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.*; +import com.github.javaparser.ast.stmt.*; +import com.github.javaparser.ast.type.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.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.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.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.type.*; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class VoidVisitorAdapter<A> implements VoidVisitor<A> { + + @Override public void visit(final AnnotationDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + n.getNameExpr().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); + visitAnnotations(n, 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); + for (ArrayCreationLevel level : n.getLevels()) { + level.accept(this, arg); + } + if (n.getInitializer() != null) { + 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) { + } + + @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.getParam().accept(this, arg); + n.getBody().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); + visitAnnotations(n, arg); + n.getNameExpr().accept(this, arg); + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + for (final ClassOrInterfaceType c : n.getExtends()) { + c.accept(this, arg); + } + for (final ClassOrInterfaceType c : n.getImplements()) { + c.accept(this, arg); + } + for (final BodyDeclaration<?> member : n.getMembers()) { + member.accept(this, arg); + } + } + + @Override public void visit(final ClassOrInterfaceType n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArguments() != null) { + for (final Type t : n.getTypeArguments()) { + 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); + visitAnnotations(n, arg); + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + n.getNameExpr().accept(this, arg); + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + p.accept(this, arg); + } + } + if (n.getThrows() != null) { + for (final ReferenceType name : n.getThrows()) { + name.accept(this, arg); + } + } + n.getBody().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); + } + + @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); + n.getNameExpr().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); + visitAnnotations(n, 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); + visitAnnotations(n, arg); + n.getNameExpr().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() && n.getExpr() != null) { + n.getExpr().accept(this, arg); + } + if (n.getTypeArguments() != null) { + for (final Type t : n.getTypeArguments()) { + 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); + n.getFieldExpr().accept(this, arg); + } + + @Override public void visit(final FieldDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + n.getElementType().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); + 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) { + } + + @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) { + } + + @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.getTypeArguments() != null) { + for (final Type t : n.getTypeArguments()) { + t.accept(this, arg); + } + } + n.getNameExpr().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); + visitAnnotations(n, arg); + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + n.getElementType().accept(this, arg); + n.getNameExpr().accept(this, arg); + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + p.accept(this, arg); + } + } + if (n.getThrows() != null) { + for (final ReferenceType 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.getTypeArguments() != null) { + for (final Type t : n.getTypeArguments()) { + 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); + visitAnnotations(n, arg); + n.getName().accept(this, arg); + } + + @Override public void visit(final Parameter n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + n.getElementType().accept(this, arg); + n.getId().accept(this, arg); + } + + @Override public void visit(final PrimitiveType n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + } + + @Override public void visit(final QualifiedNameExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getQualifier().accept(this, arg); + } + + @Override + public void visit(ArrayType n, A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + n.getComponentType().accept(this, arg); + } + + @Override + public void visit(ArrayCreationLevel n, A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + if(n.getDimension()!=null) { + n.getDimension().accept(this, arg); + } + } + + @Override public void visit(final IntersectionType n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + for (ReferenceType element : n.getElements()) { + element.accept(this, arg); + } + } + + @Override public void visit(final UnionType n, final A arg) { + visitComment(n.getComment(), arg); + visitAnnotations(n, arg); + for (ReferenceType element : n.getElements()) { + element.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.getBody().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); + visitAnnotations(n, arg); + n.getElementType().accept(this, arg); + for (final VariableDeclarator v : n.getVariables()) { + 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); + visitAnnotations(n, 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); + visitAnnotations(n, 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) { + visitComment(n.getComment(), 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) { + visitComment(n.getComment(), arg); + if (n.getTypeArguments() != null) { + for (final Type t : n.getTypeArguments()) { + t.accept(this, arg); + } + } + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + } + + @Override + public void visit(TypeExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getType() != null) { + n.getType().accept(this, arg); + } + } + + @Override + public void visit(ArrayBracketPair n, A arg) { + visitAnnotations(n, arg); + } + + private void visitComment(final Comment n, final A arg) { + if (n != null) { + n.accept(this, arg); + } + } + + private void visitAnnotations(NodeWithAnnotations<?> n, A arg) { + for (AnnotationExpr annotation : n.getAnnotations()) { + annotation.accept(this, arg); + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/ClassUtils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/ClassUtils.java new file mode 100644 index 000000000..476986812 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/ClassUtils.java @@ -0,0 +1,69 @@ +package com.github.javaparser.utils; + +import java.util.HashMap; +import java.util.Map; + +public class ClassUtils { + /** + * Maps primitive {@code Class}es to their corresponding wrapper {@code Class}. + */ + private static final Map<Class<?>, Class<?>> primitiveWrapperMap = new HashMap<Class<?>, Class<?>>(); + static { + primitiveWrapperMap.put(Boolean.TYPE, Boolean.class); + primitiveWrapperMap.put(Byte.TYPE, Byte.class); + primitiveWrapperMap.put(Character.TYPE, Character.class); + primitiveWrapperMap.put(Short.TYPE, Short.class); + primitiveWrapperMap.put(Integer.TYPE, Integer.class); + primitiveWrapperMap.put(Long.TYPE, Long.class); + primitiveWrapperMap.put(Double.TYPE, Double.class); + primitiveWrapperMap.put(Float.TYPE, Float.class); + primitiveWrapperMap.put(Void.TYPE, Void.TYPE); + } + + /** + * Maps wrapper {@code Class}es to their corresponding primitive types. + */ + private static final Map<Class<?>, Class<?>> wrapperPrimitiveMap = new HashMap<Class<?>, Class<?>>(); + static { + for (final Class<?> primitiveClass : primitiveWrapperMap.keySet()) { + final Class<?> wrapperClass = primitiveWrapperMap.get(primitiveClass); + if (!primitiveClass.equals(wrapperClass)) { + wrapperPrimitiveMap.put(wrapperClass, primitiveClass); + } + } + } + + /** + * Returns whether the given {@code type} is a primitive or primitive wrapper ({@link Boolean}, {@link Byte}, + * {@link Character}, + * {@link Short}, {@link Integer}, {@link Long}, {@link Double}, {@link Float}). + * + * @param type + * The class to query or null. + * @return true if the given {@code type} is a primitive or primitive wrapper ({@link Boolean}, {@link Byte}, + * {@link Character}, + * {@link Short}, {@link Integer}, {@link Long}, {@link Double}, {@link Float}). + */ + public static boolean isPrimitiveOrWrapper(final Class<?> type) { + if (type == null) { + return false; + } + return type.isPrimitive() || isPrimitiveWrapper(type); + } + + /** + * Returns whether the given {@code type} is a primitive wrapper ({@link Boolean}, {@link Byte}, {@link Character}, + * {@link Short}, + * {@link Integer}, {@link Long}, {@link Double}, {@link Float}). + * + * @param type + * The class to query or null. + * @return true if the given {@code type} is a primitive wrapper ({@link Boolean}, {@link Byte}, {@link Character}, + * {@link Short}, + * {@link Integer}, {@link Long}, {@link Double}, {@link Float}). + * @since 3.1 + */ + public static boolean isPrimitiveWrapper(final Class<?> type) { + return wrapperPrimitiveMap.containsKey(type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/Pair.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/Pair.java new file mode 100644 index 000000000..40ce85d83 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/Pair.java @@ -0,0 +1,16 @@ +package com.github.javaparser.utils; + +/** + * Simply a pair of objects. + * @param <A> type of object a. + * @param <B> type of object b. + */ +public class Pair<A, B> { + public final A a; + public final B b; + + public Pair(A a, B b) { + this.a = a; + this.b = b; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/PositionUtils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/PositionUtils.java new file mode 100644 index 000000000..e1ecf190e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/PositionUtils.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.utils; + +import static java.lang.Integer.signum; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import com.github.javaparser.ast.Node; +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 com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; +import com.github.javaparser.ast.nodeTypes.NodeWithElementType; +import com.github.javaparser.ast.nodeTypes.NodeWithType; + +public final class PositionUtils { + + private PositionUtils() { + // prevent instantiation + } + + public static <T extends Node> void sortByBeginPosition(List<T> nodes){ + sortByBeginPosition(nodes, false); + } + + public static <T extends Node> void sortByBeginPosition(List<T> nodes, final boolean ignoringAnnotations){ + Collections.sort(nodes, (o1, o2) -> 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.getBegin().line - b.getBegin().line ); + if (signLine == 0) { + return signum(a.getBegin().column - b.getBegin().column); + } else { + return signLine; + } + } + + public static AnnotationExpr getLastAnnotation(Node node) { + if (node instanceof NodeWithAnnotations){ + List<AnnotationExpr> annotations = new LinkedList<>(); + annotations.addAll(((NodeWithAnnotations<?>) node).getAnnotations()); + if (annotations.isEmpty()){ + return null; + } + sortByBeginPosition(annotations); + return annotations.get(annotations.size()-1); + } else { + return null; + } + } + + private static int beginLineWithoutConsideringAnnotation(Node node) { + return beginNodeWithoutConsideringAnnotations(node).getBegin().line; + } + + + private static int beginColumnWithoutConsideringAnnotation(Node node) { + return beginNodeWithoutConsideringAnnotations(node).getBegin().column; + } + + private static Node beginNodeWithoutConsideringAnnotations(Node node) { + if (node instanceof MethodDeclaration || node instanceof FieldDeclaration) { + NodeWithElementType<?> casted = (NodeWithElementType<?>) node; + return casted.getElementType(); + } 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 NodeWithAnnotations){ + int bl = beginLineWithoutConsideringAnnotation(container); + int bc = beginColumnWithoutConsideringAnnotation(container); + if (bl>contained.getBegin().line) return false; + if (bl==contained.getBegin().line && bc>contained.getBegin().column) return false; + if (container.getEnd().line<contained.getEnd().line) return false; + // TODO < or <= ? + return !(container.getEnd().line == contained.getEnd().line && container.getEnd().column < contained.getEnd().column); + } + return true; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/Utils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/Utils.java new file mode 100644 index 000000000..b9320852d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/utils/Utils.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2016 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.utils; + +import com.github.javaparser.Provider; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.Reader; +import java.util.*; + +/** + * Any kind of utility. + * + * @author Federico Tomassetti + */ +public class Utils { + public static final String EOL = System.getProperty("line.separator"); + public static <T> List<T> ensureNotNull(List<T> list) { + return list == null ? new ArrayList<T>() : list; + } + + public static <E> boolean isNullOrEmpty(Collection<E> collection) { + return collection == null || collection.isEmpty(); + } + + public static <T> T assertNotNull(T o) { + if (o == null) { + throw new NullPointerException("Assertion failed."); + } + return o; + } + + /** + * @return string with ASCII characters 10 and 13 replaced by the text "\n" and "\r". + */ + public static String escapeEndOfLines(String string) { + StringBuilder escapedString = new StringBuilder(); + for (char c : string.toCharArray()) { + switch (c) { + case '\n': + escapedString.append("\\n"); + break; + case '\r': + escapedString.append("\\r"); + break; + default: + escapedString.append(c); + } + } + return escapedString.toString(); + } + + public static String readerToString(Reader reader) throws IOException { + final StringBuilder result = new StringBuilder(); + final char[] buffer = new char[8 * 1024]; + int numChars; + + while ((numChars = reader.read(buffer, 0, buffer.length)) > 0) { + result.append(buffer, 0, numChars); + } + + return result.toString(); + } + + public static String providerToString(Provider provider) throws IOException { + final StringBuilder result = new StringBuilder(); + final char[] buffer = new char[8 * 1024]; + int numChars; + + while ((numChars = provider.read(buffer, 0, buffer.length)) != -1) { + result.append(buffer, 0, numChars); + } + + return result.toString(); + } + + /** + * Puts varargs in a mutable list. + * This does not have the disadvantage of Arrays#asList that it has a static size. + */ + public static <T> List<T> arrayToList(T[] array){ + List<T> list = new LinkedList<>(); + Collections.addAll(list, array); + return list; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParser.java new file mode 100644 index 000000000..97ed88103 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParser.java @@ -0,0 +1,9318 @@ +/* ASTParser.java */ +/* 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 <http://www.gnu.org/licenses/>. + */ +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.*; +import com.github.javaparser.utils.*; +import static com.github.javaparser.ASTParser.*; +import static com.github.javaparser.Range.*; +import static com.github.javaparser.Position.*; +import static com.github.javaparser.ast.type.ArrayType.*; + +/** + * <p>This class was generated automatically by javacc, do not edit.</p> + */ +final class ASTParser implements ASTParserConstants { + + private final Position INVALID = pos(-1, 0); + List<Problem> problems = new ArrayList<Problem>(); + + void reset(InputStream in, String encoding) throws IOException { + ReInit(new StreamProvider(in, encoding)); + } + + private <T> List<T> add(List<T> list, T obj) { + if (list == null) { + list = new LinkedList<T>(); + } + list.add(obj); + return list; + } + + private <T> List<T> add(int pos, List<T> list, T obj) { + if (list == null) { + list = new LinkedList<T>(); + } + list.add(pos, obj); + return list; + } + + private class ModifierHolder { + final EnumSet<Modifier> modifiers; + final List<AnnotationExpr> annotations; + final Position begin; + + public ModifierHolder(Position begin, EnumSet<Modifier> modifiers, List<AnnotationExpr> annotations) { + this.begin = begin; + this.modifiers = modifiers; + this.annotations = annotations; + } + } + + public void addModifier(EnumSet<Modifier> modifiers, Modifier mod) { + if (modifiers.contains(mod)) { + addProblem("Duplicated modifier"); + } + modifiers.add(mod); + } + + public void addMultipleModifier(EnumSet<Modifier> modifiers, EnumSet<Modifier> mods) { + if(mods == null) + return; + for(Modifier m : mods) + if (modifiers.contains(m)) + addProblem("Duplicated modifier"); + for(Modifier m : mods) + modifiers.add(m); + } + + /** + * Return the list of tokens that have been encountered while parsing code using + * this parser. + * + * @return a list of tokens + */ + public List<Token> getTokens() { + return token_source.getTokens(); + } + + public CommentsCollection getCommentsCollection() { + return token_source.getCommentsCollection(); + } + + private void addProblem(String message) { + problems.add(new Problem(message + ": \"" + token.image, Optional.of(tokenRange()), Optional.empty())); + } + + private Expression generateLambda(Expression ret, Statement lambdaBody) { + if (ret instanceof EnclosedExpr) { + Expression inner = ((EnclosedExpr) ret).getInner(); + if (inner != null && inner instanceof NameExpr) { + VariableDeclaratorId id = new VariableDeclaratorId(inner.getRange(), ((NameExpr)inner).getName(), null); + List<Parameter> params = add(null, new Parameter(ret.getRange(), EnumSet.noneOf(Modifier.class), null, new UnknownType(), null, false, id)); + ret = new LambdaExpr(range(ret.getBegin(), lambdaBody.getEnd()), params, lambdaBody, true); + } else { + ret = new LambdaExpr(range(ret.getBegin(), lambdaBody.getEnd()), null, lambdaBody, true); + } + } else if (ret instanceof NameExpr) { + VariableDeclaratorId id = new VariableDeclaratorId(ret.getRange(), ((NameExpr)ret).getName(), null); + List<Parameter> params = add(null, new Parameter(ret.getRange(), EnumSet.noneOf(Modifier.class), null, new UnknownType(), null, false, id)); + ret = new LambdaExpr(ret.getRange(), params, lambdaBody, false); + } else if (ret instanceof LambdaExpr) { + ((LambdaExpr) ret).setBody(lambdaBody); + ret.setEnd(lambdaBody.getEnd()); + } else if (ret instanceof CastExpr) { + CastExpr castExpr = (CastExpr)ret; + Expression inner = generateLambda(castExpr.getExpr(), lambdaBody); + castExpr.setExpr(inner); + } else { + addProblem("Failed to parse lambda expression! Please create an issue at https://github.com/javaparser/javaparser/issues"); + } + return ret; + } + + private ArrayCreationExpr juggleArrayCreation(Range range, Type type, List<Expression> dimensions, List<List<AnnotationExpr>> arrayAnnotations, ArrayInitializerExpr arrayInitializerExpr) { + List<ArrayCreationLevel> levels = new ArrayList<ArrayCreationLevel>(); + + for(int i = 0; i < arrayAnnotations.size(); i++){ + levels.add(new ArrayCreationLevel(range, dimensions.get(i), arrayAnnotations.get(i))); + } + return new ArrayCreationExpr(range, type, levels, arrayInitializerExpr); + } + + + 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 static class RangedList<T> { + Range range = Range.UNKNOWN; + List<T> list; + RangedList(List<T> list) { + this.list = list; + } + void beginAt(Position begin) { + range=range.withBegin(begin); + } + void endAt(Position end) { + range=range.withEnd(end); + } + void add(T t) { + if (list == null) { + list = new LinkedList<T>(); + } + list.add(t); + } + } + + private Position tokenBegin() { + return pos(token.beginLine,token.beginColumn); + } + + private Position tokenEnd() { + return pos(token.endLine,token.endColumn); + } + + private Range tokenRange() { + return tokenRange(token); + } + + public static Range tokenRange(Token token) { + return range(token.beginLine, token.beginColumn, token.endLine, token.endColumn); + } + +/***************************************** + * THE JAVA LANGUAGE GRAMMAR STARTS HERE * + *****************************************/ + +/* + * Program structuring syntax follows. + */ + final public +CompilationUnit CompilationUnit() {PackageDeclaration pakage = null; + List<ImportDeclaration> imports = null; + ImportDeclaration in = null; + List<TypeDeclaration<?>> types = null; + TypeDeclaration tn = null; + Position begin = INVALID; + if (jj_2_1(2147483647)) { + pakage = PackageDeclaration(); +begin = begin.orIfInvalid(pakage.getBegin()); + } else { + ; + } + label_1: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IMPORT: + case SEMICOLON:{ + ; + break; + } + default: + jj_la1[0] = jj_gen; + break label_1; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IMPORT:{ + in = ImportDeclaration(); +begin = begin.orIfInvalid(in.getBegin()); imports = add(imports, in); + break; + } + case SEMICOLON:{ + in = EmptyImportDeclaration(); +begin = begin.orIfInvalid(in.getBegin()); imports = add(imports, in); + break; + } + default: + jj_la1[1] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():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[2] = jj_gen; + break label_2; + } + tn = TypeDeclaration(); +begin = begin.orIfInvalid(tn.getBegin()); types = add(types, tn); + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case 0:{ + jj_consume_token(0); + break; + } + case 156:{ + jj_consume_token(156); + break; + } + default: + jj_la1[3] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return new CompilationUnit(begin.invalid() ? Range.UNKNOWN : range(begin, tokenEnd()), pakage, imports, types); + } + + final public ImportDeclaration EmptyImportDeclaration() {Position begin; + jj_consume_token(SEMICOLON); +begin = tokenBegin(); +return ImportDeclaration.createEmptyDeclaration(range(begin, tokenEnd())); + } + + final public PackageDeclaration PackageDeclaration() {List<AnnotationExpr> annotations = null; + NameExpr name; + Position begin; + annotations = Annotations(); + jj_consume_token(PACKAGE); +begin = tokenBegin(); + name = Name(); + jj_consume_token(SEMICOLON); +return new PackageDeclaration(range(begin, tokenEnd()), annotations, name); + } + + final public ImportDeclaration ImportDeclaration() {NameExpr name; + boolean isStatic = false; + boolean isAsterisk = false; + Position begin; + jj_consume_token(IMPORT); +begin = tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():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_f():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); +return new ImportDeclaration(range(begin, tokenEnd()),name, isStatic, isAsterisk); + } + +/* + * 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 +ModifierHolder Modifiers() {Position begin = INVALID; + EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class); + List<AnnotationExpr> annotations = null; + AnnotationExpr ann; + label_3: + while (true) { + if (jj_2_2(2)) { + ; + } else { + break label_3; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PUBLIC:{ + jj_consume_token(PUBLIC); +addModifier(modifiers, Modifier.PUBLIC); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case STATIC:{ + jj_consume_token(STATIC); +addModifier(modifiers, Modifier.STATIC); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case PROTECTED:{ + jj_consume_token(PROTECTED); +addModifier(modifiers, Modifier.PROTECTED); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case PRIVATE:{ + jj_consume_token(PRIVATE); +addModifier(modifiers, Modifier.PRIVATE); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case FINAL:{ + jj_consume_token(FINAL); +addModifier(modifiers, Modifier.FINAL); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case ABSTRACT:{ + jj_consume_token(ABSTRACT); +addModifier(modifiers, Modifier.ABSTRACT); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case SYNCHRONIZED:{ + jj_consume_token(SYNCHRONIZED); +addModifier(modifiers, Modifier.SYNCHRONIZED); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case NATIVE:{ + jj_consume_token(NATIVE); +addModifier(modifiers, Modifier.NATIVE); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case TRANSIENT:{ + jj_consume_token(TRANSIENT); +addModifier(modifiers, Modifier.TRANSIENT); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case VOLATILE:{ + jj_consume_token(VOLATILE); +addModifier(modifiers, Modifier.VOLATILE); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case STRICTFP:{ + jj_consume_token(STRICTFP); +addModifier(modifiers, Modifier.STRICTFP); begin = begin.orIfInvalid(tokenBegin()); + break; + } + case AT:{ + ann = Annotation(); +annotations = add(annotations, ann); begin = begin.orIfInvalid(ann.getBegin()); + break; + } + default: + jj_la1[6] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return new ModifierHolder(begin, modifiers, annotations); + } + +/* + * Declaration syntax follows. + */ + final public TypeDeclaration TypeDeclaration() {ModifierHolder modifier; + TypeDeclaration ret; + + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SEMICOLON:{ + jj_consume_token(SEMICOLON); +ret = new EmptyTypeDeclaration(tokenRange()); + 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_f():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(); + } +return ret; + } + + final public ClassOrInterfaceDeclaration ClassOrInterfaceDeclaration(ModifierHolder modifier) {boolean isInterface = false; + NameExpr name; + RangedList<TypeParameter> typePar = new RangedList<TypeParameter>(null); + List<ClassOrInterfaceType> extList = null; + List<ClassOrInterfaceType> impList = null; + List<BodyDeclaration<?>> members; + Position begin = modifier.begin; + switch ((jj_ntk==-1)?jj_ntk_f():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(); + } +begin = begin.orIfInvalid(tokenBegin()); + name = Name(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typePar = TypeParameters(); + break; + } + default: + jj_la1[10] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case EXTENDS:{ + extList = ExtendsList(isInterface); + break; + } + default: + jj_la1[11] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IMPLEMENTS:{ + impList = ImplementsList(isInterface); + break; + } + default: + jj_la1[12] = jj_gen; + ; + } + members = ClassOrInterfaceBody(isInterface); +ClassOrInterfaceDeclaration tmp = new ClassOrInterfaceDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, isInterface, null, typePar.list, extList, impList, members); + tmp.setNameExpr(name); + return tmp; + } + + final public List<ClassOrInterfaceType> ExtendsList(boolean isInterface) {boolean extendsMoreThanOne = false; + List<ClassOrInterfaceType> ret = new LinkedList<ClassOrInterfaceType>(); + ClassOrInterfaceType cit; + jj_consume_token(EXTENDS); + cit = AnnotatedClassOrInterfaceType(); +ret.add(cit); + label_4: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[13] = jj_gen; + break label_4; + } + jj_consume_token(COMMA); + cit = AnnotatedClassOrInterfaceType(); +ret.add(cit); extendsMoreThanOne = true; + } +if (extendsMoreThanOne && !isInterface) + addProblem("A class cannot extend more than one other class"); +return ret; + } + + final public List<ClassOrInterfaceType> ImplementsList(boolean isInterface) {List<ClassOrInterfaceType> ret = new LinkedList<ClassOrInterfaceType>(); + ClassOrInterfaceType cit; + jj_consume_token(IMPLEMENTS); + cit = AnnotatedClassOrInterfaceType(); +ret.add(cit); + label_5: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[14] = jj_gen; + break label_5; + } + jj_consume_token(COMMA); + cit = AnnotatedClassOrInterfaceType(); +ret.add(cit); + } +if (isInterface) + addProblem("An interface cannot implement other interfaces"); +return ret; + } + + final public EnumDeclaration EnumDeclaration(ModifierHolder modifier) {NameExpr name; + List<ClassOrInterfaceType> impList = null; + EnumConstantDeclaration entry; + List<EnumConstantDeclaration> entries = null; + BodyDeclaration<?> member; + List<BodyDeclaration<?>> members = null; + Position begin = modifier.begin; + jj_consume_token(ENUM); +begin = begin.orIfInvalid(tokenBegin()); + name = Name(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IMPLEMENTS:{ + impList = ImplementsList(false); + break; + } + default: + jj_la1[15] = jj_gen; + ; + } + jj_consume_token(LBRACE); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER: + case AT:{ +entries = new LinkedList<EnumConstantDeclaration>(); + entry = EnumConstantDeclaration(); +entries.add(entry); + label_6: + while (true) { + if (jj_2_3(2)) { + ; + } else { + break label_6; + } + jj_consume_token(COMMA); + entry = EnumConstantDeclaration(); +entries.add(entry); + } + break; + } + default: + jj_la1[16] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + jj_consume_token(COMMA); + break; + } + default: + jj_la1[17] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SEMICOLON:{ + jj_consume_token(SEMICOLON); + label_7: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():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[18] = jj_gen; + break label_7; + } + member = ClassOrInterfaceBodyDeclaration(false); +members = add(members, member); + } + break; + } + default: + jj_la1[19] = jj_gen; + ; + } + jj_consume_token(RBRACE); +EnumDeclaration tmp = new EnumDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, null, impList, entries, members); + tmp.setNameExpr(name); + return tmp; + } + + final public EnumConstantDeclaration EnumConstantDeclaration() {List<AnnotationExpr> annotations = null; + AnnotationExpr ann; + String name; + List<Expression> args = null; + List<BodyDeclaration<?>> classBody = null; + Position begin = INVALID; + + label_8: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case AT:{ + ; + break; + } + default: + jj_la1[20] = jj_gen; + break label_8; + } + ann = Annotation(); +annotations = add(annotations, ann); begin = begin.orIfInvalid(ann.getBegin()); + } + jj_consume_token(IDENTIFIER); +name = token.image; begin = begin.orIfInvalid(tokenBegin()); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LPAREN:{ + args = Arguments(); + break; + } + default: + jj_la1[21] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACE:{ + classBody = ClassOrInterfaceBody(false); + break; + } + default: + jj_la1[22] = jj_gen; + ; + } +return new EnumConstantDeclaration(range(begin, tokenEnd()), annotations, name, args, classBody); + } + +/** + * If the list inside the returned RangedList is null, there are no brackets. + * If it is empty, there are brackets, but nothing is in them <>. + * The normal case is that it contains TypeParameters, like <A, B, C>. + */ + final public RangedList<TypeParameter> TypeParameters() {RangedList<TypeParameter> ret = new RangedList<TypeParameter>(new LinkedList<TypeParameter>()); + TypeParameter tp; + List<AnnotationExpr> annotations = null; + jj_consume_token(LT); +ret.beginAt(tokenBegin()); + annotations = Annotations(); + tp = TypeParameter(); +ret.add(tp); tp.setAnnotations(annotations); annotations = null; + label_9: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[23] = jj_gen; + break label_9; + } + jj_consume_token(COMMA); + annotations = Annotations(); + tp = TypeParameter(); +ret.add(tp); tp.setAnnotations(annotations); annotations = null; + } + jj_consume_token(GT); +ret.endAt(tokenEnd()); +return ret; + } + + final public TypeParameter TypeParameter() {String name; + List<ClassOrInterfaceType> typeBound = null; + Position begin; + jj_consume_token(IDENTIFIER); +name = token.image; begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case EXTENDS:{ + typeBound = TypeBound(); + break; + } + default: + jj_la1[24] = jj_gen; + ; + } +return new TypeParameter(range(begin, tokenEnd()),name, typeBound); + } + + final public List<ClassOrInterfaceType> TypeBound() {List<ClassOrInterfaceType> ret = new LinkedList<ClassOrInterfaceType>(); + ClassOrInterfaceType cit; + jj_consume_token(EXTENDS); + cit = AnnotatedClassOrInterfaceType(); +ret.add(cit); + label_10: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BIT_AND:{ + ; + break; + } + default: + jj_la1[25] = jj_gen; + break label_10; + } + jj_consume_token(BIT_AND); + cit = AnnotatedClassOrInterfaceType(); +ret.add(cit); + } +return ret; + } + + final public List<BodyDeclaration<?>> ClassOrInterfaceBody(boolean isInterface) {List<BodyDeclaration<?>> ret = new LinkedList<BodyDeclaration<?>>(); + BodyDeclaration member; + jj_consume_token(LBRACE); + label_11: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():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[26] = jj_gen; + break label_11; + } + member = ClassOrInterfaceBodyDeclaration(isInterface); +ret.add(member); + } + jj_consume_token(RBRACE); +return ret; + } + + final public BodyDeclaration<?> ClassOrInterfaceBodyDeclaration(boolean isInterface) {ModifierHolder modifier; + ModifierHolder modifier2 = null; + EnumSet<Modifier> aux = null; + BodyDeclaration<?> ret; + boolean isDefault = false; + + if (jj_2_6(2)) { + ret = InitializerDeclaration(); +if (isInterface) + addProblem("An interface cannot have initializers"); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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_f():jj_ntk) { + case _DEFAULT:{ + jj_consume_token(_DEFAULT); + modifier2 = Modifiers(); +if(!isInterface) + { + addProblem("A class cannot have default members"); + } + isDefault = true; + break; + } + default: + jj_la1[27] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():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[28] = 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_f():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) + { + addProblem("\"default\" methods must have a body"); + } + ((MethodDeclaration)ret).setDefault(isDefault); + if(modifier2!= null) + { + aux = modifier2.modifiers; + } + addMultipleModifier(modifier.modifiers, aux); + ((MethodDeclaration)ret).setModifiers(modifier.modifiers); + break; + } + default: + jj_la1[29] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } +if(isDefault && ! (ret instanceof MethodDeclaration)) + { + addProblem("Only methods can have the keyword \"default\"."); + } + break; + } + case SEMICOLON:{ + jj_consume_token(SEMICOLON); +ret = new EmptyMemberDeclaration(tokenRange()); + break; + } + default: + jj_la1[30] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public FieldDeclaration FieldDeclaration(ModifierHolder modifier) {Type type; + List<VariableDeclarator> variables = new LinkedList<VariableDeclarator>(); + VariableDeclarator val; + // Modifiers are already matched in the caller + type = Type(); + val = VariableDeclarator(); +variables.add(val); + label_12: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[31] = jj_gen; + break label_12; + } + jj_consume_token(COMMA); + val = VariableDeclarator(); +variables.add(val); + } + jj_consume_token(SEMICOLON); +Position begin = modifier.begin.orIfInvalid(type.getBegin()); + Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type); + return new FieldDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, typeListPair.a, variables, typeListPair.b); + } + + final public VariableDeclarator VariableDeclarator() {VariableDeclaratorId id; + Expression init = null; + id = VariableDeclaratorId(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ASSIGN:{ + jj_consume_token(ASSIGN); + init = VariableInitializer(); + break; + } + default: + jj_la1[32] = jj_gen; + ; + } +return new VariableDeclarator(range(id.getBegin(), tokenEnd()), id, init); + } + + final public VariableDeclaratorId VariableDeclaratorId() {String name; + Position begin; + ArrayBracketPair arrayBracketPair; + List<ArrayBracketPair> arrayBracketPairs = null; + jj_consume_token(IDENTIFIER); +name = token.image; begin=tokenBegin(); + label_13: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACKET: + case AT:{ + ; + break; + } + default: + jj_la1[33] = jj_gen; + break label_13; + } + arrayBracketPair = ArrayBracketPair(); +arrayBracketPairs=add(arrayBracketPairs, arrayBracketPair); + } +return new VariableDeclaratorId(range(begin, tokenEnd()),name, arrayBracketPairs); + } + + final public Expression VariableInitializer() {Expression ret; + switch ((jj_ntk==-1)?jj_ntk_f():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[34] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public ArrayInitializerExpr ArrayInitializer() {List<Expression> values = null; + Expression val; + Position begin; + jj_consume_token(LBRACE); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():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_14: + while (true) { + if (jj_2_7(2)) { + ; + } else { + break label_14; + } + jj_consume_token(COMMA); + val = VariableInitializer(); +values = add(values, val); + } + break; + } + default: + jj_la1[35] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + jj_consume_token(COMMA); + break; + } + default: + jj_la1[36] = jj_gen; + ; + } + jj_consume_token(RBRACE); +return new ArrayInitializerExpr(range(begin, tokenEnd()), values); + } + + final public MethodDeclaration MethodDeclaration(ModifierHolder modifier) {RangedList<TypeParameter> typeParameters = new RangedList<TypeParameter>(null); + Type type; + NameExpr name; + List<Parameter> parameters; + ArrayBracketPair arrayBracketPair; + List<ArrayBracketPair> arrayBracketPairs = null; + List<ReferenceType> throws_ = null; + BlockStmt block = null; + Position begin = modifier.begin; + ReferenceType throwType; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeParameters = TypeParameters(); +begin = begin.orIfInvalid(typeParameters.range.begin); + break; + } + default: + jj_la1[37] = jj_gen; + ; + } + type = ResultType(); +begin = begin.orIfInvalid(type.getBegin()); + name = Name(); + parameters = FormalParameters(); + label_15: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACKET: + case AT:{ + ; + break; + } + default: + jj_la1[38] = jj_gen; + break label_15; + } + arrayBracketPair = ArrayBracketPair(); +arrayBracketPairs=add(arrayBracketPairs, arrayBracketPair); + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case THROWS:{ + jj_consume_token(THROWS); + throwType = ReferenceTypeWithAnnotations(); +throws_ = add(throws_, throwType); + label_16: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[39] = jj_gen; + break label_16; + } + jj_consume_token(COMMA); + throwType = ReferenceTypeWithAnnotations(); +throws_ = add(throws_, throwType); + } + break; + } + default: + jj_la1[40] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACE:{ + block = Block(); + break; + } + case SEMICOLON:{ + jj_consume_token(SEMICOLON); + break; + } + default: + jj_la1[41] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type); + return new MethodDeclaration(range(begin, pos(token.endLine, token.endColumn)), modifier.modifiers, modifier.annotations, typeParameters.list, typeListPair.a, typeListPair.b, name, parameters, arrayBracketPairs, throws_, block); + } + + final public ReferenceType ReferenceTypeWithAnnotations() {List<AnnotationExpr> annotations; + ReferenceType type; + annotations = Annotations(); + type = ReferenceType(); +if(annotations != null){ + if (type.getAnnotations() != null) { + type.getAnnotations().addAll(annotations); + } else { + type.setAnnotations(annotations); + } + } + return type; + } + + final public List<Parameter> FormalParameters() {List<Parameter> ret = null; + Parameter par; + jj_consume_token(LPAREN); + switch ((jj_ntk==-1)?jj_ntk_f():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_17: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[42] = jj_gen; + break label_17; + } + jj_consume_token(COMMA); + par = FormalParameter(); +ret = add(ret, par); + } + break; + } + default: + jj_la1[43] = jj_gen; + ; + } + jj_consume_token(RPAREN); +return ret; + } + + final public List<Parameter> FormalLambdaParameters() {List<Parameter> ret = null; + Parameter par; + jj_consume_token(COMMA); + par = FormalParameter(); +ret = add(ret, par); + label_18: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[44] = jj_gen; + break label_18; + } + jj_consume_token(COMMA); + par = FormalParameter(); +ret = add(ret, par); + } +return ret; + } + + final public List<Parameter> InferredLambdaParameters() {List<Parameter> ret = null; + VariableDeclaratorId id; + jj_consume_token(COMMA); + id = VariableDeclaratorId(); +ret = add(ret, new Parameter(range(id.getBegin(), id.getEnd()), EnumSet.noneOf(Modifier.class), null, new UnknownType(), null, false, id)); + label_19: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[45] = jj_gen; + break label_19; + } + jj_consume_token(COMMA); + id = VariableDeclaratorId(); +ret = add(ret, new Parameter(range(id.getBegin(), id.getEnd()), EnumSet.noneOf(Modifier.class), null, new UnknownType(), null, false, id)); + } +return ret; + } + + final public Parameter FormalParameter() {ModifierHolder modifier; + Type type; + boolean isVarArg = false; + VariableDeclaratorId id; + modifier = Modifiers(); + type = Type(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ELLIPSIS:{ + jj_consume_token(ELLIPSIS); +isVarArg = true; + break; + } + default: + jj_la1[46] = jj_gen; + ; + } + id = VariableDeclaratorId(); +Position begin = modifier.begin.orIfInvalid(type.getBegin()); + Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type); + return new Parameter(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, typeListPair.a, typeListPair.b, isVarArg, id); + } + + final public ConstructorDeclaration ConstructorDeclaration(ModifierHolder modifier) {RangedList<TypeParameter> typeParameters = new RangedList<TypeParameter>(null); + NameExpr name; + List<Parameter> parameters; + List<ReferenceType> throws_ = null; + ExplicitConstructorInvocationStmt exConsInv = null; + List<Statement> stmts; + Position begin = modifier.begin; + Position blockBegin = INVALID; + ReferenceType throwType; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeParameters = TypeParameters(); +begin = begin.orIfInvalid(typeParameters.range.begin); + break; + } + default: + jj_la1[47] = jj_gen; + ; + } + // Modifiers matched in the caller + name = SimpleName(); +begin = begin.orIfInvalid(typeParameters.range.begin); + parameters = FormalParameters(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case THROWS:{ + jj_consume_token(THROWS); + throwType = ReferenceTypeWithAnnotations(); +throws_ = add(throws_, throwType); + label_20: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[48] = jj_gen; + break label_20; + } + jj_consume_token(COMMA); + throwType = ReferenceTypeWithAnnotations(); +throws_ = add(throws_, throwType); + } + break; + } + default: + jj_la1[49] = jj_gen; + ; + } + jj_consume_token(LBRACE); +blockBegin=tokenBegin(); + 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(range(begin, pos(token.endLine, token.endColumn)), modifier.modifiers, modifier.annotations, typeParameters.list, null, parameters, throws_, new BlockStmt(range(blockBegin, tokenEnd()), stmts)); + tmp.setNameExpr(name); + return tmp; + } + + final public ExplicitConstructorInvocationStmt ExplicitConstructorInvocation() {boolean isThis = false; + List<Expression> args; + Expression expr = null; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + Position begin = INVALID; + if (jj_2_10(2147483647)) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); +begin=typeArgs.range.begin; + break; + } + default: + jj_la1[50] = jj_gen; + ; + } + jj_consume_token(THIS); +begin = begin.orIfInvalid(tokenBegin()); isThis = true; + args = Arguments(); + jj_consume_token(SEMICOLON); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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:{ + if (jj_2_9(2147483647)) { + expr = PrimaryExpressionWithoutSuperSuffix(); + jj_consume_token(DOT); +begin=expr.getBegin(); + } else { + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); +begin = begin.orIfInvalid(typeArgs.range.begin); + break; + } + default: + jj_la1[51] = jj_gen; + ; + } + jj_consume_token(SUPER); +begin = begin.orIfInvalid(tokenBegin()); + args = Arguments(); + jj_consume_token(SEMICOLON); + break; + } + default: + jj_la1[52] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return new ExplicitConstructorInvocationStmt(range(begin, tokenEnd()),typeArgs.list, isThis, expr, args); + } + + final public List<Statement> Statements() {List<Statement> ret = null; + Statement stmt; + label_21: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():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[53] = jj_gen; + break label_21; + } + stmt = BlockStatement(); +ret = add(ret, stmt); + } +return ret; + } + + final public InitializerDeclaration InitializerDeclaration() {BlockStmt block; + Position begin = INVALID; + boolean isStatic = false; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case STATIC:{ + jj_consume_token(STATIC); +isStatic = true; begin=tokenBegin(); + break; + } + default: + jj_la1[54] = jj_gen; + ; + } + block = Block(); +begin = begin.orIfInvalid(block.getBegin()); +return new InitializerDeclaration(range(begin, tokenEnd()), isStatic, block); + } + +/* + * Type, name and expression syntax follows. + */ + final public +Type Type() {Type ret; + if (jj_2_11(2)) { + ret = ReferenceType(); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT:{ + ret = PrimitiveType(); + break; + } + default: + jj_la1[55] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public ReferenceType ReferenceType() {Type type; + ArrayBracketPair arrayBracketPair; + List<ArrayBracketPair> arrayBracketPairs = null; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT:{ + type = PrimitiveType(); + label_22: + while (true) { + arrayBracketPair = ArrayBracketPair(); +arrayBracketPairs=add(arrayBracketPairs, arrayBracketPair); + if (jj_2_12(2)) { + ; + } else { + break label_22; + } + } + break; + } + case IDENTIFIER:{ + type = ClassOrInterfaceType(); + label_23: + while (true) { + if (jj_2_13(2)) { + ; + } else { + break label_23; + } + arrayBracketPair = ArrayBracketPair(); +arrayBracketPairs=add(arrayBracketPairs, arrayBracketPair); + } + break; + } + default: + jj_la1[56] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return (ReferenceType)wrapInArrayTypes(type, arrayBracketPairs); + } + + final public ArrayBracketPair ArrayBracketPair() {List<AnnotationExpr> annotations = null; + Position begin = INVALID; + annotations = Annotations(); + jj_consume_token(LBRACKET); +begin = begin.orIfInvalid(tokenBegin()); + jj_consume_token(RBRACKET); +return new ArrayBracketPair(range(begin, tokenEnd()), annotations); + } + + final public IntersectionType IntersectionType() {Position begin; + ReferenceType elementType; + List<ReferenceType> elements = null; + elementType = ReferenceType(); +begin=elementType.getBegin(); elements = add(elements, elementType); + jj_consume_token(BIT_AND); + label_24: + while (true) { + elementType = ReferenceType(); +elements = add(elements, elementType); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER:{ + ; + break; + } + default: + jj_la1[57] = jj_gen; + break label_24; + } + } +return new IntersectionType(range(begin, tokenEnd()), elements); + } + + final public ClassOrInterfaceType AnnotatedClassOrInterfaceType() {List<AnnotationExpr> annotations; + ClassOrInterfaceType cit; + annotations = Annotations(); + cit = ClassOrInterfaceType(); +if (cit.getScope()!=null) { + cit.getScope().setAnnotations(annotations); + } else { + cit.setAnnotations(annotations); + } + return cit; + } + + final public ClassOrInterfaceType ClassOrInterfaceType() {ClassOrInterfaceType ret; + String name; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + Position begin; + List<AnnotationExpr> annotations = null; + jj_consume_token(IDENTIFIER); +begin=tokenBegin(); +name = token.image; + if (jj_2_14(2)) { + typeArgs = TypeArguments(); + } else { + ; + } +ret = new ClassOrInterfaceType(range(begin, tokenEnd()),null, name, typeArgs.list); + label_25: + while (true) { + if (jj_2_15(2)) { + ; + } else { + break label_25; + } + jj_consume_token(DOT); + annotations = Annotations(); + jj_consume_token(IDENTIFIER); +name = token.image; + if (jj_2_16(2)) { + typeArgs = TypeArguments(); + } else { + ; + } +ret = new ClassOrInterfaceType(range(begin, tokenEnd()),ret, name, typeArgs.list); + ret.setAnnotations(annotations); + annotations = null; + } +return ret; + } + + final public RangedList<Type<?>> TypeArguments() {RangedList<Type<?>> ret = new RangedList<Type<?>>(new LinkedList<Type<?>>()); + Type type; + jj_consume_token(LT); +ret.beginAt(tokenBegin()); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER: + case AT: + case HOOK:{ + type = TypeArgument(); +ret.add(type); + label_26: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[58] = jj_gen; + break label_26; + } + jj_consume_token(COMMA); + type = TypeArgument(); +ret.add(type); + } + break; + } + default: + jj_la1[59] = jj_gen; + ; + } + jj_consume_token(GT); +ret.endAt(tokenEnd()); +return ret; + } + + final public Type TypeArgument() {Type ret; + List<AnnotationExpr> annotations = null; + annotations = Annotations(); + switch ((jj_ntk==-1)?jj_ntk_f():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[60] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +ret.setAnnotations(annotations); return ret; + } + + final public WildcardType Wildcard() {ReferenceType ext = null; + ReferenceType sup = null; + Position begin; + List<AnnotationExpr> annotations = null; + jj_consume_token(HOOK); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case EXTENDS: + case SUPER:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case EXTENDS:{ + jj_consume_token(EXTENDS); + annotations = Annotations(); + ext = ReferenceType(); +ext.setAnnotations(annotations); + break; + } + case SUPER:{ + jj_consume_token(SUPER); + annotations = Annotations(); + sup = ReferenceType(); +sup.setAnnotations(annotations); + break; + } + default: + jj_la1[61] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + } + default: + jj_la1[62] = jj_gen; + ; + } +return new WildcardType(range(begin, tokenEnd()),ext, sup); + } + + final public PrimitiveType PrimitiveType() {PrimitiveType ret; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN:{ + jj_consume_token(BOOLEAN); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Boolean); + break; + } + case CHAR:{ + jj_consume_token(CHAR); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Char); + break; + } + case BYTE:{ + jj_consume_token(BYTE); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Byte); + break; + } + case SHORT:{ + jj_consume_token(SHORT); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Short); + break; + } + case INT:{ + jj_consume_token(INT); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Int); + break; + } + case LONG:{ + jj_consume_token(LONG); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Long); + break; + } + case FLOAT:{ + jj_consume_token(FLOAT); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Float); + break; + } + case DOUBLE:{ + jj_consume_token(DOUBLE); +ret = new PrimitiveType(tokenRange(), PrimitiveType.Primitive.Double); + break; + } + default: + jj_la1[63] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Type ResultType() {Type ret; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case VOID:{ + jj_consume_token(VOID); +ret = new VoidType(tokenRange()); + 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[64] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public NameExpr Name() {NameExpr ret; + jj_consume_token(IDENTIFIER); +ret = new NameExpr(tokenRange(), token.image); + label_27: + while (true) { + if (jj_2_17(2)) { + ; + } else { + break label_27; + } + jj_consume_token(DOT); + jj_consume_token(IDENTIFIER); +ret = new QualifiedNameExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, token.image); + } +return ret; + } + + final public NameExpr SimpleName() {NameExpr ret; + jj_consume_token(IDENTIFIER); +ret = new NameExpr(tokenRange(), token.image); +return ret; + } + +/* + * Expression syntax follows. + */ + final public +Expression Expression() {Expression ret; + AssignExpr.Operator op; + Expression value; + Statement lambdaBody = null; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + ret = ConditionalExpression(); + switch ((jj_ntk==-1)?jj_ntk_f():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(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, value, op); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ARROW:{ + jj_consume_token(ARROW); + lambdaBody = LambdaBody(); +if (ret instanceof CastExpr) + { + ret = generateLambda(ret, lambdaBody); + } + 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_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + break; + } + default: + jj_la1[65] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + jj_consume_token(IDENTIFIER); + break; + } + case NEW:{ + jj_consume_token(NEW); + break; + } + default: + jj_la1[66] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +ret = new MethodReferenceExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, typeArgs.list, token.image); + break; + } + default: + jj_la1[67] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + } + default: + jj_la1[68] = jj_gen; + ; + } +return ret; + } + + final public AssignExpr.Operator AssignmentOperator() {AssignExpr.Operator ret; + switch ((jj_ntk==-1)?jj_ntk_f():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[69] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Expression ConditionalExpression() {Expression ret; + Expression left; + Expression right; + ret = ConditionalOrExpression(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case HOOK:{ + jj_consume_token(HOOK); + left = Expression(); + jj_consume_token(COLON); + right = ConditionalExpression(); +ret = new ConditionalExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, left, right); + break; + } + default: + jj_la1[70] = jj_gen; + ; + } +return ret; + } + + final public Expression ConditionalOrExpression() {Expression ret; + Expression right; + ret = ConditionalAndExpression(); + label_28: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SC_OR:{ + ; + break; + } + default: + jj_la1[71] = jj_gen; + break label_28; + } + jj_consume_token(SC_OR); + right = ConditionalAndExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, BinaryExpr.Operator.or); + } +return ret; + } + + final public Expression ConditionalAndExpression() {Expression ret; + Expression right; + ret = InclusiveOrExpression(); + label_29: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SC_AND:{ + ; + break; + } + default: + jj_la1[72] = jj_gen; + break label_29; + } + jj_consume_token(SC_AND); + right = InclusiveOrExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, BinaryExpr.Operator.and); + } +return ret; + } + + final public Expression InclusiveOrExpression() {Expression ret; + Expression right; + ret = ExclusiveOrExpression(); + label_30: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BIT_OR:{ + ; + break; + } + default: + jj_la1[73] = jj_gen; + break label_30; + } + jj_consume_token(BIT_OR); + right = ExclusiveOrExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, BinaryExpr.Operator.binOr); + } +return ret; + } + + final public Expression ExclusiveOrExpression() {Expression ret; + Expression right; + ret = AndExpression(); + label_31: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case XOR:{ + ; + break; + } + default: + jj_la1[74] = jj_gen; + break label_31; + } + jj_consume_token(XOR); + right = AndExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, BinaryExpr.Operator.xor); + } +return ret; + } + + final public Expression AndExpression() {Expression ret; + Expression right; + ret = EqualityExpression(); + label_32: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BIT_AND:{ + ; + break; + } + default: + jj_la1[75] = jj_gen; + break label_32; + } + jj_consume_token(BIT_AND); + right = EqualityExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, BinaryExpr.Operator.binAnd); + } +return ret; + } + + final public Expression EqualityExpression() {Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = InstanceOfExpression(); + label_33: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case EQ: + case NE:{ + ; + break; + } + default: + jj_la1[76] = jj_gen; + break label_33; + } + switch ((jj_ntk==-1)?jj_ntk_f():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[77] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = InstanceOfExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, op); + } +return ret; + } + + final public Expression InstanceOfExpression() {Expression ret; + Type type; + ret = RelationalExpression(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case INSTANCEOF:{ + jj_consume_token(INSTANCEOF); + type = Type(); +ret = new InstanceOfExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, type); + break; + } + default: + jj_la1[78] = jj_gen; + ; + } +return ret; + } + + final public Expression RelationalExpression() {Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = ShiftExpression(); + label_34: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT: + case LE: + case GE: + case GT:{ + ; + break; + } + default: + jj_la1[79] = jj_gen; + break label_34; + } + switch ((jj_ntk==-1)?jj_ntk_f():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[80] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = ShiftExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, op); + } +return ret; + } + + final public Expression ShiftExpression() {Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = AdditiveExpression(); + label_35: + while (true) { + if (jj_2_19(1)) { + ; + } else { + break label_35; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LSHIFT:{ + jj_consume_token(LSHIFT); +op = BinaryExpr.Operator.lShift; + break; + } + default: + jj_la1[81] = 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(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, op); + } +return ret; + } + + final public Expression AdditiveExpression() {Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = MultiplicativeExpression(); + label_36: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PLUS: + case MINUS:{ + ; + break; + } + default: + jj_la1[82] = jj_gen; + break label_36; + } + switch ((jj_ntk==-1)?jj_ntk_f():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[83] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = MultiplicativeExpression(); +ret = new BinaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, right, op); + } +return ret; + } + + final public Expression MultiplicativeExpression() {Expression ret; + Expression right; + BinaryExpr.Operator op; + ret = UnaryExpression(); + label_37: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case STAR: + case SLASH: + case REM:{ + ; + break; + } + default: + jj_la1[84] = jj_gen; + break label_37; + } + switch ((jj_ntk==-1)?jj_ntk_f():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[85] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + right = UnaryExpression(); +ret = new BinaryExpr(range(ret.getBegin(), tokenEnd()), ret, right, op); + } +return ret; + } + + final public Expression UnaryExpression() {Expression ret; + UnaryExpr.Operator op; + Position begin = INVALID; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case INCR:{ + ret = PreIncrementExpression(); + break; + } + case DECR:{ + ret = PreDecrementExpression(); + break; + } + case PLUS: + case MINUS:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case PLUS:{ + jj_consume_token(PLUS); +op = UnaryExpr.Operator.positive; begin=tokenBegin(); + break; + } + case MINUS:{ + jj_consume_token(MINUS); +op = UnaryExpr.Operator.negative; begin=tokenBegin(); + break; + } + default: + jj_la1[86] = 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(range(begin, tokenEnd())); + } else if (ret instanceof LongLiteralExpr && ((LongLiteralExpr)ret).isMinValue()) { + ret = new LongLiteralMinValueExpr(range(begin, tokenEnd())); + } else { + ret = new UnaryExpr(range(begin, tokenEnd()), ret, op); + } + } else { + ret = new UnaryExpr(range(begin, tokenEnd()), 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[87] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Expression PreIncrementExpression() {Expression ret; + Position begin = INVALID; + jj_consume_token(INCR); +begin=tokenBegin(); + ret = UnaryExpression(); +ret = new UnaryExpr(range(begin, tokenEnd()), ret, UnaryExpr.Operator.preIncrement); +return ret; + } + + final public Expression PreDecrementExpression() {Expression ret; + Position begin; + jj_consume_token(DECR); +begin=tokenBegin(); + ret = UnaryExpression(); +ret = new UnaryExpr(range(begin, tokenEnd()), ret, UnaryExpr.Operator.preDecrement); +return ret; + } + + final public Expression UnaryExpressionNotPlusMinus() {Expression ret; + UnaryExpr.Operator op; + Position begin = INVALID; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BANG: + case TILDE:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TILDE:{ + jj_consume_token(TILDE); +op = UnaryExpr.Operator.inverse; begin=tokenBegin(); + break; + } + case BANG:{ + jj_consume_token(BANG); +op = UnaryExpr.Operator.not; begin=tokenBegin(); + break; + } + default: + jj_la1[88] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + ret = UnaryExpression(); +ret = new UnaryExpr(range(begin, tokenEnd()), ret, op); + break; + } + default: + jj_la1[89] = jj_gen; + if (jj_2_22(2147483647)) { + ret = CastExpression(); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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[90] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } +return ret; + } + + final public Expression PostfixExpression() {Expression ret; + UnaryExpr.Operator op; + ret = PrimaryExpression(); + if (jj_2_23(2)) { + switch ((jj_ntk==-1)?jj_ntk_f():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[91] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +ret = new UnaryExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, op); + } else { + ; + } +return ret; + } + + final public Expression CastExpression() {Expression ret; + ReferenceType referenceType; + PrimitiveType primitiveType; + Position begin = INVALID; + List<AnnotationExpr> annotations = null; + List<ReferenceType> typesOfMultiCast = null; + jj_consume_token(LPAREN); +begin=tokenBegin(); + annotations = Annotations(); + if (jj_2_24(2)) { + primitiveType = PrimitiveType(); + jj_consume_token(RPAREN); + ret = UnaryExpression(); +primitiveType.setAnnotations(annotations); ret = new CastExpr(range(begin, tokenEnd()), primitiveType, ret); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT: + case IDENTIFIER:{ + referenceType = ReferenceType(); +typesOfMultiCast = add(typesOfMultiCast, referenceType); referenceType.setAnnotations(annotations); + label_38: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BIT_AND:{ + ; + break; + } + default: + jj_la1[92] = jj_gen; + break label_38; + } + jj_consume_token(BIT_AND); + referenceType = ReferenceType(); +typesOfMultiCast = add(typesOfMultiCast, referenceType); + } + jj_consume_token(RPAREN); + ret = UnaryExpressionNotPlusMinus(); +if (typesOfMultiCast.size() > 1) { + ret = new CastExpr(range(begin, tokenEnd()), new IntersectionType(range(begin, tokenEnd()), typesOfMultiCast), ret); + } + ret = new CastExpr(range(begin, tokenEnd()), referenceType, ret); + break; + } + default: + jj_la1[93] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public Expression PrimaryExpression() {Expression ret; + ret = PrimaryPrefix(); + label_39: + while (true) { + if (jj_2_25(2)) { + ; + } else { + break label_39; + } + ret = PrimarySuffix(ret); + } +return ret; + } + + final public Expression PrimaryExpressionWithoutSuperSuffix() {Expression ret; + ret = PrimaryPrefix(); + label_40: + while (true) { + if (jj_2_26(2147483647)) { + ; + } else { + break label_40; + } + ret = PrimarySuffixWithoutSuper(ret); + } +return ret; + } + + final public Expression PrimaryPrefix() {Expression ret = null; + NameExpr name; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + List<Expression> args = null; + List<Parameter> params = null; + boolean hasArgs = false; + boolean isLambda = false; + Type type; + Position begin; + Parameter p = null; + VariableDeclaratorId id = null; + switch ((jj_ntk==-1)?jj_ntk_f():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(tokenRange(), null); + break; + } + case SUPER:{ + jj_consume_token(SUPER); +ret = new SuperExpr(tokenRange(), null); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DOT:{ + jj_consume_token(DOT); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + break; + } + default: + jj_la1[94] = jj_gen; + ; + } + name = SimpleName(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LPAREN:{ + args = Arguments(); +hasArgs=true; + break; + } + default: + jj_la1[95] = jj_gen; + ; + } +if (hasArgs) { + MethodCallExpr m = new MethodCallExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, typeArgs.list, null, args); + m.setNameExpr(name); + ret = m; + } else { + FieldAccessExpr f = new FieldAccessExpr(range(ret.getBegin(), pos(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_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + break; + } + default: + jj_la1[96] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + jj_consume_token(IDENTIFIER); + break; + } + case NEW:{ + jj_consume_token(NEW); + break; + } + default: + jj_la1[97] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +ret = new MethodReferenceExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, typeArgs.list, token.image); + break; + } + default: + jj_la1[98] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + } + case LPAREN:{ + jj_consume_token(LPAREN); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():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_f():jj_ntk) { + case COMMA:{ + params = FormalLambdaParameters(); + break; + } + default: + jj_la1[99] = jj_gen; + ; + } + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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_f():jj_ntk) { + case COMMA:{ + params = InferredLambdaParameters(); +isLambda = true; + break; + } + default: + jj_la1[100] = jj_gen; + ; + } + break; + } + default: + jj_la1[101] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + } + default: + jj_la1[102] = jj_gen; + ; + } + jj_consume_token(RPAREN); +if(!isLambda) { ret = new EnclosedExpr(range(begin, tokenEnd()), ret);} + else{ + if(ret != null){ + if(ret instanceof NameExpr) + { + id = new VariableDeclaratorId(range(ret.getBegin(), ret.getEnd()), ((NameExpr)ret).getName(), null); + p = new Parameter(range(ret.getBegin(), ret.getEnd()), EnumSet.noneOf(Modifier.class), null, new UnknownType(), null, false, id); + } + + } + params = add(0, params, p); + // TODO p may be null here + ret = new LambdaExpr(range(p.getBegin(), tokenEnd()), params, null, true); + } + break; + } + case NEW:{ + ret = AllocationExpression(null); + break; + } + default: + jj_la1[106] = jj_gen; + if (jj_2_28(2147483647)) { + type = ResultType(); + jj_consume_token(DOT); + jj_consume_token(CLASS); +ret = new ClassExpr(range(type.getBegin(), tokenEnd()), type); + } else if (jj_2_29(2147483647)) { + type = ResultType(); + jj_consume_token(DOUBLECOLON); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + break; + } + default: + jj_la1[103] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + jj_consume_token(IDENTIFIER); + break; + } + case NEW:{ + jj_consume_token(NEW); + break; + } + default: + jj_la1[104] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +ret = new TypeExpr(type.getRange(), type); + ret = new MethodReferenceExpr(ret.getRange(), ret, typeArgs.list, token.image); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + name = SimpleName(); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LPAREN:{ + args = Arguments(); +hasArgs=true; + break; + } + default: + jj_la1[105] = jj_gen; + ; + } +if (hasArgs) { + MethodCallExpr m = new MethodCallExpr(range(begin, tokenEnd()), null, null, null, args); + m.setNameExpr(name); + ret = m; + } else { + ret = name; + } + break; + } + default: + jj_la1[107] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } +return ret; + } + + final public Expression PrimarySuffix(Expression scope) {Expression ret; + if (jj_2_30(2)) { + ret = PrimarySuffixWithoutSuper(scope); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DOT:{ + jj_consume_token(DOT); + jj_consume_token(SUPER); +ret = new SuperExpr(range(scope.getBegin(), tokenEnd()), scope); + break; + } + default: + jj_la1[108] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public Expression PrimarySuffixWithoutSuper(Expression scope) {Expression ret; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + List<Expression> args = null; + boolean hasArgs = false; + NameExpr name; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case DOT:{ + jj_consume_token(DOT); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case THIS:{ + jj_consume_token(THIS); +ret = new ThisExpr(range(scope.getBegin(), tokenEnd()), scope); + break; + } + case NEW:{ + ret = AllocationExpression(scope); + break; + } + default: + jj_la1[111] = jj_gen; + if (jj_2_31(2147483647)) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + break; + } + default: + jj_la1[109] = jj_gen; + ; + } + name = SimpleName(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LPAREN:{ + args = Arguments(); +hasArgs=true; + break; + } + default: + jj_la1[110] = jj_gen; + ; + } +if (hasArgs) { + MethodCallExpr m = new MethodCallExpr(range(scope.getBegin(), tokenEnd()), scope, typeArgs.list, null, args); + m.setNameExpr(name); + ret = m; + } else { + FieldAccessExpr f = new FieldAccessExpr(range(scope.getBegin(), tokenEnd()), scope, typeArgs.list, 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(range(scope.getBegin(), tokenEnd()), scope, ret); + break; + } + default: + jj_la1[112] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Expression Literal() {Expression ret; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case INTEGER_LITERAL:{ + jj_consume_token(INTEGER_LITERAL); +ret = new IntegerLiteralExpr(tokenRange(), token.image); + break; + } + case LONG_LITERAL:{ + jj_consume_token(LONG_LITERAL); +ret = new LongLiteralExpr(tokenRange(), token.image); + break; + } + case FLOATING_POINT_LITERAL:{ + jj_consume_token(FLOATING_POINT_LITERAL); +ret = new DoubleLiteralExpr(tokenRange(), token.image); + break; + } + case CHARACTER_LITERAL:{ + jj_consume_token(CHARACTER_LITERAL); +ret = new CharLiteralExpr(tokenRange(), token.image.substring(1, token.image.length()-1)); + break; + } + case STRING_LITERAL:{ + jj_consume_token(STRING_LITERAL); +ret = new StringLiteralExpr(tokenRange(), token.image.substring(1, token.image.length()-1)); + break; + } + case FALSE: + case TRUE:{ + ret = BooleanLiteral(); + break; + } + case NULL:{ + ret = NullLiteral(); + break; + } + default: + jj_la1[113] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Expression BooleanLiteral() {Expression ret; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case TRUE:{ + jj_consume_token(TRUE); +ret = new BooleanLiteralExpr(tokenRange(), true); + break; + } + case FALSE:{ + jj_consume_token(FALSE); +ret = new BooleanLiteralExpr(tokenRange(), false); + break; + } + default: + jj_la1[114] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Expression NullLiteral() { + jj_consume_token(NULL); +return new NullLiteralExpr(tokenRange()); + } + + final public List<Expression> Arguments() {List<Expression> ret = null; + jj_consume_token(LPAREN); + switch ((jj_ntk==-1)?jj_ntk_f():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[115] = jj_gen; + ; + } + jj_consume_token(RPAREN); +return ret; + } + + final public List<Expression> ArgumentList() {List<Expression> ret = new LinkedList<Expression>(); + Expression expr; + expr = Expression(); +ret.add(expr); + label_41: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[116] = jj_gen; + break label_41; + } + jj_consume_token(COMMA); + expr = Expression(); +ret.add(expr); + } +return ret; + } + + final public Expression AllocationExpression(Expression scope) {Expression ret; + Type type; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + List<BodyDeclaration<?>> anonymousBody = null; + List<Expression> args; + Position begin; + List<AnnotationExpr> annotations = null; + jj_consume_token(NEW); +if(scope==null) {begin=tokenBegin();} else {begin=scope.getBegin();} + annotations = Annotations(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BOOLEAN: + case BYTE: + case CHAR: + case DOUBLE: + case FLOAT: + case INT: + case LONG: + case SHORT:{ + type = PrimitiveType(); +type.setAnnotations(annotations); + ret = ArrayCreation(begin, type); + break; + } + case IDENTIFIER: + case AT: + case LT:{ + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + annotations = Annotations(); + break; + } + default: + jj_la1[117] = jj_gen; + ; + } + type = AnnotatedClassOrInterfaceType(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACKET: + case AT:{ + ret = ArrayCreation(begin, type); + break; + } + case LPAREN:{ + args = Arguments(); + if (jj_2_32(2)) { + anonymousBody = ClassOrInterfaceBody(false); + } else { + ; + } +ret = new ObjectCreationExpr(range(begin, tokenEnd()), scope, (ClassOrInterfaceType) type, typeArgs.list, args, anonymousBody); + break; + } + default: + jj_la1[118] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + } + default: + jj_la1[119] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + +/* + * The third LOOKAHEAD specification below is to parse to PrimarySuffix + * if there is an expression between the "[...]". + */ + final public ArrayCreationExpr ArrayCreation(Position begin, Type type) {Expression expr = null; + ArrayInitializerExpr arrayInitializerExpr = null; + List<Expression> inits = null; + List<List<AnnotationExpr>> accum = null; + List<AnnotationExpr> annotations = null; + label_42: + while (true) { + annotations = Annotations(); + jj_consume_token(LBRACKET); + switch ((jj_ntk==-1)?jj_ntk_f():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[120] = jj_gen; + ; + } +accum = add(accum, annotations); inits = add(inits, expr); annotations=null; expr=null; + jj_consume_token(RBRACKET); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACKET: + case AT:{ + ; + break; + } + default: + jj_la1[121] = jj_gen; + break label_42; + } + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LBRACE:{ + arrayInitializerExpr = ArrayInitializer(); + break; + } + default: + jj_la1[122] = jj_gen; + ; + } +return juggleArrayCreation(range(begin, tokenEnd()), type, inits, accum, arrayInitializerExpr); + } + +/* + * Statement syntax follows. + */ + final public +Statement Statement() {Statement ret; + if (jj_2_33(2)) { + ret = LabeledStatement(); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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[123] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public AssertStmt AssertStatement() {Expression check; + Expression msg = null; + Position begin; + jj_consume_token(ASSERT); +begin=tokenBegin(); + check = Expression(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COLON:{ + jj_consume_token(COLON); + msg = Expression(); + break; + } + default: + jj_la1[124] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); +return new AssertStmt(range(begin, tokenEnd()),check, msg); + } + + final public LabeledStmt LabeledStatement() {String label; + Statement stmt; + Position begin; + jj_consume_token(IDENTIFIER); +begin=tokenBegin(); +label = token.image; + jj_consume_token(COLON); + stmt = Statement(); +return new LabeledStmt(range(begin, tokenEnd()),label, stmt); + } + + final public BlockStmt Block() {List<Statement> stmts; + Position begin; + jj_consume_token(LBRACE); +begin=tokenBegin(); + stmts = Statements(); + jj_consume_token(RBRACE); +return new BlockStmt(range(begin, tokenEnd()), stmts); + } + +/* + * Classes inside block stametents can only be abstract or final. The semantic must check it. + */ + final public Statement BlockStatement() {Statement ret; + Expression expr; + ClassOrInterfaceDeclaration typeDecl; + ModifierHolder modifier; + if (jj_2_34(2147483647)) { + + modifier = Modifiers(); + typeDecl = ClassOrInterfaceDeclaration(modifier); +ret = new TypeDeclarationStmt(range(typeDecl.getBegin().line, typeDecl.getBegin().column, token.endLine, token.endColumn), typeDecl); + } else if (jj_2_35(2147483647)) { + expr = VariableDeclarationExpression(); + jj_consume_token(SEMICOLON); +ret = new ExpressionStmt(range(expr.getBegin().line, expr.getBegin().column, token.endLine, token.endColumn), expr); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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[125] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public VariableDeclarationExpr VariableDeclarationExpression() {ModifierHolder modifier; + Type type; + List<VariableDeclarator> variables = new LinkedList<VariableDeclarator>(); + VariableDeclarator var; + modifier = Modifiers(); + type = Type(); + var = VariableDeclarator(); +variables.add(var); + label_43: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[126] = jj_gen; + break label_43; + } + jj_consume_token(COMMA); + var = VariableDeclarator(); +variables.add(var); + } +Position begin=modifier.begin.orIfInvalid(type.getBegin()); + Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type); + return new VariableDeclarationExpr(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, typeListPair.a, variables, typeListPair.b); + } + + final public EmptyStmt EmptyStatement() { + jj_consume_token(SEMICOLON); +return new EmptyStmt(tokenRange()); + } + + final public Statement LambdaBody() {Expression expr; + Statement n = null; + switch ((jj_ntk==-1)?jj_ntk_f():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(range(expr.getBegin(), tokenEnd()), expr); + break; + } + case LBRACE:{ + n = Block(); + break; + } + default: + jj_la1[127] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return n; + } + + final public ExpressionStmt StatementExpression() {Expression expr; + AssignExpr.Operator op; + Expression value; + RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null); + Statement lambdaBody; + if (jj_2_36(2)) { + expr = PreIncrementExpression(); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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_f():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_f():jj_ntk) { + case INCR:{ + jj_consume_token(INCR); +expr = new UnaryExpr(range(expr.getBegin(), tokenEnd()), expr, UnaryExpr.Operator.posIncrement); + break; + } + case DECR:{ + jj_consume_token(DECR); +expr = new UnaryExpr(range(expr.getBegin(), tokenEnd()), 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(range(expr.getBegin(), tokenEnd()), expr, value, op); + break; + } + case DOUBLECOLON:{ + jj_consume_token(DOUBLECOLON); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LT:{ + typeArgs = TypeArguments(); + break; + } + default: + jj_la1[128] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + jj_consume_token(IDENTIFIER); + break; + } + case NEW:{ + jj_consume_token(NEW); + break; + } + default: + jj_la1[129] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +expr = new MethodReferenceExpr(range(expr.getBegin(), tokenEnd()), expr, typeArgs.list, token.image); + break; + } + case ARROW:{ + jj_consume_token(ARROW); + lambdaBody = LambdaBody(); +expr = generateLambda(expr, lambdaBody); + break; + } + default: + jj_la1[130] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + } + default: + jj_la1[131] = jj_gen; + ; + } + break; + } + default: + jj_la1[132] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(SEMICOLON); +return new ExpressionStmt(range(expr.getBegin(), tokenEnd()), expr); + } + + final public SwitchStmt SwitchStatement() {Expression selector; + SwitchEntryStmt entry; + List<SwitchEntryStmt> entries = null; + Position begin; + jj_consume_token(SWITCH); +begin=tokenBegin(); + jj_consume_token(LPAREN); + selector = Expression(); + jj_consume_token(RPAREN); + jj_consume_token(LBRACE); + label_44: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CASE: + case _DEFAULT:{ + ; + break; + } + default: + jj_la1[133] = jj_gen; + break label_44; + } + entry = SwitchEntry(); +entries = add(entries, entry); + } + jj_consume_token(RBRACE); +return new SwitchStmt(range(begin, tokenEnd()), selector, entries); + } + + final public SwitchEntryStmt SwitchEntry() {Expression label = null; + List<Statement> stmts; + Position begin; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CASE:{ + jj_consume_token(CASE); +begin=tokenBegin(); + label = Expression(); + break; + } + case _DEFAULT:{ + jj_consume_token(_DEFAULT); +begin=tokenBegin(); + break; + } + default: + jj_la1[134] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(COLON); + stmts = Statements(); +return new SwitchEntryStmt(range(begin, tokenEnd()),label, stmts); + } + + final public IfStmt IfStatement() {Expression condition; + Statement thenStmt; + Statement elseStmt = null; + Position begin; + Comment thenCmmt = null; + Comment elseCmmt = null; + jj_consume_token(IF); +begin=tokenBegin(); + jj_consume_token(LPAREN); + condition = Expression(); + jj_consume_token(RPAREN); + + thenStmt = Statement(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ELSE:{ + jj_consume_token(ELSE); + + elseStmt = Statement(); + break; + } + default: + jj_la1[135] = jj_gen; + ; + } +IfStmt tmp = new IfStmt(range(begin, tokenEnd()),condition, thenStmt, elseStmt); + + // TODO comment is always null + thenStmt.setComment(thenCmmt); + if (elseStmt != null) + // TODO comment is always null + elseStmt.setComment(elseCmmt); + return tmp; + } + + final public WhileStmt WhileStatement() {Expression condition; + Statement body; + Position begin; + jj_consume_token(WHILE); +begin=tokenBegin(); + jj_consume_token(LPAREN); + condition = Expression(); + jj_consume_token(RPAREN); + body = Statement(); +return new WhileStmt(range(begin, tokenEnd()),condition, body); + } + + final public DoStmt DoStatement() {Expression condition; + Statement body; + Position begin; + jj_consume_token(DO); +begin=tokenBegin(); + body = Statement(); + jj_consume_token(WHILE); + jj_consume_token(LPAREN); + condition = Expression(); + jj_consume_token(RPAREN); + jj_consume_token(SEMICOLON); +return new DoStmt(range(begin, tokenEnd()),body, condition); + } + + final public Statement ForStatement() {VariableDeclarationExpr varExpr = null; + Expression expr = null; + List<Expression> init = null; + List<Expression> update = null; + Statement body; + Position begin; + jj_consume_token(FOR); +begin=tokenBegin(); + jj_consume_token(LPAREN); + if (jj_2_37(2147483647)) { + varExpr = VariableDeclarationExpression(); + jj_consume_token(COLON); + expr = Expression(); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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_f():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[136] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk==-1)?jj_ntk_f():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[137] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + switch ((jj_ntk==-1)?jj_ntk_f():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[138] = jj_gen; + ; + } + break; + } + default: + jj_la1[139] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RPAREN); + body = Statement(); +if (varExpr != null) { + return new ForeachStmt(range(begin, tokenEnd()),varExpr, expr, body); + } + return new ForStmt(range(begin, tokenEnd()),init, expr, update, body); + } + + final public List<Expression> ForInit() {List<Expression> ret; + Expression expr; + if (jj_2_38(2147483647)) { + expr = VariableDeclarationExpression(); +ret = new LinkedList<Expression>(); ret.add(expr); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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[140] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public List<Expression> ExpressionList() {List<Expression> ret = new LinkedList<Expression>(); + Expression expr; + expr = Expression(); +ret.add(expr); + label_45: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[141] = jj_gen; + break label_45; + } + jj_consume_token(COMMA); + expr = Expression(); +ret.add(expr); + } +return ret; + } + + final public List<Expression> ForUpdate() {List<Expression> ret; + ret = ExpressionList(); +return ret; + } + + final public BreakStmt BreakStatement() {String id = null; + Position begin; + jj_consume_token(BREAK); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + jj_consume_token(IDENTIFIER); +id = token.image; + break; + } + default: + jj_la1[142] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); +return new BreakStmt(range(begin, tokenEnd()),id); + } + + final public ContinueStmt ContinueStatement() {String id = null; + Position begin; + jj_consume_token(CONTINUE); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + jj_consume_token(IDENTIFIER); +id = token.image; + break; + } + default: + jj_la1[143] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); +return new ContinueStmt(range(begin, tokenEnd()),id); + } + + final public ReturnStmt ReturnStatement() {Expression expr = null; + Position begin; + jj_consume_token(RETURN); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():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[144] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); +return new ReturnStmt(range(begin, tokenEnd()),expr); + } + + final public ThrowStmt ThrowStatement() {Expression expr; + Position begin; + jj_consume_token(THROW); +begin=tokenBegin(); + expr = Expression(); + jj_consume_token(SEMICOLON); +return new ThrowStmt(range(begin, tokenEnd()),expr); + } + + final public SynchronizedStmt SynchronizedStatement() {Expression expr; + BlockStmt block; + Position begin; + jj_consume_token(SYNCHRONIZED); +begin=tokenBegin(); + jj_consume_token(LPAREN); + expr = Expression(); + jj_consume_token(RPAREN); + block = Block(); +return new SynchronizedStmt(range(begin, tokenEnd()),expr, block); + } + + final public TryStmt TryStatement() {List<VariableDeclarationExpr> resources = null; + BlockStmt tryBlock; + BlockStmt finallyBlock = null; + List<CatchClause> catchs = null; + BlockStmt catchBlock; + ModifierHolder exceptModifier; + ReferenceType exceptionType; + List<ReferenceType> exceptionTypes = new LinkedList<ReferenceType>(); + VariableDeclaratorId exceptId; + Position begin; + Position catchBegin; + Type type; + jj_consume_token(TRY); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case LPAREN:{ + resources = ResourceSpecification(); + break; + } + default: + jj_la1[145] = jj_gen; + ; + } + tryBlock = Block(); + label_46: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case CATCH:{ + ; + break; + } + default: + jj_la1[146] = jj_gen; + break label_46; + } + jj_consume_token(CATCH); +catchBegin=tokenBegin(); + jj_consume_token(LPAREN); + exceptModifier = Modifiers(); + exceptionType = ReferenceType(); +exceptionTypes.add(exceptionType); + label_47: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case BIT_OR:{ + ; + break; + } + default: + jj_la1[147] = jj_gen; + break label_47; + } + jj_consume_token(BIT_OR); + exceptionType = ReferenceTypeWithAnnotations(); +exceptionTypes.add(exceptionType); + } + exceptId = VariableDeclaratorId(); + jj_consume_token(RPAREN); + catchBlock = Block(); +if (exceptionTypes.size() > 1) { + type = new UnionType(exceptionTypes); + } else { + type = (Type)exceptionTypes.get(0); + } + catchs = add(catchs, new CatchClause(range(catchBegin, tokenEnd()), exceptModifier.modifiers, exceptModifier.annotations, type, exceptId, catchBlock)); + exceptionTypes = new LinkedList<ReferenceType>(); + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case FINALLY:{ + jj_consume_token(FINALLY); + finallyBlock = Block(); + break; + } + default: + jj_la1[148] = jj_gen; + ; + } +if (finallyBlock==null && catchs==null && resources==null) { + addProblem("Try has no finally, no catch, and no resources"); + } + return new TryStmt(range(begin, tokenEnd()), resources, tryBlock, catchs, finallyBlock); + } + + final public List<VariableDeclarationExpr> ResourceSpecification() {List<VariableDeclarationExpr> variables; + jj_consume_token(LPAREN); + variables = Resources(); + if (jj_2_39(2)) { + jj_consume_token(SEMICOLON); + } else { + ; + } + jj_consume_token(RPAREN); +return variables; + } + + final public List<VariableDeclarationExpr> Resources() {List<VariableDeclarationExpr> variables = new LinkedList<VariableDeclarationExpr>(); + VariableDeclarationExpr var; + /*this is a bit more lenient than we need to be, eg allowing access modifiers like private*/ + var = VariableDeclarationExpression(); +variables.add(var); + label_48: + while (true) { + if (jj_2_40(2)) { + ; + } else { + break label_48; + } + jj_consume_token(SEMICOLON); + var = VariableDeclarationExpression(); +variables.add(var); + } +return variables; + } + +/* We use productions to match >>>, >> and > so that we can keep the + * type declaration syntax with generics clean + */ + final public +void RUNSIGNEDSHIFT() { + 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() { + 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 +List<AnnotationExpr> Annotations() {List<AnnotationExpr> annotations = null; + AnnotationExpr annotation; + label_49: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case AT:{ + ; + break; + } + default: + jj_la1[149] = jj_gen; + break label_49; + } + annotation = Annotation(); +annotations = add(annotations, annotation); + } +return annotations; + } + + final public AnnotationExpr Annotation() {AnnotationExpr ret; + if (jj_2_41(2147483647)) { + ret = NormalAnnotation(); + } else if (jj_2_42(2147483647)) { + ret = SingleMemberAnnotation(); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case AT:{ + ret = MarkerAnnotation(); + break; + } + default: + jj_la1[150] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +return ret; + } + + final public NormalAnnotationExpr NormalAnnotation() {NameExpr name; + List<MemberValuePair> pairs = null; + Position begin; + jj_consume_token(AT); +begin=tokenBegin(); + name = Name(); + jj_consume_token(LPAREN); + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case IDENTIFIER:{ + pairs = MemberValuePairs(); + break; + } + default: + jj_la1[151] = jj_gen; + ; + } + jj_consume_token(RPAREN); +return new NormalAnnotationExpr(range(begin, tokenEnd()),name, pairs); + } + + final public MarkerAnnotationExpr MarkerAnnotation() {NameExpr name; + Position begin; + jj_consume_token(AT); +begin=tokenBegin(); + name = Name(); +return new MarkerAnnotationExpr(range(begin, tokenEnd()),name); + } + + final public SingleMemberAnnotationExpr SingleMemberAnnotation() {NameExpr name; + Expression memberVal; + Position begin; + jj_consume_token(AT); +begin=tokenBegin(); + name = Name(); + jj_consume_token(LPAREN); + memberVal = MemberValue(); + jj_consume_token(RPAREN); +return new SingleMemberAnnotationExpr(range(begin, tokenEnd()),name, memberVal); + } + + final public List<MemberValuePair> MemberValuePairs() {List<MemberValuePair> ret = new LinkedList<MemberValuePair>(); + MemberValuePair pair; + pair = MemberValuePair(); +ret.add(pair); + label_50: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + ; + break; + } + default: + jj_la1[152] = jj_gen; + break label_50; + } + jj_consume_token(COMMA); + pair = MemberValuePair(); +ret.add(pair); + } +return ret; + } + + final public MemberValuePair MemberValuePair() {String name; + Expression value; + Position begin; + jj_consume_token(IDENTIFIER); +name = token.image; begin=tokenBegin(); + jj_consume_token(ASSIGN); + value = MemberValue(); +return new MemberValuePair(range(begin, tokenEnd()),name, value); + } + + final public Expression MemberValue() {Expression ret; + switch ((jj_ntk==-1)?jj_ntk_f():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[153] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public Expression MemberValueArrayInitializer() {List<Expression> ret = new LinkedList<Expression>(); + Expression member; + Position begin; + jj_consume_token(LBRACE); +begin=tokenBegin(); + switch ((jj_ntk==-1)?jj_ntk_f():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_51: + while (true) { + if (jj_2_43(2)) { + ; + } else { + break label_51; + } + jj_consume_token(COMMA); + member = MemberValue(); +ret.add(member); + } + break; + } + default: + jj_la1[154] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMA:{ + jj_consume_token(COMMA); + break; + } + default: + jj_la1[155] = jj_gen; + ; + } + jj_consume_token(RBRACE); +return new ArrayInitializerExpr(range(begin, tokenEnd()),ret); + } + +/* Annotation Types. */ + final public +AnnotationDeclaration AnnotationTypeDeclaration(ModifierHolder modifier) {NameExpr name; + List<BodyDeclaration<?>> members; + Position begin = modifier.begin; + jj_consume_token(AT); +begin=begin.orIfInvalid(tokenBegin()); + jj_consume_token(INTERFACE); + name = Name(); + members = AnnotationTypeBody(); +AnnotationDeclaration tmp = new AnnotationDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, null, members); + tmp.setNameExpr(name); + return tmp; + } + + final public List<BodyDeclaration<?>> AnnotationTypeBody() {List<BodyDeclaration<?>> ret = null; + BodyDeclaration member; + jj_consume_token(LBRACE); + label_52: + while (true) { + switch ((jj_ntk==-1)?jj_ntk_f():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[156] = jj_gen; + break label_52; + } + member = AnnotationBodyDeclaration(); +ret = add(ret, member); + } + jj_consume_token(RBRACE); +return ret; + } + + final public BodyDeclaration<?> AnnotationBodyDeclaration() {ModifierHolder modifier; + BodyDeclaration ret; + + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case SEMICOLON:{ + jj_consume_token(SEMICOLON); +ret = new EmptyTypeDeclaration(tokenRange()); + 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_44(2147483647)) { + ret = AnnotationTypeMemberDeclaration(modifier); + } else { + switch ((jj_ntk==-1)?jj_ntk_f():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[157] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + } + default: + jj_la1[158] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } +return ret; + } + + final public AnnotationMemberDeclaration AnnotationTypeMemberDeclaration(ModifierHolder modifier) {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_f():jj_ntk) { + case _DEFAULT:{ + defaultVal = DefaultValue(); + break; + } + default: + jj_la1[159] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); +Position begin = modifier.begin.orIfInvalid(tokenBegin()); + return new AnnotationMemberDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, type, name, defaultVal); + } + + final public Expression DefaultValue() {Expression ret; + jj_consume_token(_DEFAULT); + ret = MemberValue(); +return ret; + } + + 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_3_38() + { + if (jj_3R_95()) return true; + if (jj_3R_68()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_341() + { + if (jj_3R_345()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_373()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_385() + { + if (jj_scan_token(ELSE)) return true; + if (jj_3R_277()) return true; + return false; + } + + private boolean jj_3R_377() + { + if (jj_3R_93()) return true; + return false; + } + + private boolean jj_3R_427() + { + if (jj_3R_80()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_429()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_159() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_78()) return true; + if (jj_3R_158()) return true; + return false; + } + + private boolean jj_3_21() + { + if (jj_3R_83()) return true; + return false; + } + + private boolean jj_3_20() + { + if (jj_3R_82()) return true; + return false; + } + + private boolean jj_3R_426() + { + if (jj_3R_427()) return true; + return false; + } + + private boolean jj_3R_81() + { + if (jj_scan_token(LSHIFT)) return true; + return false; + } + + private boolean jj_3R_402() + { + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_103() + { + if (jj_scan_token(LT)) return true; + if (jj_3R_78()) return true; + if (jj_3R_158()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_159()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3_19() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_81()) { + jj_scanpos = xsp; + if (jj_3_20()) { + jj_scanpos = xsp; + if (jj_3_21()) return true; + } + } + if (jj_3R_341()) return true; + return false; + } + + private boolean jj_3R_425() + { + if (jj_3R_96()) return true; + return false; + } + + private boolean jj_3R_342() + { + if (jj_scan_token(INSTANCEOF)) return true; + if (jj_3R_68()) return true; + return false; + } + + private boolean jj_3R_339() + { + if (jj_3R_341()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_19()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_419() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_425()) { + jj_scanpos = xsp; + if (jj_3R_426()) return true; + } + return false; + } + + private boolean jj_3R_364() + { + if (jj_scan_token(GE)) return true; + return false; + } + + private boolean jj_3R_363() + { + if (jj_scan_token(LE)) return true; + return false; + } + + private boolean jj_3R_362() + { + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_361() + { + if (jj_scan_token(LT)) return true; + return false; + } + + private boolean jj_3R_376() + { + if (jj_3R_163()) return true; + return false; + } + + private boolean jj_3R_346() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_361()) { + jj_scanpos = xsp; + if (jj_3R_362()) { + jj_scanpos = xsp; + if (jj_3R_363()) { + jj_scanpos = xsp; + if (jj_3R_364()) return true; + } + } + } + if (jj_3R_339()) return true; + return false; + } + + private boolean jj_3_37() + { + if (jj_3R_96()) return true; + if (jj_scan_token(COLON)) return true; + return false; + } + + private boolean jj_3R_102() + { + if (jj_3R_101()) return true; + return false; + } + + private boolean jj_3R_367() + { + if (jj_3R_183()) return true; + return false; + } + + private boolean jj_3R_66() + { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_102()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(IDENTIFIER)) return true; + xsp = jj_scanpos; + if (jj_3R_376()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_377()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_401() + { + if (jj_3R_419()) return true; + return false; + } + + private boolean jj_3R_387() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_401()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + xsp = jj_scanpos; + if (jj_3R_402()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + xsp = jj_scanpos; + if (jj_3R_403()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_337() + { + if (jj_3R_339()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_346()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_386() + { + if (jj_3R_96()) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_352() + { + if (jj_scan_token(SEMICOLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_367()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_338() + { + if (jj_scan_token(BIT_AND)) return true; + if (jj_3R_314()) return true; + return false; + } + + private boolean jj_3R_325() + { + if (jj_scan_token(FOR)) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_386()) { + jj_scanpos = xsp; + if (jj_3R_387()) return true; + } + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_277()) return true; + return false; + } + + private boolean jj_3R_332() + { + if (jj_3R_337()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_342()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_351() + { + if (jj_3R_66()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_3()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_344() + { + if (jj_scan_token(NE)) return true; + return false; + } + + private boolean jj_3R_343() + { + if (jj_scan_token(EQ)) return true; + return false; + } + + private boolean jj_3R_340() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_343()) { + jj_scanpos = xsp; + if (jj_3R_344()) return true; + } + if (jj_3R_332()) return true; + return false; + } + + private boolean jj_3R_333() + { + if (jj_scan_token(XOR)) return true; + if (jj_3R_285()) return true; + return false; + } + + private boolean jj_3R_324() + { + if (jj_scan_token(DO)) return true; + if (jj_3R_277()) return true; + if (jj_scan_token(WHILE)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_350() + { + if (jj_3R_366()) return true; + return false; + } + + private boolean jj_3R_315() + { + if (jj_scan_token(BIT_OR)) return true; + if (jj_3R_265()) return true; + return false; + } + + private boolean jj_3R_314() + { + if (jj_3R_332()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_340()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_271() + { + if (jj_scan_token(ENUM)) return true; + if (jj_3R_98()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_350()) jj_scanpos = xsp; + if (jj_scan_token(LBRACE)) return true; + xsp = jj_scanpos; + if (jj_3R_351()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(113)) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_352()) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_323() + { + if (jj_scan_token(WHILE)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_277()) return true; + return false; + } + + private boolean jj_3R_286() + { + if (jj_scan_token(SC_AND)) return true; + if (jj_3R_237()) return true; + return false; + } + + private boolean jj_3R_285() + { + if (jj_3R_314()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_338()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_267() + { + if (jj_scan_token(SC_OR)) return true; + if (jj_3R_207()) return true; + return false; + } + + private boolean jj_3R_375() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_251()) return true; + return false; + } + + private boolean jj_3R_366() + { + if (jj_scan_token(IMPLEMENTS)) return true; + if (jj_3R_251()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_375()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_265() + { + if (jj_3R_285()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_333()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_322() + { + if (jj_scan_token(IF)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_277()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_385()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_237() + { + if (jj_3R_265()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_315()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_374() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_251()) return true; + return false; + } + + private boolean jj_3R_365() + { + if (jj_scan_token(EXTENDS)) return true; + if (jj_3R_251()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_374()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_207() + { + if (jj_3R_237()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_286()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_418() + { + if (jj_scan_token(_DEFAULT)) return true; + return false; + } + + private boolean jj_3R_417() + { + if (jj_scan_token(CASE)) return true; + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_289() + { + if (jj_scan_token(INTERFACE)) return true; + return false; + } + + private boolean jj_3R_349() + { + if (jj_3R_366()) return true; + return false; + } + + private boolean jj_3R_176() + { + if (jj_3R_207()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_267()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_348() + { + if (jj_3R_365()) return true; + return false; + } + + private boolean jj_3R_400() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_417()) { + jj_scanpos = xsp; + if (jj_3R_418()) return true; + } + if (jj_scan_token(COLON)) return true; + if (jj_3R_160()) return true; + return false; + } + + private boolean jj_3R_347() + { + if (jj_3R_103()) return true; + return false; + } + + private boolean jj_3R_270() + { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(45)) { + jj_scanpos = xsp; + if (jj_3R_289()) return true; + } + if (jj_3R_98()) return true; + xsp = jj_scanpos; + if (jj_3R_347()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_348()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_349()) jj_scanpos = xsp; + if (jj_3R_93()) return true; + return false; + } + + private boolean jj_3R_150() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_149()) return true; + return false; + } + + private boolean jj_3R_241() + { + if (jj_scan_token(HOOK)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_129()) return true; + return false; + } + + private boolean jj_3R_384() + { + if (jj_3R_400()) return true; + return false; + } + + private boolean jj_3R_129() + { + if (jj_3R_176()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_241()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_321() + { + if (jj_scan_token(SWITCH)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_80()) 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_384()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_128() + { + if (jj_scan_token(ORASSIGN)) return true; + return false; + } + + private boolean jj_3R_424() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_127() + { + if (jj_scan_token(XORASSIGN)) return true; + return false; + } + + private boolean jj_3R_126() + { + if (jj_scan_token(ANDASSIGN)) return true; + return false; + } + + private boolean jj_3R_125() + { + if (jj_scan_token(RUNSIGNEDSHIFTASSIGN)) return true; + return false; + } + + private boolean jj_3R_124() + { + if (jj_scan_token(RSIGNEDSHIFTASSIGN)) return true; + return false; + } + + private boolean jj_3R_123() + { + if (jj_scan_token(LSHIFTASSIGN)) return true; + return false; + } + + private boolean jj_3R_416() + { + if (jj_scan_token(ARROW)) return true; + if (jj_3R_268()) return true; + return false; + } + + private boolean jj_3R_122() + { + if (jj_scan_token(MINUSASSIGN)) return true; + return false; + } + + private boolean jj_3R_121() + { + if (jj_scan_token(PLUSASSIGN)) return true; + return false; + } + + private boolean jj_3R_415() + { + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_424()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(103)) { + jj_scanpos = xsp; + if (jj_scan_token(68)) return true; + } + return false; + } + + private boolean jj_3R_120() + { + if (jj_scan_token(REMASSIGN)) return true; + return false; + } + + private boolean jj_3R_414() + { + if (jj_3R_79()) return true; + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_119() + { + if (jj_scan_token(SLASHASSIGN)) return true; + return false; + } + + private boolean jj_3R_118() + { + if (jj_scan_token(STARASSIGN)) return true; + return false; + } + + private boolean jj_3R_413() + { + if (jj_scan_token(DECR)) return true; + return false; + } + + private boolean jj_3R_117() + { + if (jj_scan_token(ASSIGN)) return true; + return false; + } + + private boolean jj_3R_412() + { + if (jj_scan_token(INCR)) return true; + return false; + } + + private boolean jj_3R_399() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_412()) { + jj_scanpos = xsp; + if (jj_3R_413()) { + jj_scanpos = xsp; + if (jj_3R_414()) { + jj_scanpos = xsp; + if (jj_3R_415()) { + jj_scanpos = xsp; + if (jj_3R_416()) return true; + } + } + } + } + return false; + } + + private boolean jj_3R_79() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_117()) { + jj_scanpos = xsp; + if (jj_3R_118()) { + jj_scanpos = xsp; + if (jj_3R_119()) { + jj_scanpos = xsp; + if (jj_3R_120()) { + jj_scanpos = xsp; + if (jj_3R_121()) { + jj_scanpos = xsp; + if (jj_3R_122()) { + jj_scanpos = xsp; + if (jj_3R_123()) { + jj_scanpos = xsp; + if (jj_3R_124()) { + jj_scanpos = xsp; + if (jj_3R_125()) { + jj_scanpos = xsp; + if (jj_3R_126()) { + jj_scanpos = xsp; + if (jj_3R_127()) { + jj_scanpos = xsp; + if (jj_3R_128()) return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_336() + { + if (jj_3R_266()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_399()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_335() + { + if (jj_3R_216()) return true; + return false; + } + + private boolean jj_3R_269() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3_36() + { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_243() + { + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_269()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(103)) { + jj_scanpos = xsp; + if (jj_scan_token(68)) return true; + } + return false; + } + + private boolean jj_3R_320() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_36()) { + jj_scanpos = xsp; + if (jj_3R_335()) { + jj_scanpos = xsp; + if (jj_3R_336()) return true; + } + } + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_65() + { + if (jj_3R_101()) return true; + return false; + } + + private boolean jj_3R_64() + { + if (jj_scan_token(STRICTFP)) return true; + return false; + } + + private boolean jj_3R_63() + { + if (jj_scan_token(VOLATILE)) return true; + return false; + } + + private boolean jj_3R_62() + { + if (jj_scan_token(TRANSIENT)) return true; + return false; + } + + private boolean jj_3R_61() + { + if (jj_scan_token(NATIVE)) return true; + return false; + } + + private boolean jj_3R_60() + { + if (jj_scan_token(SYNCHRONIZED)) return true; + return false; + } + + private boolean jj_3R_288() + { + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_59() + { + if (jj_scan_token(ABSTRACT)) return true; + return false; + } + + private boolean jj_3R_58() + { + if (jj_scan_token(FINAL)) return true; + return false; + } + + private boolean jj_3_18() + { + if (jj_3R_79()) return true; + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_242() + { + if (jj_scan_token(ARROW)) return true; + if (jj_3R_268()) return true; + return false; + } + + private boolean jj_3R_57() + { + if (jj_scan_token(PRIVATE)) return true; + return false; + } + + private boolean jj_3R_56() + { + if (jj_scan_token(PROTECTED)) return true; + return false; + } + + private boolean jj_3R_213() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_18()) { + jj_scanpos = xsp; + if (jj_3R_242()) { + jj_scanpos = xsp; + if (jj_3R_243()) return true; + } + } + return false; + } + + private boolean jj_3R_287() + { + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_55() + { + if (jj_scan_token(STATIC)) return true; + return false; + } + + private boolean jj_3R_54() + { + if (jj_scan_token(PUBLIC)) return true; + return false; + } + + private boolean jj_3R_80() + { + if (jj_3R_129()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_213()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3_2() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_54()) { + jj_scanpos = xsp; + if (jj_3R_55()) { + jj_scanpos = xsp; + if (jj_3R_56()) { + jj_scanpos = xsp; + if (jj_3R_57()) { + jj_scanpos = xsp; + if (jj_3R_58()) { + jj_scanpos = xsp; + if (jj_3R_59()) { + jj_scanpos = xsp; + if (jj_3R_60()) { + jj_scanpos = xsp; + if (jj_3R_61()) { + jj_scanpos = xsp; + if (jj_3R_62()) { + jj_scanpos = xsp; + if (jj_3R_63()) { + jj_scanpos = xsp; + if (jj_3R_64()) { + jj_scanpos = xsp; + if (jj_3R_65()) return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_268() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_287()) { + jj_scanpos = xsp; + if (jj_3R_288()) return true; + } + return false; + } + + private boolean jj_3R_95() + { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_2()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_319() + { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3_35() + { + if (jj_3R_96()) return true; + return false; + } + + private boolean jj_3R_96() + { + if (jj_3R_95()) return true; + if (jj_3R_68()) return true; + if (jj_3R_149()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_150()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_202() + { + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3_34() + { + if (jj_3R_95()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(45)) { + jj_scanpos = xsp; + if (jj_scan_token(65)) return true; + } + return false; + } + + private boolean jj_3R_255() + { + if (jj_3R_277()) return true; + return false; + } + + private boolean jj_3R_383() + { + if (jj_scan_token(COLON)) return true; + if (jj_3R_80()) 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_254() + { + if (jj_3R_96()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_98() + { + 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_53() + { + if (jj_3R_78()) return true; + if (jj_scan_token(PACKAGE)) return true; + if (jj_3R_98()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_253() + { + if (jj_3R_95()) return true; + if (jj_3R_270()) return true; + return false; + } + + private boolean jj_3R_147() + { + if (jj_3R_68()) return true; + return false; + } + + private boolean jj_3R_146() + { + if (jj_scan_token(VOID)) return true; + return false; + } + + private boolean jj_3R_220() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_253()) { + jj_scanpos = xsp; + if (jj_3R_254()) { + jj_scanpos = xsp; + if (jj_3R_255()) return true; + } + } + return false; + } + + private boolean jj_3_1() + { + if (jj_3R_53()) return true; + return false; + } + + private boolean jj_3R_91() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_146()) { + jj_scanpos = xsp; + if (jj_3R_147()) return true; + } + return false; + } + + private boolean jj_3R_140() + { + if (jj_scan_token(DOUBLE)) return true; + return false; + } + + private boolean jj_3R_106() + { + if (jj_scan_token(LBRACE)) return true; + if (jj_3R_160()) return true; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_139() + { + if (jj_scan_token(FLOAT)) return true; + return false; + } + + private boolean jj_3R_138() + { + if (jj_scan_token(LONG)) return true; + return false; + } + + private boolean jj_3R_137() + { + if (jj_scan_token(INT)) return true; + return false; + } + + private boolean jj_3R_136() + { + if (jj_scan_token(SHORT)) return true; + return false; + } + + private boolean jj_3R_135() + { + if (jj_scan_token(BYTE)) return true; + return false; + } + + private boolean jj_3R_94() + { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(COLON)) return true; + if (jj_3R_277()) return true; + return false; + } + + private boolean jj_3R_134() + { + if (jj_scan_token(CHAR)) return true; + return false; + } + + private boolean jj_3R_133() + { + if (jj_scan_token(BOOLEAN)) return true; + return false; + } + + private boolean jj_3R_313() + { + if (jj_scan_token(SUPER)) return true; + if (jj_3R_78()) return true; + if (jj_3R_75()) return true; + return false; + } + + private boolean jj_3R_87() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_133()) { + jj_scanpos = xsp; + if (jj_3R_134()) { + jj_scanpos = xsp; + if (jj_3R_135()) { + jj_scanpos = xsp; + if (jj_3R_136()) { + jj_scanpos = xsp; + if (jj_3R_137()) { + jj_scanpos = xsp; + if (jj_3R_138()) { + jj_scanpos = xsp; + if (jj_3R_139()) { + jj_scanpos = xsp; + if (jj_3R_140()) return true; + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_204() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_175()) return true; + return false; + } + + private boolean jj_3R_312() + { + if (jj_scan_token(EXTENDS)) return true; + if (jj_3R_78()) return true; + if (jj_3R_75()) return true; + return false; + } + + private boolean jj_3R_284() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_312()) { + jj_scanpos = xsp; + if (jj_3R_313()) return true; + } + return false; + } + + private boolean jj_3R_318() + { + if (jj_scan_token(ASSERT)) return true; + if (jj_3R_80()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_383()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_308() + { + if (jj_3R_331()) return true; + return false; + } + + private boolean jj_3R_307() + { + if (jj_3R_330()) return true; + return false; + } + + private boolean jj_3R_306() + { + if (jj_3R_329()) return true; + return false; + } + + private boolean jj_3R_305() + { + if (jj_3R_328()) return true; + return false; + } + + private boolean jj_3R_304() + { + if (jj_3R_327()) return true; + return false; + } + + private boolean jj_3R_303() + { + if (jj_3R_326()) return true; + return false; + } + + private boolean jj_3R_236() + { + if (jj_scan_token(HOOK)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_284()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_302() + { + if (jj_3R_325()) return true; + return false; + } + + private boolean jj_3R_301() + { + if (jj_3R_324()) return true; + return false; + } + + private boolean jj_3R_300() + { + if (jj_3R_323()) return true; + return false; + } + + private boolean jj_3R_299() + { + if (jj_3R_322()) return true; + return false; + } + + private boolean jj_3R_298() + { + if (jj_3R_321()) return true; + return false; + } + + private boolean jj_3R_297() + { + if (jj_3R_320()) return true; + return false; + } + + private boolean jj_3R_206() + { + if (jj_3R_236()) return true; + return false; + } + + private boolean jj_3R_296() + { + if (jj_3R_319()) return true; + return false; + } + + private boolean jj_3R_205() + { + if (jj_3R_75()) return true; + return false; + } + + private boolean jj_3R_295() + { + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_294() + { + if (jj_3R_318()) return true; + return false; + } + + private boolean jj_3R_175() + { + if (jj_3R_78()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_205()) { + jj_scanpos = xsp; + if (jj_3R_206()) return true; + } + return false; + } + + private boolean jj_3_33() + { + if (jj_3R_94()) return true; + return false; + } + + private boolean jj_3R_115() + { + if (jj_3R_175()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_204()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_277() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_33()) { + jj_scanpos = xsp; + if (jj_3R_294()) { + jj_scanpos = xsp; + if (jj_3R_295()) { + jj_scanpos = xsp; + if (jj_3R_296()) { + jj_scanpos = xsp; + if (jj_3R_297()) { + jj_scanpos = xsp; + if (jj_3R_298()) { + jj_scanpos = xsp; + if (jj_3R_299()) { + jj_scanpos = xsp; + if (jj_3R_300()) { + jj_scanpos = xsp; + if (jj_3R_301()) { + jj_scanpos = xsp; + if (jj_3R_302()) { + jj_scanpos = xsp; + if (jj_3R_303()) { + jj_scanpos = xsp; + if (jj_3R_304()) { + jj_scanpos = xsp; + if (jj_3R_305()) { + jj_scanpos = xsp; + if (jj_3R_306()) { + jj_scanpos = xsp; + if (jj_3R_307()) { + jj_scanpos = xsp; + if (jj_3R_308()) return true; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_77() + { + if (jj_scan_token(LT)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_115()) jj_scanpos = xsp; + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3_16() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3_32() + { + if (jj_3R_93()) return true; + return false; + } + + private boolean jj_3_15() + { + if (jj_scan_token(DOT)) return true; + if (jj_3R_78()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_16()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_311() + { + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_283() + { + if (jj_3R_161()) return true; + return false; + } + + private boolean jj_3R_282() + { + if (jj_3R_78()) return true; + if (jj_scan_token(LBRACKET)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_311()) jj_scanpos = xsp; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_261() + { + Token xsp; + if (jj_3R_282()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_282()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_283()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3_14() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_174() + { + 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_256() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_264() + { + if (jj_3R_163()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_32()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_263() + { + if (jj_3R_261()) return true; + return false; + } + + private boolean jj_3R_262() + { + if (jj_3R_77()) return true; + if (jj_3R_78()) return true; + return false; + } + + private boolean jj_3R_235() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_262()) jj_scanpos = xsp; + if (jj_3R_251()) return true; + xsp = jj_scanpos; + if (jj_3R_263()) { + jj_scanpos = xsp; + if (jj_3R_264()) return true; + } + return false; + } + + private boolean jj_3R_234() + { + if (jj_3R_87()) return true; + if (jj_3R_261()) return true; + return false; + } + + private boolean jj_3R_251() + { + if (jj_3R_78()) return true; + if (jj_3R_174()) return true; + return false; + } + + private boolean jj_3_13() + { + if (jj_3R_76()) return true; + return false; + } + + private boolean jj_3R_428() + { + if (jj_3R_430()) return true; + return false; + } + + private boolean jj_3R_200() + { + if (jj_scan_token(NEW)) return true; + if (jj_3R_78()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_234()) { + jj_scanpos = xsp; + if (jj_3R_235()) return true; + } + return false; + } + + private boolean jj_3_12() + { + if (jj_3R_76()) return true; + return false; + } + + private boolean jj_3R_355() + { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_370()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_371()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_76() + { + if (jj_3R_78()) return true; + if (jj_scan_token(LBRACKET)) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_221() + { + if (jj_3R_80()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_256()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_195() + { + if (jj_3R_221()) return true; + return false; + } + + private boolean jj_3R_114() + { + if (jj_3R_174()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_13()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_163() + { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_195()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_113() + { + if (jj_3R_87()) 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_75() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_113()) { + jj_scanpos = xsp; + if (jj_3R_114()) return true; + } + return false; + } + + private boolean jj_3R_258() + { + if (jj_scan_token(NULL)) return true; + return false; + } + + private boolean jj_3R_279() + { + if (jj_scan_token(FALSE)) return true; + return false; + } + + private boolean jj_3R_278() + { + if (jj_scan_token(TRUE)) return true; + return false; + } + + private boolean jj_3R_104() + { + if (jj_3R_87()) return true; + return false; + } + + private boolean jj_3_11() + { + if (jj_3R_75()) return true; + return false; + } + + private boolean jj_3R_68() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_11()) { + jj_scanpos = xsp; + if (jj_3R_104()) return true; + } + return false; + } + + private boolean jj_3R_257() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_278()) { + jj_scanpos = xsp; + if (jj_3R_279()) return true; + } + return false; + } + + private boolean jj_3R_430() + { + if (jj_scan_token(_DEFAULT)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_228() + { + if (jj_3R_258()) return true; + return false; + } + + private boolean jj_3R_227() + { + if (jj_3R_257()) return true; + return false; + } + + private boolean jj_3R_226() + { + if (jj_scan_token(STRING_LITERAL)) return true; + return false; + } + + private boolean jj_3R_105() + { + if (jj_scan_token(STATIC)) return true; + return false; + } + + private boolean jj_3R_225() + { + if (jj_scan_token(CHARACTER_LITERAL)) return true; + return false; + } + + private boolean jj_3R_423() + { + if (jj_3R_68()) 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_428()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_70() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_105()) jj_scanpos = xsp; + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_224() + { + if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; + return false; + } + + private boolean jj_3R_194() + { + if (jj_3R_220()) return true; + return false; + } + + private boolean jj_3_44() + { + if (jj_3R_68()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_411() + { + if (jj_3R_274()) return true; + return false; + } + + private boolean jj_3R_160() + { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_194()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_410() + { + if (jj_3R_272()) return true; + return false; + } + + private boolean jj_3R_223() + { + if (jj_scan_token(LONG_LITERAL)) return true; + return false; + } + + private boolean jj_3_9() + { + if (jj_3R_73()) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + private boolean jj_3R_409() + { + if (jj_3R_271()) return true; + return false; + } + + private boolean jj_3R_408() + { + if (jj_3R_270()) return true; + return false; + } + + private boolean jj_3R_222() + { + if (jj_scan_token(INTEGER_LITERAL)) return true; + return false; + } + + private boolean jj_3R_407() + { + if (jj_3R_423()) return true; + return false; + } + + private boolean jj_3R_74() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_165() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3_10() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_74()) jj_scanpos = xsp; + if (jj_scan_token(THIS)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_164() + { + if (jj_3R_73()) return true; + if (jj_scan_token(DOT)) return true; + return false; + } + + private boolean jj_3_43() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_92() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_196() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_222()) { + jj_scanpos = xsp; + if (jj_3R_223()) { + jj_scanpos = xsp; + if (jj_3R_224()) { + jj_scanpos = xsp; + if (jj_3R_225()) { + jj_scanpos = xsp; + if (jj_3R_226()) { + jj_scanpos = xsp; + if (jj_3R_227()) { + jj_scanpos = xsp; + if (jj_3R_228()) return true; + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_394() + { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_110() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_164()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_165()) jj_scanpos = xsp; + if (jj_scan_token(SUPER)) return true; + if (jj_3R_163()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_143() + { + if (jj_scan_token(LBRACKET)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3_31() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_92()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_395() + { + if (jj_3R_95()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_407()) { + jj_scanpos = xsp; + if (jj_3R_408()) { + jj_scanpos = xsp; + if (jj_3R_409()) { + jj_scanpos = xsp; + if (jj_3R_410()) { + jj_scanpos = xsp; + if (jj_3R_411()) return true; + } + } + } + } + return false; + } + + private boolean jj_3R_162() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_109() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_162()) jj_scanpos = xsp; + if (jj_scan_token(THIS)) return true; + if (jj_3R_163()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_212() + { + if (jj_3R_163()) return true; + return false; + } + + private boolean jj_3R_378() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_394()) { + jj_scanpos = xsp; + if (jj_3R_395()) return true; + } + return false; + } + + private boolean jj_3R_211() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_181() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_211()) jj_scanpos = xsp; + if (jj_3R_202()) return true; + xsp = jj_scanpos; + if (jj_3R_212()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_368() + { + if (jj_3R_378()) return true; + return false; + } + + private boolean jj_3R_180() + { + if (jj_3R_200()) return true; + return false; + } + + private boolean jj_3R_72() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_109()) { + jj_scanpos = xsp; + if (jj_3R_110()) return true; + } + return false; + } + + private boolean jj_3R_179() + { + if (jj_scan_token(THIS)) return true; + return false; + } + + private boolean jj_3R_353() + { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_368()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_259() + { + if (jj_3R_280()) return true; + return false; + } + + private boolean jj_3_8() + { + if (jj_3R_72()) return true; + return false; + } + + private boolean jj_3R_144() + { + if (jj_scan_token(ELLIPSIS)) return true; + return false; + } + + private boolean jj_3R_142() + { + if (jj_scan_token(DOT)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_179()) { + jj_scanpos = xsp; + if (jj_3R_180()) { + jj_scanpos = xsp; + if (jj_3R_181()) return true; + } + } + return false; + } + + private boolean jj_3R_309() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_90()) return true; + return false; + } + + private boolean jj_3R_89() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_142()) { + jj_scanpos = xsp; + if (jj_3R_143()) return true; + } + return false; + } + + private boolean jj_3R_356() + { + if (jj_3R_72()) return true; + return false; + } + + private boolean jj_3R_272() + { + if (jj_scan_token(AT)) return true; + if (jj_scan_token(INTERFACE)) return true; + if (jj_3R_98()) return true; + if (jj_3R_353()) return true; + return false; + } + + private boolean jj_3R_371() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_370()) return true; + return false; + } + + private boolean jj_3R_317() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_316()) return true; + return false; + } + + private boolean jj_3R_290() + { + if (jj_3R_103()) return true; + return false; + } + + private boolean jj_3R_141() + { + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(SUPER)) return true; + return false; + } + + private boolean jj_3R_273() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_290()) jj_scanpos = xsp; + if (jj_3R_202()) return true; + if (jj_3R_354()) return true; + xsp = jj_scanpos; + if (jj_3R_355()) jj_scanpos = xsp; + if (jj_scan_token(LBRACE)) return true; + xsp = jj_scanpos; + if (jj_3R_356()) jj_scanpos = xsp; + if (jj_3R_160()) return true; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_334() + { + if (jj_3R_100()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_43()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3_30() + { + if (jj_3R_89()) return true; + return false; + } + + private boolean jj_3R_201() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_379() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_90()) return true; + return false; + } + + private boolean jj_3R_88() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_30()) { + jj_scanpos = xsp; + if (jj_3R_141()) return true; + } + return false; + } + + private boolean jj_3R_189() + { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_334()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(113)) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_203() + { + if (jj_3R_163()) return true; + return false; + } + + private boolean jj_3R_154() + { + if (jj_3R_129()) return true; + return false; + } + + private boolean jj_3R_153() + { + if (jj_3R_189()) return true; + return false; + } + + private boolean jj_3R_173() + { + if (jj_3R_202()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_203()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_152() + { + if (jj_3R_101()) return true; + return false; + } + + private boolean jj_3_29() + { + if (jj_3R_91()) return true; + if (jj_scan_token(DOUBLECOLON)) return true; + return false; + } + + private boolean jj_3_28() + { + if (jj_3R_91()) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(CLASS)) return true; + return false; + } + + private boolean jj_3R_90() + { + if (jj_3R_95()) return true; + if (jj_3R_68()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_144()) jj_scanpos = xsp; + if (jj_3R_145()) return true; + return false; + } + + private boolean jj_3R_100() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_152()) { + jj_scanpos = xsp; + if (jj_3R_153()) { + jj_scanpos = xsp; + if (jj_3R_154()) return true; + } + } + return false; + } + + private boolean jj_3_7() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_71()) return true; + return false; + } + + private boolean jj_3R_260() + { + if (jj_3R_281()) return true; + return false; + } + + private boolean jj_3R_172() + { + if (jj_3R_91()) return true; + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_201()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(103)) { + jj_scanpos = xsp; + if (jj_scan_token(68)) return true; + } + return false; + } + + private boolean jj_3R_276() + { + if (jj_3R_293()) return true; + return false; + } + + private boolean jj_3R_171() + { + if (jj_3R_91()) return true; + if (jj_scan_token(DOT)) return true; + if (jj_scan_token(CLASS)) return true; + return false; + } + + private boolean jj_3R_316() + { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(ASSIGN)) return true; + if (jj_3R_100()) return true; + return false; + } + + private boolean jj_3R_310() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_145()) return true; + return false; + } + + private boolean jj_3R_170() + { + if (jj_3R_200()) return true; + return false; + } + + private boolean jj_3R_281() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_145()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_310()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3_27() + { + if (jj_3R_90()) return true; + return false; + } + + private boolean jj_3R_293() + { + if (jj_3R_316()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_317()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_358() + { + if (jj_3R_76()) return true; + return false; + } + + private boolean jj_3R_233() + { + if (jj_3R_80()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_260()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_280() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_90()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_309()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_232() + { + if (jj_3R_90()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_259()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_199() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_232()) { + jj_scanpos = xsp; + if (jj_3R_233()) return true; + } + return false; + } + + private boolean jj_3R_231() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3R_369() + { + if (jj_3R_90()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_379()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_191() + { + if (jj_scan_token(AT)) return true; + if (jj_3R_98()) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_100()) return true; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_99() + { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(ASSIGN)) return true; + return false; + } + + private boolean jj_3R_169() + { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_199()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_198() + { + if (jj_scan_token(DOUBLECOLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_231()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(103)) { + jj_scanpos = xsp; + if (jj_scan_token(68)) return true; + } + return false; + } + + private boolean jj_3R_354() + { + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_369()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_192() + { + if (jj_scan_token(AT)) return true; + if (jj_3R_98()) return true; + return false; + } + + private boolean jj_3_42() + { + if (jj_scan_token(AT)) return true; + if (jj_3R_98()) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3_41() + { + if (jj_scan_token(AT)) return true; + if (jj_3R_98()) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_99()) { + jj_scanpos = xsp; + if (jj_scan_token(107)) return true; + } + return false; + } + + private boolean jj_3R_230() + { + if (jj_3R_163()) return true; + return false; + } + + private boolean jj_3R_190() + { + if (jj_scan_token(AT)) return true; + if (jj_3R_98()) return true; + if (jj_scan_token(LPAREN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_276()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_370() + { + if (jj_3R_78()) return true; + if (jj_3R_75()) return true; + return false; + } + + private boolean jj_3R_197() + { + if (jj_scan_token(DOT)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_229()) jj_scanpos = xsp; + if (jj_3R_202()) return true; + xsp = jj_scanpos; + if (jj_3R_230()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_229() + { + if (jj_3R_77()) return true; + return false; + } + + private boolean jj_3_40() + { + if (jj_scan_token(SEMICOLON)) return true; + if (jj_3R_96()) return true; + return false; + } + + private boolean jj_3_26() + { + if (jj_3R_89()) return true; + return false; + } + + private boolean jj_3R_157() + { + if (jj_3R_192()) return true; + return false; + } + + private boolean jj_3R_182() + { + if (jj_3R_76()) return true; + return false; + } + + private boolean jj_3R_168() + { + if (jj_scan_token(SUPER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_197()) { + jj_scanpos = xsp; + if (jj_3R_198()) return true; + } + return false; + } + + private boolean jj_3R_156() + { + if (jj_3R_191()) return true; + return false; + } + + private boolean jj_3R_167() + { + if (jj_scan_token(THIS)) return true; + return false; + } + + private boolean jj_3R_155() + { + if (jj_3R_190()) return true; + return false; + } + + private boolean jj_3R_166() + { + if (jj_3R_196()) return true; + return false; + } + + private boolean jj_3R_292() + { + if (jj_3R_71()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_7()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_372() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_370()) return true; + return false; + } + + private boolean jj_3R_360() + { + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_112() + { + if (jj_3R_89()) return true; + return false; + } + + private boolean jj_3R_359() + { + if (jj_scan_token(THROWS)) return true; + if (jj_3R_370()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_372()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_291() + { + if (jj_3R_103()) return true; + return false; + } + + private boolean jj_3R_111() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_166()) { + jj_scanpos = xsp; + if (jj_3R_167()) { + jj_scanpos = xsp; + if (jj_3R_168()) { + jj_scanpos = xsp; + if (jj_3R_169()) { + jj_scanpos = xsp; + if (jj_3R_170()) { + jj_scanpos = xsp; + if (jj_3R_171()) { + jj_scanpos = xsp; + if (jj_3R_172()) { + jj_scanpos = xsp; + if (jj_3R_173()) return true; + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_101() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_155()) { + jj_scanpos = xsp; + if (jj_3R_156()) { + jj_scanpos = xsp; + if (jj_3R_157()) return true; + } + } + return false; + } + + private boolean jj_3R_275() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_291()) jj_scanpos = xsp; + if (jj_3R_91()) return true; + if (jj_3R_98()) return true; + if (jj_3R_354()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_358()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_359()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_360()) { + jj_scanpos = xsp; + if (jj_scan_token(112)) return true; + } + return false; + } + + private boolean jj_3_25() + { + if (jj_3R_88()) return true; + return false; + } + + private boolean jj_3R_116() + { + if (jj_3R_101()) return true; + return false; + } + + private boolean jj_3R_78() + { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_116()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_130() + { + return false; + } + + private boolean jj_3R_73() + { + if (jj_3R_111()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_112()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_131() + { + return false; + } + + private boolean jj_3R_161() + { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_292()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(113)) jj_scanpos = xsp; + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_82() + { + jj_lookingAhead = true; + jj_semLA = getToken(1).kind == GT && + ((GTToken)getToken(1)).realKind == RSIGNEDSHIFT; + jj_lookingAhead = false; + if (!jj_semLA || jj_3R_130()) return true; + if (jj_scan_token(GT)) return true; + if (jj_scan_token(GT)) return true; + return false; + } + + private boolean jj_3R_108() + { + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_107() + { + if (jj_3R_161()) return true; + return false; + } + + private boolean jj_3R_184() + { + if (jj_scan_token(ASSIGN)) return true; + if (jj_3R_71()) return true; + return false; + } + + private boolean jj_3R_266() + { + if (jj_3R_111()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_25()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_83() + { + jj_lookingAhead = true; + jj_semLA = getToken(1).kind == GT && + ((GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT; + jj_lookingAhead = false; + if (!jj_semLA || jj_3R_131()) 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_71() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_107()) { + jj_scanpos = xsp; + if (jj_3R_108()) return true; + } + return false; + } + + private boolean jj_3R_177() + { + if (jj_scan_token(BIT_AND)) return true; + if (jj_3R_75()) return true; + return false; + } + + private boolean jj_3R_132() + { + if (jj_3R_75()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_177()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_178()) return true; + return false; + } + + private boolean jj_3R_421() + { + if (jj_3R_96()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_40()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_145() + { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_182()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3_24() + { + if (jj_3R_87()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_84() + { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_78()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_24()) { + jj_scanpos = xsp; + if (jj_3R_132()) return true; + } + return false; + } + + private boolean jj_3_39() + { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_149() + { + if (jj_3R_145()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_184()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_404() + { + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_421()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_39()) jj_scanpos = xsp; + if (jj_scan_token(RPAREN)) return true; + return false; + } + + private boolean jj_3R_406() + { + if (jj_scan_token(FINALLY)) return true; + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_393() + { + if (jj_scan_token(FINALLY)) return true; + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_422() + { + if (jj_scan_token(BIT_OR)) return true; + if (jj_3R_370()) return true; + return false; + } + + private boolean jj_3R_69() + { + if (jj_3R_76()) return true; + return false; + } + + private boolean jj_3R_86() + { + if (jj_scan_token(DECR)) return true; + return false; + } + + private boolean jj_3_23() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_85()) { + jj_scanpos = xsp; + if (jj_3R_86()) return true; + } + return false; + } + + private boolean jj_3R_85() + { + if (jj_scan_token(INCR)) return true; + return false; + } + + private boolean jj_3R_357() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_149()) return true; + return false; + } + + private boolean jj_3_22() + { + if (jj_3R_84()) return true; + return false; + } + + private boolean jj_3R_405() + { + if (jj_scan_token(CATCH)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_95()) return true; + if (jj_3R_75()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_422()) { jj_scanpos = xsp; break; } + } + if (jj_3R_145()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_274() + { + if (jj_3R_68()) return true; + if (jj_3R_149()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_357()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_240() + { + if (jj_3R_266()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_23()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_215() + { + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_209() + { + if (jj_3R_84()) return true; + return false; + } + + private boolean jj_3R_210() + { + if (jj_3R_240()) return true; + return false; + } + + private boolean jj_3R_239() + { + if (jj_scan_token(BANG)) return true; + return false; + } + + private boolean jj_3R_238() + { + if (jj_scan_token(TILDE)) return true; + return false; + } + + private boolean jj_3R_208() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_238()) { + jj_scanpos = xsp; + if (jj_3R_239()) return true; + } + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3_5() + { + if (jj_3R_68()) return true; + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_69()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_scan_token(113)) { + jj_scanpos = xsp; + if (jj_scan_token(116)) { + jj_scanpos = xsp; + if (jj_scan_token(112)) return true; + } + } + return false; + } + + private boolean jj_3R_392() + { + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_405()) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_406()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_67() + { + if (jj_3R_103()) return true; + return false; + } + + private boolean jj_3_4() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_67()) jj_scanpos = xsp; + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_178() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_208()) { + jj_scanpos = xsp; + if (jj_3R_209()) { + jj_scanpos = xsp; + if (jj_3R_210()) return true; + } + } + return false; + } + + private boolean jj_3R_250() + { + if (jj_3R_275()) return true; + return false; + } + + private boolean jj_3R_391() + { + if (jj_3R_404()) return true; + return false; + } + + private boolean jj_3R_331() + { + if (jj_scan_token(TRY)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_391()) jj_scanpos = xsp; + if (jj_3R_106()) return true; + xsp = jj_scanpos; + if (jj_3R_392()) { + jj_scanpos = xsp; + if (jj_3R_393()) return true; + } + return false; + } + + private boolean jj_3R_244() + { + if (jj_scan_token(_DEFAULT)) return true; + if (jj_3R_95()) return true; + return false; + } + + private boolean jj_3R_249() + { + if (jj_3R_274()) return true; + return false; + } + + private boolean jj_3R_248() + { + if (jj_3R_273()) return true; + return false; + } + + private boolean jj_3R_247() + { + if (jj_3R_272()) return true; + return false; + } + + private boolean jj_3R_216() + { + if (jj_scan_token(DECR)) return true; + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_246() + { + if (jj_3R_271()) return true; + return false; + } + + private boolean jj_3R_245() + { + if (jj_3R_270()) return true; + return false; + } + + private boolean jj_3R_390() + { + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_193() + { + if (jj_3R_219()) return true; + return false; + } + + private boolean jj_3R_97() + { + if (jj_scan_token(INCR)) return true; + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_188() + { + if (jj_3R_178()) return true; + return false; + } + + private boolean jj_3R_389() + { + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_330() + { + if (jj_scan_token(SYNCHRONIZED)) return true; + if (jj_scan_token(LPAREN)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(RPAREN)) return true; + if (jj_3R_106()) return true; + return false; + } + + private boolean jj_3R_214() + { + if (jj_3R_95()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_244()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_245()) { + jj_scanpos = xsp; + if (jj_3R_246()) { + jj_scanpos = xsp; + if (jj_3R_247()) { + jj_scanpos = xsp; + if (jj_3R_248()) { + jj_scanpos = xsp; + if (jj_3R_249()) { + jj_scanpos = xsp; + if (jj_3R_250()) return true; + } + } + } + } + } + return false; + } + + private boolean jj_3_6() + { + if (jj_3R_70()) return true; + return false; + } + + private boolean jj_3R_388() + { + if (jj_scan_token(IDENTIFIER)) return true; + return false; + } + + private boolean jj_3R_218() + { + if (jj_scan_token(MINUS)) return true; + return false; + } + + private boolean jj_3R_217() + { + if (jj_scan_token(PLUS)) return true; + return false; + } + + private boolean jj_3R_329() + { + if (jj_scan_token(THROW)) return true; + if (jj_3R_80()) return true; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_187() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_217()) { + jj_scanpos = xsp; + if (jj_3R_218()) return true; + } + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_186() + { + if (jj_3R_216()) return true; + return false; + } + + private boolean jj_3R_185() + { + if (jj_3R_97()) return true; + return false; + } + + private boolean jj_3R_183() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3_6()) { + jj_scanpos = xsp; + if (jj_3R_214()) { + jj_scanpos = xsp; + if (jj_3R_215()) return true; + } + } + return false; + } + + private boolean jj_3R_429() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_80()) return true; + return false; + } + + private boolean jj_3R_328() + { + if (jj_scan_token(RETURN)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_390()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_148() + { + if (jj_3R_183()) return true; + return false; + } + + private boolean jj_3R_151() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_185()) { + jj_scanpos = xsp; + if (jj_3R_186()) { + jj_scanpos = xsp; + if (jj_3R_187()) { + jj_scanpos = xsp; + if (jj_3R_188()) return true; + } + } + } + return false; + } + + private boolean jj_3R_398() + { + if (jj_scan_token(REM)) return true; + return false; + } + + private boolean jj_3R_397() + { + if (jj_scan_token(SLASH)) return true; + return false; + } + + private boolean jj_3R_327() + { + if (jj_scan_token(CONTINUE)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_389()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_93() + { + if (jj_scan_token(LBRACE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_148()) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(RBRACE)) return true; + return false; + } + + private boolean jj_3R_396() + { + if (jj_scan_token(STAR)) return true; + return false; + } + + private boolean jj_3R_380() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_396()) { + jj_scanpos = xsp; + if (jj_3R_397()) { + jj_scanpos = xsp; + if (jj_3R_398()) return true; + } + } + if (jj_3R_151()) return true; + return false; + } + + private boolean jj_3R_403() + { + if (jj_3R_420()) return true; + return false; + } + + private boolean jj_3R_252() + { + if (jj_scan_token(BIT_AND)) return true; + if (jj_3R_251()) return true; + return false; + } + + private boolean jj_3R_326() + { + if (jj_scan_token(BREAK)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_388()) jj_scanpos = xsp; + if (jj_scan_token(SEMICOLON)) return true; + return false; + } + + private boolean jj_3R_219() + { + if (jj_scan_token(EXTENDS)) return true; + if (jj_3R_251()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_252()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_345() + { + if (jj_3R_151()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_380()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_382() + { + if (jj_scan_token(MINUS)) return true; + return false; + } + + private boolean jj_3R_381() + { + if (jj_scan_token(PLUS)) return true; + return false; + } + + private boolean jj_3_3() + { + if (jj_scan_token(COMMA)) return true; + if (jj_3R_66()) return true; + return false; + } + + private boolean jj_3R_373() + { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_381()) { + jj_scanpos = xsp; + if (jj_3R_382()) return true; + } + if (jj_3R_345()) return true; + return false; + } + + private boolean jj_3R_158() + { + if (jj_scan_token(IDENTIFIER)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_193()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_420() + { + if (jj_3R_427()) return true; + 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[160]; + 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,0x0,0x0,0x1,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,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,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,0x0,0x0,0x0,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x40000000,0x40000000,0x902020,0x0,0x0,0x0,0x800020,0x102000,0x902020,0x2000,0x0,0x200000,0x20000000,0x0,0x0,0x20000000,0x0,0x0,0x29532a0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x29532a0,0x10000,0x102000,0x2041280,0x29532a0,0x0,0x0,0x0,0x2441280,0x2441280,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x28412a0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2441280,0x16c6b3e0,0x0,0x2041280,0x2041280,0x2041280,0x0,0x2041280,0x2041280,0x200000,0x200000,0x2041280,0x2041280,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2441280,0x0,0x0,0x2441280,0x0,0x0,0x2041280,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2441280,0x2c412a0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x2441280,0x0,0x0,0x0,0x2041280,0x2441280,0x0,0x0,0x164693c0,0x0,0x164693c0,0x0,0x2441280,0x0,0x0,0x0,0x0,0x2441280,0x10400,0x10400,0x80000,0x2c412a0,0x2441280,0x2441280,0x2c412a0,0x2441280,0x0,0x0,0x0,0x2441280,0x0,0x800,0x0,0x1000000,0x0,0x0,0x0,0x0,0x2441280,0x2441280,0x0,0x29432a0,0x2143280,0x29432a0,0x10000,}; + } + private static void jj_la1_init_2() { + jj_la1_2 = new int[] {0x0,0x0,0x111338a,0x0,0x1000,0x0,0x1113388,0x2,0x111338a,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1913b8f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1913b8f,0x0,0x2,0x800805,0x1913b8f,0x0,0x0,0x0,0xca24835,0xca24835,0x0,0x0,0x0,0x0,0x80000,0x0,0x0,0x1113b8d,0x0,0x0,0x0,0x0,0x0,0x80000,0x0,0x0,0xca24835,0xff7ffbf,0x1000,0x805,0x805,0x805,0x0,0x805,0x805,0x4000,0x4000,0x805,0x800805,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xca24835,0x0,0x0,0xca24835,0x0,0x0,0x805,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0xca24835,0xdb37bbd,0x0,0x10,0x0,0xc224030,0x0,0x0,0x0,0x0,0x20010,0x0,0xc200020,0x200000,0xca24835,0x0,0x0,0x0,0x805,0xca24835,0x0,0x0,0xee7cc35,0x0,0xee7cc35,0x0,0xca24835,0x0,0x10,0x0,0x0,0xca24835,0x0,0x0,0x0,0xdb37bbd,0xca24835,0xca24835,0xdb37bbd,0xca24835,0x0,0x0,0x0,0xca24835,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xca24835,0xca24835,0x0,0x1113b8f,0x807,0x1113b8f,0x0,}; + } + private static void jj_la1_init_3() { + jj_la1_3 = new int[] {0x10000,0x10000,0x90000,0x0,0x0,0x40000,0x80000,0x80000,0x90000,0x0,0x200000,0x0,0x0,0x20000,0x20000,0x0,0x80080,0x20000,0x291080,0x10000,0x80000,0x400,0x1000,0x20000,0x0,0x0,0x291080,0x0,0x80000,0x200080,0x290080,0x20000,0x100000,0x84000,0xc014e1,0xc014e1,0x20000,0x200000,0x84000,0x20000,0x0,0x11000,0x20000,0x80080,0x20000,0x20000,0x0,0x200000,0x20000,0x0,0x200000,0x200000,0x2004e1,0x914e1,0x0,0x0,0x80,0x80,0x20000,0x1080080,0x1000080,0x0,0x0,0x0,0x80,0x200000,0x80,0x0,0x100000,0x100000,0x1000000,0x40000000,0x80000000,0x0,0x0,0x0,0x24000000,0x24000000,0x0,0x18200000,0x18200000,0x0,0x0,0x0,0x0,0x0,0x0,0xc004e1,0xc00000,0xc00000,0x4e1,0x0,0x0,0x80,0x200000,0x400,0x200000,0x80,0x40000,0x20000,0x20000,0xc004e1,0xc804e1,0x200000,0x80,0x400,0x461,0x80,0x40000,0x200000,0x400,0x0,0x44000,0x61,0x0,0xc004e1,0x20000,0x200000,0x84400,0x280080,0xc004e1,0x84000,0x1000,0x114e1,0x2000000,0x114e1,0x20000,0xc014e1,0x200000,0x80,0x100000,0x100000,0x4e1,0x0,0x0,0x0,0xc804e1,0xc004e1,0xc004e1,0xc904e1,0xc004e1,0x20000,0x80,0x80,0xc004e1,0x400,0x0,0x0,0x0,0x80000,0x80000,0x80,0x20000,0xc814e1,0xc814e1,0x20000,0x90080,0x80080,0x90080,0x0,}; + } + private static void jj_la1_init_4() { + jj_la1_4 = new int[] {0x0,0x0,0x0,0x10000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x1bff800,0x3ff800,0x0,0x0,0x0,0x80,0x100,0x40,0x0,0x0,0x0,0x8000000,0x8000000,0x400,0xc,0xc,0x230,0x230,0xc,0xf,0x0,0x0,0x0,0x3,0x40,0x0,0x0,0x0,0x0,0x0,0x1000000,0x0,0x0,0xf,0xf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0x0,0x0,0x0,0x0,0xf,0x0,0x0,0x3,0x0,0x3,0x0,0xf,0x0,0x0,0x1bff803,0x1bff803,0x2,0x0,0x0,0x0,0xf,0xf,0xf,0xf,0xf,0x0,0x0,0x0,0xf,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0xf,0xf,0x0,0x0,0x0,0x0,0x0,}; + } + final private JJCalls[] jj_2_rtns = new JJCalls[44]; + private boolean jj_rescan = false; + private int jj_gc = 0; + + /** Constructor. */ + public ASTParser(Provider 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 < 160; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Constructor. */ + public ASTParser(String dsl) throws ParseException, TokenMgrException { + this(new StringProvider(dsl)); + } + + public void ReInit(String s) { + ReInit(new StringProvider(s)); + } + /** Reinitialise. */ + public void ReInit(Provider stream) { + if (jj_input_stream == null) { + jj_input_stream = new JavaCharStream(stream, 1, 1); + } else { + jj_input_stream.ReInit(stream, 1, 1); + } + if (token_source == null) { + token_source = new ASTParserTokenManager(jj_input_stream); + } + + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 160; 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 < 160; 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 < 160; 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) { + 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(); + } + + @SuppressWarnings("serial") + static private final class LookaheadSuccess extends java.lang.RuntimeException { } + 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_f() { + 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<int[]> jj_expentries = new java.util.ArrayList<int[]>(); + 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]; + } + + for (int[] oldentry : jj_expentries) { + if (oldentry.length == jj_expentry.length) { + boolean isMatched = true; + + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + isMatched = false; + break; + } + + } + if (isMatched) { + jj_expentries.add(jj_expentry); + break; + } + } + } + + if (pos != 0) { + jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } + } + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[157]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 160; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1<<j)) != 0) { + la1tokens[j] = true; + } + if ((jj_la1_1[i] & (1<<j)) != 0) { + la1tokens[32+j] = true; + } + if ((jj_la1_2[i] & (1<<j)) != 0) { + la1tokens[64+j] = true; + } + if ((jj_la1_3[i] & (1<<j)) != 0) { + la1tokens[96+j] = true; + } + if ((jj_la1_4[i] & (1<<j)) != 0) { + la1tokens[128+j] = true; + } + } + } + } + for (int i = 0; i < 157; i++) { + if (la1tokens[i]) { + jj_expentry = new int[1]; + jj_expentry[0] = i; + jj_expentries.add(jj_expentry); + } + } + jj_endpos = 0; + jj_rescan_token(); + jj_add_error_token(0, 0); + int[][] exptokseq = new int[jj_expentries.size()][]; + for (int i = 0; i < jj_expentries.size(); i++) { + exptokseq[i] = jj_expentries.get(i); + } + return new ParseException(token, exptokseq, tokenImage, token_source == null ? null : ASTParserTokenManager.lexStateNames[token_source.curLexState]); + } + + /** Enable tracing. */ + final public void enable_tracing() { + } + + /** Disable tracing. */ + final public void disable_tracing() { + } + + private void jj_rescan_token() { + jj_rescan = true; + for (int i = 0; i < 44; i++) { + try { + JJCalls p = jj_2_rtns[i]; + + do { + if (p.gen > 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; + } + } + 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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParserConstants.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParserConstants.java new file mode 100644 index 000000000..b256848a9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParserConstants.java @@ -0,0 +1,438 @@ +/* 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 <http://www.gnu.org/licenses/>. + */ +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 = 31; + /** RegularExpression Id. */ + int JAVA_DOC_COMMENT = 34; + /** RegularExpression Id. */ + int MULTI_LINE_COMMENT = 35; + /** RegularExpression Id. */ + int ABSTRACT = 37; + /** RegularExpression Id. */ + int ASSERT = 38; + /** RegularExpression Id. */ + int BOOLEAN = 39; + /** RegularExpression Id. */ + int BREAK = 40; + /** RegularExpression Id. */ + int BYTE = 41; + /** RegularExpression Id. */ + int CASE = 42; + /** RegularExpression Id. */ + int CATCH = 43; + /** RegularExpression Id. */ + int CHAR = 44; + /** RegularExpression Id. */ + int CLASS = 45; + /** RegularExpression Id. */ + int CONST = 46; + /** RegularExpression Id. */ + int CONTINUE = 47; + /** RegularExpression Id. */ + int _DEFAULT = 48; + /** RegularExpression Id. */ + int DO = 49; + /** RegularExpression Id. */ + int DOUBLE = 50; + /** RegularExpression Id. */ + int ELSE = 51; + /** RegularExpression Id. */ + int ENUM = 52; + /** RegularExpression Id. */ + int EXTENDS = 53; + /** RegularExpression Id. */ + int FALSE = 54; + /** RegularExpression Id. */ + int FINAL = 55; + /** RegularExpression Id. */ + int FINALLY = 56; + /** RegularExpression Id. */ + int FLOAT = 57; + /** RegularExpression Id. */ + int FOR = 58; + /** RegularExpression Id. */ + int GOTO = 59; + /** RegularExpression Id. */ + int IF = 60; + /** RegularExpression Id. */ + int IMPLEMENTS = 61; + /** RegularExpression Id. */ + int IMPORT = 62; + /** RegularExpression Id. */ + int INSTANCEOF = 63; + /** RegularExpression Id. */ + int INT = 64; + /** RegularExpression Id. */ + int INTERFACE = 65; + /** RegularExpression Id. */ + int LONG = 66; + /** RegularExpression Id. */ + int NATIVE = 67; + /** RegularExpression Id. */ + int NEW = 68; + /** RegularExpression Id. */ + int NULL = 69; + /** RegularExpression Id. */ + int PACKAGE = 70; + /** RegularExpression Id. */ + int PRIVATE = 71; + /** RegularExpression Id. */ + int PROTECTED = 72; + /** RegularExpression Id. */ + int PUBLIC = 73; + /** RegularExpression Id. */ + int RETURN = 74; + /** RegularExpression Id. */ + int SHORT = 75; + /** RegularExpression Id. */ + int STATIC = 76; + /** RegularExpression Id. */ + int STRICTFP = 77; + /** RegularExpression Id. */ + int SUPER = 78; + /** RegularExpression Id. */ + int SWITCH = 79; + /** RegularExpression Id. */ + int SYNCHRONIZED = 80; + /** RegularExpression Id. */ + int THIS = 81; + /** RegularExpression Id. */ + int THROW = 82; + /** RegularExpression Id. */ + int THROWS = 83; + /** RegularExpression Id. */ + int TRANSIENT = 84; + /** RegularExpression Id. */ + int TRUE = 85; + /** RegularExpression Id. */ + int TRY = 86; + /** RegularExpression Id. */ + int VOID = 87; + /** RegularExpression Id. */ + int VOLATILE = 88; + /** RegularExpression Id. */ + int WHILE = 89; + /** RegularExpression Id. */ + int LONG_LITERAL = 90; + /** RegularExpression Id. */ + int INTEGER_LITERAL = 91; + /** RegularExpression Id. */ + int DECIMAL_LITERAL = 92; + /** RegularExpression Id. */ + int HEX_LITERAL = 93; + /** RegularExpression Id. */ + int OCTAL_LITERAL = 94; + /** RegularExpression Id. */ + int BINARY_LITERAL = 95; + /** RegularExpression Id. */ + int FLOATING_POINT_LITERAL = 96; + /** RegularExpression Id. */ + int DECIMAL_FLOATING_POINT_LITERAL = 97; + /** RegularExpression Id. */ + int DECIMAL_EXPONENT = 98; + /** RegularExpression Id. */ + int HEXADECIMAL_FLOATING_POINT_LITERAL = 99; + /** RegularExpression Id. */ + int HEXADECIMAL_EXPONENT = 100; + /** RegularExpression Id. */ + int CHARACTER_LITERAL = 101; + /** RegularExpression Id. */ + int STRING_LITERAL = 102; + /** RegularExpression Id. */ + int IDENTIFIER = 103; + /** RegularExpression Id. */ + int LETTER = 104; + /** RegularExpression Id. */ + int PART_LETTER = 105; + /** RegularExpression Id. */ + int LPAREN = 106; + /** RegularExpression Id. */ + int RPAREN = 107; + /** RegularExpression Id. */ + int LBRACE = 108; + /** RegularExpression Id. */ + int RBRACE = 109; + /** RegularExpression Id. */ + int LBRACKET = 110; + /** RegularExpression Id. */ + int RBRACKET = 111; + /** RegularExpression Id. */ + int SEMICOLON = 112; + /** RegularExpression Id. */ + int COMMA = 113; + /** RegularExpression Id. */ + int DOT = 114; + /** RegularExpression Id. */ + int AT = 115; + /** RegularExpression Id. */ + int ASSIGN = 116; + /** RegularExpression Id. */ + int LT = 117; + /** RegularExpression Id. */ + int BANG = 118; + /** RegularExpression Id. */ + int TILDE = 119; + /** RegularExpression Id. */ + int HOOK = 120; + /** RegularExpression Id. */ + int COLON = 121; + /** RegularExpression Id. */ + int EQ = 122; + /** RegularExpression Id. */ + int LE = 123; + /** RegularExpression Id. */ + int GE = 124; + /** RegularExpression Id. */ + int NE = 125; + /** RegularExpression Id. */ + int SC_OR = 126; + /** RegularExpression Id. */ + int SC_AND = 127; + /** RegularExpression Id. */ + int INCR = 128; + /** RegularExpression Id. */ + int DECR = 129; + /** RegularExpression Id. */ + int PLUS = 130; + /** RegularExpression Id. */ + int MINUS = 131; + /** RegularExpression Id. */ + int STAR = 132; + /** RegularExpression Id. */ + int SLASH = 133; + /** RegularExpression Id. */ + int BIT_AND = 134; + /** RegularExpression Id. */ + int BIT_OR = 135; + /** RegularExpression Id. */ + int XOR = 136; + /** RegularExpression Id. */ + int REM = 137; + /** RegularExpression Id. */ + int LSHIFT = 138; + /** RegularExpression Id. */ + int PLUSASSIGN = 139; + /** RegularExpression Id. */ + int MINUSASSIGN = 140; + /** RegularExpression Id. */ + int STARASSIGN = 141; + /** RegularExpression Id. */ + int SLASHASSIGN = 142; + /** RegularExpression Id. */ + int ANDASSIGN = 143; + /** RegularExpression Id. */ + int ORASSIGN = 144; + /** RegularExpression Id. */ + int XORASSIGN = 145; + /** RegularExpression Id. */ + int REMASSIGN = 146; + /** RegularExpression Id. */ + int LSHIFTASSIGN = 147; + /** RegularExpression Id. */ + int RSIGNEDSHIFTASSIGN = 148; + /** RegularExpression Id. */ + int RUNSIGNEDSHIFTASSIGN = 149; + /** RegularExpression Id. */ + int ELLIPSIS = 150; + /** RegularExpression Id. */ + int ARROW = 151; + /** RegularExpression Id. */ + int DOUBLECOLON = 152; + /** RegularExpression Id. */ + int RUNSIGNEDSHIFT = 153; + /** RegularExpression Id. */ + int RSIGNEDSHIFT = 154; + /** RegularExpression Id. */ + int GT = 155; + + /** 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 = { + "<EOF>", + "\" \"", + "\"\\t\"", + "\"\\n\"", + "\"\\r\"", + "\"\\f\"", + "\"\\u0085\"", + "\"\\u00a0\"", + "\"\\u1680\"", + "\"\\u180e\"", + "\"\\u2000\"", + "\"\\u2001\"", + "\"\\u2002\"", + "\"\\u2003\"", + "\"\\u2004\"", + "\"\\u2005\"", + "\"\\u2006\"", + "\"\\u2007\"", + "\"\\u2008\"", + "\"\\u2009\"", + "\"\\u200a\"", + "\"\\u200b\"", + "\"\\u200c\"", + "\"\\u200d\"", + "\"\\u2028\"", + "\"\\u2029\"", + "\"\\u202f\"", + "\"\\u205f\"", + "\"\\u2060\"", + "\"\\u3000\"", + "\"\\ufeff\"", + "<SINGLE_LINE_COMMENT>", + "<token of kind 32>", + "\"/*\"", + "\"*/\"", + "\"*/\"", + "<token of kind 36>", + "\"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\"", + "<LONG_LITERAL>", + "<INTEGER_LITERAL>", + "<DECIMAL_LITERAL>", + "<HEX_LITERAL>", + "<OCTAL_LITERAL>", + "<BINARY_LITERAL>", + "<FLOATING_POINT_LITERAL>", + "<DECIMAL_FLOATING_POINT_LITERAL>", + "<DECIMAL_EXPONENT>", + "<HEXADECIMAL_FLOATING_POINT_LITERAL>", + "<HEXADECIMAL_EXPONENT>", + "<CHARACTER_LITERAL>", + "<STRING_LITERAL>", + "<IDENTIFIER>", + "<LETTER>", + "<PART_LETTER>", + "\"(\"", + "\")\"", + "\"{\"", + "\"}\"", + "\"[\"", + "\"]\"", + "\";\"", + "\",\"", + "\".\"", + "\"@\"", + "\"=\"", + "\"<\"", + "\"!\"", + "\"~\"", + "\"?\"", + "\":\"", + "\"==\"", + "\"<=\"", + "\">=\"", + "\"!=\"", + "\"||\"", + "\"&&\"", + "\"++\"", + "\"--\"", + "\"+\"", + "\"-\"", + "\"*\"", + "\"/\"", + "\"&\"", + "\"|\"", + "\"^\"", + "\"%\"", + "\"<<\"", + "\"+=\"", + "\"-=\"", + "\"*=\"", + "\"/=\"", + "\"&=\"", + "\"|=\"", + "\"^=\"", + "\"%=\"", + "\"<<=\"", + "\">>=\"", + "\">>>=\"", + "\"...\"", + "\"->\"", + "\"::\"", + "\">>>\"", + "\">>\"", + "\">\"", + "\"\\u001a\"", + }; + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParserTokenManager.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParserTokenManager.java new file mode 100644 index 000000000..fe6c0c668 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ASTParserTokenManager.java @@ -0,0 +1,2643 @@ +/* ASTParserTokenManager.java */ +/* 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 <http://www.gnu.org/licenses/>. + */ +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.*; +import com.github.javaparser.utils.*; +import static com.github.javaparser.ASTParser.*; +import static com.github.javaparser.Range.*; +import static com.github.javaparser.Position.*; +import static com.github.javaparser.ast.type.ArrayType.*; + +/** Token Manager. */ +@SuppressWarnings("unused")public class ASTParserTokenManager implements ASTParserConstants { + private List<Token> tokens = new ArrayList<Token>(); + private CommentsCollection commentsCollection = new CommentsCollection(); + + List<Token> getTokens() { + return tokens; + } + + CommentsCollection getCommentsCollection() { + return commentsCollection; + } + + private void CommonTokenAction(Token token) { + tokens.add(token); + + while (token.specialToken != null) { + token = token.specialToken; + String commentText = token.image; + if (commentText.startsWith("/**")) { + JavadocComment comment = new JavadocComment(tokenRange(token), commentText.substring(3, commentText.length() - 2)); + commentsCollection.addComment(comment); + } else if (commentText.startsWith("/*")) { + BlockComment comment = new BlockComment(tokenRange(token), commentText.substring(2, commentText.length() - 2)); + commentsCollection.addComment(comment); + } else if (commentText.startsWith("//")) { + // line comments have their end of line character(s) included, and we don't want that. + Range range = tokenRange(token); + while (commentText.endsWith("\r") || commentText.endsWith("\n")) { + commentText = commentText.substring(0, commentText.length() - 1); + } + range = range.withEnd(pos(range.begin.line, range.begin.column + commentText.length())); + LineComment comment = new LineComment(tokenRange(token), commentText.substring(2)); + commentsCollection.addComment(comment); + } else { + throw new AssertionError("Didn't expect to get here. Please file a bug report. [" + commentText + "]"); + } + } + } + + /** 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 & 0xffffffe000000000L) != 0L || (active1 & 0x3ffffffL) != 0L) + { + jjmatchedKind = 103; + return 43; + } + if ((active0 & 0x200000000L) != 0L || (active2 & 0x4020L) != 0L) + return 45; + if ((active1 & 0x4000000000000L) != 0L || (active2 & 0x400000L) != 0L) + return 1; + return -1; + case 1: + if ((active0 & 0xeff9ffe000000000L) != 0L || (active1 & 0x3ffffffL) != 0L) + { + if (jjmatchedPos != 1) + { + jjmatchedKind = 103; + jjmatchedPos = 1; + } + return 43; + } + if ((active0 & 0x1006000000000000L) != 0L) + return 43; + if ((active0 & 0x200000000L) != 0L) + return 50; + return -1; + case 2: + if ((active0 & 0x400000000000000L) != 0L || (active1 & 0x400013L) != 0L) + return 43; + if ((active0 & 0xebfdffe000000000L) != 0L || (active1 & 0x3bfffecL) != 0L) + { + if (jjmatchedPos != 2) + { + jjmatchedKind = 103; + jjmatchedPos = 2; + } + return 43; + } + return -1; + case 3: + if ((active0 & 0xe3e5e9e000000000L) != 0L || (active1 & 0x31dffcaL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 3; + return 43; + } + if ((active0 & 0x818160000000000L) != 0L || (active1 & 0xa20024L) != 0L) + return 43; + return -1; + case 4: + if ((active0 & 0xe02580e000000000L) != 0L || (active1 & 0x111b7caL) != 0L) + { + if (jjmatchedPos != 4) + { + jjmatchedKind = 103; + jjmatchedPos = 4; + } + return 43; + } + if ((active0 & 0x3c0690000000000L) != 0L || (active1 & 0x20c4800L) != 0L) + return 43; + return -1; + case 5: + if ((active0 & 0x4004004000000000L) != 0L || (active1 & 0x89608L) != 0L) + return 43; + if ((active0 & 0xa12180a000000000L) != 0L || (active1 & 0x11121c2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 5; + return 43; + } + return -1; + case 6: + if ((active0 & 0x121008000000000L) != 0L || (active1 & 0xc0L) != 0L) + return 43; + if ((active0 & 0xa000802000000000L) != 0L || (active1 & 0x1112102L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 6; + return 43; + } + return -1; + case 7: + if ((active0 & 0xa000000000000000L) != 0L || (active1 & 0x110102L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 7; + return 43; + } + if ((active0 & 0x802000000000L) != 0L || (active1 & 0x1002000L) != 0L) + return 43; + return -1; + case 8: + if ((active1 & 0x100102L) != 0L) + return 43; + if ((active0 & 0xa000000000000000L) != 0L || (active1 & 0x10000L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 8; + return 43; + } + return -1; + case 9: + if ((active0 & 0xa000000000000000L) != 0L) + return 43; + if ((active1 & 0x10000L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 9; + return 43; + } + return -1; + case 10: + if ((active1 & 0x10000L) != 0L) + { + jjmatchedKind = 103; + 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, 156); + case 33: + jjmatchedKind = 118; + return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000000000000L, 0x0L); + case 37: + jjmatchedKind = 137; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x40000L); + case 38: + jjmatchedKind = 134; + return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000000000000L, 0x8000L); + case 40: + return jjStopAtPos(0, 106); + case 41: + return jjStopAtPos(0, 107); + case 42: + jjmatchedKind = 132; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x2000L); + case 43: + jjmatchedKind = 130; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x801L); + case 44: + return jjStopAtPos(0, 113); + case 45: + jjmatchedKind = 131; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x801002L); + case 46: + jjmatchedKind = 114; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x400000L); + case 47: + jjmatchedKind = 133; + return jjMoveStringLiteralDfa1_0(0x200000000L, 0x0L, 0x4000L); + case 58: + jjmatchedKind = 121; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x1000000L); + case 59: + return jjStopAtPos(0, 112); + case 60: + jjmatchedKind = 117; + return jjMoveStringLiteralDfa1_0(0x0L, 0x800000000000000L, 0x80400L); + case 61: + jjmatchedKind = 116; + return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000000000L, 0x0L); + case 62: + jjmatchedKind = 155; + return jjMoveStringLiteralDfa1_0(0x0L, 0x1000000000000000L, 0x6300000L); + case 63: + return jjStopAtPos(0, 120); + case 64: + return jjStopAtPos(0, 115); + case 91: + return jjStopAtPos(0, 110); + case 93: + return jjStopAtPos(0, 111); + case 94: + jjmatchedKind = 136; + return jjMoveStringLiteralDfa1_0(0x0L, 0x0L, 0x20000L); + case 97: + return jjMoveStringLiteralDfa1_0(0x6000000000L, 0x0L, 0x0L); + case 98: + return jjMoveStringLiteralDfa1_0(0x38000000000L, 0x0L, 0x0L); + case 99: + return jjMoveStringLiteralDfa1_0(0xfc0000000000L, 0x0L, 0x0L); + case 100: + return jjMoveStringLiteralDfa1_0(0x7000000000000L, 0x0L, 0x0L); + case 101: + return jjMoveStringLiteralDfa1_0(0x38000000000000L, 0x0L, 0x0L); + case 102: + return jjMoveStringLiteralDfa1_0(0x7c0000000000000L, 0x0L, 0x0L); + case 103: + return jjMoveStringLiteralDfa1_0(0x800000000000000L, 0x0L, 0x0L); + case 105: + return jjMoveStringLiteralDfa1_0(0xf000000000000000L, 0x3L, 0x0L); + case 108: + return jjMoveStringLiteralDfa1_0(0x0L, 0x4L, 0x0L); + case 110: + return jjMoveStringLiteralDfa1_0(0x0L, 0x38L, 0x0L); + case 112: + return jjMoveStringLiteralDfa1_0(0x0L, 0x3c0L, 0x0L); + case 114: + return jjMoveStringLiteralDfa1_0(0x0L, 0x400L, 0x0L); + case 115: + return jjMoveStringLiteralDfa1_0(0x0L, 0x1f800L, 0x0L); + case 116: + return jjMoveStringLiteralDfa1_0(0x0L, 0x7e0000L, 0x0L); + case 118: + return jjMoveStringLiteralDfa1_0(0x0L, 0x1800000L, 0x0L); + case 119: + return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L, 0x0L); + case 123: + return jjStopAtPos(0, 108); + case 124: + jjmatchedKind = 135; + return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000000000000L, 0x10000L); + case 125: + return jjStopAtPos(0, 109); + case 126: + return jjStopAtPos(0, 119); + case 133: + return jjStopAtPos(0, 6); + case 160: + return jjStopAtPos(0, 7); + case 5760: + return jjStopAtPos(0, 8); + case 6158: + return jjStopAtPos(0, 9); + case 8192: + return jjStopAtPos(0, 10); + case 8193: + return jjStopAtPos(0, 11); + case 8194: + return jjStopAtPos(0, 12); + case 8195: + return jjStopAtPos(0, 13); + case 8196: + return jjStopAtPos(0, 14); + case 8197: + return jjStopAtPos(0, 15); + case 8198: + return jjStopAtPos(0, 16); + case 8199: + return jjStopAtPos(0, 17); + case 8200: + return jjStopAtPos(0, 18); + case 8201: + return jjStopAtPos(0, 19); + case 8202: + return jjStopAtPos(0, 20); + case 8203: + return jjStopAtPos(0, 21); + case 8204: + return jjStopAtPos(0, 22); + case 8205: + return jjStopAtPos(0, 23); + case 8232: + return jjStopAtPos(0, 24); + case 8233: + return jjStopAtPos(0, 25); + case 8239: + return jjStopAtPos(0, 26); + case 8287: + return jjStopAtPos(0, 27); + case 8288: + return jjStopAtPos(0, 28); + case 12288: + return jjStopAtPos(0, 29); + case 65279: + return jjStopAtPos(0, 30); + 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 & 0x8000000000000000L) != 0L) + return jjStopAtPos(1, 127); + break; + case 42: + if ((active0 & 0x200000000L) != 0L) + return jjStartNfaWithStates_0(1, 33, 50); + break; + case 43: + if ((active2 & 0x1L) != 0L) + return jjStopAtPos(1, 128); + break; + case 45: + if ((active2 & 0x2L) != 0L) + return jjStopAtPos(1, 129); + break; + case 46: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x400000L); + case 58: + if ((active2 & 0x1000000L) != 0L) + return jjStopAtPos(1, 152); + break; + case 60: + if ((active2 & 0x400L) != 0L) + { + jjmatchedKind = 138; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x80000L); + case 61: + if ((active1 & 0x400000000000000L) != 0L) + return jjStopAtPos(1, 122); + else if ((active1 & 0x800000000000000L) != 0L) + return jjStopAtPos(1, 123); + else if ((active1 & 0x1000000000000000L) != 0L) + return jjStopAtPos(1, 124); + else if ((active1 & 0x2000000000000000L) != 0L) + return jjStopAtPos(1, 125); + else if ((active2 & 0x800L) != 0L) + return jjStopAtPos(1, 139); + else if ((active2 & 0x1000L) != 0L) + return jjStopAtPos(1, 140); + else if ((active2 & 0x2000L) != 0L) + return jjStopAtPos(1, 141); + else if ((active2 & 0x4000L) != 0L) + return jjStopAtPos(1, 142); + else if ((active2 & 0x8000L) != 0L) + return jjStopAtPos(1, 143); + else if ((active2 & 0x10000L) != 0L) + return jjStopAtPos(1, 144); + else if ((active2 & 0x20000L) != 0L) + return jjStopAtPos(1, 145); + else if ((active2 & 0x40000L) != 0L) + return jjStopAtPos(1, 146); + break; + case 62: + if ((active2 & 0x800000L) != 0L) + return jjStopAtPos(1, 151); + else if ((active2 & 0x4000000L) != 0L) + { + jjmatchedKind = 154; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0L, active2, 0x2300000L); + case 97: + return jjMoveStringLiteralDfa2_0(active0, 0x400c0000000000L, active1, 0x48L, active2, 0L); + case 98: + return jjMoveStringLiteralDfa2_0(active0, 0x2000000000L, active1, 0L, active2, 0L); + case 101: + return jjMoveStringLiteralDfa2_0(active0, 0x1000000000000L, active1, 0x410L, active2, 0L); + case 102: + if ((active0 & 0x1000000000000000L) != 0L) + return jjStartNfaWithStates_0(1, 60, 43); + break; + case 104: + return jjMoveStringLiteralDfa2_0(active0, 0x100000000000L, active1, 0x20e0800L, active2, 0L); + case 105: + return jjMoveStringLiteralDfa2_0(active0, 0x180000000000000L, active1, 0L, active2, 0L); + case 108: + return jjMoveStringLiteralDfa2_0(active0, 0x208200000000000L, active1, 0L, active2, 0L); + case 109: + return jjMoveStringLiteralDfa2_0(active0, 0x6000000000000000L, active1, 0L, active2, 0L); + case 110: + return jjMoveStringLiteralDfa2_0(active0, 0x8010000000000000L, active1, 0x3L, active2, 0L); + case 111: + if ((active0 & 0x2000000000000L) != 0L) + { + jjmatchedKind = 49; + jjmatchedPos = 1; + } + return jjMoveStringLiteralDfa2_0(active0, 0xc04c08000000000L, active1, 0x1800004L, active2, 0L); + case 114: + return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L, active1, 0x700180L, active2, 0L); + case 115: + return jjMoveStringLiteralDfa2_0(active0, 0x4000000000L, active1, 0L, active2, 0L); + case 116: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x3000L, active2, 0L); + case 117: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4220L, active2, 0L); + case 119: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x8000L, active2, 0L); + case 120: + return jjMoveStringLiteralDfa2_0(active0, 0x20000000000000L, active1, 0L, active2, 0L); + case 121: + return jjMoveStringLiteralDfa2_0(active0, 0x20000000000L, active1, 0x10000L, active2, 0L); + case 124: + if ((active1 & 0x4000000000000000L) != 0L) + return jjStopAtPos(1, 126); + 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 ((active2 & 0x400000L) != 0L) + return jjStopAtPos(2, 150); + break; + case 61: + if ((active2 & 0x80000L) != 0L) + return jjStopAtPos(2, 147); + else if ((active2 & 0x100000L) != 0L) + return jjStopAtPos(2, 148); + break; + case 62: + if ((active2 & 0x2000000L) != 0L) + { + jjmatchedKind = 153; + jjmatchedPos = 2; + } + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0L, active2, 0x200000L); + case 97: + return jjMoveStringLiteralDfa3_0(active0, 0x300000000000L, active1, 0x101000L, active2, 0L); + case 98: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x200L, active2, 0L); + case 99: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x40L, active2, 0L); + case 101: + return jjMoveStringLiteralDfa3_0(active0, 0x10000000000L, active1, 0L, active2, 0L); + case 102: + return jjMoveStringLiteralDfa3_0(active0, 0x1000000000000L, active1, 0L, active2, 0L); + case 105: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x2828080L, active2, 0L); + case 108: + return jjMoveStringLiteralDfa3_0(active0, 0x40000000000000L, active1, 0x1000020L, active2, 0L); + case 110: + return jjMoveStringLiteralDfa3_0(active0, 0x180c00000000000L, active1, 0x10004L, active2, 0L); + case 111: + return jjMoveStringLiteralDfa3_0(active0, 0x200008000000000L, active1, 0x900L, active2, 0L); + case 112: + return jjMoveStringLiteralDfa3_0(active0, 0x6000000000000000L, active1, 0x4000L, active2, 0L); + case 114: + if ((active0 & 0x400000000000000L) != 0L) + return jjStartNfaWithStates_0(2, 58, 43); + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0xc2000L, active2, 0L); + case 115: + return jjMoveStringLiteralDfa3_0(active0, 0x8008046000000000L, active1, 0L, active2, 0L); + case 116: + if ((active1 & 0x1L) != 0L) + { + jjmatchedKind = 64; + jjmatchedPos = 2; + } + return jjMoveStringLiteralDfa3_0(active0, 0x8200a0000000000L, active1, 0x40aL, active2, 0L); + case 117: + return jjMoveStringLiteralDfa3_0(active0, 0x14000000000000L, active1, 0x200000L, active2, 0L); + case 119: + if ((active1 & 0x10L) != 0L) + return jjStartNfaWithStates_0(2, 68, 43); + break; + case 121: + if ((active1 & 0x400000L) != 0L) + return jjStartNfaWithStates_0(2, 86, 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, active2); + return 3; + } + switch(curChar) + { + case 61: + if ((active2 & 0x200000L) != 0L) + return jjStopAtPos(3, 149); + break; + case 97: + return jjMoveStringLiteralDfa4_0(active0, 0x381010000000000L, active1, 0x1000000L, active2, 0L); + case 98: + return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L, active1, 0L, active2, 0L); + case 99: + return jjMoveStringLiteralDfa4_0(active0, 0x80000000000L, active1, 0x10000L, active2, 0L); + case 100: + if ((active1 & 0x800000L) != 0L) + return jjStartNfaWithStates_0(3, 87, 43); + break; + case 101: + if ((active0 & 0x20000000000L) != 0L) + return jjStartNfaWithStates_0(3, 41, 43); + else if ((active0 & 0x40000000000L) != 0L) + return jjStartNfaWithStates_0(3, 42, 43); + else if ((active0 & 0x8000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 51, 43); + else if ((active1 & 0x200000L) != 0L) + return jjStartNfaWithStates_0(3, 85, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x20004000000000L, active1, 0x4002L, active2, 0L); + case 103: + if ((active1 & 0x4L) != 0L) + return jjStartNfaWithStates_0(3, 66, 43); + break; + case 105: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x2008L, active2, 0L); + case 107: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x40L, active2, 0L); + case 108: + if ((active1 & 0x20L) != 0L) + return jjStartNfaWithStates_0(3, 69, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x2000008000000000L, active1, 0x2000200L, active2, 0L); + case 109: + if ((active0 & 0x10000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 52, 43); + break; + case 110: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x100000L, active2, 0L); + case 111: + if ((active0 & 0x800000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 59, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000000L, active1, 0xc0000L, active2, 0L); + case 114: + if ((active0 & 0x100000000000L) != 0L) + return jjStartNfaWithStates_0(3, 44, 43); + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x800L, active2, 0L); + case 115: + if ((active1 & 0x20000L) != 0L) + return jjStartNfaWithStates_0(3, 81, 43); + return jjMoveStringLiteralDfa4_0(active0, 0x40600000000000L, active1, 0L, active2, 0L); + case 116: + return jjMoveStringLiteralDfa4_0(active0, 0x8000802000000000L, active1, 0x9100L, active2, 0L); + case 117: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x400L, active2, 0L); + case 118: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x80L, active2, 0L); + default : + break; + } + return jjStartNfa_0(2, active0, active1, active2); +} +private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1, long old2, long active2){ + if (((active0 &= old0) | (active1 &= old1) | (active2 &= old2)) == 0L) + return jjStartNfa_0(2, old0, old1, old2); + 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, 0x8000000000000000L, active1, 0xc0L); + case 99: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0xa000L); + case 101: + if ((active0 & 0x40000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 54, 43); + else if ((active1 & 0x2000000L) != 0L) + return jjStartNfaWithStates_0(4, 89, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x2000008000000000L, active1, 0x100L); + case 104: + if ((active0 & 0x80000000000L) != 0L) + return jjStartNfaWithStates_0(4, 43, 43); + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x10000L); + case 105: + return jjMoveStringLiteralDfa5_0(active0, 0x800000000000L, active1, 0x1200L); + case 107: + if ((active0 & 0x10000000000L) != 0L) + return jjStartNfaWithStates_0(4, 40, 43); + break; + case 108: + if ((active0 & 0x80000000000000L) != 0L) + { + jjmatchedKind = 55; + jjmatchedPos = 4; + } + return jjMoveStringLiteralDfa5_0(active0, 0x104000000000000L, active1, 0L); + case 110: + return jjMoveStringLiteralDfa5_0(active0, 0x20000000000000L, active1, 0L); + case 114: + if ((active1 & 0x4000L) != 0L) + return jjStartNfaWithStates_0(4, 78, 43); + return jjMoveStringLiteralDfa5_0(active0, 0x4000006000000000L, active1, 0x402L); + case 115: + if ((active0 & 0x200000000000L) != 0L) + return jjStartNfaWithStates_0(4, 45, 43); + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x100000L); + case 116: + if ((active0 & 0x400000000000L) != 0L) + return jjStartNfaWithStates_0(4, 46, 43); + else if ((active0 & 0x200000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 57, 43); + else if ((active1 & 0x800L) != 0L) + return jjStartNfaWithStates_0(4, 75, 43); + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x1000000L); + case 117: + return jjMoveStringLiteralDfa5_0(active0, 0x1000000000000L, active1, 0L); + case 118: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x8L); + case 119: + if ((active1 & 0x40000L) != 0L) + { + jjmatchedKind = 82; + jjmatchedPos = 4; + } + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x80000L); + 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, active1, 0L); + return 5; + } + switch(curChar) + { + case 97: + return jjMoveStringLiteralDfa6_0(active0, 0xa000000000L, active1, 0L); + case 99: + if ((active1 & 0x200L) != 0L) + return jjStartNfaWithStates_0(5, 73, 43); + else if ((active1 & 0x1000L) != 0L) + return jjStartNfaWithStates_0(5, 76, 43); + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x100L); + case 100: + return jjMoveStringLiteralDfa6_0(active0, 0x20000000000000L, active1, 0L); + case 101: + if ((active0 & 0x4000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 50, 43); + else if ((active1 & 0x8L) != 0L) + return jjStartNfaWithStates_0(5, 67, 43); + break; + case 102: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x2L); + case 103: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x40L); + case 104: + if ((active1 & 0x8000L) != 0L) + return jjStartNfaWithStates_0(5, 79, 43); + break; + case 105: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x1100000L); + case 108: + return jjMoveStringLiteralDfa6_0(active0, 0x101000000000000L, active1, 0L); + case 109: + return jjMoveStringLiteralDfa6_0(active0, 0x2000000000000000L, active1, 0L); + case 110: + if ((active1 & 0x400L) != 0L) + return jjStartNfaWithStates_0(5, 74, 43); + return jjMoveStringLiteralDfa6_0(active0, 0x8000800000000000L, active1, 0L); + case 114: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x10000L); + case 115: + if ((active1 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(5, 83, 43); + break; + case 116: + if ((active0 & 0x4000000000L) != 0L) + return jjStartNfaWithStates_0(5, 38, 43); + else if ((active0 & 0x4000000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 62, 43); + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x2080L); + default : + break; + } + return jjStartNfa_0(4, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long active1){ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(4, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(5, active0, active1, 0L); + return 6; + } + switch(curChar) + { + case 97: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x2L); + case 99: + return jjMoveStringLiteralDfa7_0(active0, 0x8000002000000000L, active1, 0L); + case 101: + if ((active1 & 0x40L) != 0L) + return jjStartNfaWithStates_0(6, 70, 43); + else if ((active1 & 0x80L) != 0L) + return jjStartNfaWithStates_0(6, 71, 43); + return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000000L, active1, 0x100000L); + case 102: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x2000L); + case 108: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x1000000L); + case 110: + if ((active0 & 0x8000000000L) != 0L) + return jjStartNfaWithStates_0(6, 39, 43); + break; + case 111: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x10000L); + case 115: + if ((active0 & 0x20000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 53, 43); + break; + case 116: + if ((active0 & 0x1000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 48, 43); + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x100L); + case 117: + return jjMoveStringLiteralDfa7_0(active0, 0x800000000000L, active1, 0L); + case 121: + if ((active0 & 0x100000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 56, 43); + break; + default : + break; + } + return jjStartNfa_0(5, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long active1){ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(5, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(6, active0, active1, 0L); + return 7; + } + switch(curChar) + { + case 99: + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x2L); + case 101: + if ((active0 & 0x800000000000L) != 0L) + return jjStartNfaWithStates_0(7, 47, 43); + else if ((active1 & 0x1000000L) != 0L) + return jjStartNfaWithStates_0(7, 88, 43); + return jjMoveStringLiteralDfa8_0(active0, 0x8000000000000000L, active1, 0x100L); + case 110: + return jjMoveStringLiteralDfa8_0(active0, 0x2000000000000000L, active1, 0x110000L); + case 112: + if ((active1 & 0x2000L) != 0L) + return jjStartNfaWithStates_0(7, 77, 43); + break; + case 116: + if ((active0 & 0x2000000000L) != 0L) + return jjStartNfaWithStates_0(7, 37, 43); + break; + default : + break; + } + return jjStartNfa_0(6, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long active1){ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(6, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(7, active0, active1, 0L); + return 8; + } + switch(curChar) + { + case 100: + if ((active1 & 0x100L) != 0L) + return jjStartNfaWithStates_0(8, 72, 43); + break; + case 101: + if ((active1 & 0x2L) != 0L) + return jjStartNfaWithStates_0(8, 65, 43); + break; + case 105: + return jjMoveStringLiteralDfa9_0(active0, 0L, active1, 0x10000L); + case 111: + return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000000L, active1, 0L); + case 116: + if ((active1 & 0x100000L) != 0L) + return jjStartNfaWithStates_0(8, 84, 43); + return jjMoveStringLiteralDfa9_0(active0, 0x2000000000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(7, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long active1){ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(7, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(8, active0, active1, 0L); + return 9; + } + switch(curChar) + { + case 102: + if ((active0 & 0x8000000000000000L) != 0L) + return jjStartNfaWithStates_0(9, 63, 43); + break; + case 115: + if ((active0 & 0x2000000000000000L) != 0L) + return jjStartNfaWithStates_0(9, 61, 43); + break; + case 122: + return jjMoveStringLiteralDfa10_0(active0, 0L, active1, 0x10000L); + default : + break; + } + return jjStartNfa_0(8, active0, active1, 0L); +} +private int jjMoveStringLiteralDfa10_0(long old0, long active0, long old1, long active1){ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(8, old0, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(9, 0L, active1, 0L); + return 10; + } + switch(curChar) + { + case 101: + return jjMoveStringLiteralDfa11_0(active1, 0x10000L); + default : + break; + } + return jjStartNfa_0(9, 0L, active1, 0L); +} +private int jjMoveStringLiteralDfa11_0(long old1, long active1){ + if (((active1 &= old1)) == 0L) + return jjStartNfa_0(9, 0L, old1, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(10, 0L, active1, 0L); + return 11; + } + switch(curChar) + { + case 100: + if ((active1 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(11, 80, 43); + break; + default : + break; + } + return jjStartNfa_0(10, 0L, active1, 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 > 31) + kind = 31; + { jjCheckNAddStates(0, 2); } + } + break; + case 0: + if ((0x3ff000000000000L & l) != 0L) + { + if (kind > 91) + kind = 91; + { jjCheckNAddStates(3, 17); } + } + else if (curChar == 47) + { jjAddStates(18, 19); } + else if (curChar == 36) + { + if (kind > 103) + kind = 103; + { 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 > 96) + kind = 96; + { jjCheckNAddStates(35, 38); } + break; + case 2: + if ((0x3ff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(2, 3); } + break; + case 3: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(39, 41); } + break; + case 5: + if ((0x280000000000L & l) != 0L) + { jjCheckNAdd(6); } + break; + case 6: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(42, 44); } + break; + case 7: + if ((0x3ff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(7, 8); } + break; + case 8: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddTwoStates(6, 9); } + break; + case 10: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(45, 48); } + break; + case 11: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { 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 > 101) + kind = 101; + 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 > 102) + kind = 102; + 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 > 103) + kind = 103; + { jjCheckNAdd(43); } + break; + case 43: + if ((0x3ff00100fffc1ffL & l) == 0L) + break; + if (kind > 103) + kind = 103; + { jjCheckNAdd(43); } + break; + case 44: + if (curChar == 47) + { jjAddStates(18, 19); } + break; + case 46: + if ((0xffffffffffffdbffL & l) == 0L) + break; + if (kind > 31) + kind = 31; + { jjCheckNAddStates(0, 2); } + break; + case 47: + if ((0x2400L & l) != 0L && kind > 31) + kind = 31; + break; + case 48: + if (curChar == 10 && kind > 31) + kind = 31; + 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 > 32) + kind = 32; + break; + case 52: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 50; + break; + case 53: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 91) + kind = 91; + { 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 > 91) + kind = 91; + 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 > 96) + kind = 96; + { jjCheckNAddStates(81, 83); } + break; + case 75: + if ((0x3ff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(75, 76); } + break; + case 76: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddTwoStates(74, 9); } + break; + case 77: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { 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 > 96) + kind = 96; + { jjCheckNAddStates(95, 97); } + break; + case 83: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(98, 101); } + break; + case 84: + if ((0x3ff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(84, 85); } + break; + case 85: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(95, 97); } + break; + case 87: + if ((0x280000000000L & l) != 0L) + { jjCheckNAdd(88); } + break; + case 88: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(102, 104); } + break; + case 89: + if ((0x3ff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(89, 90); } + break; + case 90: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddTwoStates(88, 9); } + break; + case 91: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { jjCheckNAddStates(105, 108); } + break; + case 92: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + { 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 > 91) + kind = 91; + { jjCheckNAddTwoStates(108, 109); } + break; + case 108: + if ((0x3ff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(108, 109); } + break; + case 110: + if ((0xff000000000000L & l) == 0L) + break; + if (kind > 91) + kind = 91; + { jjCheckNAddTwoStates(111, 112); } + break; + case 111: + if ((0xff000000000000L & l) != 0L) + { jjCheckNAddTwoStates(111, 112); } + break; + case 112: + if ((0xff000000000000L & l) != 0L && kind > 91) + kind = 91; + break; + case 114: + if ((0x3000000000000L & l) == 0L) + break; + if (kind > 91) + kind = 91; + { jjCheckNAddTwoStates(115, 116); } + break; + case 115: + if ((0x3000000000000L & l) != 0L) + { jjCheckNAddTwoStates(115, 116); } + break; + case 116: + if ((0x3000000000000L & l) != 0L && kind > 91) + kind = 91; + 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 > 96) + kind = 96; + { 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 > 96) + kind = 96; + { 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 > 103) + kind = 103; + { 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 > 96) + kind = 96; + 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 > 103) + kind = 103; + { jjCheckNAdd(43); } + break; + case 46: + if (kind > 31) + kind = 31; + { jjAddStates(0, 2); } + break; + case 51: + if (kind > 32) + kind = 32; + break; + case 54: + if (curChar == 95) + { jjAddStates(144, 145); } + break; + case 56: + if ((0x100000001000L & l) != 0L && kind > 90) + kind = 90; + 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 > 91) + kind = 91; + { jjCheckNAddTwoStates(108, 109); } + break; + case 108: + if ((0x7e8000007eL & l) != 0L) + { jjCheckNAddTwoStates(108, 109); } + break; + case 109: + if ((0x7e0000007eL & l) != 0L && kind > 91) + kind = 91; + 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 = (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 > 103) + kind = 103; + { 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 > 103) + kind = 103; + { jjCheckNAdd(43); } + break; + case 46: + if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) + break; + if (kind > 31) + kind = 31; + { jjAddStates(0, 2); } + break; + case 51: + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 32) + kind = 32; + break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else 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(0x800000000L); + 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 & 0x800000000L) != 0L) + return jjStopAtPos(1, 35); + break; + default : + return 2; + } + return 2; +} +private int jjMoveStringLiteralDfa0_1(){ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_1(0x400000000L); + 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 & 0x400000000L) != 0L) + return jjStopAtPos(1, 34); + 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, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, 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", }; +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(Exception e) + { + jjmatchedKind = 0; + jjmatchedPos = -1; + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + CommonTokenAction(matchedToken); + 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 > 36) + { + jjmatchedKind = 36; + } + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + if (jjmatchedPos == 0 && jjmatchedKind > 36) + { + jjmatchedKind = 36; + } + 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]; + CommonTokenAction(matchedToken); + 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 TokenMgrException(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrException.LEXICAL_ERROR); + } + } +} + +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + case 32 : + image.append(input_stream.GetSuffix(jjimageLen)); + jjimageLen = 0; + input_stream.backup(1); + break; + default : + break; + } +} +void TokenLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + case 153 : + image.append(jjstrLiteralImages[153]); + lengthOfMatch = jjstrLiteralImages[153].length(); + matchedToken.kind = GT; + ((ASTParser.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; + input_stream.backup(2); + break; + case 154 : + image.append(jjstrLiteralImages[154]); + lengthOfMatch = jjstrLiteralImages[154].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); +} + + /** Constructor. */ + public ASTParserTokenManager(JavaCharStream stream){ + + if (JavaCharStream.staticFlag) + throw new RuntimeException("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + + input_stream = stream; + } + + /** Constructor. */ + public ASTParserTokenManager (JavaCharStream stream, int lexState){ + ReInit(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 TokenMgrException("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrException.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + +/** 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, -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, 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, +}; +static final long[] jjtoToken = { + 0xffffffe000000001L, 0xfffffce10fffffffL, 0x1fffffffL, +}; +static final long[] jjtoSkip = { + 0xcfffffffeL, 0x0L, 0x0L, +}; +static final long[] jjtoSpecial = { + 0xc80000000L, 0x0L, 0x0L, +}; +static final long[] jjtoMore = { + 0x1300000000L, 0x0L, 0x0L, +}; + protected JavaCharStream input_stream; + + private final int[] jjrounds = new int[130]; + private final int[] jjstateSet = new int[2 * 130]; + + private final StringBuilder jjimage = new StringBuilder(); + private StringBuilder image = jjimage; + private int jjimageLen; + private int lengthOfMatch; + + protected int curChar; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/JavaCharStream.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/JavaCharStream.java new file mode 100644 index 000000000..da924dbe0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/JavaCharStream.java @@ -0,0 +1,560 @@ +/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 6.1 */ +/* 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 <http://www.gnu.org/licenses/>. + */ +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 Provider inputStream; + + protected char[] nextCharBuf; + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int nextCharInd = -1; + protected int inBuf = 0; + protected int tabSize = 1; + protected boolean trackLineColumn = true; + + public void setTabSize(int i) { tabSize = i; } + public 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 (Exception t) + { + throw new RuntimeException(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 RuntimeException("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(Provider 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(Provider dstream, + int startline, int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + +/** Constructor. */ + public JavaCharStream(Provider dstream) + { + this(dstream, 1, 1, 4096); + } +/** Reinitialise. */ + public void ReInit(Provider 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(Provider dstream, + int startline, int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + +/** Reinitialise. */ + public void ReInit(Provider 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]; + } + boolean getTrackLineColumn() { return trackLineColumn; } + void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } + +} +/* JavaCC - OriginalChecksum=9ab0136fd4b1e2a45a251f41181a5bd8 (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ParseException.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ParseException.java new file mode 100644 index 000000000..32283676c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/ParseException.java @@ -0,0 +1,227 @@ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 6.1 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=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 <http://www.gnu.org/licenses/>. + */ +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 <i>serialized</i> form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + private static final String INDENT = " "; + + /** + * The end of line string (we do not use System.getProperty("") so that we are compatible with Android/GWT); + */ + protected static String EOL = "\n"; + + + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) + { + this (currentTokenVal, expectedTokenSequencesVal, tokenImageVal, null); + } + + + /** + * 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, + String lexicalStateName + ) + { + super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal, lexicalStateName)); + 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 lexicalStateName) { + StringBuilder sb = new StringBuilder(); + StringBuffer expected = new StringBuffer(); + + int maxSize = 0; + java.util.TreeSet<String> sortedOptions = new java.util.TreeSet<String>(); + 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++) { + sortedOptions.add(tokenImage[expectedTokenSequences[i][j]]); + } + } + + for (String option : sortedOptions) { + expected.append(INDENT).append(option).append(EOL); + } + + sb.append("Encountered unexpected token:"); + + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + String tokenText = tok.image; + String escapedTokenText = add_escapes(tokenText); + if (i != 0) { + sb.append(" "); + } + if (tok.kind == 0) { + sb.append(tokenImage[0]); + break; + } + sb.append(" \""); + sb.append(escapedTokenText); + sb.append("\""); + sb.append(" " + tokenImage[tok.kind]); + tok = tok.next; + } + sb.append(EOL).append(INDENT).append("at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn); + sb.append(".").append(EOL); + + if (expectedTokenSequences.length == 0) { + // Nothing to add here + } else { + int numExpectedTokens = expectedTokenSequences.length; + sb.append(EOL).append("Was expecting"+ (numExpectedTokens == 1 ? ":" : " one of:") + EOL + EOL); + sb.append(expected.toString()); + } + // 2013/07/30 --> Seems to be inaccurate as represents the readahead state, not the lexical state BEFORE the unknown token +// if (lexicalStateName != null) { +// sb.append(EOL).append("** Lexical State : ").append(lexicalStateName).append(EOL).append(EOL); +// } + + return sb.toString(); + } + + + /** + * 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 '\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=c0da6a86ac0d0ec8b633aeafa43e6e37 (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/Provider.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/Provider.java new file mode 100644 index 000000000..bfd9da886 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/Provider.java @@ -0,0 +1,39 @@ +/* Generated By:JavaCC: Do not edit this line. Provider.java Version 6.1 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=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 <http://www.gnu.org/licenses/>. + */ +package com.github.javaparser; + + +import java.io.IOException; + +public interface Provider { + /** + * Reads characters into an array + * @param buffer Destination buffer + * @param offset Offset at which to start storing characters + * @param length The maximum possible number of characters to read + * @return The number of characters read, or -1 if all read + * @exception IOException + */ + public int read(char buffer[], int offset, int len) throws IOException; + + /** + * Closes the stream and releases any system resources associated with + * it. + * @exception IOException + */ + public void close() throws IOException; + +} +/* JavaCC - OriginalChecksum=89684d4e3db82aa5e480d095c170b352 (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/StreamProvider.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/StreamProvider.java new file mode 100644 index 000000000..2c30e1610 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/StreamProvider.java @@ -0,0 +1,70 @@ +/* Generated By:JavaCC: Do not edit this line. StreamProvider.java Version 6.1 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=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 <http://www.gnu.org/licenses/>. + */ +package com.github.javaparser; + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; + +/** + * NOTE : This generated class can be safely deleted if installing in a GWT installation (use StringProvider instead) + */ +public class StreamProvider implements Provider { + + Reader _reader; + + public StreamProvider(Reader reader) { + _reader = reader; + } + + public StreamProvider(InputStream stream) throws IOException { + _reader = new BufferedReader(new InputStreamReader(stream)); + } + + public StreamProvider(InputStream stream, String charsetName) throws IOException { + _reader = new BufferedReader(new InputStreamReader(stream, charsetName)); + } + + @Override + public int read(char[] buffer, int off, int len) throws IOException { + int result = _reader.read(buffer, off, len); + + /* CBA -- Added 2014/03/29 -- + This logic allows the generated Java code to be easily translated to C# (via sharpen) - + as in C# 0 represents end of file, and in Java, -1 represents end of file + See : http://msdn.microsoft.com/en-us/library/9kstw824(v=vs.110).aspx + ** Technically, this is not required for java but the overhead is extremely low compared to the code generation benefits. + */ + + if (result == 0) { + if (off < buffer.length && len > 0) { + result = -1; + } + } + + return result; + } + + @Override + public void close() throws IOException { + _reader.close(); + } + +} + +/* JavaCC - OriginalChecksum=b849e0746bbbf4528197ca9d130650d6 (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/StringProvider.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/StringProvider.java new file mode 100644 index 000000000..83c3504c9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/StringProvider.java @@ -0,0 +1,60 @@ +/* Generated By:JavaCC: Do not edit this line. StringProvider.java Version 6.1 */ +/* JavaCCOptions:KEEP_LINE_COLUMN=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 <http://www.gnu.org/licenses/>. + */ +package com.github.javaparser; + + + import java.io.IOException; + + public class StringProvider implements Provider { + + String _string; + int _position = 0; + int _size; + + public StringProvider(String string) { + _string = string; + _size = string.length(); + } + + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + int numCharsOutstandingInString = _size - _position; + + if (numCharsOutstandingInString == 0) { + return -1; + } + + int numBytesInBuffer = cbuf.length; + int numBytesToRead = numBytesInBuffer -off; + numBytesToRead = numBytesToRead > len ? len : numBytesToRead; + + if (numBytesToRead > numCharsOutstandingInString) { + numBytesToRead = numCharsOutstandingInString; + } + + _string.getChars(_position, _position + numBytesToRead, cbuf, off); + + _position += numBytesToRead; + + return numBytesToRead; + } + + @Override + public void close() throws IOException { + _string = null; + } + + } +/* JavaCC - OriginalChecksum=9873e92cad8666980a4c6d392c0c7ad4 (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/Token.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/Token.java new file mode 100644 index 000000000..2731d0427 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/Token.java @@ -0,0 +1,143 @@ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 6.1 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,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 <http://www.gnu.org/licenses/>. + */ +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 <i>serialized</i> 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=fd43051db65fcdc22df39a61d81bf7a4 (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/TokenMgrError.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/TokenMgrError.java new file mode 100644 index 000000000..09197e805 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/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 <http://www.gnu.org/licenses/>. + */ +package com.github.javaparser; + +/** Token Manager Error. */ +public class TokenMgrError extends Error +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the <i>serialized</i> 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 ? "<EOF> " : ("\"" + 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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/TokenMgrException.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/TokenMgrException.java new file mode 100644 index 000000000..d290424fb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources/com/github/javaparser/TokenMgrException.java @@ -0,0 +1,158 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrException.java Version 6.1 */ +/* 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 <http://www.gnu.org/licenses/>. + */ +package com.github.javaparser; + +/** Token Manager Error. */ +public class TokenMgrException extends RuntimeException +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the <i>serialized</i> 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. + */ + public static final int LEXICAL_ERROR = 0; + + /** + * An attempt was made to create a second instance of a static token manager. + */ + public static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + public static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + public 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 '\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 LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { + char curChar1 = (char)curChar; + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + (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 TokenMgrException() { + } + + /** Constructor with message and reason. */ + public TokenMgrException(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + public TokenMgrException(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) { + this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} +/* JavaCC - OriginalChecksum=d2d40125d51af5fe5bc7e2ab87d062ad (do not edit this line) */ diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ASTParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ASTParser.java new file mode 100644 index 000000000..151cff21a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +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.*; + +/** + * <p>This class was generated automatically by javacc, do not edit.</p> + */ +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) { + if ((ModifierSet.hasModifier(modifiers, mod))) { + throwParseException(token, "Duplicated modifier"); + } + return ModifierSet.addModifier(modifiers, mod); + } + + private void throwParseException(Token token, String message) { + StringBuilder buf = new StringBuilder(); + buf.append(message); + buf.append(": \""); + buf.append(token.image); + buf.append("\" 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) { + 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() { + 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() { + 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() { + 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() { + 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() { + 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) { + 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) { + 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) { + 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) { + 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() { + 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() { + 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() { + 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() { + 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) { + 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) { + 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, "\"default\" 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 \"default\"."); + } + 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) { + 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() { + 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() { + 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() { + 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() { + 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) { + 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() { + 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() { + 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() { + 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() { + 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) { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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) { + 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) { + 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() { + 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() { + 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() { + 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() { + 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() { + 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) { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + List ret; + ret = ExpressionList(); + {if (true) return ret;} + throw new Error("Missing return statement in function"); + } + + final public BreakStmt BreakStatement() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { +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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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) { + 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() { + 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() { + 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) { + 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() { + 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) { + 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<int[]> jj_expentries = new java.util.ArrayList<int[]>(); + 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<<j)) != 0) { + la1tokens[j] = true; + } + if ((jj_la1_1[i] & (1<<j)) != 0) { + la1tokens[32+j] = true; + } + if ((jj_la1_2[i] & (1<<j)) != 0) { + la1tokens[64+j] = true; + } + if ((jj_la1_3[i] & (1<<j)) != 0) { + la1tokens[96+j] = true; + } + if ((jj_la1_4[i] & (1<<j)) != 0) { + la1tokens[128+j] = true; + } + } + } + } + for (int i = 0; i < 133; i++) { + if (la1tokens[i]) { + jj_expentry = new int[1]; + jj_expentry[0] = i; + jj_expentries.add(jj_expentry); + } + } + jj_endpos = 0; + jj_rescan_token(); + jj_add_error_token(0, 0); + int[][] exptokseq = new int[jj_expentries.size()][]; + for (int i = 0; i < jj_expentries.size(); i++) { + exptokseq[i] = jj_expentries.get(i); + } + return new ParseException(token, exptokseq, tokenImage); + } + + /** Enable tracing. */ + final public void enable_tracing() { + } + + /** Disable tracing. */ + final public void disable_tracing() { + } + + private void jj_rescan_token() { + jj_rescan = true; + for (int i = 0; i < 47; i++) { + try { + JJCalls p = jj_2_rtns[i]; + do { + if (p.gen > 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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ASTParserConstants.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ASTParserConstants.java new file mode 100644 index 000000000..3692dfc71 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +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 = { + "<EOF>", + "\" \"", + "\"\\t\"", + "\"\\n\"", + "\"\\r\"", + "\"\\f\"", + "<SINGLE_LINE_COMMENT>", + "<token of kind 7>", + "\"/*\"", + "\"*/\"", + "\"*/\"", + "<token of kind 11>", + "\"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\"", + "<LONG_LITERAL>", + "<INTEGER_LITERAL>", + "<DECIMAL_LITERAL>", + "<HEX_LITERAL>", + "<OCTAL_LITERAL>", + "<BINARY_LITERAL>", + "<FLOATING_POINT_LITERAL>", + "<DECIMAL_FLOATING_POINT_LITERAL>", + "<DECIMAL_EXPONENT>", + "<HEXADECIMAL_FLOATING_POINT_LITERAL>", + "<HEXADECIMAL_EXPONENT>", + "<CHARACTER_LITERAL>", + "<STRING_LITERAL>", + "<IDENTIFIER>", + "<LETTER>", + "<PART_LETTER>", + "\"(\"", + "\")\"", + "\"{\"", + "\"}\"", + "\"[\"", + "\"]\"", + "\";\"", + "\",\"", + "\".\"", + "\"@\"", + "\"=\"", + "\"<\"", + "\"!\"", + "\"~\"", + "\"?\"", + "\":\"", + "\"==\"", + "\"<=\"", + "\">=\"", + "\"!=\"", + "\"||\"", + "\"&&\"", + "\"++\"", + "\"--\"", + "\"+\"", + "\"-\"", + "\"*\"", + "\"/\"", + "\"&\"", + "\"|\"", + "\"^\"", + "\"%\"", + "\"<<\"", + "\"+=\"", + "\"-=\"", + "\"*=\"", + "\"/=\"", + "\"&=\"", + "\"|=\"", + "\"^=\"", + "\"%=\"", + "\"<<=\"", + "\">>=\"", + "\">>>=\"", + "\"...\"", + "\"->\"", + "\"::\"", + "\">>>\"", + "\">>\"", + "\">\"", + "\"\\u001a\"", + "\"<>\"", + }; + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ASTParserTokenManager.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ASTParserTokenManager.java new file mode 100644 index 000000000..8c157641c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/JavaCharStream.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/JavaCharStream.java new file mode 100644 index 000000000..62a6544b3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ParseException.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/ParseException.java new file mode 100644 index 000000000..31d07cd51 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +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 <i>serialized</i> 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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/Token.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/Token.java new file mode 100644 index 000000000..8aa85f4dd --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +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 <i>serialized</i> 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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/TokenMgrError.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/com/github/javaparser/TokenMgrError.java new file mode 100644 index 000000000..09197e805 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/generated/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 <http://www.gnu.org/licenses/>. + */ +package com.github.javaparser; + +/** Token Manager Error. */ +public class TokenMgrError extends Error +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the <i>serialized</i> 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 ? "<EOF> " : ("\"" + 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/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ASTHelper.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ASTHelper.java new file mode 100644 index 000000000..7e706cd64 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ASTHelper.java @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.QualifiedNameExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.PrimitiveType; +import com.github.javaparser.ast.type.ReferenceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.type.VoidType; +import com.github.javaparser.ast.type.PrimitiveType.Primitive; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class helps to construct new nodes. + * + * @author Júlio Vilmar Gesser + */ +public final class ASTHelper { + + public static final PrimitiveType BYTE_TYPE = new PrimitiveType(Primitive.Byte); + + public static final PrimitiveType SHORT_TYPE = new PrimitiveType(Primitive.Short); + + public static final PrimitiveType INT_TYPE = new PrimitiveType(Primitive.Int); + + public static final PrimitiveType LONG_TYPE = new PrimitiveType(Primitive.Long); + + public static final PrimitiveType FLOAT_TYPE = new PrimitiveType(Primitive.Float); + + public static final PrimitiveType DOUBLE_TYPE = new PrimitiveType(Primitive.Double); + + public static final PrimitiveType BOOLEAN_TYPE = new PrimitiveType(Primitive.Boolean); + + public static final PrimitiveType CHAR_TYPE = new PrimitiveType(Primitive.Char); + + public static final VoidType VOID_TYPE = new VoidType(); + + private ASTHelper() { + // nop + } + + /** + * Creates a new {@link NameExpr} from a qualified name.<br> + * The qualified name can contains "." (dot) characters. + * + * @param qualifiedName + * qualified name + * @return instanceof {@link NameExpr} + */ + public static NameExpr createNameExpr(String qualifiedName) { + String[] split = qualifiedName.split("\\."); + NameExpr ret = new NameExpr(split[0]); + for (int i = 1; i < split.length; i++) { + ret = new QualifiedNameExpr(ret, split[i]); + } + return ret; + } + + /** + * Creates a new {@link Parameter}. + * + * @param type + * type of the parameter + * @param name + * name of the parameter + * @return instance of {@link Parameter} + */ + public static Parameter createParameter(Type type, String name) { + return new Parameter(type, new VariableDeclaratorId(name)); + } + + /** + * Creates a {@link FieldDeclaration}. + * + * @param modifiers + * modifiers + * @param type + * type + * @param variable + * variable declarator + * @return instance of {@link FieldDeclaration} + */ + public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, VariableDeclarator variable) { + List<VariableDeclarator> variables = new ArrayList<VariableDeclarator>(); + variables.add(variable); + FieldDeclaration ret = new FieldDeclaration(modifiers, type, variables); + return ret; + } + + /** + * Creates a {@link FieldDeclaration}. + * + * @param modifiers + * modifiers + * @param type + * type + * @param name + * field name + * @return instance of {@link FieldDeclaration} + */ + public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, String name) { + VariableDeclaratorId id = new VariableDeclaratorId(name); + VariableDeclarator variable = new VariableDeclarator(id); + return createFieldDeclaration(modifiers, type, variable); + } + + /** + * Creates a {@link VariableDeclarationExpr}. + * + * @param type + * type + * @param name + * name + * @return instance of {@link VariableDeclarationExpr} + */ + public static VariableDeclarationExpr createVariableDeclarationExpr(Type type, String name) { + List<VariableDeclarator> vars = new ArrayList<VariableDeclarator>(); + vars.add(new VariableDeclarator(new VariableDeclaratorId(name))); + return new VariableDeclarationExpr(type, vars); + } + + /** + * Adds the given parameter to the method. The list of parameters will be + * initialized if it is <code>null</code>. + * + * @param method + * method + * @param parameter + * parameter + */ + public static void addParameter(MethodDeclaration method, Parameter parameter) { + List<Parameter> parameters = method.getParameters(); + if (parameters == null) { + parameters = new ArrayList<Parameter>(); + method.setParameters(parameters); + } + parameters.add(parameter); + } + + /** + * Adds the given argument to the method call. The list of arguments will be + * initialized if it is <code>null</code>. + * + * @param call + * method call + * @param arg + * argument value + */ + public static void addArgument(MethodCallExpr call, Expression arg) { + List<Expression> args = call.getArgs(); + if (args == null) { + args = new ArrayList<Expression>(); + call.setArgs(args); + } + args.add(arg); + } + + /** + * Adds the given type declaration to the compilation unit. The list of + * types will be initialized if it is <code>null</code>. + * + * @param cu + * compilation unit + * @param type + * type declaration + */ + public static void addTypeDeclaration(CompilationUnit cu, TypeDeclaration type) { + List<TypeDeclaration> types = cu.getTypes(); + if (types == null) { + types = new ArrayList<TypeDeclaration>(); + cu.setTypes(types); + } + types.add(type); + + } + + /** + * Creates a new {@link ReferenceType} for a class or interface. + * + * @param name + * name of the class or interface + * @param arrayCount + * number of arrays or <code>0</code> if is not a array. + * @return instanceof {@link ReferenceType} + */ + public static ReferenceType createReferenceType(String name, int arrayCount) { + return new ReferenceType(new ClassOrInterfaceType(name), arrayCount); + } + + /** + * Creates a new {@link ReferenceType} for the given primitive type. + * + * @param type + * primitive type + * @param arrayCount + * number of arrays or <code>0</code> if is not a array. + * @return instanceof {@link ReferenceType} + */ + public static ReferenceType createReferenceType(PrimitiveType type, int arrayCount) { + return new ReferenceType(type, arrayCount); + } + + /** + * Adds the given statement to the specified block. The list of statements + * will be initialized if it is <code>null</code>. + * + * @param block to have expression added to + * @param stmt to be added + */ + public static void addStmt(BlockStmt block, Statement stmt) { + List<Statement> stmts = block.getStmts(); + if (stmts == null) { + stmts = new ArrayList<Statement>(); + block.setStmts(stmts); + } + stmts.add(stmt); + } + + /** + * Adds the given expression to the specified block. The list of statements + * will be initialized if it is <code>null</code>. + * + * @param block to have expression added to + * @param expr to be added + */ + public static void addStmt(BlockStmt block, Expression expr) { + addStmt(block, new ExpressionStmt(expr)); + } + + /** + * Adds the given declaration to the specified type. The list of members + * will be initialized if it is <code>null</code>. + * + * @param type + * type declaration + * @param decl + * member declaration + */ + public static void addMember(TypeDeclaration type, BodyDeclaration decl) { + List<BodyDeclaration> members = type.getMembers(); + if (members == null) { + members = new ArrayList<BodyDeclaration>(); + type.setMembers(members); + } + members.add(decl); + } + + public static <N extends Node> List<N> getNodesByType(Node container, Class<N> clazz) { + List<N> nodes = new ArrayList<N>(); + for (Node child : container.getChildrenNodes()) { + if (clazz.isInstance(child)) { + nodes.add(clazz.cast(child)); + } + nodes.addAll(getNodesByType(child, clazz)); + } + return nodes; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/JavaParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/JavaParser.java new file mode 100644 index 000000000..431255051 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/JavaParser.java @@ -0,0 +1,452 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import static com.github.javaparser.PositionUtils.areInOrder; +import static com.github.javaparser.PositionUtils.sortByBeginPosition; + +import com.github.javaparser.ASTParser; +import com.github.javaparser.ParseException; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.CommentsCollection; +import com.github.javaparser.ast.comments.CommentsParser; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.Statement; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +// FIXME this file does not seem to be generated by javacc. Is the doc wrong, or the javacc config? +/** + * <p> + * This class was generated automatically by javacc, do not edit. + * </p> + * <p> + * Parse Java 1.5 source code and creates Abstract Syntax Tree classes. + * </p> + * + * @author Júlio Vilmar Gesser + */ +public final class JavaParser { + private JavaParser() { + // hide the constructor + } + + private static boolean _doNotAssignCommentsPreceedingEmptyLines = true; + + private static boolean _doNotConsiderAnnotationsAsNodeStartForCodeAttribution = false; + + public static boolean getDoNotConsiderAnnotationsAsNodeStartForCodeAttribution() + { + return _doNotConsiderAnnotationsAsNodeStartForCodeAttribution; + } + + public static void setDoNotConsiderAnnotationsAsNodeStartForCodeAttribution(boolean doNotConsiderAnnotationsAsNodeStartForCodeAttribution) { + _doNotConsiderAnnotationsAsNodeStartForCodeAttribution = doNotConsiderAnnotationsAsNodeStartForCodeAttribution; + } + + public static boolean getDoNotAssignCommentsPreceedingEmptyLines() + { + return _doNotAssignCommentsPreceedingEmptyLines; + } + + public static void setDoNotAssignCommentsPreceedingEmptyLines(boolean doNotAssignCommentsPreceedingEmptyLines) + { + _doNotAssignCommentsPreceedingEmptyLines = doNotAssignCommentsPreceedingEmptyLines; + } + + public static CompilationUnit parse(final InputStream in, + final String encoding) { + return parse(in,encoding,true); + } + + /** + * Parses the Java code contained in the {@link InputStream} and returns a + * {@link CompilationUnit} that represents it. + * + * @param in + * {@link InputStream} containing Java source code + * @param encoding + * encoding of the source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + */ + public static CompilationUnit parse(final InputStream in, + final String encoding, boolean considerComments) { + try { + String code = SourcesHelper.streamToString(in, encoding); + InputStream in1 = SourcesHelper.stringToStream(code, encoding); + CompilationUnit cu = new ASTParser(in1, encoding).CompilationUnit(); + if (considerComments){ + insertComments(cu,code); + } + return cu; + } catch (IOException ioe){ + throw new ParseException(ioe.getMessage()); + } + } + + /** + * Parses the Java code contained in the {@link InputStream} and returns a + * {@link CompilationUnit} that represents it. + * + * @param in + * {@link InputStream} containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + */ + public static CompilationUnit parse(final InputStream in) + { + return parse(in, null,true); + } + + public static CompilationUnit parse(final File file, final String encoding) + throws ParseException, IOException { + return parse(file,encoding,true); + } + + /** + * Parses the Java code contained in a {@link File} and returns a + * {@link CompilationUnit} that represents it. + * + * @param file + * {@link File} containing Java source code + * @param encoding + * encoding of the source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + * @throws IOException + */ + public static CompilationUnit parse(final File file, final String encoding, boolean considerComments) + throws ParseException, IOException { + final FileInputStream in = new FileInputStream(file); + try { + return parse(in, encoding, considerComments); + } finally { + in.close(); + } + } + + /** + * Parses the Java code contained in a {@link File} and returns a + * {@link CompilationUnit} that represents it. + * + * @param file + * {@link File} containing Java source code + * @return CompilationUnit representing the Java source code + * @throws ParseException + * if the source code has parser errors + * @throws IOException + */ + public static CompilationUnit parse(final File file) throws ParseException, + IOException { + return parse(file, null,true); + } + + public static CompilationUnit parse(final Reader reader, boolean considerComments) + { + try { + String code = SourcesHelper.readerToString(reader); + Reader reader1 = SourcesHelper.stringToReader(code); + CompilationUnit cu = new ASTParser(reader1).CompilationUnit(); + if (considerComments){ + insertComments(cu,code); + } + return cu; + } catch (IOException ioe){ + throw new ParseException(ioe.getMessage()); + } + } + + /** + * Parses the Java block contained in a {@link String} and returns a + * {@link BlockStmt} that represents it. + * + * @param blockStatement + * {@link String} containing Java block code + * @return BlockStmt representing the Java block + * @throws ParseException + * if the source code has parser errors + */ + public static BlockStmt parseBlock(final String blockStatement) + { + StringReader sr = new StringReader(blockStatement); + BlockStmt result = new ASTParser(sr).Block(); + sr.close(); + return result; + } + + /** + * Parses the Java statement contained in a {@link String} and returns a + * {@link Statement} that represents it. + * + * @param statement + * {@link String} containing Java statement code + * @return Statement representing the Java statement + * @throws ParseException + * if the source code has parser errors + */ + public static Statement parseStatement(final String statement) { + StringReader sr = new StringReader(statement); + Statement stmt = new ASTParser(sr).Statement(); + sr.close(); + return stmt; + } + + /** + * Parses the Java import contained in a {@link String} and returns a + * {@link ImportDeclaration} that represents it. + * + * @param importDeclaration + * {@link String} containing Java import code + * @return ImportDeclaration representing the Java import declaration + * @throws ParseException + * if the source code has parser errors + */ + public static ImportDeclaration parseImport(final String importDeclaration) { + StringReader sr = new StringReader(importDeclaration); + ImportDeclaration id = new ASTParser(sr).ImportDeclaration(); + sr.close(); + return id; + } + + /** + * Parses the Java expression contained in a {@link String} and returns a + * {@link Expression} that represents it. + * + * @param expression + * {@link String} containing Java expression + * @return Expression representing the Java expression + * @throws ParseException + * if the source code has parser errors + */ + public static Expression parseExpression(final String expression) { + StringReader sr = new StringReader(expression); + Expression e = new ASTParser(sr).Expression(); + sr.close(); + return e; + } + + /** + * Parses the Java annotation contained in a {@link String} and returns a + * {@link AnnotationExpr} that represents it. + * + * @param annotation + * {@link String} containing Java annotation + * @return AnnotationExpr representing the Java annotation + * @throws ParseException + * if the source code has parser errors + */ + public static AnnotationExpr parseAnnotation(final String annotation) { + StringReader sr = new StringReader(annotation); + AnnotationExpr ae = new ASTParser(sr).Annotation(); + sr.close(); + return ae; + } + + /** + * Parses the Java body declaration(e.g fields or methods) contained in a + * {@link String} and returns a {@link BodyDeclaration} that represents it. + * + * @param body + * {@link String} containing Java body declaration + * @return BodyDeclaration representing the Java annotation + * @throws ParseException + * if the source code has parser errors + */ + public static BodyDeclaration parseBodyDeclaration(final String body) { + StringReader sr = new StringReader(body); + BodyDeclaration bd = new ASTParser(sr).AnnotationBodyDeclaration(); + sr.close(); + return bd; + } + + /** + * Comments are attributed to the thing the comment and are removed from + * allComments. + */ + private static void insertCommentsInCu(CompilationUnit cu, CommentsCollection commentsCollection){ + if (commentsCollection.size()==0) return; + + // I should sort all the direct children and the comments, if a comment is the first thing then it + // a comment to the CompilationUnit + // FIXME if there is no package it could be also a comment to the following class... + // so I could use some heuristics in these cases to distinguish the two cases + + List<Comment> comments = commentsCollection.getAll(); + PositionUtils.sortByBeginPosition(comments); + List<Node> children = cu.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + if (cu.getPackage()!=null && (children.size()==0 || PositionUtils.areInOrder(comments.get(0), children.get(0)))){ + cu.setComment(comments.get(0)); + comments.remove(0); + } + + insertCommentsInNode(cu,comments); + } + + private static boolean attributeLineCommentToNodeOrChild(Node node, LineComment lineComment) + { + // The node start and end at the same line as the comment, + // let's give to it the comment + if (node.getBeginLine()==lineComment.getBeginLine() && !node.hasComment()) + { + node.setComment(lineComment); + return true; + } else { + // try with all the children, sorted by reverse position (so the + // first one is the nearest to the comment + List<Node> children = new LinkedList<Node>(); + children.addAll(node.getChildrenNodes()); + PositionUtils.sortByBeginPosition(children); + Collections.reverse(children); + + for (Node child : children) + { + if (attributeLineCommentToNodeOrChild(child, lineComment)) + { + return true; + } + } + + return false; + } + } + + /** + * This method try to attributes the nodes received to child of the node. + * It returns the node that were not attributed. + */ + private static void insertCommentsInNode(Node node, List<Comment> commentsToAttribute){ + if (commentsToAttribute.size()==0) return; + + // the comments can: + // 1) Inside one of the child, then it is the child that have to associate them + // 2) If they are not inside a child they could be preceeding nothing, a comment or a child + // if they preceed a child they are assigned to it, otherweise they remain "orphans" + + List<Node> children = node.getChildrenNodes(); + PositionUtils.sortByBeginPosition(children); + + for (Node child : children){ + List<Comment> commentsInsideChild = new LinkedList<Comment>(); + for (Comment c : commentsToAttribute){ + if (PositionUtils.nodeContains(child, c, _doNotConsiderAnnotationsAsNodeStartForCodeAttribution)){ + commentsInsideChild.add(c); + } + } + commentsToAttribute.removeAll(commentsInsideChild); + insertCommentsInNode(child,commentsInsideChild); + } + + // I can attribute in line comments to elements preceeding them, if there + // is something contained in their line + List<Comment> attributedComments = new LinkedList<Comment>(); + for (Comment comment : commentsToAttribute) + { + if (comment.isLineComment()) + { + for (Node child : children) + { + if (child.getEndLine()==comment.getBeginLine()) + { + if (attributeLineCommentToNodeOrChild(child, comment.asLineComment())) + { + attributedComments.add(comment); + } + } + } + } + } + + // at this point I create an ordered list of all remaining comments and children + Comment previousComment = null; + attributedComments = new LinkedList<Comment>(); + List<Node> childrenAndComments = new LinkedList<Node>(); + childrenAndComments.addAll(children); + childrenAndComments.addAll(commentsToAttribute); + PositionUtils.sortByBeginPosition(childrenAndComments, _doNotConsiderAnnotationsAsNodeStartForCodeAttribution); + + for (Node thing : childrenAndComments){ + if (thing instanceof Comment){ + previousComment = (Comment)thing; + if (!previousComment.isOrphan()) + { + previousComment = null; + } + } else { + if (previousComment != null && !thing.hasComment()){ + if (!_doNotAssignCommentsPreceedingEmptyLines || !thereAreLinesBetween(previousComment, thing)) { + thing.setComment(previousComment); + attributedComments.add(previousComment); + previousComment = null; + } + } + } + } + + commentsToAttribute.removeAll(attributedComments); + + // all the remaining are orphan nodes + for (Comment c : commentsToAttribute){ + if (c.isOrphan()) { + node.addOrphanComment(c); + } + } + } + + private static boolean thereAreLinesBetween(Node a, Node b) + { + if (!PositionUtils.areInOrder(a, b)) + { + return thereAreLinesBetween(b, a); + } + int endOfA = a.getEndLine(); + return b.getBeginLine()>(a.getEndLine()+1); + } + + private static void insertComments(CompilationUnit cu, String code) throws IOException { + CommentsParser commentsParser = new CommentsParser(); + CommentsCollection allComments = commentsParser.parse(code); + + insertCommentsInCu(cu,allComments); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/Position.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/Position.java new file mode 100644 index 000000000..522411c27 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/Position.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import com.github.javaparser.ast.Node; + +public class Position { + private int line; + private int column; + + public static final Position ABSOLUTE_START = new Position(Node.ABSOLUTE_BEGIN_LINE,-1); + public static final Position ABSOLUTE_END = new Position(Node.ABSOLUTE_END_LINE,-1); + + public static Position beginOf(Node node){ + return new Position(node.getBeginLine(),node.getBeginColumn()); + } + + public static Position endOf(Node node){ + return new Position(node.getEndLine(),node.getEndColumn()); + } + + public Position(int line, int column){ + this.line = line; + this.column = column; + } + + public int getLine(){ + return this.line; + } + + public int getColumn(){ + return this.column; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/PositionUtils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/PositionUtils.java new file mode 100644 index 000000000..41df81710 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/PositionUtils.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.AnnotableNode; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.lang.Override; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; + +import static java.lang.Integer.signum; + +public final class PositionUtils { + + private PositionUtils() { + // prevent instantiation + } + + public static <T extends Node> void sortByBeginPosition(List<T> nodes){ + sortByBeginPosition(nodes, false); + } + + public static <T extends Node> void sortByBeginPosition(List<T> nodes, final boolean ignoringAnnotations){ + Collections.sort(nodes, new Comparator<Node>() { + @Override + public int compare(Node o1, Node o2) { + return PositionUtils.compare(o1, o2, ignoringAnnotations); + } + }); + } + + public static boolean areInOrder(Node a, Node b){ + return areInOrder(a, b, false); + } + + public static boolean areInOrder(Node a, Node b, boolean ignoringAnnotations){ + return compare(a, b, ignoringAnnotations) <= 0; + } + + private static int compare(Node a, Node b, boolean ignoringAnnotations) { + if (ignoringAnnotations) { + int signLine = signum(beginLineWithoutConsideringAnnotation(a) - beginLineWithoutConsideringAnnotation(b)); + if (signLine == 0) { + return signum(beginColumnWithoutConsideringAnnotation(a) - beginColumnWithoutConsideringAnnotation(b)); + } else { + return signLine; + } + } + + int signLine = signum( a.getBeginLine() - b.getBeginLine() ); + if (signLine == 0) { + return signum(a.getBeginColumn() - b.getBeginColumn()); + } else { + return signLine; + } + } + + public static AnnotationExpr getLastAnnotation(Node node) { + if (node instanceof AnnotableNode){ + List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>(); + annotations.addAll(((AnnotableNode) node).getAnnotations()); + if (annotations.size()==0){ + return null; + } + sortByBeginPosition(annotations); + return annotations.get(annotations.size()-1); + } else { + return null; + } + } + + private static int beginLineWithoutConsideringAnnotation(Node node) { + return beginNodeWithoutConsideringAnnotations(node).getBeginLine(); + } + + + private static int beginColumnWithoutConsideringAnnotation(Node node) { + return beginNodeWithoutConsideringAnnotations(node).getBeginColumn(); + } + + private static Node beginNodeWithoutConsideringAnnotations(Node node) { + if (node instanceof MethodDeclaration) { + MethodDeclaration casted = (MethodDeclaration) node; + return casted.getType(); + } else if (node instanceof FieldDeclaration) { + FieldDeclaration casted = (FieldDeclaration) node; + return casted.getType(); + } else if (node instanceof ClassOrInterfaceDeclaration) { + ClassOrInterfaceDeclaration casted = (ClassOrInterfaceDeclaration) node; + return casted.getNameExpr(); + } else { + return node; + } + } + + public static boolean nodeContains(Node container, Node contained, boolean ignoringAnnotations){ + if (!ignoringAnnotations || PositionUtils.getLastAnnotation(container)==null){ + return container.contains(contained); + } + if (!container.contains(contained)){ + return false; + } + // if the node is contained, but it comes immediately after the annotations, + // let's not consider it contained + if (container instanceof AnnotableNode){ + int bl = beginLineWithoutConsideringAnnotation(container); + int bc = beginColumnWithoutConsideringAnnotation(container); + if (bl>contained.getBeginLine()) return false; + if (bl==contained.getBeginLine() && bc>contained.getBeginColumn()) return false; + if (container.getEndLine()<contained.getEndLine()) return false; + if (container.getEndLine()==contained.getEndLine() && container.getEndColumn()<contained.getEndColumn()) return false; + return true; + } + return true; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/SourcesHelper.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/SourcesHelper.java new file mode 100644 index 000000000..87f83f0da --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/SourcesHelper.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser; + +import java.io.*; + +public class SourcesHelper { + + static String streamToString(InputStream in, String encoding){ + if (encoding == null) { + return streamToString(in); + } else { + java.util.Scanner s = new java.util.Scanner(in, encoding).useDelimiter("\\A"); + return s.hasNext() ? s.next() : ""; + } + } + + static String streamToString(InputStream in){ + java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A"); + return s.hasNext() ? s.next() : ""; + } + + static InputStream stringToStream(String s, String encoding) throws UnsupportedEncodingException { + byte[] rawData = encoding != null ? s.getBytes(encoding) : s.getBytes(); + return new ByteArrayInputStream(rawData); + } + + static String readerToString(Reader reader) throws IOException { + char[] arr = new char[8*1024]; // 8K at a time + StringBuilder buf = new StringBuilder(); + int numChars; + + while ((numChars = reader.read(arr, 0, arr.length)) > 0) { + buf.append(arr, 0, numChars); + } + + return buf.toString(); + } + + static Reader stringToReader(String s){ + return new StringReader(s); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/AccessSpecifier.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/AccessSpecifier.java new file mode 100644 index 000000000..5eafdac64 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/AccessSpecifier.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +/** + * Access specifier. Represents one of the possible levels of + * access permitted by the language. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public enum AccessSpecifier { + + PUBLIC("public"), + PRIVATE("private"), + PROTECTED("protected"), + DEFAULT(""); + + private String codeRepresenation; + + private AccessSpecifier(String codeRepresentation) { + this.codeRepresenation = codeRepresentation; + } + + public String getCodeRepresenation(){ + return this.codeRepresenation; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/CompilationUnit.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/CompilationUnit.java new file mode 100644 index 000000000..f3db30274 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/CompilationUnit.java @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the entire compilation unit. Each java file denotes a + * compilation unit. + * </p> + * The CompilationUnit is constructed following the syntax:<br> + * <pre> + * {@code + * CompilationUnit ::= ( }{@link PackageDeclaration}{@code )? + * ( }{@link ImportDeclaration}{@code )* + * ( }{@link TypeDeclaration}{@code )* + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class CompilationUnit extends Node { + + private PackageDeclaration pakage; + + private List<ImportDeclaration> imports; + + private List<TypeDeclaration> types; + + public CompilationUnit() { + } + + public CompilationUnit(PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) { + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + public CompilationUnit(int beginLine, int beginColumn, int endLine, int endColumn, PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) { + super(beginLine, beginColumn, endLine, endColumn); + setPackage(pakage); + setImports(imports); + setTypes(types); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return a list containing all comments declared in this compilation unit. + * Including javadocs, line comments and block comments of all types, + * inner-classes and other members.<br> + * If there is no comment, <code>null</code> is returned. + * + * @return list with all comments of this compilation unit or + * <code>null</code> + * @see JavadocComment + * @see com.github.javaparser.ast.comments.LineComment + * @see com.github.javaparser.ast.comments.BlockComment + */ + public List<Comment> getComments() { + return this.getAllContainedComments(); + } + + /** + * Retrieves the list of imports declared in this compilation unit or + * <code>null</code> if there is no import. + * + * @return the list of imports or <code>null</code> if there is no import + */ + public List<ImportDeclaration> getImports() { + return imports; + } + + /** + * Retrieves the package declaration of this compilation unit.<br> + * If this compilation unit has no package declaration (default package), + * <code>null</code> is returned. + * + * @return the package declaration or <code>null</code> + */ + public PackageDeclaration getPackage() { + return pakage; + } + + /** + * Return the list of types declared in this compilation unit.<br> + * If there is no types declared, <code>null</code> is returned. + * + * @return the list of types or <code>null</code> null if there is no type + * @see AnnotationDeclaration + * @see ClassOrInterfaceDeclaration + * @see EmptyTypeDeclaration + * @see EnumDeclaration + */ + public List<TypeDeclaration> getTypes() { + return types; + } + + /** + * Sets the list of comments of this compilation unit. + * + * @param comments + * the list of comments + */ + public void setComments(List<Comment> comments) { + throw new RuntimeException("Not implemented!"); + } + + /** + * Sets the list of imports of this compilation unit. The list is initially + * <code>null</code>. + * + * @param imports + * the list of imports + */ + public void setImports(List<ImportDeclaration> imports) { + this.imports = imports; + setAsParentNodeOf(this.imports); + } + + /** + * Sets or clear the package declarations of this compilation unit. + * + * @param pakage + * the pakage declaration to set or <code>null</code> to default + * package + */ + public void setPackage(PackageDeclaration pakage) { + this.pakage = pakage; + setAsParentNodeOf(this.pakage); + } + + /** + * Sets the list of types declared in this compilation unit. + * + * @param types + * the lis of types + */ + public void setTypes(List<TypeDeclaration> types) { + this.types = types; + setAsParentNodeOf(this.types); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/DocumentableNode.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/DocumentableNode.java new file mode 100644 index 000000000..0038831b8 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/DocumentableNode.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.comments.JavadocComment; + +/** + * Node which can be documented through a Javadoc comment. + */ +public interface DocumentableNode { + + public JavadocComment getJavaDoc(); + public void setJavaDoc(JavadocComment javadocComment); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/ImportDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/ImportDeclaration.java new file mode 100644 index 000000000..da249e20b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/ImportDeclaration.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * This class represents a import declaration. Imports are optional for the + * {@link CompilationUnit}. + * </p> + * The ImportDeclaration is constructed following the syntax:<br> + * <pre> + * {@code + * ImportDeclaration ::= "import" ( "static" )? }{@link NameExpr}{@code ( "." "*" )? ";" + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class ImportDeclaration extends Node { + + private NameExpr name; + + private boolean static_; + + private boolean asterisk; + + public ImportDeclaration() { + } + + public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk) { + setAsterisk(isAsterisk); + setName(name); + setStatic(isStatic); + } + + public ImportDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, NameExpr name, boolean isStatic, boolean isAsterisk) { + super(beginLine, beginColumn, endLine, endColumn); + setAsterisk(isAsterisk); + setName(name); + setStatic(isStatic); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the name of the import. + * + * @return the name of the import + */ + public NameExpr getName() { + return name; + } + + /** + * Return if the import ends with "*". + * + * @return <code>true</code> if the import ends with "*", <code>false</code> + * otherwise + */ + public boolean isAsterisk() { + return asterisk; + } + + /** + * Return if the import is static. + * + * @return <code>true</code> if the import is static, <code>false</code> + * otherwise + */ + public boolean isStatic() { + return static_; + } + + /** + * Sets if this import is asterisk. + * + * @param asterisk + * <code>true</code> if this import is asterisk + */ + public void setAsterisk(boolean asterisk) { + this.asterisk = asterisk; + } + + /** + * Sets the name this import. + * + * @param name + * the name to set + */ + public void setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + } + + /** + * Sets if this import is static. + * + * @param static_ + * <code>true</code> if this import is static + */ + public void setStatic(boolean static_) { + this.static_ = static_; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/NamedNode.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/NamedNode.java new file mode 100644 index 000000000..7885d71d2 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/NamedNode.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +/** + * A node having a name. + * + * The main reason for this interface is to permit users to manipulate homogeneously all nodes with a getName method. + * + * @since 2.0.1 + */ +public interface NamedNode { + String getName(); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/Node.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/Node.java new file mode 100644 index 000000000..f5f9cb238 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/Node.java @@ -0,0 +1,376 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.visitor.*; + +/** + * Abstract class for all nodes of the AST. + * + * Each Node can have one associated comment which describe it and + * a number of "orphan comments" which it contains but are not specifically + * associated to any element. + * + * @author Julio Vilmar Gesser + */ +public abstract class Node implements Cloneable { + + private int beginLine; + + private int beginColumn; + + private int endLine; + + private int endColumn; + + private Node parentNode; + + private List<Node> childrenNodes = new LinkedList<Node>(); + private List<Comment> orphanComments = new LinkedList<Comment>(); + + /** + * This attribute can store additional information from semantic analysis. + */ + private Object data; + + private Comment comment; + + public Node() { + } + + public Node(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + this.beginLine = beginLine; + this.beginColumn = beginColumn; + this.endLine = endLine; + this.endColumn = endColumn; + } + + /** + * Accept method for visitor support. + * + * @param <R> + * the type the return value of the visitor + * @param <A> + * the type the argument passed to the visitor + * @param v + * the visitor implementation + * @param arg + * the argument passed to the visitor + * @return the result of the visit + */ + public abstract <R, A> R accept(GenericVisitor<R, A> v, A arg); + + /** + * Accept method for visitor support. + * + * @param <A> + * the type the argument passed for the visitor + * @param v + * the visitor implementation + * @param arg + * any value relevant for the visitor + */ + public abstract <A> void accept(VoidVisitor<A> v, A arg); + + /** + * Return the begin column of this node. + * + * @return the begin column of this node + */ + public final int getBeginColumn() { + return beginColumn; + } + + /** + * Return the begin line of this node. + * + * @return the begin line of this node + */ + public final int getBeginLine() { + return beginLine; + } + + /** + * This is a comment associated with this node. + * + * @return comment property + */ + public final Comment getComment() { + return comment; + } + + /** + * Use this to retrieve additional information associated to this node. + * + * @return data property + */ + public final Object getData() { + return data; + } + + /** + * Return the end column of this node. + * + * @return the end column of this node + */ + public final int getEndColumn() { + return endColumn; + } + + /** + * Return the end line of this node. + * + * @return the end line of this node + */ + public final int getEndLine() { + return endLine; + } + + /** + * Sets the begin column of this node. + * + * @param beginColumn + * the begin column of this node + */ + public final void setBeginColumn(final int beginColumn) { + this.beginColumn = beginColumn; + } + + /** + * Sets the begin line of this node. + * + * @param beginLine + * the begin line of this node + */ + public final void setBeginLine(final int beginLine) { + this.beginLine = beginLine; + } + + /** + * Use this to store additional information to this node. + * + * @param comment to be set + */ + public final void setComment(final Comment comment) { + if (comment != null && (this instanceof Comment)) { + throw new RuntimeException("A comment can not be commented"); + } + if (this.comment != null) + { + this.comment.setCommentedNode(null); + } + this.comment = comment; + if (comment != null) { + this.comment.setCommentedNode(this); + } + } + + /** + * Use this to store additional information to this node. + * + * @param data to be set + */ + public final void setData(final Object data) { + this.data = data; + } + + /** + * Sets the end column of this node. + * + * @param endColumn + * the end column of this node + */ + public final void setEndColumn(final int endColumn) { + this.endColumn = endColumn; + } + + /** + * Sets the end line of this node. + * + * @param endLine + * the end line of this node + */ + public final void setEndLine(final int endLine) { + this.endLine = endLine; + } + + /** + * Return the String representation of this node. + * + * @return the String representation of this node + */ + @Override + public final String toString() { + final DumpVisitor visitor = new DumpVisitor(); + accept(visitor, null); + return visitor.getSource(); + } + + public final String toStringWithoutComments() { + final DumpVisitor visitor = new DumpVisitor(false); + accept(visitor, null); + return visitor.getSource(); + } + + @Override + public final int hashCode() { + return toString().hashCode(); + } + + @Override + public boolean equals(final Object obj) { + if (obj == null || !(obj instanceof Node)) { + return false; + } + return EqualsVisitor.equals(this, (Node) obj); + } + + @Override + public Node clone() { + return this.accept(new CloneVisitor(), null); + } + + public Node getParentNode() { + return parentNode; + } + + public List<Node> getChildrenNodes() { + return childrenNodes; + } + + public boolean contains(Node other) { + if (getBeginLine() > other.getBeginLine()) return false; + if (getBeginLine() == other.getBeginLine() && getBeginColumn() > other.getBeginColumn()) return false; + if (getEndLine() < other.getEndLine()) return false; + if (getEndLine() == other.getEndLine() && getEndColumn() < other.getEndColumn()) return false; + return true; + } + + public void addOrphanComment(Comment comment) { + orphanComments.add(comment); + comment.setParentNode(this); + } + + /** + * This is a list of Comment which are inside the node and are not associated + * with any meaningful AST Node. + * + * For example, comments at the end of methods (immediately before the parenthesis) + * or at the end of CompilationUnit are orphan comments. + * + * When more than one comments preceed a statement, the one immediately preceeding it + * it is associated with the statements, while the others are "orphan". + * @return all comments that cannot be attributed to a concept + */ + public List<Comment> getOrphanComments() { + return orphanComments; + } + + /** + * This is the list of Comment which are contained in the Node either because + * they are properly associated to one of its children or because they are floating + * around inside the Node + * @return all Comments within the node as a list + */ + public List<Comment> getAllContainedComments() { + List<Comment> comments = new LinkedList<Comment>(); + comments.addAll(getOrphanComments()); + + for (Node child : getChildrenNodes()) { + if (child.getComment() != null) { + comments.add(child.getComment()); + } + comments.addAll(child.getAllContainedComments()); + } + + return comments; + } + + /** + * Assign a new parent to this node, removing it + * from the list of children of the previous parent, if any. + * + * @param parentNode node to be set as parent + */ + public void setParentNode(Node parentNode) { + // remove from old parent, if any + if (this.parentNode != null) { + this.parentNode.childrenNodes.remove(this); + } + this.parentNode = parentNode; + // add to new parent, if any + if (this.parentNode != null) { + this.parentNode.childrenNodes.add(this); + } + } + + protected void setAsParentNodeOf(List<? extends Node> childNodes) { + if (childNodes != null) { + Iterator<? extends Node> it = childNodes.iterator(); + while (it.hasNext()) { + Node current = it.next(); + current.setParentNode(this); + } + } + } + + protected void setAsParentNodeOf(Node childNode) { + if (childNode != null) { + childNode.setParentNode(this); + } + } + + public static final int ABSOLUTE_BEGIN_LINE = -1; + public static final int ABSOLUTE_END_LINE = -2; + + public boolean isPositionedAfter(int line, int column) { + if (line == ABSOLUTE_BEGIN_LINE) return true; + if (getBeginLine() > line) { + return true; + } else if (getBeginLine() == line) { + return getBeginColumn() > column; + } else { + return false; + } + } + + public boolean isPositionedBefore(int line, int column) { + if (line == ABSOLUTE_END_LINE) return true; + if (getEndLine() < line) { + return true; + } else if (getEndLine() == line) { + return getEndColumn() < column; + } else { + return false; + } + } + + public boolean hasComment() + { + return comment != null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/PackageDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/PackageDeclaration.java new file mode 100644 index 000000000..d0aaf5b1e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/PackageDeclaration.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the package declaration. The package declaration is + * optional for the {@link CompilationUnit}. + * </p> + * The PackageDeclaration is constructed following the syntax:<br> + * <pre> + * {@code + * PackageDeclaration ::= ( }{@link AnnotationExpr}{@code )* "package" }{@link NameExpr}{@code ) ";" + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class PackageDeclaration extends Node { + + private List<AnnotationExpr> annotations; + + private NameExpr name; + + public PackageDeclaration() { + } + + public PackageDeclaration(NameExpr name) { + setName(name); + } + + public PackageDeclaration(List<AnnotationExpr> annotations, NameExpr name) { + setAnnotations(annotations); + setName(name); + } + + public PackageDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, NameExpr name) { + super(beginLine, beginColumn, endLine, endColumn); + setAnnotations(annotations); + setName(name); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Retrieves the list of annotations declared before the package + * declaration. Return <code>null</code> if there are no annotations. + * + * @return list of annotations or <code>null</code> + */ + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + /** + * Return the name of the package. + * + * @return the name of the package + */ + public NameExpr getName() { + return name; + } + + /** + * @param annotations + * the annotations to set + */ + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } + + /** + * Sets the name of this package declaration. + * + * @param name + * the name to set + */ + public void setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(this.name); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TreeVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TreeVisitor.java new file mode 100644 index 000000000..f3b2672d0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TreeVisitor.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +public abstract class TreeVisitor { + + public void visitDepthFirst(Node node){ + process(node); + for (Node child : node.getChildrenNodes()){ + visitDepthFirst(child); + } + } + + public abstract void process(Node node); + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TypeParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TypeParameter.java new file mode 100644 index 000000000..c43d3793d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/TypeParameter.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * <p> + * This class represents the declaration of a generics argument. + * </p> + * The TypeParameter is constructed following the syntax:<br> + * <pre> + * {@code + * TypeParameter ::= <IDENTIFIER> ( "extends" }{@link ClassOrInterfaceType}{@code ( "&" }{@link ClassOrInterfaceType}{@code )* )? + * } + * </pre> + * @author Julio Vilmar Gesser + */ +public final class TypeParameter extends Node implements NamedNode { + + private String name; + + private List<AnnotationExpr> annotations; + + private List<ClassOrInterfaceType> typeBound; + + public TypeParameter() { + } + + public TypeParameter(final String name, final List<ClassOrInterfaceType> typeBound) { + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name, final List<ClassOrInterfaceType> typeBound) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setTypeBound(typeBound); + } + + public TypeParameter(int beginLine, int beginColumn, int endLine, + int endColumn, String name, List<ClassOrInterfaceType> typeBound, List<AnnotationExpr> annotations) { + this(beginLine, beginColumn, endLine, endColumn, name, typeBound); + setName(name); + setTypeBound(typeBound); + this.annotations = annotations; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + /** + * Return the name of the paramenter. + * + * @return the name of the paramenter + */ + public String getName() { + return name; + } + + /** + * Return the list of {@link ClassOrInterfaceType} that this parameter + * extends. Return <code>null</code> null if there are no type. + * + * @return list of types that this paramente extends or <code>null</code> + */ + public List<ClassOrInterfaceType> getTypeBound() { + return typeBound; + } + + /** + * Sets the name of this type parameter. + * + * @param name + * the name to set + */ + public void setName(final String name) { + this.name = name; + } + + /** + * Sets the list o types. + * + * @param typeBound + * the typeBound to set + */ + public void setTypeBound(final List<ClassOrInterfaceType> typeBound) { + this.typeBound = typeBound; + setAsParentNodeOf(typeBound); + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotableNode.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotableNode.java new file mode 100644 index 000000000..47c8c4fe8 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotableNode.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +/** + * An element which can be the target of annotations. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public interface AnnotableNode { + public List<AnnotationExpr> getAnnotations(); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationDeclaration.java new file mode 100644 index 000000000..51f25617a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationDeclaration.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class AnnotationDeclaration extends TypeDeclaration implements DocumentableNode { + + public AnnotationDeclaration() { + } + + public AnnotationDeclaration(int modifiers, String name) { + super(modifiers, name); + } + + public AnnotationDeclaration(int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) { + super(annotations, modifiers, name, members); + } + + public AnnotationDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java new file mode 100644 index 000000000..a81e6cc71 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class AnnotationMemberDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode { + + private int modifiers; + + private Type type; + + private String name; + + private Expression defaultValue; + + public AnnotationMemberDeclaration() { + } + + public AnnotationMemberDeclaration(int modifiers, Type type, String name, Expression defaultValue) { + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + public AnnotationMemberDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) { + super(annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + public AnnotationMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setType(type); + setName(name); + setDefaultValue(defaultValue); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getDefaultValue() { + return defaultValue; + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public String getName() { + return name; + } + + public Type getType() { + return type; + } + + public void setDefaultValue(Expression defaultValue) { + this.defaultValue = defaultValue; + setAsParentNodeOf(defaultValue); + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public void setName(String name) { + this.name = name; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(type); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BaseParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BaseParameter.java new file mode 100644 index 000000000..e14deb177 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BaseParameter.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +public abstract class BaseParameter extends Node { + private int modifiers; + + private List<AnnotationExpr> annotations; + + private VariableDeclaratorId id; + + public BaseParameter() { + } + + public BaseParameter(VariableDeclaratorId id) { + setId(id); + } + + public BaseParameter(int modifiers, VariableDeclaratorId id) { + setModifiers(modifiers); + setId(id); + } + + public BaseParameter(int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) { + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + } + + public BaseParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn); + setModifiers(modifiers); + setAnnotations(annotations); + setId(id); + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + public VariableDeclaratorId getId() { + return id; + } + + /** + * Return the modifiers of this parameter declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } + + public void setId(VariableDeclaratorId id) { + this.id = id; + setAsParentNodeOf(this.id); + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BodyDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BodyDeclaration.java new file mode 100644 index 000000000..bbf138b77 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/BodyDeclaration.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class BodyDeclaration extends Node implements AnnotableNode { + + private List<AnnotationExpr> annotations; + + public BodyDeclaration() { + } + + public BodyDeclaration(List<AnnotationExpr> annotations) { + setAnnotations(annotations); + } + + public BodyDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) { + super(beginLine, beginColumn, endLine, endColumn); + setAnnotations(annotations); + } + + public final List<AnnotationExpr> getAnnotations() { + if (annotations==null){ + annotations = new ArrayList<AnnotationExpr>(); + } + return annotations; + } + + public final void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java new file mode 100644 index 000000000..e098f6edb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceDeclaration extends TypeDeclaration implements DocumentableNode { + + private boolean interface_; + + private List<TypeParameter> typeParameters; + + // Can contain more than one item if this is an interface + private List<ClassOrInterfaceType> extendsList; + + private List<ClassOrInterfaceType> implementsList; + + public ClassOrInterfaceDeclaration() { + } + + public ClassOrInterfaceDeclaration(final int modifiers, final boolean isInterface, final String name) { + super(modifiers, name); + setInterface(isInterface); + } + + public ClassOrInterfaceDeclaration(final int modifiers, + final List<AnnotationExpr> annotations, final boolean isInterface, final String name, + final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList, + final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) { + super(annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + public ClassOrInterfaceDeclaration(final int beginLine, final int beginColumn, final int endLine, + final int endColumn, final int modifiers, + final List<AnnotationExpr> annotations, final boolean isInterface, final String name, + final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList, + final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + setInterface(isInterface); + setTypeParameters(typeParameters); + setExtends(extendsList); + setImplements(implementsList); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<ClassOrInterfaceType> getExtends() { + return extendsList; + } + + public List<ClassOrInterfaceType> getImplements() { + return implementsList; + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public boolean isInterface() { + return interface_; + } + + public void setExtends(final List<ClassOrInterfaceType> extendsList) { + this.extendsList = extendsList; + setAsParentNodeOf(this.extendsList); + } + + public void setImplements(final List<ClassOrInterfaceType> implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + } + + public void setInterface(final boolean interface_) { + this.interface_ = interface_; + } + + public void setTypeParameters(final List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ConstructorDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ConstructorDeclaration.java new file mode 100644 index 000000000..892810c59 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ConstructorDeclaration.java @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import java.util.List; +import java.util.ArrayList; + +import com.github.javaparser.ast.AccessSpecifier; +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ConstructorDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, + NamedNode { + + private int modifiers; + + private List<TypeParameter> typeParameters; + + private NameExpr name; + + private List<Parameter> parameters; + + private List<NameExpr> throws_; + + private BlockStmt block; + + public ConstructorDeclaration() { + } + + public ConstructorDeclaration(int modifiers, String name) { + setModifiers(modifiers); + setName(name); + } + + public ConstructorDeclaration(int modifiers, List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, + String name, List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) { + super(annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBlock(block); + } + + public ConstructorDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, + List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name, + List<Parameter> parameters, List<NameExpr> throws_, BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setName(name); + setParameters(parameters); + setThrows(throws_); + setBlock(block); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public String getName() { + return name == null ? null : name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public List<Parameter> getParameters() { + if (parameters == null) { + parameters = new ArrayList<Parameter>(); + } + return parameters; + } + + public List<NameExpr> getThrows() { + if (throws_ == null) { + throws_ = new ArrayList<NameExpr>(); + } + return throws_; + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public void setBlock(BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public void setName(String name) { + this.name = new NameExpr(name); + } + + public void setNameExpr(NameExpr name) { + this.name = name; + } + + public void setParameters(List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public void setThrows(List<NameExpr> throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + } + + public void setTypeParameters(List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + /** + * The declaration returned has this schema: + * + * [accessSpecifier] className ([paramType [paramName]]) + * [throws exceptionsList] + */ + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, + boolean includingParameterName) { + StringBuffer sb = new StringBuffer(); + if (includingModifiers) { + AccessSpecifier accessSpecifier = ModifierSet.getAccessSpecifier(getModifiers()); + sb.append(accessSpecifier.getCodeRepresenation()); + sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " "); + } + sb.append(getName()); + sb.append("("); + boolean firstParam = true; + for (Parameter param : getParameters()) + { + if (firstParam) { + firstParam = false; + } else { + sb.append(", "); + } + if (includingParameterName) { + sb.append(param.toStringWithoutComments()); + } else { + sb.append(param.getType().toStringWithoutComments()); + } + } + sb.append(")"); + if (includingThrows) { + boolean firstThrow = true; + for (NameExpr thr : getThrows()) { + if (firstThrow) { + firstThrow = false; + sb.append(" throws "); + } else { + sb.append(", "); + } + sb.append(thr.toStringWithoutComments()); + } + } + return sb.toString(); + } + + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows) { + return getDeclarationAsString(includingModifiers, includingThrows, true); + } + + @Override + public String getDeclarationAsString() { + return getDeclarationAsString(true, true, true); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyMemberDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyMemberDeclaration.java new file mode 100644 index 000000000..1c19d097f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyMemberDeclaration.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyMemberDeclaration extends BodyDeclaration implements DocumentableNode { + + public EmptyMemberDeclaration() { + super(null); + } + + public EmptyMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyTypeDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyTypeDeclaration.java new file mode 100644 index 000000000..59e868600 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EmptyTypeDeclaration.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyTypeDeclaration extends TypeDeclaration implements DocumentableNode { + + public EmptyTypeDeclaration() { + super(null, 0, null, null); + } + + public EmptyTypeDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, null, 0, null, null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + @Override + public JavadocComment getJavaDoc() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumConstantDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumConstantDeclaration.java new file mode 100644 index 000000000..d7c425cda --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumConstantDeclaration.java @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumConstantDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode { + + private String name; + + private List<Expression> args; + + private List<BodyDeclaration> classBody; + + public EnumConstantDeclaration() { + } + + public EnumConstantDeclaration(String name) { + setName(name); + } + + public EnumConstantDeclaration(List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) { + super(annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + public EnumConstantDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setName(name); + setArgs(args); + setClassBody(classBody); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + return args; + } + + public List<BodyDeclaration> getClassBody() { + return classBody; + } + + public String getName() { + return name; + } + + public void setArgs(List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setClassBody(List<BodyDeclaration> classBody) { + this.classBody = classBody; + setAsParentNodeOf(this.classBody); + } + + public void setName(String name) { + this.name = name; + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumDeclaration.java new file mode 100644 index 000000000..34b8ee4e5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/EnumDeclaration.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnumDeclaration extends TypeDeclaration implements DocumentableNode { + + private List<ClassOrInterfaceType> implementsList; + + private List<EnumConstantDeclaration> entries; + + public EnumDeclaration() { + } + + public EnumDeclaration(int modifiers, String name) { + super(modifiers, name); + } + + public EnumDeclaration(int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) { + super(annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + public EnumDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members); + setImplements(implementsList); + setEntries(entries); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<EnumConstantDeclaration> getEntries() { + return entries; + } + + public List<ClassOrInterfaceType> getImplements() { + return implementsList; + } + + public void setEntries(List<EnumConstantDeclaration> entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + } + + public void setImplements(List<ClassOrInterfaceType> implementsList) { + this.implementsList = implementsList; + setAsParentNodeOf(this.implementsList); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/FieldDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/FieldDeclaration.java new file mode 100644 index 000000000..2f48ed8f5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/FieldDeclaration.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldDeclaration extends BodyDeclaration implements DocumentableNode { + + private int modifiers; + + private Type type; + + private List<VariableDeclarator> variables; + + public FieldDeclaration() { + } + + public FieldDeclaration(int modifiers, Type type, VariableDeclarator variable) { + setModifiers(modifiers); + setType(type); + List<VariableDeclarator> aux = new ArrayList<VariableDeclarator>(); + aux.add(variable); + setVariables(aux); + } + + public FieldDeclaration(int modifiers, Type type, List<VariableDeclarator> variables) { + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + public FieldDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) { + super(annotations); + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + public FieldDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setType(type); + setVariables(variables); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public Type getType() { + return type; + } + + public List<VariableDeclarator> getVariables() { + return variables; + } + + public void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setVariables(List<VariableDeclarator> variables) { + this.variables = variables; + setAsParentNodeOf(this.variables); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/InitializerDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/InitializerDeclaration.java new file mode 100644 index 000000000..ea1df9a98 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/InitializerDeclaration.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class InitializerDeclaration extends BodyDeclaration implements DocumentableNode { + + private boolean isStatic; + + private BlockStmt block; + + public InitializerDeclaration() { + } + + public InitializerDeclaration(boolean isStatic, BlockStmt block) { + super(null); + setStatic(isStatic); + setBlock(block); + } + + public InitializerDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, boolean isStatic, BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, null); + setStatic(isStatic); + setBlock(block); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + public boolean isStatic() { + return isStatic; + } + + public void setBlock(BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + } + + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MethodDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MethodDeclaration.java new file mode 100644 index 000000000..7f9ca0b7d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MethodDeclaration.java @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.AccessSpecifier; +import com.github.javaparser.ast.DocumentableNode; +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; +import java.util.ArrayList; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodDeclaration extends BodyDeclaration implements DocumentableNode, WithDeclaration, NamedNode { + + private int modifiers; + + private List<TypeParameter> typeParameters; + + private Type type; + + private NameExpr name; + + private List<Parameter> parameters; + + private int arrayCount; + + private List<NameExpr> throws_; + + private BlockStmt body; + + private boolean isDefault = false; + + public MethodDeclaration() { + } + + public MethodDeclaration(final int modifiers, final Type type, final String name) { + setModifiers(modifiers); + setType(type); + setName(name); + } + + public MethodDeclaration(final int modifiers, final Type type, final String name, final List<Parameter> parameters) { + setModifiers(modifiers); + setType(type); + setName(name); + setParameters(parameters); + } + + public MethodDeclaration(final int modifiers, final List<AnnotationExpr> annotations, + final List<TypeParameter> typeParameters, final Type type, final String name, + final List<Parameter> parameters, final int arrayCount, final List<NameExpr> throws_, final BlockStmt block) { + super(annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setType(type); + setName(name); + setParameters(parameters); + setArrayCount(arrayCount); + setThrows(throws_); + setBody(block); + } + + public MethodDeclaration(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final int modifiers, final List<AnnotationExpr> annotations, + final List<TypeParameter> typeParameters, final Type type, final String name, + final List<Parameter> parameters, final int arrayCount, final List<NameExpr> throws_, final BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setModifiers(modifiers); + setTypeParameters(typeParameters); + setType(type); + setName(name); + setParameters(parameters); + setArrayCount(arrayCount); + setThrows(throws_); + setBody(block); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + // FIXME this is called "Block" in the constructor. Pick one. + public BlockStmt getBody() { + return body; + } + + /** + * Return the modifiers of this member declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public List<Parameter> getParameters() { + if (parameters == null) { + parameters = new ArrayList<Parameter>(); + } + return parameters; + } + + public List<NameExpr> getThrows() { + if (throws_ == null) { + throws_ = new ArrayList<NameExpr>(); + } + return throws_; + } + + public Type getType() { + return type; + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public void setArrayCount(final int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setBody(final BlockStmt body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setModifiers(final int modifiers) { + this.modifiers = modifiers; + } + + public void setName(final String name) { + this.name = new NameExpr(name); + } + + public void setNameExpr(final NameExpr name) { + this.name = name; + } + + public void setParameters(final List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public void setThrows(final List<NameExpr> throws_) { + this.throws_ = throws_; + setAsParentNodeOf(this.throws_); + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setTypeParameters(final List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(typeParameters); + } + + + public boolean isDefault() { + return isDefault; + } + + public void setDefault(boolean isDefault) { + this.isDefault = isDefault; + } + + + @Override + public String getDeclarationAsString() { + return getDeclarationAsString(true, true, true); + } + + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows) { + return getDeclarationAsString(includingModifiers, includingThrows, true); + } + + /** + * The declaration returned has this schema: + * + * [accessSpecifier] [static] [abstract] [final] [native] + * [synchronized] returnType methodName ([paramType [paramName]]) + * [throws exceptionsList] + * @return method declaration as String + */ + @Override + public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName) { + StringBuffer sb = new StringBuffer(); + if (includingModifiers) { + AccessSpecifier accessSpecifier = ModifierSet.getAccessSpecifier(getModifiers()); + sb.append(accessSpecifier.getCodeRepresenation()); + sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " "); + if (ModifierSet.isStatic(getModifiers())){ + sb.append("static "); + } + if (ModifierSet.isAbstract(getModifiers())){ + sb.append("abstract "); + } + if (ModifierSet.isFinal(getModifiers())){ + sb.append("final "); + } + if (ModifierSet.isNative(getModifiers())){ + sb.append("native "); + } + if (ModifierSet.isSynchronized(getModifiers())){ + sb.append("synchronized "); + } + } + // TODO verify it does not print comments connected to the type + sb.append(getType().toStringWithoutComments()); + sb.append(" "); + sb.append(getName()); + sb.append("("); + boolean firstParam = true; + for (Parameter param : getParameters()) + { + if (firstParam) { + firstParam = false; + } else { + sb.append(", "); + } + if (includingParameterName) { + sb.append(param.toStringWithoutComments()); + } else { + sb.append(param.getType().toStringWithoutComments()); + if (param.isVarArgs()) { + sb.append("..."); + } + } + } + sb.append(")"); + if (includingThrows) { + boolean firstThrow = true; + for (NameExpr thr : getThrows()) { + if (firstThrow) { + firstThrow = false; + sb.append(" throws "); + } else { + sb.append(", "); + } + sb.append(thr.toStringWithoutComments()); + } + } + return sb.toString(); + } + + @Override + public void setJavaDoc(JavadocComment javadocComment) { + this.javadocComment = javadocComment; + } + + @Override + public JavadocComment getJavaDoc() { + return javadocComment; + } + + private JavadocComment javadocComment; +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ModifierSet.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ModifierSet.java new file mode 100644 index 000000000..6981ced30 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/ModifierSet.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.AccessSpecifier; + +import java.lang.reflect.Modifier; + +/** + * Class to hold modifiers.<br> + * The modifier constants declared here holds equivalent values to + * {@link Modifier} constants. + */ +public final class ModifierSet { + + /* Definitions of the bits in the modifiers field. */ + + public static final int PUBLIC = Modifier.PUBLIC; + + public static final int PRIVATE = Modifier.PRIVATE; + + public static final int PROTECTED = Modifier.PROTECTED; + + public static final int STATIC = Modifier.STATIC; + + public static final int FINAL = Modifier.FINAL; + + public static final int SYNCHRONIZED = Modifier.SYNCHRONIZED; + + public static final int VOLATILE = Modifier.VOLATILE; + + public static final int TRANSIENT = Modifier.TRANSIENT; + + public static final int NATIVE = Modifier.NATIVE; + + public static final int ABSTRACT = Modifier.ABSTRACT; + + public static final int STRICTFP = Modifier.STRICT; + + public static AccessSpecifier getAccessSpecifier(int modifiers) { + if (isPublic(modifiers)){ + return AccessSpecifier.PUBLIC; + } else if (isProtected(modifiers)){ + return AccessSpecifier.PROTECTED; + } else if (isPrivate(modifiers)){ + return AccessSpecifier.PRIVATE; + } else { + return AccessSpecifier.DEFAULT; + } + } + + public static int addModifier(int modifiers, int mod) { + return modifiers | mod; + } + + public static boolean hasModifier(int modifiers, int modifier) { + return (modifiers & modifier) != 0; + } + + public static boolean isAbstract(int modifiers) { + return (modifiers & ABSTRACT) != 0; + } + + public static boolean isFinal(int modifiers) { + return (modifiers & FINAL) != 0; + } + + public static boolean isNative(int modifiers) { + return (modifiers & NATIVE) != 0; + } + + public static boolean isPrivate(int modifiers) { + return (modifiers & PRIVATE) != 0; + } + + public static boolean isProtected(int modifiers) { + return (modifiers & PROTECTED) != 0; + } + + /** + * Is the element accessible from within the package? + * It is the level of access which is applied if no modifiers are chosen, + * it is sometimes called "default". + * @param modifiers indicator + * @return true if modifier denotes package level access + */ + public static boolean hasPackageLevelAccess(int modifiers) { + return !isPublic(modifiers) && !isProtected(modifiers) && !isPrivate(modifiers); + } + + public static boolean isPublic(int modifiers) { + return (modifiers & PUBLIC) != 0; + } + + public static boolean isStatic(int modifiers) { + return (modifiers & STATIC) != 0; + } + + public static boolean isStrictfp(int modifiers) { + return (modifiers & STRICTFP) != 0; + } + + public static boolean isSynchronized(int modifiers) { + return (modifiers & SYNCHRONIZED) != 0; + } + + public static boolean isTransient(int modifiers) { + return (modifiers & TRANSIENT) != 0; + } + + public static boolean isVolatile(int modifiers) { + return (modifiers & VOLATILE) != 0; + } + + /** + * Removes the given modifier. + * @param modifiers existing modifiers + * @param mod modifier to be removed + * @return result for removing modifier + */ + public static int removeModifier(int modifiers, int mod) { + return modifiers & ~mod; + } + + private ModifierSet() { + } +}
\ No newline at end of file diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MultiTypeParameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MultiTypeParameter.java new file mode 100644 index 000000000..6dad24c71 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/MultiTypeParameter.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +public class MultiTypeParameter extends BaseParameter { + private List<Type> types; + + public MultiTypeParameter() {} + + public MultiTypeParameter(int modifiers, List<AnnotationExpr> annotations, List<Type> types, VariableDeclaratorId id) { + super(modifiers, annotations, id); + this.types = types; + } + + public MultiTypeParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, List<Type> types, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id); + this.types = types; + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Type> getTypes() { + return types; + } + + public void setTypes(List<Type> types) { + this.types = types; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/Parameter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/Parameter.java new file mode 100644 index 000000000..6113d702a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/Parameter.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class Parameter extends BaseParameter { + private Type type; + + private boolean isVarArgs; + + public Parameter() { + } + + public Parameter(Type type, VariableDeclaratorId id) { + super(id); + setType(type); + } + + public Parameter(int modifiers, Type type, VariableDeclaratorId id) { + super(modifiers, id); + setType(type); + } + + public Parameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, boolean isVarArgs, VariableDeclaratorId id) { + super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id); + setType(type); + setVarArgs(isVarArgs); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Type getType() { + return type; + } + + public boolean isVarArgs() { + return isVarArgs; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/TypeDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/TypeDeclaration.java new file mode 100644 index 000000000..bd7c09327 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/TypeDeclaration.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.NameExpr; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class TypeDeclaration extends BodyDeclaration implements NamedNode { + + private NameExpr name; + + private int modifiers; + + private List<BodyDeclaration> members; + + public TypeDeclaration() { + } + + public TypeDeclaration(int modifiers, String name) { + setName(name); + setModifiers(modifiers); + } + + public TypeDeclaration(List<AnnotationExpr> annotations, + int modifiers, String name, + List<BodyDeclaration> members) { + super(annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public TypeDeclaration(int beginLine, int beginColumn, int endLine, + int endColumn, List<AnnotationExpr> annotations, + int modifiers, String name, + List<BodyDeclaration> members) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setName(name); + setModifiers(modifiers); + setMembers(members); + } + + public final List<BodyDeclaration> getMembers() { + return members; + } + + /** + * Return the modifiers of this type declaration. + * + * @see ModifierSet + * @return modifiers + */ + public final int getModifiers() { + return modifiers; + } + + public final String getName() { + return name.getName(); + } + + public void setMembers(List<BodyDeclaration> members) { + this.members = members; + setAsParentNodeOf(this.members); + } + + public final void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public final void setName(String name) { + this.name = new NameExpr(name); + } + + public final void setNameExpr(NameExpr nameExpr) { + this.name = nameExpr; + } + + public final NameExpr getNameExpr() { + return name; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclarator.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclarator.java new file mode 100644 index 000000000..50097b863 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclarator.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclarator extends Node { + + private VariableDeclaratorId id; + + private Expression init; + + public VariableDeclarator() { + } + + public VariableDeclarator(VariableDeclaratorId id) { + setId(id); + } + + public VariableDeclarator(VariableDeclaratorId id, Expression init) { + setId(id); + setInit(init); + } + + public VariableDeclarator(int beginLine, int beginColumn, int endLine, int endColumn, VariableDeclaratorId id, Expression init) { + super(beginLine, beginColumn, endLine, endColumn); + setId(id); + setInit(init); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public VariableDeclaratorId getId() { + return id; + } + + public Expression getInit() { + return init; + } + + public void setId(VariableDeclaratorId id) { + this.id = id; + setAsParentNodeOf(this.id); + } + + public void setInit(Expression init) { + this.init = init; + setAsParentNodeOf(this.init); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclaratorId.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclaratorId.java new file mode 100644 index 000000000..c56bd8e7f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/VariableDeclaratorId.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclaratorId extends Node implements NamedNode { + + private String name; + + private int arrayCount; + + public VariableDeclaratorId() { + } + + public VariableDeclaratorId(String name) { + setName(name); + } + + public VariableDeclaratorId(int beginLine, int beginColumn, int endLine, int endColumn, String name, int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setArrayCount(arrayCount); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public String getName() { + return name; + } + + public void setArrayCount(int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/WithDeclaration.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/WithDeclaration.java new file mode 100644 index 000000000..8f1725ce6 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/body/WithDeclaration.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.body; + +/** + * Element with a declaration representable as a String. + * + * @author Federico Tomassetti + * @since July 2014 + */ +public interface WithDeclaration { + + /** + * As {@link WithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including + * the modifiers, the throws clause and the parameters with both type and name. + * @return String representation of declaration + */ + String getDeclarationAsString(); + + /** + * As {@link WithDeclaration#getDeclarationAsString(boolean, boolean, boolean)} including + * the parameters with both type and name. + * @param includingModifiers flag to include the modifiers (if present) in the string produced + * @param includingThrows flag to include the throws clause (if present) in the string produced + * @return String representation of declaration based on parameter flags + */ + String getDeclarationAsString(boolean includingModifiers, boolean includingThrows); + + /** + * A simple representation of the element declaration. + * It should fit one string. + * @param includingModifiers flag to include the modifiers (if present) in the string produced + * @param includingThrows flag to include the throws clause (if present) in the string produced + * @param includingParameterName flag to include the parameter name (while the parameter type is always included) in the string produced + * @return String representation of declaration based on parameter flags + */ + String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/BlockComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/BlockComment.java new file mode 100644 index 000000000..299493b87 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/BlockComment.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * AST node that represent block comments. + * </p> + * Block comments can has multi lines and are delimited by "/*" and + * "*/". + * + * @author Julio Vilmar Gesser + */ +public final class BlockComment extends Comment { + + public BlockComment() { + } + + public BlockComment(String content) { + super(content); + } + + public BlockComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/Comment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/Comment.java new file mode 100644 index 000000000..135972b92 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/Comment.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.Node; + +/** + * Abstract class for all AST nodes that represent comments. + * + * @see BlockComment + * @see LineComment + * @see JavadocComment + * @author Julio Vilmar Gesser + */ +public abstract class Comment extends Node { + + private String content; + private Node commentedNode; + + public Comment() { + } + + public Comment(String content) { + this.content = content; + } + + public Comment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn); + this.content = content; + } + + /** + * Return the text of the comment. + * + * @return text of the comment + */ + public final String getContent() { + return content; + } + + /** + * Sets the text of the comment. + * + * @param content + * the text of the comment to set + */ + public void setContent(String content) { + this.content = content; + } + + public boolean isLineComment() + { + return false; + } + + public LineComment asLineComment() + { + if (isLineComment()) + { + return (LineComment) this; + } else { + throw new UnsupportedOperationException("Not a line comment"); + } + } + + public Node getCommentedNode() + { + return this.commentedNode; + } + + public void setCommentedNode(Node commentedNode) + { + if (commentedNode==null) + { + this.commentedNode = commentedNode; + return; + } + if (commentedNode==this) + { + throw new IllegalArgumentException(); + } + if (commentedNode instanceof Comment) + { + throw new IllegalArgumentException(); + } + this.commentedNode = commentedNode; + } + + public boolean isOrphan() + { + return this.commentedNode == null; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsCollection.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsCollection.java new file mode 100644 index 000000000..ac94c61d5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsCollection.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import java.util.LinkedList; +import java.util.List; + +/** + * Set of comments produced by CommentsParser. + */ +public class CommentsCollection { + private List<LineComment> lineComments = new LinkedList<LineComment>(); + private List<BlockComment> blockComments = new LinkedList<BlockComment>(); + private List<JavadocComment> javadocComments = new LinkedList<JavadocComment>(); + + public List<LineComment> getLineComments(){ + return lineComments; + } + + public List<BlockComment> getBlockComments(){ + return blockComments; + } + + public List<JavadocComment> getJavadocComments(){ + return javadocComments; + } + + public void addComment(LineComment lineComment){ + this.lineComments.add(lineComment); + } + + public void addComment(BlockComment blockComment){ + this.blockComments.add(blockComment); + } + + public void addComment(JavadocComment javadocComment){ + this.javadocComments.add(javadocComment); + } + + public boolean contains(Comment comment){ + for (Comment c : getAll()){ + // we tollerate a difference of one element in the end column: + // it depends how \r and \n are calculated... + if ( c.getBeginLine()==comment.getBeginLine() && + c.getBeginColumn()==comment.getBeginColumn() && + c.getEndLine()==comment.getEndLine() && + Math.abs(c.getEndColumn()-comment.getEndColumn())<2 ){ + return true; + } + } + return false; + } + + public List<Comment> getAll(){ + List<Comment> comments = new LinkedList<Comment>(); + comments.addAll(lineComments); + comments.addAll(blockComments); + comments.addAll(javadocComments); + return comments; + } + + public int size(){ + return lineComments.size()+blockComments.size()+javadocComments.size(); + } + + public CommentsCollection minus(CommentsCollection other){ + CommentsCollection result = new CommentsCollection(); + for (LineComment comment : lineComments){ + if (!other.contains(comment)){ + result.lineComments.add(comment); + } + } + for (BlockComment comment : blockComments){ + if (!other.contains(comment)){ + result.blockComments.add(comment); + } + } + for (JavadocComment comment : javadocComments){ + if (!other.contains(comment)){ + result.javadocComments.add(comment); + } + } + return result; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsParser.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsParser.java new file mode 100644 index 000000000..3d3a59d45 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/CommentsParser.java @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import java.io.*; +import java.nio.charset.Charset; +import java.util.*; + +/** + * This parser cares exclusively about comments. + */ +public class CommentsParser { + + private enum State { + CODE, + IN_LINE_COMMENT, + IN_BLOCK_COMMENT, + IN_STRING, + IN_CHAR; + } + + private static final int COLUMNS_PER_TAB = 4; + + public CommentsCollection parse(final String source) throws IOException, UnsupportedEncodingException { + InputStream in = new ByteArrayInputStream(source.getBytes(Charset.defaultCharset())); + return parse(in, Charset.defaultCharset().name()); + } + + public CommentsCollection parse(final InputStream in, final String charsetName) throws IOException, UnsupportedEncodingException { + boolean lastWasASlashR = false; + BufferedReader br = new BufferedReader(new InputStreamReader(in, charsetName)); + CommentsCollection comments = new CommentsCollection(); + int r; + + Deque prevTwoChars = new LinkedList<Character>(Arrays.asList('z','z')); + + State state = State.CODE; + LineComment currentLineComment = null; + BlockComment currentBlockComment = null; + StringBuffer currentContent = null; + + int currLine = 1; + int currCol = 1; + + while ((r=br.read()) != -1){ + char c = (char)r; + if (c=='\r'){ + lastWasASlashR = true; + } else if (c=='\n'&&lastWasASlashR){ + lastWasASlashR=false; + continue; + } else { + lastWasASlashR=false; + } + switch (state) { + case CODE: + if (prevTwoChars.peekLast().equals('/') && c == '/') { + currentLineComment = new LineComment(); + currentLineComment.setBeginLine(currLine); + currentLineComment.setBeginColumn(currCol - 1); + state = State.IN_LINE_COMMENT; + currentContent = new StringBuffer(); + } else if (prevTwoChars.peekLast().equals('/') && c == '*') { + currentBlockComment = new BlockComment(); + currentBlockComment.setBeginLine(currLine); + currentBlockComment.setBeginColumn(currCol - 1); + state = State.IN_BLOCK_COMMENT; + currentContent = new StringBuffer(); + } else if (c == '"') { + state = State.IN_STRING; + } else if (c == '\'') { + state = State.IN_CHAR; + } else { + // nothing to do + } + break; + case IN_LINE_COMMENT: + if (c=='\n' || c=='\r'){ + currentLineComment.setContent(currentContent.toString()); + currentLineComment.setEndLine(currLine); + currentLineComment.setEndColumn(currCol); + comments.addComment(currentLineComment); + state = State.CODE; + } else { + currentContent.append(c); + } + break; + case IN_BLOCK_COMMENT: + if (prevTwoChars.peekLast().equals('*') && c=='/' && !prevTwoChars.peekFirst().equals('/')){ + + // delete last character + String content = currentContent.deleteCharAt(currentContent.toString().length()-1).toString(); + + if (content.startsWith("*")){ + JavadocComment javadocComment = new JavadocComment(); + javadocComment.setContent(content.substring(1)); + javadocComment.setBeginLine(currentBlockComment.getBeginLine()); + javadocComment.setBeginColumn(currentBlockComment.getBeginColumn()); + javadocComment.setEndLine(currLine); + javadocComment.setEndColumn(currCol+1); + comments.addComment(javadocComment); + } else { + currentBlockComment.setContent(content); + currentBlockComment.setEndLine(currLine); + currentBlockComment.setEndColumn(currCol+1); + comments.addComment(currentBlockComment); + } + state = State.CODE; + } else { + currentContent.append(c=='\r'?'\n':c); + } + break; + case IN_STRING: + if (!prevTwoChars.peekLast().equals('\\') && c == '"') { + state = State.CODE; + } + break; + case IN_CHAR: + if (!prevTwoChars.peekLast().equals('\\') && c == '\'') { + state = State.CODE; + } + break; + default: + throw new RuntimeException("Unexpected"); + } + switch (c){ + case '\n': + case '\r': + currLine+=1; + currCol = 1; + break; + case '\t': + currCol+=COLUMNS_PER_TAB; + break; + default: + currCol+=1; + } + prevTwoChars.remove(); + prevTwoChars.add(c); + } + + if (state==State.IN_LINE_COMMENT){ + currentLineComment.setContent(currentContent.toString()); + currentLineComment.setEndLine(currLine); + currentLineComment.setEndColumn(currCol); + comments.addComment(currentLineComment); + } + + return comments; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/JavadocComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/JavadocComment.java new file mode 100644 index 000000000..a070321ff --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/JavadocComment.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class JavadocComment extends Comment { + + public JavadocComment() { + } + + public JavadocComment(String content) { + super(content); + } + + public JavadocComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/LineComment.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/LineComment.java new file mode 100644 index 000000000..b3df1df0e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/comments/LineComment.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.comments; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * <p> + * AST node that represent line comments. + * </p> + * Line comments are started with "//" and finish at the end of the line ("\n"). + * + * @author Julio Vilmar Gesser + */ +public final class LineComment extends Comment { + + public LineComment() { + } + + public LineComment(String content) { + super(content); + } + + public LineComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) { + super(beginLine, beginColumn, endLine, endColumn, content); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean isLineComment() + { + return true; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AnnotationExpr.java new file mode 100644 index 000000000..8c65e926f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AnnotationExpr.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class AnnotationExpr extends Expression { + + protected NameExpr name; + + public AnnotationExpr() {} + + public AnnotationExpr(int beginLine, int beginColumn, int endLine, + int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + public NameExpr getName() { + return name; + } + + public void setName(NameExpr name) { + this.name = name; + setAsParentNodeOf(name); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayAccessExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayAccessExpr.java new file mode 100644 index 000000000..7026d15eb --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayAccessExpr.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayAccessExpr extends Expression { + + private Expression name; + + private Expression index; + + public ArrayAccessExpr() { + } + + public ArrayAccessExpr(Expression name, Expression index) { + setName(name); + setIndex(index); + } + + public ArrayAccessExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression name, Expression index) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setIndex(index); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getIndex() { + return index; + } + + public Expression getName() { + return name; + } + + public void setIndex(Expression index) { + this.index = index; + setAsParentNodeOf(this.index); + } + + public void setName(Expression name) { + this.name = name; + setAsParentNodeOf(this.name); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayCreationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayCreationExpr.java new file mode 100644 index 000000000..1ca425b51 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayCreationExpr.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayCreationExpr extends Expression { + + private Type type; + + private int arrayCount; + + private ArrayInitializerExpr initializer; + + private List<Expression> dimensions; + + private List<List<AnnotationExpr>> arraysAnnotations; + + public ArrayCreationExpr() { + } + + public ArrayCreationExpr(Type type, int arrayCount, ArrayInitializerExpr initializer) { + setType(type); + setArrayCount(arrayCount); + setInitializer(initializer); + setDimensions(null); + } + + public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, int arrayCount, ArrayInitializerExpr initializer) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + setInitializer(initializer); + setDimensions(null); + } + + public ArrayCreationExpr(Type type, List<Expression> dimensions, int arrayCount) { + setType(type); + setArrayCount(arrayCount); + setDimensions(dimensions); + setInitializer(null); + } + + public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, List<Expression> dimensions, int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + setDimensions(dimensions); + setInitializer(null); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public List<Expression> getDimensions() { + return dimensions; + } + + public ArrayInitializerExpr getInitializer() { + return initializer; + } + + public Type getType() { + return type; + } + + public void setArrayCount(int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setDimensions(List<Expression> dimensions) { + this.dimensions = dimensions; + setAsParentNodeOf(this.dimensions); + } + + public void setInitializer(ArrayInitializerExpr initializer) { + this.initializer = initializer; + setAsParentNodeOf(this.initializer); + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public List<List<AnnotationExpr>> getArraysAnnotations() { + return arraysAnnotations; + } + + public void setArraysAnnotations( + List<List<AnnotationExpr>> arraysAnnotations) { + this.arraysAnnotations = arraysAnnotations; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayInitializerExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayInitializerExpr.java new file mode 100644 index 000000000..f7fa424cf --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ArrayInitializerExpr.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ArrayInitializerExpr extends Expression { + + private List<Expression> values; + + public ArrayInitializerExpr() { + } + + public ArrayInitializerExpr(List<Expression> values) { + setValues(values); + } + + public ArrayInitializerExpr(int beginLine, int beginColumn, int endLine, int endColumn, List<Expression> values) { + super(beginLine, beginColumn, endLine, endColumn); + setValues(values); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public List<Expression> getValues() { + return values; + } + + public void setValues(List<Expression> values) { + this.values = values; + setAsParentNodeOf(this.values); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AssignExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AssignExpr.java new file mode 100644 index 000000000..b3d508fe9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/AssignExpr.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class AssignExpr extends Expression { + + public static enum Operator { + assign, // = + plus, // += + minus, // -= + star, // *= + slash, // /= + and, // &= + or, // |= + xor, // ^= + rem, // %= + lShift, // <<= + rSignedShift, // >>= + rUnsignedShift, // >>>= + } + + private Expression target; + + private Expression value; + + private Operator op; + + public AssignExpr() { + } + + public AssignExpr(Expression target, Expression value, Operator op) { + setTarget(target); + setValue(value); + setOperator(op); + } + + public AssignExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression target, Expression value, Operator op) { + super(beginLine, beginColumn, endLine, endColumn); + setTarget(target); + setValue(value); + setOperator(op); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Operator getOperator() { + return op; + } + + public Expression getTarget() { + return target; + } + + public Expression getValue() { + return value; + } + + public void setOperator(Operator op) { + this.op = op; + } + + public void setTarget(Expression target) { + this.target = target; + setAsParentNodeOf(this.target); + } + + public void setValue(Expression value) { + this.value = value; + setAsParentNodeOf(this.value); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BinaryExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BinaryExpr.java new file mode 100644 index 000000000..4ace4bec4 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BinaryExpr.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BinaryExpr extends Expression { + + public static enum Operator { + or, // || + and, // && + binOr, // | + binAnd, // & + xor, // ^ + equals, // == + notEquals, // != + less, // < + greater, // > + lessEquals, // <= + greaterEquals, // >= + lShift, // << + rSignedShift, // >> + rUnsignedShift, // >>> + plus, // + + minus, // - + times, // * + divide, // / + remainder, // % + } + + private Expression left; + + private Expression right; + + private Operator op; + + public BinaryExpr() { + } + + public BinaryExpr(Expression left, Expression right, Operator op) { + setLeft(left); + setRight(right); + setOperator(op); + } + + public BinaryExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression left, Expression right, Operator op) { + super(beginLine, beginColumn, endLine, endColumn); + setLeft(left); + setRight(right); + setOperator(op); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getLeft() { + return left; + } + + public Operator getOperator() { + return op; + } + + public Expression getRight() { + return right; + } + + public void setLeft(Expression left) { + this.left = left; + setAsParentNodeOf(this.left); + } + + public void setOperator(Operator op) { + this.op = op; + } + + public void setRight(Expression right) { + this.right = right; + setAsParentNodeOf(this.right); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BooleanLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BooleanLiteralExpr.java new file mode 100644 index 000000000..e92244a62 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/BooleanLiteralExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BooleanLiteralExpr extends LiteralExpr { + + private boolean value; + + public BooleanLiteralExpr() { + } + + public BooleanLiteralExpr(boolean value) { + setValue(value); + } + + public BooleanLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, boolean value) { + super(beginLine, beginColumn, endLine, endColumn); + setValue(value); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CastExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CastExpr.java new file mode 100644 index 000000000..843386968 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CastExpr.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class CastExpr extends Expression { + + private Type type; + + private Expression expr; + + public CastExpr() { + } + + public CastExpr(Type type, Expression expr) { + setType(type); + setExpr(expr); + } + + public CastExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setExpr(expr); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Type getType() { + return type; + } + + public void setExpr(Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CharLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CharLiteralExpr.java new file mode 100644 index 000000000..061805d47 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/CharLiteralExpr.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class CharLiteralExpr extends StringLiteralExpr { + + public CharLiteralExpr() { + } + + public CharLiteralExpr(String value) { + super(value); + } + + public CharLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ClassExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ClassExpr.java new file mode 100644 index 000000000..bd33c6730 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ClassExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassExpr extends Expression { + + private Type type; + + public ClassExpr() { + } + + public ClassExpr(Type type) { + setType(type); + } + + public ClassExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ConditionalExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ConditionalExpr.java new file mode 100644 index 000000000..31db61cca --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ConditionalExpr.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ConditionalExpr extends Expression { + + private Expression condition; + + private Expression thenExpr; + + private Expression elseExpr; + + public ConditionalExpr() { + } + + public ConditionalExpr(Expression condition, Expression thenExpr, Expression elseExpr) { + setCondition(condition); + setThenExpr(thenExpr); + setElseExpr(elseExpr); + } + + public ConditionalExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression condition, Expression thenExpr, Expression elseExpr) { + super(beginLine, beginColumn, endLine, endColumn); + setCondition(condition); + setThenExpr(thenExpr); + setElseExpr(elseExpr); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getCondition() { + return condition; + } + + public Expression getElseExpr() { + return elseExpr; + } + + public Expression getThenExpr() { + return thenExpr; + } + + public void setCondition(Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } + + public void setElseExpr(Expression elseExpr) { + this.elseExpr = elseExpr; + setAsParentNodeOf(this.elseExpr); + } + + public void setThenExpr(Expression thenExpr) { + this.thenExpr = thenExpr; + setAsParentNodeOf(this.thenExpr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/DoubleLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/DoubleLiteralExpr.java new file mode 100644 index 000000000..ce6962d7b --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/DoubleLiteralExpr.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class DoubleLiteralExpr extends StringLiteralExpr { + + public DoubleLiteralExpr() { + } + + public DoubleLiteralExpr(final String value) { + super(value); + } + + public DoubleLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/EnclosedExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/EnclosedExpr.java new file mode 100644 index 000000000..72f9de2a1 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/EnclosedExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EnclosedExpr extends Expression { + + private Expression inner; + + public EnclosedExpr() { + } + + public EnclosedExpr(final Expression inner) { + setInner(inner); + } + + public EnclosedExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression inner) { + super(beginLine, beginColumn, endLine, endColumn); + setInner(inner); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getInner() { + return inner; + } + + public void setInner(final Expression inner) { + this.inner = inner; + setAsParentNodeOf(this.inner); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/Expression.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/Expression.java new file mode 100644 index 000000000..8b36d6b1d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/Expression.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.Node; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Expression extends Node { + + public Expression() { + } + + public Expression(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/FieldAccessExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/FieldAccessExpr.java new file mode 100644 index 000000000..b57bf7fe0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/FieldAccessExpr.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class FieldAccessExpr extends Expression { + + private Expression scope; + + private List<Type> typeArgs; + + private NameExpr field; + + public FieldAccessExpr() { + } + + public FieldAccessExpr(final Expression scope, final String field) { + setScope(scope); + setField(field); + } + + public FieldAccessExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression scope, final List<Type> typeArgs, final String field) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setTypeArgs(typeArgs); + setField(field); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getField() { + return field.getName(); + } + + public NameExpr getFieldExpr() { + return field; + } + + public Expression getScope() { + return scope; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public void setField(final String field) { + this.field = new NameExpr(field); + } + + public void setFieldExpr(NameExpr field) { + this.field = field; + } + + public void setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/InstanceOfExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/InstanceOfExpr.java new file mode 100644 index 000000000..9a9786512 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/InstanceOfExpr.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class InstanceOfExpr extends Expression { + + private Expression expr; + + private Type type; + + public InstanceOfExpr() { + } + + public InstanceOfExpr(final Expression expr, final Type type) { + setExpr(expr); + setType(type); + } + + public InstanceOfExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr, final Type type) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + setType(type); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Type getType() { + return type; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralExpr.java new file mode 100644 index 000000000..b326c5770 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralExpr.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class IntegerLiteralExpr extends StringLiteralExpr { + + private static final String UNSIGNED_MIN_VALUE = "2147483648"; + + protected static final String MIN_VALUE = "-" + UNSIGNED_MIN_VALUE; + + public IntegerLiteralExpr() { + } + + public IntegerLiteralExpr(final String value) { + super(value); + } + + public IntegerLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final boolean isMinValue() { + return value != null && // + value.length() == 10 && // + value.equals(UNSIGNED_MIN_VALUE); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java new file mode 100644 index 000000000..238b56431 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class IntegerLiteralMinValueExpr extends IntegerLiteralExpr { + + public IntegerLiteralMinValueExpr() { + super(MIN_VALUE); + } + + public IntegerLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LambdaExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LambdaExpr.java new file mode 100644 index 000000000..4e4e93444 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LambdaExpr.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + + +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * Lambda expressions. + * @author Raquel Pau + * + */ +public class LambdaExpr extends Expression { + + private List<Parameter> parameters; + + private boolean parametersEnclosed; + + private Statement body; + + public LambdaExpr() { + } + + public LambdaExpr(int beginLine, int beginColumn, int endLine, + int endColumn, List<Parameter> parameters, Statement body, + boolean parametersEnclosed) { + + super(beginLine, beginColumn, endLine, endColumn); + setParameters(parameters); + setBody(body); + setParametersEnclosed(parametersEnclosed); + } + + public List<Parameter> getParameters() { + return parameters; + } + + public void setParameters(List<Parameter> parameters) { + this.parameters = parameters; + setAsParentNodeOf(this.parameters); + } + + public Statement getBody() { + return body; + } + + public void setBody(Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public boolean isParametersEnclosed() { + return parametersEnclosed; + } + + public void setParametersEnclosed(boolean parametersEnclosed) { + this.parametersEnclosed = parametersEnclosed; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LiteralExpr.java new file mode 100644 index 000000000..7827f7866 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LiteralExpr.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class LiteralExpr extends Expression { + + public LiteralExpr() { + } + + public LiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralExpr.java new file mode 100644 index 000000000..15ea255ba --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralExpr.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class LongLiteralExpr extends StringLiteralExpr { + + private static final String UNSIGNED_MIN_VALUE = "9223372036854775808"; + + protected static final String MIN_VALUE = "-" + UNSIGNED_MIN_VALUE + "L"; + + public LongLiteralExpr() { + } + + public LongLiteralExpr(final String value) { + super(value); + } + + public LongLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn, value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final boolean isMinValue() { + return value != null && // + value.length() == 20 && // + value.startsWith(UNSIGNED_MIN_VALUE) && // + (value.charAt(19) == 'L' || value.charAt(19) == 'l'); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java new file mode 100644 index 000000000..f351f7a59 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class LongLiteralMinValueExpr extends LongLiteralExpr { + + public LongLiteralMinValueExpr() { + super(MIN_VALUE); + } + + public LongLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java new file mode 100644 index 000000000..c1a354530 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class MarkerAnnotationExpr extends AnnotationExpr { + + public MarkerAnnotationExpr() { + } + + public MarkerAnnotationExpr(final NameExpr name) { + setName(name); + } + + public MarkerAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr name) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MemberValuePair.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MemberValuePair.java new file mode 100644 index 000000000..e0fa80c66 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MemberValuePair.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class MemberValuePair extends Node implements NamedNode { + + private String name; + + private Expression value; + + public MemberValuePair() { + } + + public MemberValuePair(final String name, final Expression value) { + setName(name); + setValue(value); + } + + public MemberValuePair(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name, final Expression value) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setValue(value); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getName() { + return name; + } + + public Expression getValue() { + return value; + } + + public void setName(final String name) { + this.name = name; + } + + public void setValue(final Expression value) { + this.value = value; + setAsParentNodeOf(this.value); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodCallExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodCallExpr.java new file mode 100644 index 000000000..9d5d10f06 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodCallExpr.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class MethodCallExpr extends Expression { + + private Expression scope; + + private List<Type> typeArgs; + + private NameExpr name; + + private List<Expression> args; + + public MethodCallExpr() { + } + + public MethodCallExpr(final Expression scope, final String name) { + setScope(scope); + setName(name); + } + + public MethodCallExpr(final Expression scope, final String name, final List<Expression> args) { + setScope(scope); + setName(name); + setArgs(args); + } + + public MethodCallExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setTypeArgs(typeArgs); + setName(name); + setArgs(args); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + return args; + } + + public String getName() { + return name.getName(); + } + + public NameExpr getNameExpr() { + return name; + } + + public Expression getScope() { + return scope; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setName(final String name) { + this.name = new NameExpr(name); + } + + public void setNameExpr(NameExpr name) { + this.name = name; + } + + public void setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodReferenceExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodReferenceExpr.java new file mode 100644 index 000000000..918ad3f2a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/MethodReferenceExpr.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * Method reference expressions introduced in Java 8 specifically designed to simplify lambda Expressions. + * These are some examples: + * + * System.out::println; + * + * (test ? stream.map(String::trim) : stream)::toArray; + * @author Raquel Pau + * + */ +public class MethodReferenceExpr extends Expression { + + private Expression scope; + + private List<TypeParameter> typeParameters; + + private String identifier; + + public MethodReferenceExpr() { + } + + public MethodReferenceExpr(int beginLine, int beginColumn, int endLine, + int endColumn, Expression scope, + List<TypeParameter> typeParameters, String identifier) { + + super(beginLine, beginColumn, endLine, endColumn); + setIdentifier(identifier); + setScope(scope); + setTypeParameters(typeParameters); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Expression getScope() { + return scope; + } + + public void setScope(Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public List<TypeParameter> getTypeParameters() { + return typeParameters; + } + + public void setTypeParameters(List<TypeParameter> typeParameters) { + this.typeParameters = typeParameters; + setAsParentNodeOf(this.typeParameters); + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NameExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NameExpr.java new file mode 100644 index 000000000..5cdbbbb6c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NameExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.NamedNode; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class NameExpr extends Expression implements NamedNode { + + private String name; + + public NameExpr() { + } + + public NameExpr(final String name) { + this.name = name; + } + + public NameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String name) { + super(beginLine, beginColumn, endLine, endColumn); + this.name = name; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final String getName() { + return name; + } + + public final void setName(final String name) { + this.name = name; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NormalAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NormalAnnotationExpr.java new file mode 100644 index 000000000..2b2adfd72 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NormalAnnotationExpr.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class NormalAnnotationExpr extends AnnotationExpr { + + private List<MemberValuePair> pairs; + + public NormalAnnotationExpr() { + } + + public NormalAnnotationExpr(final NameExpr name, final List<MemberValuePair> pairs) { + setName(name); + setPairs(pairs); + } + + public NormalAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr name, final List<MemberValuePair> pairs) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setPairs(pairs); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<MemberValuePair> getPairs() { + return pairs; + } + + public void setPairs(final List<MemberValuePair> pairs) { + this.pairs = pairs; + setAsParentNodeOf(this.pairs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NullLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NullLiteralExpr.java new file mode 100644 index 000000000..c7bc177d5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/NullLiteralExpr.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class NullLiteralExpr extends LiteralExpr { + + public NullLiteralExpr() { + } + + public NullLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ObjectCreationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ObjectCreationExpr.java new file mode 100644 index 000000000..228dabc2c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ObjectCreationExpr.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ObjectCreationExpr extends Expression { + + private Expression scope; + + private ClassOrInterfaceType type; + + private List<Type> typeArgs; + + private List<Expression> args; + + private List<BodyDeclaration> anonymousClassBody; + + public ObjectCreationExpr() { + } + + public ObjectCreationExpr(final Expression scope, final ClassOrInterfaceType type, final List<Expression> args) { + setScope(scope); + setType(type); + setArgs(args); + } + + public ObjectCreationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression scope, final ClassOrInterfaceType type, final List<Type> typeArgs, + final List<Expression> args, final List<BodyDeclaration> anonymousBody) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setType(type); + setTypeArgs(typeArgs); + setArgs(args); + setAnonymousClassBody(anonymousBody); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<BodyDeclaration> getAnonymousClassBody() { + return anonymousClassBody; + } + + public List<Expression> getArgs() { + return args; + } + + public Expression getScope() { + return scope; + } + + public ClassOrInterfaceType getType() { + return type; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public void setAnonymousClassBody(final List<BodyDeclaration> anonymousClassBody) { + this.anonymousClassBody = anonymousClassBody; + setAsParentNodeOf(this.anonymousClassBody); + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setScope(final Expression scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setType(final ClassOrInterfaceType type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/QualifiedNameExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/QualifiedNameExpr.java new file mode 100644 index 000000000..00a65aa7f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/QualifiedNameExpr.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class QualifiedNameExpr extends NameExpr { + + private NameExpr qualifier; + + public QualifiedNameExpr() { + } + + public QualifiedNameExpr(final NameExpr scope, final String name) { + super(name); + setQualifier(scope); + } + + public QualifiedNameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final NameExpr scope, final String name) { + super(beginLine, beginColumn, endLine, endColumn, name); + setQualifier(scope); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public NameExpr getQualifier() { + return qualifier; + } + + public void setQualifier(final NameExpr qualifier) { + this.qualifier = qualifier; + setAsParentNodeOf(this.qualifier); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java new file mode 100644 index 000000000..bd8adb116 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SingleMemberAnnotationExpr extends AnnotationExpr { + + private Expression memberValue; + + public SingleMemberAnnotationExpr() { + } + + public SingleMemberAnnotationExpr(final NameExpr name, final Expression memberValue) { + setName(name); + setMemberValue(memberValue); + } + + public SingleMemberAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, + final int endColumn, final NameExpr name, final Expression memberValue) { + super(beginLine, beginColumn, endLine, endColumn); + setName(name); + setMemberValue(memberValue); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getMemberValue() { + return memberValue; + } + + public void setMemberValue(final Expression memberValue) { + this.memberValue = memberValue; + setAsParentNodeOf(this.memberValue); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/StringLiteralExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/StringLiteralExpr.java new file mode 100644 index 000000000..6876fa23e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/StringLiteralExpr.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public class StringLiteralExpr extends LiteralExpr { + + protected String value; + + public StringLiteralExpr() { + } + + public StringLiteralExpr(final String value) { + this.value = value; + } + + public StringLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String value) { + super(beginLine, beginColumn, endLine, endColumn); + this.value = value; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public final String getValue() { + return value; + } + + public final void setValue(final String value) { + this.value = value; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SuperExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SuperExpr.java new file mode 100644 index 000000000..791d28bc9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/SuperExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SuperExpr extends Expression { + + private Expression classExpr; + + public SuperExpr() { + } + + public SuperExpr(final Expression classExpr) { + setClassExpr(classExpr); + } + + public SuperExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression classExpr) { + super(beginLine, beginColumn, endLine, endColumn); + setClassExpr(classExpr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getClassExpr() { + return classExpr; + } + + public void setClassExpr(final Expression classExpr) { + this.classExpr = classExpr; + setAsParentNodeOf(this.classExpr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ThisExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ThisExpr.java new file mode 100644 index 000000000..c269376c9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/ThisExpr.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ThisExpr extends Expression { + + private Expression classExpr; + + public ThisExpr() { + } + + public ThisExpr(final Expression classExpr) { + setClassExpr(classExpr); + } + + public ThisExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression classExpr) { + super(beginLine, beginColumn, endLine, endColumn); + setClassExpr(classExpr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getClassExpr() { + return classExpr; + } + + public void setClassExpr(final Expression classExpr) { + this.classExpr = classExpr; + setAsParentNodeOf(this.classExpr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/TypeExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/TypeExpr.java new file mode 100644 index 000000000..636d2c4a0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/TypeExpr.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * This class is just instantiated as scopes for MethodReferenceExpr nodes to encapsulate Types. + * @author Raquel Pau + * + */ +public class TypeExpr extends Expression{ + + private Type type; + + public TypeExpr(){} + + public TypeExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + } + + @Override + public <R, A> R accept(GenericVisitor<R, A> v, A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(VoidVisitor<A> v, A arg) { + v.visit(this, arg); + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/UnaryExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/UnaryExpr.java new file mode 100644 index 000000000..19d936018 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/UnaryExpr.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class UnaryExpr extends Expression { + + public static enum Operator { + positive, // + + negative, // - + preIncrement, // ++ + preDecrement, // -- + not, // ! + inverse, // ~ + posIncrement, // ++ + posDecrement, // -- + } + + private Expression expr; + + private Operator op; + + public UnaryExpr() { + } + + public UnaryExpr(final Expression expr, final Operator op) { + setExpr(expr); + setOperator(op); + } + + public UnaryExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr, final Operator op) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + setOperator(op); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public Operator getOperator() { + return op; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setOperator(final Operator op) { + this.op = op; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/VariableDeclarationExpr.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/VariableDeclarationExpr.java new file mode 100644 index 000000000..2dcaa2299 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/expr/VariableDeclarationExpr.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.expr; + +import com.github.javaparser.ast.body.ModifierSet; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class VariableDeclarationExpr extends Expression { + + private int modifiers; + + private List<AnnotationExpr> annotations; + + private Type type; + + private List<VariableDeclarator> vars; + + public VariableDeclarationExpr() { + } + + public VariableDeclarationExpr(final Type type, final List<VariableDeclarator> vars) { + setType(type); + setVars(vars); + } + + public VariableDeclarationExpr(final int modifiers, final Type type, final List<VariableDeclarator> vars) { + setModifiers(modifiers); + setType(type); + setVars(vars); + } + + public VariableDeclarationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final int modifiers, final List<AnnotationExpr> annotations, final Type type, + final List<VariableDeclarator> vars) { + super(beginLine, beginColumn, endLine, endColumn); + setModifiers(modifiers); + setAnnotations(annotations); + setType(type); + setVars(vars); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + /** + * Return the modifiers of this variable declaration. + * + * @see ModifierSet + * @return modifiers + */ + public int getModifiers() { + return modifiers; + } + + public Type getType() { + return type; + } + + public List<VariableDeclarator> getVars() { + return vars; + } + + public void setAnnotations(final List<AnnotationExpr> annotations) { + this.annotations = annotations; + setAsParentNodeOf(this.annotations); + } + + public void setModifiers(final int modifiers) { + this.modifiers = modifiers; + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + public void setVars(final List<VariableDeclarator> vars) { + this.vars = vars; + setAsParentNodeOf(this.vars); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/internal/Utils.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/internal/Utils.java new file mode 100644 index 000000000..0bb7abbba --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/internal/Utils.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.internal; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * @author Federico Tomassetti + * @since 2.0.1 + */ +public class Utils { + + public static <T> List<T> ensureNotNull(List<T> list) { + return list == null ? Collections.<T>emptyList() : list; + } + + public static <E> boolean isNullOrEmpty(Collection<E> collection) { + return collection == null || collection.isEmpty(); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/AssertStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/AssertStmt.java new file mode 100644 index 000000000..60f61bca5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/AssertStmt.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class AssertStmt extends Statement { + + private Expression check; + + private Expression msg; + + public AssertStmt() { + } + + public AssertStmt(final Expression check) { + setCheck(check); + } + + public AssertStmt(final Expression check, final Expression msg) { + setCheck(check); + setMessage(msg); + } + + public AssertStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression check, final Expression msg) { + super(beginLine, beginColumn, endLine, endColumn); + + setCheck(check); + setMessage(msg); + + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getCheck() { + return check; + } + + public Expression getMessage() { + return msg; + } + + public void setCheck(final Expression check) { + this.check = check; + setAsParentNodeOf(this.check); + } + + public void setMessage(final Expression msg) { + this.msg = msg; + setAsParentNodeOf(this.msg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BlockStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BlockStmt.java new file mode 100644 index 000000000..d8b16738e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BlockStmt.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class BlockStmt extends Statement { + + private List<Statement> stmts; + + public BlockStmt() { + } + + public BlockStmt(final List<Statement> stmts) { + setStmts(stmts); + } + + public BlockStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final List<Statement> stmts) { + super(beginLine, beginColumn, endLine, endColumn); + setStmts(stmts); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Statement> getStmts() { + return stmts; + } + + public void setStmts(final List<Statement> stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BreakStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BreakStmt.java new file mode 100644 index 000000000..1a80f3e67 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/BreakStmt.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class BreakStmt extends Statement { + + private String id; + + public BreakStmt() { + } + + public BreakStmt(final String id) { + this.id = id; + } + + public BreakStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, final String id) { + super(beginLine, beginColumn, endLine, endColumn); + this.id = id; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/CatchClause.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/CatchClause.java new file mode 100644 index 000000000..3f43e7977 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/CatchClause.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class CatchClause extends Node { + + private MultiTypeParameter except; + + private BlockStmt catchBlock; + + public CatchClause() { + } + + public CatchClause(final MultiTypeParameter except, final BlockStmt catchBlock) { + setExcept(except); + setCatchBlock(catchBlock); + } + + public CatchClause(int exceptModifier, List<AnnotationExpr> exceptAnnotations, List<Type> exceptTypes, VariableDeclaratorId exceptId, BlockStmt catchBlock) { + this(new MultiTypeParameter(exceptModifier, exceptAnnotations, exceptTypes, exceptId), catchBlock); + } + + public CatchClause(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final List<Type> exceptTypes, + final VariableDeclaratorId exceptId, final BlockStmt catchBlock) { + super(beginLine, beginColumn, endLine, endColumn); + setExcept(new MultiTypeParameter(beginLine, beginColumn, endLine, endColumn, exceptModifier, exceptAnnotations, exceptTypes, exceptId)); + setCatchBlock(catchBlock); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public BlockStmt getCatchBlock() { + return catchBlock; + } + + public MultiTypeParameter getExcept() { + return except; + } + + public void setCatchBlock(final BlockStmt catchBlock) { + this.catchBlock = catchBlock; + setAsParentNodeOf(this.catchBlock); + } + + public void setExcept(final MultiTypeParameter except) { + this.except = except; + setAsParentNodeOf(this.except); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ContinueStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ContinueStmt.java new file mode 100644 index 000000000..81760d0a0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ContinueStmt.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ContinueStmt extends Statement { + + private String id; + + public ContinueStmt() { + } + + public ContinueStmt(final String id) { + this.id = id; + } + + public ContinueStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String id) { + super(beginLine, beginColumn, endLine, endColumn); + this.id = id; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/DoStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/DoStmt.java new file mode 100644 index 000000000..0a6a77040 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/DoStmt.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class DoStmt extends Statement { + + private Statement body; + + private Expression condition; + + public DoStmt() { + } + + public DoStmt(final Statement body, final Expression condition) { + setBody(body); + setCondition(condition); + } + + public DoStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Statement body, final Expression condition) { + super(beginLine, beginColumn, endLine, endColumn); + setBody(body); + setCondition(condition); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCondition() { + return condition; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/EmptyStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/EmptyStmt.java new file mode 100644 index 000000000..fb16c4d98 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/EmptyStmt.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class EmptyStmt extends Statement { + + public EmptyStmt() { + } + + public EmptyStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java new file mode 100644 index 000000000..d0a9efe8c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.type.Type; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ExplicitConstructorInvocationStmt extends Statement { + + private List<Type> typeArgs; + + private boolean isThis; + + private Expression expr; + + private List<Expression> args; + + public ExplicitConstructorInvocationStmt() { + } + + public ExplicitConstructorInvocationStmt(final boolean isThis, + final Expression expr, final List<Expression> args) { + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + public ExplicitConstructorInvocationStmt(final int beginLine, + final int beginColumn, final int endLine, final int endColumn, + final List<Type> typeArgs, final boolean isThis, + final Expression expr, final List<Expression> args) { + super(beginLine, beginColumn, endLine, endColumn); + setTypeArgs(typeArgs); + setThis(isThis); + setExpr(expr); + setArgs(args); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<Expression> getArgs() { + return args; + } + + public Expression getExpr() { + return expr; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public boolean isThis() { + return isThis; + } + + public void setArgs(final List<Expression> args) { + this.args = args; + setAsParentNodeOf(this.args); + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } + + public void setThis(final boolean isThis) { + this.isThis = isThis; + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExpressionStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExpressionStmt.java new file mode 100644 index 000000000..3c441e2a3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ExpressionStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ExpressionStmt extends Statement { + + private Expression expr; + + public ExpressionStmt() { + } + + public ExpressionStmt(final Expression expr) { + setExpression(expr); + } + + public ExpressionStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setExpression(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpression() { + return expr; + } + + public void setExpression(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForStmt.java new file mode 100644 index 000000000..8e349bf2c --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForStmt.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForStmt extends Statement { + + private List<Expression> init; + + private Expression compare; + + private List<Expression> update; + + private Statement body; + + public ForStmt() { + } + + public ForStmt(final List<Expression> init, final Expression compare, + final List<Expression> update, final Statement body) { + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + public ForStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, + final List<Expression> init, final Expression compare, + final List<Expression> update, final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setCompare(compare); + setInit(init); + setUpdate(update); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCompare() { + return compare; + } + + public List<Expression> getInit() { + return init; + } + + public List<Expression> getUpdate() { + return update; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setCompare(final Expression compare) { + this.compare = compare; + setAsParentNodeOf(this.compare); + } + + public void setInit(final List<Expression> init) { + this.init = init; + setAsParentNodeOf(this.init); + } + + public void setUpdate(final List<Expression> update) { + this.update = update; + setAsParentNodeOf(this.update); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForeachStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForeachStmt.java new file mode 100644 index 000000000..245622fc5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ForeachStmt.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ForeachStmt extends Statement { + + private VariableDeclarationExpr var; + + private Expression iterable; + + private Statement body; + + public ForeachStmt() { + } + + public ForeachStmt(final VariableDeclarationExpr var, + final Expression iterable, final Statement body) { + setVariable(var); + setIterable(iterable); + setBody(body); + } + + public ForeachStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, + final VariableDeclarationExpr var, final Expression iterable, + final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setVariable(var); + setIterable(iterable); + setBody(body); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getIterable() { + return iterable; + } + + public VariableDeclarationExpr getVariable() { + return var; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setIterable(final Expression iterable) { + this.iterable = iterable; + setAsParentNodeOf(this.iterable); + } + + public void setVariable(final VariableDeclarationExpr var) { + this.var = var; + setAsParentNodeOf(this.var); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/IfStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/IfStmt.java new file mode 100644 index 000000000..ccddd903e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/IfStmt.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class IfStmt extends Statement { + + private Expression condition; + + private Statement thenStmt; + + private Statement elseStmt; + + public IfStmt() { + } + + public IfStmt(final Expression condition, final Statement thenStmt, final Statement elseStmt) { + setCondition(condition); + setThenStmt(thenStmt); + setElseStmt(elseStmt); + } + + public IfStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression condition, final Statement thenStmt, final Statement elseStmt) { + super(beginLine, beginColumn, endLine, endColumn); + setCondition(condition); + setThenStmt(thenStmt); + setElseStmt(elseStmt); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getCondition() { + return condition; + } + + public Statement getElseStmt() { + return elseStmt; + } + + public Statement getThenStmt() { + return thenStmt; + } + + public void setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } + + public void setElseStmt(final Statement elseStmt) { + this.elseStmt = elseStmt; + setAsParentNodeOf(this.elseStmt); + } + + public void setThenStmt(final Statement thenStmt) { + this.thenStmt = thenStmt; + setAsParentNodeOf(this.thenStmt); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/LabeledStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/LabeledStmt.java new file mode 100644 index 000000000..85d8e7b99 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/LabeledStmt.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class LabeledStmt extends Statement { + + private String label; + + private Statement stmt; + + public LabeledStmt() { + } + + public LabeledStmt(final String label, final Statement stmt) { + setLabel(label); + setStmt(stmt); + } + + public LabeledStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final String label, final Statement stmt) { + super(beginLine, beginColumn, endLine, endColumn); + setLabel(label); + setStmt(stmt); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getLabel() { + return label; + } + + public Statement getStmt() { + return stmt; + } + + public void setLabel(final String label) { + this.label = label; + } + + public void setStmt(final Statement stmt) { + this.stmt = stmt; + setAsParentNodeOf(this.stmt); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ReturnStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ReturnStmt.java new file mode 100644 index 000000000..3ac6fa65e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ReturnStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ReturnStmt extends Statement { + + private Expression expr; + + public ReturnStmt() { + } + + public ReturnStmt(final Expression expr) { + setExpr(expr); + } + + public ReturnStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/Statement.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/Statement.java new file mode 100644 index 000000000..30c462d05 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/Statement.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.Node; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Statement extends Node { + + public Statement() { + } + + public Statement(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchEntryStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchEntryStmt.java new file mode 100644 index 000000000..8f5a85ad5 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchEntryStmt.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchEntryStmt extends Statement { + + private Expression label; + + private List<Statement> stmts; + + public SwitchEntryStmt() { + } + + public SwitchEntryStmt(final Expression label, final List<Statement> stmts) { + setLabel(label); + setStmts(stmts); + } + + public SwitchEntryStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression label, + final List<Statement> stmts) { + super(beginLine, beginColumn, endLine, endColumn); + setLabel(label); + setStmts(stmts); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getLabel() { + return label; + } + + public List<Statement> getStmts() { + return stmts; + } + + public void setLabel(final Expression label) { + this.label = label; + setAsParentNodeOf(this.label); + } + + public void setStmts(final List<Statement> stmts) { + this.stmts = stmts; + setAsParentNodeOf(this.stmts); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchStmt.java new file mode 100644 index 000000000..49fe903da --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SwitchStmt.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class SwitchStmt extends Statement { + + private Expression selector; + + private List<SwitchEntryStmt> entries; + + public SwitchStmt() { + } + + public SwitchStmt(final Expression selector, + final List<SwitchEntryStmt> entries) { + setSelector(selector); + setEntries(entries); + } + + public SwitchStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression selector, + final List<SwitchEntryStmt> entries) { + super(beginLine, beginColumn, endLine, endColumn); + setSelector(selector); + setEntries(entries); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<SwitchEntryStmt> getEntries() { + return entries; + } + + public Expression getSelector() { + return selector; + } + + public void setEntries(final List<SwitchEntryStmt> entries) { + this.entries = entries; + setAsParentNodeOf(this.entries); + } + + public void setSelector(final Expression selector) { + this.selector = selector; + setAsParentNodeOf(this.selector); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SynchronizedStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SynchronizedStmt.java new file mode 100644 index 000000000..e91fc0b19 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/SynchronizedStmt.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class SynchronizedStmt extends Statement { + + private Expression expr; + + private BlockStmt block; + + public SynchronizedStmt() { + } + + public SynchronizedStmt(final Expression expr, final BlockStmt block) { + setExpr(expr); + setBlock(block); + } + + public SynchronizedStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, final Expression expr, + final BlockStmt block) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + setBlock(block); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public BlockStmt getBlock() { + return block; + } + + public Expression getExpr() { + return expr; + } + + public void setBlock(final BlockStmt block) { + this.block = block; + setAsParentNodeOf(this.block); + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ThrowStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ThrowStmt.java new file mode 100644 index 000000000..48283b16d --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/ThrowStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class ThrowStmt extends Statement { + + private Expression expr; + + public ThrowStmt() { + } + + public ThrowStmt(final Expression expr) { + setExpr(expr); + } + + public ThrowStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression expr) { + super(beginLine, beginColumn, endLine, endColumn); + setExpr(expr); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Expression getExpr() { + return expr; + } + + public void setExpr(final Expression expr) { + this.expr = expr; + setAsParentNodeOf(this.expr); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TryStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TryStmt.java new file mode 100644 index 000000000..44009c4c9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TryStmt.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class TryStmt extends Statement { + + private List<VariableDeclarationExpr> resources; + + private BlockStmt tryBlock; + + private List<CatchClause> catchs; + + private BlockStmt finallyBlock; + + public TryStmt() { + } + + public TryStmt(final BlockStmt tryBlock, final List<CatchClause> catchs, + final BlockStmt finallyBlock) { + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + public TryStmt(final int beginLine, final int beginColumn, + final int endLine, final int endColumn, List<VariableDeclarationExpr> resources, + final BlockStmt tryBlock, final List<CatchClause> catchs, final BlockStmt finallyBlock) { + super(beginLine, beginColumn, endLine, endColumn); + setResources(resources); + setTryBlock(tryBlock); + setCatchs(catchs); + setFinallyBlock(finallyBlock); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public List<CatchClause> getCatchs() { + return catchs; + } + + public BlockStmt getFinallyBlock() { + return finallyBlock; + } + + public BlockStmt getTryBlock() { + return tryBlock; + } + + public List<VariableDeclarationExpr> getResources() { + return resources; + } + + public void setCatchs(final List<CatchClause> catchs) { + this.catchs = catchs; + setAsParentNodeOf(this.catchs); + } + + public void setFinallyBlock(final BlockStmt finallyBlock) { + this.finallyBlock = finallyBlock; + setAsParentNodeOf(this.finallyBlock); + } + + public void setTryBlock(final BlockStmt tryBlock) { + this.tryBlock = tryBlock; + setAsParentNodeOf(this.tryBlock); + } + + public void setResources(List<VariableDeclarationExpr> resources) { + this.resources = resources; + setAsParentNodeOf(this.resources); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java new file mode 100644 index 000000000..79b507a1f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class TypeDeclarationStmt extends Statement { + + private TypeDeclaration typeDecl; + + public TypeDeclarationStmt() { + } + + public TypeDeclarationStmt(final TypeDeclaration typeDecl) { + setTypeDeclaration(typeDecl); + } + + public TypeDeclarationStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final TypeDeclaration typeDecl) { + super(beginLine, beginColumn, endLine, endColumn); + setTypeDeclaration(typeDecl); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public TypeDeclaration getTypeDeclaration() { + return typeDecl; + } + + public void setTypeDeclaration(final TypeDeclaration typeDecl) { + this.typeDecl = typeDecl; + setAsParentNodeOf(this.typeDecl); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/WhileStmt.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/WhileStmt.java new file mode 100644 index 000000000..51b2a1a23 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/stmt/WhileStmt.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.stmt; + +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class WhileStmt extends Statement { + + private Expression condition; + + private Statement body; + + public WhileStmt() { + } + + public WhileStmt(final Expression condition, final Statement body) { + setCondition(condition); + setBody(body); + } + + public WhileStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Expression condition, final Statement body) { + super(beginLine, beginColumn, endLine, endColumn); + setCondition(condition); + setBody(body); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Statement getBody() { + return body; + } + + public Expression getCondition() { + return condition; + } + + public void setBody(final Statement body) { + this.body = body; + setAsParentNodeOf(this.body); + } + + public void setCondition(final Expression condition) { + this.condition = condition; + setAsParentNodeOf(this.condition); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ClassOrInterfaceType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ClassOrInterfaceType.java new file mode 100644 index 000000000..a7efbf4e3 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ClassOrInterfaceType.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ClassOrInterfaceType extends Type { + + private ClassOrInterfaceType scope; + + private String name; + + private List<Type> typeArgs; + + public ClassOrInterfaceType() { + } + + public ClassOrInterfaceType(final String name) { + setName(name); + } + + public ClassOrInterfaceType(final ClassOrInterfaceType scope, final String name) { + setScope(scope); + setName(name); + } + + public ClassOrInterfaceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final ClassOrInterfaceType scope, final String name, final List<Type> typeArgs) { + super(beginLine, beginColumn, endLine, endColumn); + setScope(scope); + setName(name); + setTypeArgs(typeArgs); + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public String getName() { + return name; + } + + public ClassOrInterfaceType getScope() { + return scope; + } + + public List<Type> getTypeArgs() { + return typeArgs; + } + + public boolean isBoxedType() { + return PrimitiveType.unboxMap.containsKey(name); + } + + public PrimitiveType toUnboxedType() throws UnsupportedOperationException { + if (!isBoxedType()) throw new UnsupportedOperationException(name + " isn't a boxed type."); + return new PrimitiveType(PrimitiveType.unboxMap.get(name)); + } + + public void setName(final String name) { + this.name = name; + } + + public void setScope(final ClassOrInterfaceType scope) { + this.scope = scope; + setAsParentNodeOf(this.scope); + } + + public void setTypeArgs(final List<Type> typeArgs) { + this.typeArgs = typeArgs; + setAsParentNodeOf(this.typeArgs); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/PrimitiveType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/PrimitiveType.java new file mode 100644 index 000000000..561a89657 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/PrimitiveType.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import java.util.HashMap; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class PrimitiveType extends Type { + + public enum Primitive { + Boolean ("Boolean"), + Char ("Character"), + Byte ("Byte"), + Short ("Short"), + Int ("Integer"), + Long ("Long"), + Float ("Float"), + Double ("Double"); + + final String nameOfBoxedType; + + public ClassOrInterfaceType toBoxedType() { + return new ClassOrInterfaceType(nameOfBoxedType); + } + + private Primitive(String nameOfBoxedType) { + this.nameOfBoxedType = nameOfBoxedType; + } + } + + static final HashMap<String, Primitive> unboxMap = new HashMap<String, Primitive>(); + static { + for(Primitive unboxedType : Primitive.values()) { + unboxMap.put(unboxedType.nameOfBoxedType, unboxedType); + } + } + + private Primitive type; + + public PrimitiveType() { + } + + public PrimitiveType(final Primitive type) { + this.type = type; + } + + public PrimitiveType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Primitive type) { + super(beginLine, beginColumn, endLine, endColumn); + this.type = type; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public Primitive getType() { + return type; + } + + public ClassOrInterfaceType toBoxedType() { + return type.toBoxedType(); + } + + public void setType(final Primitive type) { + this.type = type; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ReferenceType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ReferenceType.java new file mode 100644 index 000000000..608848fc0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/ReferenceType.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public final class ReferenceType extends Type { + + private Type type; + + private int arrayCount; + + private List<List<AnnotationExpr>> arraysAnnotations; + + public ReferenceType() { + } + + public ReferenceType(final Type type) { + setType(type); + } + + public ReferenceType(final Type type, final int arrayCount) { + setType(type); + setArrayCount(arrayCount); + } + + public ReferenceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final Type type, final int arrayCount) { + super(beginLine, beginColumn, endLine, endColumn); + setType(type); + setArrayCount(arrayCount); + } + + public ReferenceType(int beginLine, int beginColumn, int endLine, + int endColumn, Type type, int arrayCount, + List<AnnotationExpr> annotations, + List<List<AnnotationExpr>> arraysAnnotations) { + super(beginLine, beginColumn, endLine, endColumn, annotations); + setType(type); + setArrayCount(arrayCount); + this.arraysAnnotations = arraysAnnotations; + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public int getArrayCount() { + return arrayCount; + } + + public Type getType() { + return type; + } + + public void setArrayCount(final int arrayCount) { + this.arrayCount = arrayCount; + } + + public void setType(final Type type) { + this.type = type; + setAsParentNodeOf(this.type); + } + + /** + * <p>Arrays annotations are annotations on the arrays modifiers of the type. + * Consider this example:</p> + * + * <p><pre> + * {@code + * int @Ann1 [] @Ann2 [] array; + * }</pre></p> + * + * <p>in this this method will return a list with the annotation expressions <pre>@Ann1</pre> + * and <pre>@Ann2</pre></p> + * + * <p>Note that the first list element of arraysAnnotations will refer to the first array modifier encountered. + * Considering the example the first element will be a list containing just @Ann1 while the second element will + * be a list containing just @Ann2. + * </p> + * + * <p>This property is guaranteed to hold: <pre>{@code getArraysAnnotations().size() == getArrayCount()}</pre> + * If a certain array modifier has no annotation the corresponding entry of arraysAnnotations will be null</p> + */ + public List<List<AnnotationExpr>> getArraysAnnotations() { + return arraysAnnotations; + } + + /** + * For a description of the arrayAnnotations field refer to {@link #getArraysAnnotations()} + */ + public void setArraysAnnotations(List<List<AnnotationExpr>> arraysAnnotations) { + this.arraysAnnotations = arraysAnnotations; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/Type.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/Type.java new file mode 100644 index 000000000..22c91240f --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/Type.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.AnnotationExpr; + +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class Type extends Node { + + private List<AnnotationExpr> annotations; + + public Type() { + } + + public Type(List<AnnotationExpr> annotation){ + this.annotations = annotation; + } + + public Type(int beginLine, int beginColumn, int endLine, int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + public Type(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) { + super(beginLine, beginColumn, endLine, endColumn); + this.annotations = annotations; + } + + public List<AnnotationExpr> getAnnotations() { + return annotations; + } + + public void setAnnotations(List<AnnotationExpr> annotations) { + this.annotations = annotations; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/UnknownType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/UnknownType.java new file mode 100644 index 000000000..af6d4d979 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/UnknownType.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * An unknown parameter type object. It plays the role of a null object for + * lambda parameters that have no explicit type declared. As such, it has no + * lexical representation and hence gets no comment attributed. + * + * @author Didier Villevalois + */ +public final class UnknownType extends Type { + + public UnknownType() { + } + + @Override + public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override + public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/VoidType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/VoidType.java new file mode 100644 index 000000000..5dacbe1e7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/VoidType.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class VoidType extends Type { + + public VoidType() { + } + + public VoidType(final int beginLine, final int beginColumn, final int endLine, final int endColumn) { + super(beginLine, beginColumn, endLine, endColumn); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/WildcardType.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/WildcardType.java new file mode 100644 index 000000000..8016ed70e --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/type/WildcardType.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.type; + +import com.github.javaparser.ast.visitor.GenericVisitor; +import com.github.javaparser.ast.visitor.VoidVisitor; + +/** + * @author Julio Vilmar Gesser + */ +public final class WildcardType extends Type { + + private ReferenceType ext; + + private ReferenceType sup; + + public WildcardType() { + } + + public WildcardType(final ReferenceType ext) { + setExtends(ext); + } + + public WildcardType(final ReferenceType ext, final ReferenceType sup) { + setExtends(ext); + setSuper(sup); + } + + public WildcardType(final int beginLine, final int beginColumn, final int endLine, final int endColumn, + final ReferenceType ext, final ReferenceType sup) { + super(beginLine, beginColumn, endLine, endColumn); + setExtends(ext); + setSuper(sup); + } + + @Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { + return v.visit(this, arg); + } + + @Override public <A> void accept(final VoidVisitor<A> v, final A arg) { + v.visit(this, arg); + } + + public ReferenceType getExtends() { + return ext; + } + + public ReferenceType getSuper() { + return sup; + } + + public void setExtends(final ReferenceType ext) { + this.ext = ext; + setAsParentNodeOf(this.ext); + } + + public void setSuper(final ReferenceType sup) { + this.sup = sup; + setAsParentNodeOf(this.sup); + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/CloneVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/CloneVisitor.java new file mode 100644 index 000000000..3d8d299aa --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/CloneVisitor.java @@ -0,0 +1,1211 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.*; +import com.github.javaparser.ast.type.*; + +public class CloneVisitor implements GenericVisitor<Node, Object> { + + @Override + public Node visit(CompilationUnit _n, Object _arg) { + PackageDeclaration package_ = cloneNodes(_n.getPackage(), _arg); + List<ImportDeclaration> imports = visit(_n.getImports(), _arg); + List<TypeDeclaration> types = visit(_n.getTypes(), _arg); + + return new CompilationUnit( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + package_, imports, types + ); + } + + @Override + public Node visit(PackageDeclaration _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + PackageDeclaration r = new PackageDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + annotations, name + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ImportDeclaration _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ImportDeclaration r = new ImportDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, _n.isStatic(), _n.isAsterisk() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TypeParameter _n, Object _arg) { + List<ClassOrInterfaceType> typeBound = visit(_n.getTypeBound(), _arg); + + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + TypeParameter r = new TypeParameter(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName(), typeBound, annotations); + + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LineComment _n, Object _arg) { + return new LineComment(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getContent()); + } + + @Override + public Node visit(BlockComment _n, Object _arg) { + return new BlockComment(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getContent()); + } + + @Override + public Node visit(ClassOrInterfaceDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + List<ClassOrInterfaceType> extendsList = visit(_n.getExtends(), _arg); + List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg); + List<BodyDeclaration> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassOrInterfaceDeclaration r = new ClassOrInterfaceDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, _n.isInterface(), _n.getName(), typeParameters, extendsList, implementsList, members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnumDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg); + List<EnumConstantDeclaration> entries = visit(_n.getEntries(), _arg); + List<BodyDeclaration> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnumDeclaration r = new EnumDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, _n.getName(), implementsList, entries, members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyTypeDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyTypeDeclaration r = new EmptyTypeDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnumConstantDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + List<BodyDeclaration> classBody = visit(_n.getClassBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnumConstantDeclaration r = new EnumConstantDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + annotations, _n.getName(), args, classBody + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AnnotationDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<BodyDeclaration> members = visit(_n.getMembers(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AnnotationDeclaration r = new AnnotationDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, _n.getName(), members + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AnnotationMemberDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + Expression defaultValue = cloneNodes(_n.getDefaultValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AnnotationMemberDeclaration r = new AnnotationMemberDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, _n.getName(), defaultValue + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(FieldDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<VariableDeclarator> variables = visit(_n.getVariables(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + FieldDeclaration r = new FieldDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, variables + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclarator _n, Object _arg) { + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Expression init = cloneNodes(_n.getInit(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + VariableDeclarator r = new VariableDeclarator( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + id, init + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclaratorId _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + VariableDeclaratorId r = new VariableDeclaratorId( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName(), _n.getArrayCount() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ConstructorDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + List<Parameter> parameters = visit(_n.getParameters(), _arg); + List<NameExpr> throws_ = visit(_n.getThrows(), _arg); + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ConstructorDeclaration r = new ConstructorDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, typeParameters, _n.getName(), parameters, throws_, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MethodDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<Parameter> parameters = visit(_n.getParameters(), _arg); + List<NameExpr> throws_ = visit(_n.getThrows(), _arg); + BlockStmt block = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MethodDeclaration r = new MethodDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(Parameter _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + Parameter r = new Parameter( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, _n.isVarArgs(), id + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MultiTypeParameter _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + List<Type> types = visit(_n.getTypes(), _arg); + VariableDeclaratorId id = cloneNodes(_n.getId(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MultiTypeParameter r = new MultiTypeParameter( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, types, id + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyMemberDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyMemberDeclaration r = new EmptyMemberDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(InitializerDeclaration _n, Object _arg) { + JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg); + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + InitializerDeclaration r = new InitializerDeclaration( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.isStatic(), block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(JavadocComment _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + JavadocComment r = new JavadocComment( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getContent() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ClassOrInterfaceType _n, Object _arg) { + ClassOrInterfaceType scope = cloneNodes(_n.getScope(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassOrInterfaceType r = new ClassOrInterfaceType( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, _n.getName(), typeArgs + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(PrimitiveType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + PrimitiveType r = new PrimitiveType( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getType() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ReferenceType _n, Object _arg) { + List<AnnotationExpr> ann = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<List<AnnotationExpr>> arraysAnnotations = _n.getArraysAnnotations(); + List<List<AnnotationExpr>> _arraysAnnotations = null; + if(arraysAnnotations != null){ + _arraysAnnotations = new LinkedList<List<AnnotationExpr>>(); + for(List<AnnotationExpr> aux: arraysAnnotations){ + _arraysAnnotations.add(visit(aux, _arg)); + } + } + + ReferenceType r = new ReferenceType(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), type_, + _n.getArrayCount(), ann, _arraysAnnotations); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VoidType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + VoidType r = new VoidType(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(WildcardType _n, Object _arg) { + ReferenceType ext = cloneNodes(_n.getExtends(), _arg); + ReferenceType sup = cloneNodes(_n.getSuper(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + WildcardType r = new WildcardType( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + ext, sup + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(UnknownType _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + UnknownType r = new UnknownType(); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayAccessExpr _n, Object _arg) { + Expression name = cloneNodes(_n.getName(), _arg); + Expression index = cloneNodes(_n.getIndex(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ArrayAccessExpr r = new ArrayAccessExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, index + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayCreationExpr _n, Object _arg) { + Type type_ = cloneNodes(_n.getType(), _arg); + List<Expression> dimensions = visit(_n.getDimensions(), _arg); + ArrayCreationExpr r = new ArrayCreationExpr(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), type_, + dimensions, _n.getArrayCount()); + if (_n.getInitializer() != null) {// ArrayCreationExpr has two mutually + // exclusive constructors + r.setInitializer(cloneNodes(_n.getInitializer(), _arg)); + } + List<List<AnnotationExpr>> arraysAnnotations = _n.getArraysAnnotations(); + List<List<AnnotationExpr>> _arraysAnnotations = null; + if(arraysAnnotations != null){ + _arraysAnnotations = new LinkedList<List<AnnotationExpr>>(); + for(List<AnnotationExpr> aux: arraysAnnotations){ + _arraysAnnotations.add(visit(aux, _arg)); + } + } + r.setArraysAnnotations(_arraysAnnotations); + Comment comment = cloneNodes(_n.getComment(), _arg); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ArrayInitializerExpr _n, Object _arg) { + List<Expression> values = visit(_n.getValues(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ArrayInitializerExpr r = new ArrayInitializerExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + values + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AssignExpr _n, Object _arg) { + Expression target = cloneNodes(_n.getTarget(), _arg); + Expression value = cloneNodes(_n.getValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AssignExpr r = new AssignExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + target, value, _n.getOperator()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BinaryExpr _n, Object _arg) { + Expression left = cloneNodes(_n.getLeft(), _arg); + Expression right = cloneNodes(_n.getRight(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + BinaryExpr r = new BinaryExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + left, right, _n.getOperator() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CastExpr _n, Object _arg) { + Type type_ = cloneNodes(_n.getType(), _arg); + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + CastExpr r = new CastExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + type_, expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ClassExpr _n, Object _arg) { + Type type_ = cloneNodes(_n.getType(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ClassExpr r = new ClassExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + type_ + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ConditionalExpr _n, Object _arg) { + Expression condition = cloneNodes(_n.getCondition(), _arg); + Expression thenExpr = cloneNodes(_n.getThenExpr(), _arg); + Expression elseExpr = cloneNodes(_n.getElseExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ConditionalExpr r = new ConditionalExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + condition, thenExpr, elseExpr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EnclosedExpr _n, Object _arg) { + Expression inner = cloneNodes(_n.getInner(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + EnclosedExpr r = new EnclosedExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + inner + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(FieldAccessExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + FieldAccessExpr r = new FieldAccessExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, typeArgs, _n.getField() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(InstanceOfExpr _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + InstanceOfExpr r = new InstanceOfExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr, type_ + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(StringLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + StringLiteralExpr r = new StringLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IntegerLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + IntegerLiteralExpr r = new IntegerLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LongLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + LongLiteralExpr r = new LongLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IntegerLiteralMinValueExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + IntegerLiteralMinValueExpr r = new IntegerLiteralMinValueExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LongLiteralMinValueExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + LongLiteralMinValueExpr r = new LongLiteralMinValueExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CharLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + CharLiteralExpr r = new CharLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(DoubleLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + DoubleLiteralExpr r = new DoubleLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BooleanLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + BooleanLiteralExpr r = new BooleanLiteralExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getValue() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NullLiteralExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + NullLiteralExpr r = new NullLiteralExpr(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MethodCallExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MethodCallExpr r = new MethodCallExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, typeArgs, _n.getName(), args + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NameExpr _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + NameExpr r = new NameExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ObjectCreationExpr _n, Object _arg) { + Expression scope = cloneNodes(_n.getScope(), _arg); + ClassOrInterfaceType type_ = cloneNodes(_n.getType(), _arg); + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + List<BodyDeclaration> anonymousBody = visit(_n.getAnonymousClassBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ObjectCreationExpr r = new ObjectCreationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, type_, typeArgs, args, anonymousBody + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(QualifiedNameExpr _n, Object _arg) { + NameExpr scope = cloneNodes(_n.getQualifier(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + QualifiedNameExpr r = new QualifiedNameExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + scope, _n.getName() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ThisExpr _n, Object _arg) { + Expression classExpr = cloneNodes(_n.getClassExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ThisExpr r = new ThisExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + classExpr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SuperExpr _n, Object _arg) { + Expression classExpr = cloneNodes(_n.getClassExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SuperExpr r = new SuperExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + classExpr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(UnaryExpr _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + UnaryExpr r = new UnaryExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr, _n.getOperator() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(VariableDeclarationExpr _n, Object _arg) { + List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); + Type type_ = cloneNodes(_n.getType(), _arg); + List<VariableDeclarator> vars = visit(_n.getVars(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + VariableDeclarationExpr r = new VariableDeclarationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getModifiers(), annotations, type_, vars + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MarkerAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MarkerAnnotationExpr r = new MarkerAnnotationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SingleMemberAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + Expression memberValue = cloneNodes(_n.getMemberValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SingleMemberAnnotationExpr r = new SingleMemberAnnotationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, memberValue + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(NormalAnnotationExpr _n, Object _arg) { + NameExpr name = cloneNodes(_n.getName(), _arg); + List<MemberValuePair> pairs = visit(_n.getPairs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + NormalAnnotationExpr r = new NormalAnnotationExpr( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + name, pairs + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(MemberValuePair _n, Object _arg) { + Expression value = cloneNodes(_n.getValue(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + MemberValuePair r = new MemberValuePair( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getName(), value + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ExplicitConstructorInvocationStmt _n, Object _arg) { + List<Type> typeArgs = visit(_n.getTypeArgs(), _arg); + Expression expr = cloneNodes(_n.getExpr(), _arg); + List<Expression> args = visit(_n.getArgs(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ExplicitConstructorInvocationStmt r = new ExplicitConstructorInvocationStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + typeArgs, _n.isThis(), expr, args + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TypeDeclarationStmt _n, Object _arg) { + TypeDeclaration typeDecl = cloneNodes(_n.getTypeDeclaration(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + TypeDeclarationStmt r = new TypeDeclarationStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + typeDecl + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(AssertStmt _n, Object _arg) { + Expression check = cloneNodes(_n.getCheck(), _arg); + Expression message = cloneNodes(_n.getMessage(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + AssertStmt r = new AssertStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + check, message + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BlockStmt _n, Object _arg) { + List<Statement> stmts = visit(_n.getStmts(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + BlockStmt r = new BlockStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + stmts + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LabeledStmt _n, Object _arg) { + Statement stmt = cloneNodes(_n.getStmt(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + LabeledStmt r = new LabeledStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getLabel(), stmt + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(EmptyStmt _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + EmptyStmt r = new EmptyStmt(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn()); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ExpressionStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpression(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ExpressionStmt r = new ExpressionStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SwitchStmt _n, Object _arg) { + Expression selector = cloneNodes(_n.getSelector(), _arg); + List<SwitchEntryStmt> entries = visit(_n.getEntries(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SwitchStmt r = new SwitchStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + selector, entries + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SwitchEntryStmt _n, Object _arg) { + Expression label = cloneNodes(_n.getLabel(), _arg); + List<Statement> stmts = visit(_n.getStmts(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SwitchEntryStmt r = new SwitchEntryStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + label, stmts + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(BreakStmt _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + BreakStmt r = new BreakStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getId() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ReturnStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ReturnStmt r = new ReturnStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(IfStmt _n, Object _arg) { + Expression condition = cloneNodes(_n.getCondition(), _arg); + Statement thenStmt = cloneNodes(_n.getThenStmt(), _arg); + Statement elseStmt = cloneNodes(_n.getElseStmt(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + IfStmt r = new IfStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + condition, thenStmt, elseStmt + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(WhileStmt _n, Object _arg) { + Expression condition = cloneNodes(_n.getCondition(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + WhileStmt r = new WhileStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + condition, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ContinueStmt _n, Object _arg) { + Comment comment = cloneNodes(_n.getComment(), _arg); + + ContinueStmt r = new ContinueStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + _n.getId() + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(DoStmt _n, Object _arg) { + Statement body = cloneNodes(_n.getBody(), _arg); + Expression condition = cloneNodes(_n.getCondition(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + DoStmt r = new DoStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + body, condition + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ForeachStmt _n, Object _arg) { + VariableDeclarationExpr var = cloneNodes(_n.getVariable(), _arg); + Expression iterable = cloneNodes(_n.getIterable(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ForeachStmt r = new ForeachStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + var, iterable, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ForStmt _n, Object _arg) { + List<Expression> init = visit(_n.getInit(), _arg); + Expression compare = cloneNodes(_n.getCompare(), _arg); + List<Expression> update = visit(_n.getUpdate(), _arg); + Statement body = cloneNodes(_n.getBody(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ForStmt r = new ForStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + init, compare, update, body + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(ThrowStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + ThrowStmt r = new ThrowStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(SynchronizedStmt _n, Object _arg) { + Expression expr = cloneNodes(_n.getExpr(), _arg); + BlockStmt block = cloneNodes(_n.getBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + SynchronizedStmt r = new SynchronizedStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + expr, block + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(TryStmt _n, Object _arg) { + List<VariableDeclarationExpr> resources = visit(_n.getResources(),_arg); + BlockStmt tryBlock = cloneNodes(_n.getTryBlock(), _arg); + List<CatchClause> catchs = visit(_n.getCatchs(), _arg); + BlockStmt finallyBlock = cloneNodes(_n.getFinallyBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + TryStmt r = new TryStmt( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + resources, tryBlock, catchs, finallyBlock + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(CatchClause _n, Object _arg) { + MultiTypeParameter except = cloneNodes(_n.getExcept(), _arg); + BlockStmt catchBlock = cloneNodes(_n.getCatchBlock(), _arg); + Comment comment = cloneNodes(_n.getComment(), _arg); + + CatchClause r = new CatchClause( + _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), + except.getModifiers(), except.getAnnotations(), except.getTypes(), except.getId(), catchBlock + ); + r.setComment(comment); + return r; + } + + @Override + public Node visit(LambdaExpr _n, Object _arg) { + + List<Parameter> lambdaParameters = visit(_n.getParameters(), _arg); + + Statement body = cloneNodes(_n.getBody(), _arg); + + LambdaExpr r = new LambdaExpr(_n.getBeginLine(), _n.getBeginColumn(), + _n.getEndLine(), _n.getEndColumn(), lambdaParameters, body, + _n.isParametersEnclosed()); + + return r; + } + + @Override + public Node visit(MethodReferenceExpr _n, Object arg) { + + List<TypeParameter> typeParams = visit(_n.getTypeParameters(), arg); + Expression scope = cloneNodes(_n.getScope(), arg); + + MethodReferenceExpr r = new MethodReferenceExpr(_n.getBeginLine(), + _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), scope, + typeParams, _n.getIdentifier()); + return r; + } + + @Override + public Node visit(TypeExpr n, Object arg) { + + Type t = cloneNodes(n.getType(), arg); + + TypeExpr r = new TypeExpr(n.getBeginLine(), n.getBeginColumn(), + n.getEndLine(), n.getEndColumn(), t); + + return r; + } + + public <T extends Node> List<T> visit(List<T> _nodes, Object _arg) { + if (_nodes == null) + return null; + List<T> r = new ArrayList<T>(_nodes.size()); + for (T n : _nodes) { + T rN = cloneNodes(n, _arg); + if (rN != null) + r.add(rN); + } + return r; + } + + protected <T extends Node> T cloneNodes(T _node, Object _arg) { + if (_node == null) + return null; + Node r = _node.accept(this, _arg); + if (r == null) + return null; + return (T) r; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/DumpVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/DumpVisitor.java new file mode 100644 index 000000000..8b04afe0a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/DumpVisitor.java @@ -0,0 +1,1657 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import static com.github.javaparser.PositionUtils.sortByBeginPosition; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.ModifierSet; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import static com.github.javaparser.ast.internal.Utils.isNullOrEmpty; + +/** + * Dumps the AST to formatted Java source code. + * + * @author Julio Vilmar Gesser + */ +public final class DumpVisitor implements VoidVisitor<Object> { + + private boolean printComments; + + public DumpVisitor() { + this(true); + } + + public DumpVisitor(boolean printComments) { + this.printComments = printComments; + } + + private static class SourcePrinter { + + private int level = 0; + + private boolean indented = false; + + private final StringBuilder buf = new StringBuilder(); + + public void indent() { + level++; + } + + public void unindent() { + level--; + } + + private void makeIndent() { + for (int i = 0; i < level; i++) { + buf.append(" "); + } + } + + public void print(final String arg) { + if (!indented) { + makeIndent(); + indented = true; + } + buf.append(arg); + } + + public void printLn(final String arg) { + print(arg); + printLn(); + } + + public void printLn() { + buf.append(System.getProperty("line.separator")); + indented = false; + } + + public String getSource() { + return buf.toString(); + } + + @Override public String toString() { + return getSource(); + } + } + + private final SourcePrinter printer = new SourcePrinter(); + + public String getSource() { + return printer.getSource(); + } + + private void printModifiers(final int modifiers) { + if (ModifierSet.isPrivate(modifiers)) { + printer.print("private "); + } + if (ModifierSet.isProtected(modifiers)) { + printer.print("protected "); + } + if (ModifierSet.isPublic(modifiers)) { + printer.print("public "); + } + if (ModifierSet.isAbstract(modifiers)) { + printer.print("abstract "); + } + if (ModifierSet.isStatic(modifiers)) { + printer.print("static "); + } + if (ModifierSet.isFinal(modifiers)) { + printer.print("final "); + } + if (ModifierSet.isNative(modifiers)) { + printer.print("native "); + } + if (ModifierSet.isStrictfp(modifiers)) { + printer.print("strictfp "); + } + if (ModifierSet.isSynchronized(modifiers)) { + printer.print("synchronized "); + } + if (ModifierSet.isTransient(modifiers)) { + printer.print("transient "); + } + if (ModifierSet.isVolatile(modifiers)) { + printer.print("volatile "); + } + } + + private void printMembers(final List<BodyDeclaration> members, final Object arg) { + for (final BodyDeclaration member : members) { + printer.printLn(); + member.accept(this, arg); + printer.printLn(); + } + } + + private void printMemberAnnotations(final List<AnnotationExpr> annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.printLn(); + } + } + } + + private void printAnnotations(final List<AnnotationExpr> annotations, final Object arg) { + if (!isNullOrEmpty(annotations)) { + for (final AnnotationExpr a : annotations) { + a.accept(this, arg); + printer.print(" "); + } + } + } + + private void printTypeArgs(final List<Type> args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator<Type> i = args.iterator(); i.hasNext();) { + final Type t = i.next(); + t.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + } + + private void printTypeParameters(final List<TypeParameter> args, final Object arg) { + if (!isNullOrEmpty(args)) { + printer.print("<"); + for (final Iterator<TypeParameter> i = args.iterator(); i.hasNext();) { + final TypeParameter t = i.next(); + t.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + } + + private void printArguments(final List<Expression> args, final Object arg) { + printer.print("("); + if (!isNullOrEmpty(args)) { + for (final Iterator<Expression> i = args.iterator(); i.hasNext();) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + } + + private void printJavadoc(final JavadocComment javadoc, final Object arg) { + if (javadoc != null) { + javadoc.accept(this, arg); + } + } + + private void printJavaComment(final Comment javacomment, final Object arg) { + if (javacomment != null) { + javacomment.accept(this, arg); + } + } + + @Override public void visit(final CompilationUnit n, final Object arg) { + printJavaComment(n.getComment(), arg); + + if (n.getPackage() != null) { + n.getPackage().accept(this, arg); + } + + if (n.getImports() != null) { + for (final ImportDeclaration i : n.getImports()) { + i.accept(this, arg); + } + printer.printLn(); + } + + if (n.getTypes() != null) { + for (final Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) { + i.next().accept(this, arg); + printer.printLn(); + if (i.hasNext()) { + printer.printLn(); + } + } + } + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final PackageDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), arg); + printer.print("package "); + n.getName().accept(this, arg); + printer.printLn(";"); + printer.printLn(); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final NameExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final QualifiedNameExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getQualifier().accept(this, arg); + printer.print("."); + printer.print(n.getName()); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final ImportDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("import "); + if (n.isStatic()) { + printer.print("static "); + } + n.getName().accept(this, arg); + if (n.isAsterisk()) { + printer.print(".*"); + } + printer.printLn(";"); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final ClassOrInterfaceDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + if (n.isInterface()) { + printer.print("interface "); + } else { + printer.print("class "); + } + + printer.print(n.getName()); + + printTypeParameters(n.getTypeParameters(), arg); + + if (!isNullOrEmpty(n.getExtends())) { + printer.print(" extends "); + for (final Iterator<ClassOrInterfaceType> i = n.getExtends().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + if (!isNullOrEmpty(n.getImplements())) { + printer.print(" implements "); + for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + printer.printLn(" {"); + printer.indent(); + if (!isNullOrEmpty(n.getMembers())) { + printMembers(n.getMembers(), arg); + } + + printOrphanCommentsEnding(n); + + printer.unindent(); + printer.print("}"); + } + + @Override public void visit(final EmptyTypeDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printer.print(";"); + + printOrphanCommentsEnding(n); + } + + @Override public void visit(final JavadocComment n, final Object arg) { + printer.print("/**"); + printer.print(n.getContent()); + printer.printLn("*/"); + } + + @Override public void visit(final ClassOrInterfaceType n, final Object arg) { + printJavaComment(n.getComment(), arg); + + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + + if (n.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + printer.print(n.getName()); + printTypeArgs(n.getTypeArgs(), arg); + } + + @Override public void visit(final TypeParameter n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ann : n.getAnnotations()) { + ann.accept(this, arg); + printer.print(" "); + } + } + printer.print(n.getName()); + if (n.getTypeBound() != null) { + printer.print(" extends "); + for (final Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(" & "); + } + } + } + } + + @Override public void visit(final PrimitiveType n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + switch (n.getType()) { + case Boolean: + printer.print("boolean"); + break; + case Byte: + printer.print("byte"); + break; + case Char: + printer.print("char"); + break; + case Double: + printer.print("double"); + break; + case Float: + printer.print("float"); + break; + case Int: + printer.print("int"); + break; + case Long: + printer.print("long"); + break; + case Short: + printer.print("short"); + break; + } + } + + @Override public void visit(final ReferenceType n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + ae.accept(this, arg); + printer.print(" "); + } + } + n.getType().accept(this, arg); + List<List<AnnotationExpr>> arraysAnnotations = n.getArraysAnnotations(); + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + List<AnnotationExpr> annotations = arraysAnnotations.get(i); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + printer.print(" "); + ae.accept(this, arg); + + } + } + } + printer.print("[]"); + } + } + + @Override public void visit(final WildcardType n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (AnnotationExpr ae : n.getAnnotations()) { + printer.print(" "); + ae.accept(this, arg); + } + } + printer.print("?"); + if (n.getExtends() != null) { + printer.print(" extends "); + n.getExtends().accept(this, arg); + } + if (n.getSuper() != null) { + printer.print(" super "); + n.getSuper().accept(this, arg); + } + } + + @Override public void visit(final UnknownType n, final Object arg) { + // Nothing to dump + } + + @Override public void visit(final FieldDeclaration n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + n.getType().accept(this, arg); + + printer.print(" "); + for (final Iterator<VariableDeclarator> i = n.getVariables().iterator(); i.hasNext();) { + final VariableDeclarator var = i.next(); + var.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + + printer.print(";"); + } + + @Override public void visit(final VariableDeclarator n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getId().accept(this, arg); + if (n.getInit() != null) { + printer.print(" = "); + n.getInit().accept(this, arg); + } + } + + @Override public void visit(final VariableDeclaratorId n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + for (int i = 0; i < n.getArrayCount(); i++) { + printer.print("[]"); + } + } + + @Override public void visit(final ArrayInitializerExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("{"); + if (n.getValues() != null) { + printer.print(" "); + for (final Iterator<Expression> i = n.getValues().iterator(); i.hasNext();) { + final Expression expr = i.next(); + expr.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(" "); + } + printer.print("}"); + } + + @Override public void visit(final VoidType n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("void"); + } + + @Override public void visit(final ArrayAccessExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getName().accept(this, arg); + printer.print("["); + n.getIndex().accept(this, arg); + printer.print("]"); + } + + @Override public void visit(final ArrayCreationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("new "); + n.getType().accept(this, arg); + List<List<AnnotationExpr>> arraysAnnotations = n.getArraysAnnotations(); + if (n.getDimensions() != null) { + int j = 0; + for (final Expression dim : n.getDimensions()) { + + if (arraysAnnotations != null && j < arraysAnnotations.size()) { + List<AnnotationExpr> annotations = arraysAnnotations.get(j); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + printer.print(" "); + ae.accept(this, arg); + } + } + } + printer.print("["); + dim.accept(this, arg); + printer.print("]"); + j++; + } + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + + List<AnnotationExpr> annotations = arraysAnnotations.get(i); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + printer.print(" "); + ae.accept(this, arg); + + } + } + } + printer.print("[]"); + } + + } else { + for (int i = 0; i < n.getArrayCount(); i++) { + if (arraysAnnotations != null && i < arraysAnnotations.size()) { + List<AnnotationExpr> annotations = arraysAnnotations.get(i); + if (annotations != null) { + for (AnnotationExpr ae : annotations) { + ae.accept(this, arg); + printer.print(" "); + } + } + } + printer.print("[]"); + } + printer.print(" "); + n.getInitializer().accept(this, arg); + } + } + + @Override public void visit(final AssignExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getTarget().accept(this, arg); + printer.print(" "); + switch (n.getOperator()) { + case assign: + printer.print("="); + break; + case and: + printer.print("&="); + break; + case or: + printer.print("|="); + break; + case xor: + printer.print("^="); + break; + case plus: + printer.print("+="); + break; + case minus: + printer.print("-="); + break; + case rem: + printer.print("%="); + break; + case slash: + printer.print("/="); + break; + case star: + printer.print("*="); + break; + case lShift: + printer.print("<<="); + break; + case rSignedShift: + printer.print(">>="); + break; + case rUnsignedShift: + printer.print(">>>="); + break; + } + printer.print(" "); + n.getValue().accept(this, arg); + } + + @Override public void visit(final BinaryExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getLeft().accept(this, arg); + printer.print(" "); + switch (n.getOperator()) { + case or: + printer.print("||"); + break; + case and: + printer.print("&&"); + break; + case binOr: + printer.print("|"); + break; + case binAnd: + printer.print("&"); + break; + case xor: + printer.print("^"); + break; + case equals: + printer.print("=="); + break; + case notEquals: + printer.print("!="); + break; + case less: + printer.print("<"); + break; + case greater: + printer.print(">"); + break; + case lessEquals: + printer.print("<="); + break; + case greaterEquals: + printer.print(">="); + break; + case lShift: + printer.print("<<"); + break; + case rSignedShift: + printer.print(">>"); + break; + case rUnsignedShift: + printer.print(">>>"); + break; + case plus: + printer.print("+"); + break; + case minus: + printer.print("-"); + break; + case times: + printer.print("*"); + break; + case divide: + printer.print("/"); + break; + case remainder: + printer.print("%"); + break; + } + printer.print(" "); + n.getRight().accept(this, arg); + } + + @Override public void visit(final CastExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("("); + n.getType().accept(this, arg); + printer.print(") "); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final ClassExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getType().accept(this, arg); + printer.print(".class"); + } + + @Override public void visit(final ConditionalExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + printer.print(" ? "); + n.getThenExpr().accept(this, arg); + printer.print(" : "); + n.getElseExpr().accept(this, arg); + } + + @Override public void visit(final EnclosedExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("("); + if (n.getInner() != null) { + n.getInner().accept(this, arg); + } + printer.print(")"); + } + + @Override public void visit(final FieldAccessExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getScope().accept(this, arg); + printer.print("."); + printer.print(n.getField()); + } + + @Override public void visit(final InstanceOfExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + printer.print(" instanceof "); + n.getType().accept(this, arg); + } + + @Override public void visit(final CharLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("'"); + printer.print(n.getValue()); + printer.print("'"); + } + + @Override public void visit(final DoubleLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final IntegerLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final LongLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final IntegerLiteralMinValueExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final LongLiteralMinValueExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getValue()); + } + + @Override public void visit(final StringLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("\""); + printer.print(n.getValue()); + printer.print("\""); + } + + @Override public void visit(final BooleanLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(String.valueOf(n.getValue())); + } + + @Override public void visit(final NullLiteralExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("null"); + } + + @Override public void visit(final ThisExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + printer.print("."); + } + printer.print("this"); + } + + @Override public void visit(final SuperExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + printer.print("."); + } + printer.print("super"); + } + + @Override public void visit(final MethodCallExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + printTypeArgs(n.getTypeArgs(), arg); + printer.print(n.getName()); + printArguments(n.getArgs(), arg); + } + + @Override public void visit(final ObjectCreationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + printer.print("."); + } + + printer.print("new "); + + printTypeArgs(n.getTypeArgs(), arg); + if (!isNullOrEmpty(n.getTypeArgs())) { + printer.print(" "); + } + + n.getType().accept(this, arg); + + printArguments(n.getArgs(), arg); + + if (n.getAnonymousClassBody() != null) { + printer.printLn(" {"); + printer.indent(); + printMembers(n.getAnonymousClassBody(), arg); + printer.unindent(); + printer.print("}"); + } + } + + @Override public void visit(final UnaryExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + switch (n.getOperator()) { + case positive: + printer.print("+"); + break; + case negative: + printer.print("-"); + break; + case inverse: + printer.print("~"); + break; + case not: + printer.print("!"); + break; + case preIncrement: + printer.print("++"); + break; + case preDecrement: + printer.print("--"); + break; + default: + } + + n.getExpr().accept(this, arg); + + switch (n.getOperator()) { + case posIncrement: + printer.print("++"); + break; + case posDecrement: + printer.print("--"); + break; + default: + } + } + + @Override public void visit(final ConstructorDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printTypeParameters(n.getTypeParameters(), arg); + if (n.getTypeParameters() != null) { + printer.print(" "); + } + printer.print(n.getName()); + + printer.print("("); + if (n.getParameters() != null) { + for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) { + final Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + + if (!isNullOrEmpty(n.getThrows())) { + printer.print(" throws "); + for (final Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) { + final NameExpr name = i.next(); + name.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(" "); + n.getBlock().accept(this, arg); + } + + @Override public void visit(final MethodDeclaration n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + if (n.isDefault()) { + printer.print("default "); + } + printTypeParameters(n.getTypeParameters(), arg); + if (n.getTypeParameters() != null) { + printer.print(" "); + } + + n.getType().accept(this, arg); + printer.print(" "); + printer.print(n.getName()); + + printer.print("("); + if (n.getParameters() != null) { + for (final Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) { + final Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + + for (int i = 0; i < n.getArrayCount(); i++) { + printer.print("[]"); + } + + if (!isNullOrEmpty(n.getThrows())) { + printer.print(" throws "); + for (final Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) { + final NameExpr name = i.next(); + name.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (n.getBody() == null) { + printer.print(";"); + } else { + printer.print(" "); + n.getBody().accept(this, arg); + } + } + + @Override public void visit(final Parameter n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + if (n.getType() != null) { + n.getType().accept(this, arg); + } + if (n.isVarArgs()) { + printer.print("..."); + } + printer.print(" "); + n.getId().accept(this, arg); + } + + @Override public void visit(MultiTypeParameter n, Object arg) { + printAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + Iterator<Type> types = n.getTypes().iterator(); + types.next().accept(this, arg); + while (types.hasNext()) { + printer.print(" | "); + types.next().accept(this, arg); + } + + printer.print(" "); + n.getId().accept(this, arg); + } + + @Override public void visit(final ExplicitConstructorInvocationStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.isThis()) { + printTypeArgs(n.getTypeArgs(), arg); + printer.print("this"); + } else { + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + printer.print("."); + } + printTypeArgs(n.getTypeArgs(), arg); + printer.print("super"); + } + printArguments(n.getArgs(), arg); + printer.print(";"); + } + + @Override public void visit(final VariableDeclarationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + n.getType().accept(this, arg); + printer.print(" "); + + for (final Iterator<VariableDeclarator> i = n.getVars().iterator(); i.hasNext();) { + final VariableDeclarator v = i.next(); + v.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + @Override public void visit(final TypeDeclarationStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + n.getTypeDeclaration().accept(this, arg); + } + + @Override public void visit(final AssertStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("assert "); + n.getCheck().accept(this, arg); + if (n.getMessage() != null) { + printer.print(" : "); + n.getMessage().accept(this, arg); + } + printer.print(";"); + } + + @Override public void visit(final BlockStmt n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + printJavaComment(n.getComment(), arg); + printer.printLn("{"); + if (n.getStmts() != null) { + printer.indent(); + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + printer.printLn(); + } + printer.unindent(); + } + printOrphanCommentsEnding(n); + printer.print("}"); + + } + + @Override public void visit(final LabeledStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getLabel()); + printer.print(": "); + n.getStmt().accept(this, arg); + } + + @Override public void visit(final EmptyStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(";"); + } + + @Override public void visit(final ExpressionStmt n, final Object arg) { + printOrphanCommentsBeforeThisChildNode(n); + printJavaComment(n.getComment(), arg); + n.getExpression().accept(this, arg); + printer.print(";"); + } + + @Override public void visit(final SwitchStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("switch("); + n.getSelector().accept(this, arg); + printer.printLn(") {"); + if (n.getEntries() != null) { + printer.indent(); + for (final SwitchEntryStmt e : n.getEntries()) { + e.accept(this, arg); + } + printer.unindent(); + } + printer.print("}"); + + } + + @Override public void visit(final SwitchEntryStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getLabel() != null) { + printer.print("case "); + n.getLabel().accept(this, arg); + printer.print(":"); + } else { + printer.print("default:"); + } + printer.printLn(); + printer.indent(); + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + printer.printLn(); + } + } + printer.unindent(); + } + + @Override public void visit(final BreakStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("break"); + if (n.getId() != null) { + printer.print(" "); + printer.print(n.getId()); + } + printer.print(";"); + } + + @Override public void visit(final ReturnStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("return"); + if (n.getExpr() != null) { + printer.print(" "); + n.getExpr().accept(this, arg); + } + printer.print(";"); + } + + @Override public void visit(final EnumDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printer.print("enum "); + printer.print(n.getName()); + + if (n.getImplements() != null) { + printer.print(" implements "); + for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext();) { + final ClassOrInterfaceType c = i.next(); + c.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + + printer.printLn(" {"); + printer.indent(); + if (n.getEntries() != null) { + printer.printLn(); + for (final Iterator<EnumConstantDeclaration> i = n.getEntries().iterator(); i.hasNext();) { + final EnumConstantDeclaration e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (n.getMembers() != null) { + printer.printLn(";"); + printMembers(n.getMembers(), arg); + } else { + if (n.getEntries() != null) { + printer.printLn(); + } + } + printer.unindent(); + printer.print("}"); + } + + @Override public void visit(final EnumConstantDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printer.print(n.getName()); + + if (n.getArgs() != null) { + printArguments(n.getArgs(), arg); + } + + if (n.getClassBody() != null) { + printer.printLn(" {"); + printer.indent(); + printMembers(n.getClassBody(), arg); + printer.unindent(); + printer.printLn("}"); + } + } + + @Override public void visit(final EmptyMemberDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printer.print(";"); + } + + @Override public void visit(final InitializerDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + if (n.isStatic()) { + printer.print("static "); + } + n.getBlock().accept(this, arg); + } + + @Override public void visit(final IfStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("if ("); + n.getCondition().accept(this, arg); + final boolean thenBlock = n.getThenStmt() instanceof BlockStmt; + if (thenBlock) // block statement should start on the same line + printer.print(") "); + else { + printer.printLn(")"); + printer.indent(); + } + n.getThenStmt().accept(this, arg); + if (!thenBlock) + printer.unindent(); + if (n.getElseStmt() != null) { + if (thenBlock) + printer.print(" "); + else + printer.printLn(); + final boolean elseIf = n.getElseStmt() instanceof IfStmt; + final boolean elseBlock = n.getElseStmt() instanceof BlockStmt; + if (elseIf || elseBlock) // put chained if and start of block statement on a same level + printer.print("else "); + else { + printer.printLn("else"); + printer.indent(); + } + n.getElseStmt().accept(this, arg); + if (!(elseIf || elseBlock)) + printer.unindent(); + } + } + + @Override public void visit(final WhileStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("while ("); + n.getCondition().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ContinueStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("continue"); + if (n.getId() != null) { + printer.print(" "); + printer.print(n.getId()); + } + printer.print(";"); + } + + @Override public void visit(final DoStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("do "); + n.getBody().accept(this, arg); + printer.print(" while ("); + n.getCondition().accept(this, arg); + printer.print(");"); + } + + @Override public void visit(final ForeachStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("for ("); + n.getVariable().accept(this, arg); + printer.print(" : "); + n.getIterable().accept(this, arg); + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ForStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("for ("); + if (n.getInit() != null) { + for (final Iterator<Expression> i = n.getInit().iterator(); i.hasNext();) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print("; "); + if (n.getCompare() != null) { + n.getCompare().accept(this, arg); + } + printer.print("; "); + if (n.getUpdate() != null) { + for (final Iterator<Expression> i = n.getUpdate().iterator(); i.hasNext();) { + final Expression e = i.next(); + e.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(") "); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ThrowStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("throw "); + n.getExpr().accept(this, arg); + printer.print(";"); + } + + @Override public void visit(final SynchronizedStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("synchronized ("); + n.getExpr().accept(this, arg); + printer.print(") "); + n.getBlock().accept(this, arg); + } + + @Override public void visit(final TryStmt n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("try "); + if (!n.getResources().isEmpty()) { + printer.print("("); + Iterator<VariableDeclarationExpr> resources = n.getResources().iterator(); + boolean first = true; + while (resources.hasNext()) { + visit(resources.next(), arg); + if (resources.hasNext()) { + printer.print(";"); + printer.printLn(); + if (first) { + printer.indent(); + } + } + first = false; + } + if (n.getResources().size() > 1) { + printer.unindent(); + } + printer.print(") "); + } + n.getTryBlock().accept(this, arg); + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + c.accept(this, arg); + } + } + if (n.getFinallyBlock() != null) { + printer.print(" finally "); + n.getFinallyBlock().accept(this, arg); + } + } + + @Override public void visit(final CatchClause n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(" catch ("); + n.getExcept().accept(this, arg); + printer.print(") "); + n.getCatchBlock().accept(this, arg); + + } + + @Override public void visit(final AnnotationDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + printer.print("@interface "); + printer.print(n.getName()); + printer.printLn(" {"); + printer.indent(); + if (n.getMembers() != null) { + printMembers(n.getMembers(), arg); + } + printer.unindent(); + printer.print("}"); + } + + @Override public void visit(final AnnotationMemberDeclaration n, final Object arg) { + printJavaComment(n.getComment(), arg); + printJavadoc(n.getJavaDoc(), arg); + printMemberAnnotations(n.getAnnotations(), arg); + printModifiers(n.getModifiers()); + + n.getType().accept(this, arg); + printer.print(" "); + printer.print(n.getName()); + printer.print("()"); + if (n.getDefaultValue() != null) { + printer.print(" default "); + n.getDefaultValue().accept(this, arg); + } + printer.print(";"); + } + + @Override public void visit(final MarkerAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + } + + @Override public void visit(final SingleMemberAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + printer.print("("); + n.getMemberValue().accept(this, arg); + printer.print(")"); + } + + @Override public void visit(final NormalAnnotationExpr n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print("@"); + n.getName().accept(this, arg); + printer.print("("); + if (n.getPairs() != null) { + for (final Iterator<MemberValuePair> i = n.getPairs().iterator(); i.hasNext();) { + final MemberValuePair m = i.next(); + m.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + printer.print(")"); + } + + @Override public void visit(final MemberValuePair n, final Object arg) { + printJavaComment(n.getComment(), arg); + printer.print(n.getName()); + printer.print(" = "); + n.getValue().accept(this, arg); + } + + @Override public void visit(final LineComment n, final Object arg) { + if (!this.printComments) { + return; + } + printer.print("//"); + String tmp = n.getContent(); + tmp = tmp.replace('\r', ' '); + tmp = tmp.replace('\n', ' '); + printer.printLn(tmp); + } + + @Override public void visit(final BlockComment n, final Object arg) { + if (!this.printComments) { + return; + } + printer.print("/*"); + printer.print(n.getContent()); + printer.printLn("*/"); + } + + @Override + public void visit(LambdaExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + + List<Parameter> parameters = n.getParameters(); + boolean printPar = false; + printPar = n.isParametersEnclosed(); + + if (printPar) { + printer.print("("); + } + if (parameters != null) { + for (Iterator<Parameter> i = parameters.iterator(); i.hasNext();) { + Parameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + } + if (printPar) { + printer.print(")"); + } + + printer.print(" -> "); + Statement body = n.getBody(); + if (body instanceof ExpressionStmt) { + // Print the expression directly + ((ExpressionStmt) body).getExpression().accept(this, arg); + } else { + body.accept(this, arg); + } + } + + + @Override + public void visit(MethodReferenceExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + Expression scope = n.getScope(); + String identifier = n.getIdentifier(); + if (scope != null) { + n.getScope().accept(this, arg); + } + + printer.print("::"); + if (n.getTypeParameters() != null) { + printer.print("<"); + for (Iterator<TypeParameter> i = n.getTypeParameters().iterator(); i + .hasNext();) { + TypeParameter p = i.next(); + p.accept(this, arg); + if (i.hasNext()) { + printer.print(", "); + } + } + printer.print(">"); + } + if (identifier != null) { + printer.print(identifier); + } + + } + + @Override + public void visit(TypeExpr n, Object arg) { + printJavaComment(n.getComment(), arg); + if (n.getType() != null) { + n.getType().accept(this, arg); + } + } + + private void printOrphanCommentsBeforeThisChildNode(final Node node){ + if (node instanceof Comment) return; + + Node parent = node.getParentNode(); + if (parent==null) return; + List<Node> everything = new LinkedList<Node>(); + everything.addAll(parent.getChildrenNodes()); + sortByBeginPosition(everything); + int positionOfTheChild = -1; + for (int i=0;i<everything.size();i++){ + if (everything.get(i)==node) positionOfTheChild=i; + } + if (positionOfTheChild==-1) throw new RuntimeException("My index not found!!! "+node); + int positionOfPreviousChild = -1; + for (int i=positionOfTheChild-1;i>=0 && positionOfPreviousChild==-1;i--){ + if (!(everything.get(i) instanceof Comment)) positionOfPreviousChild = i; + } + for (int i=positionOfPreviousChild+1;i<positionOfTheChild;i++){ + Node nodeToPrint = everything.get(i); + if (!(nodeToPrint instanceof Comment)) throw new RuntimeException("Expected comment, instead "+nodeToPrint.getClass()+". Position of previous child: "+positionOfPreviousChild+", position of child "+positionOfTheChild); + nodeToPrint.accept(this,null); + } + } + + + private void printOrphanCommentsEnding(final Node node){ + List<Node> everything = new LinkedList<Node>(); + everything.addAll(node.getChildrenNodes()); + sortByBeginPosition(everything); + if (everything.size()==0) return; + + int commentsAtEnd = 0; + boolean findingComments = true; + while (findingComments&&commentsAtEnd<everything.size()){ + Node last = everything.get(everything.size()-1-commentsAtEnd); + findingComments = (last instanceof Comment); + if (findingComments) commentsAtEnd++; + } + for (int i=0;i<commentsAtEnd;i++){ + everything.get(everything.size()-commentsAtEnd+i).accept(this,null); + } + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/EqualsVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/EqualsVisitor.java new file mode 100644 index 000000000..8f4a786c0 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/EqualsVisitor.java @@ -0,0 +1,1468 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BaseParameter; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import java.util.Iterator; +import java.util.List; + +/** + * @author Julio Vilmar Gesser + */ +public class EqualsVisitor implements GenericVisitor<Boolean, Node> { + + private static final EqualsVisitor SINGLETON = new EqualsVisitor(); + + public static boolean equals(final Node n1, final Node n2) { + return SINGLETON.nodeEquals(n1, n2); + } + + private EqualsVisitor() { + // hide constructor + } + + /** + * Check for equality that can be applied to each kind of node, + * to not repeat it in every method we store that here. + */ + private boolean commonNodeEquality(Node n1, Node n2) { + if (!nodeEquals(n1.getComment(), n2.getComment())) { + return false; + } + if (!nodesEquals(n1.getOrphanComments(), n2.getOrphanComments())){ + return false; + } + return true; + } + + private <T extends Node> boolean nodesEquals(final List<T> nodes1, final List<T> nodes2) { + if (nodes1 == null) { + if (nodes2 == null) { + return true; + } + return false; + } else if (nodes2 == null) { + return false; + } + if (nodes1.size() != nodes2.size()) { + return false; + } + for (int i = 0; i < nodes1.size(); i++) { + if (!nodeEquals(nodes1.get(i), nodes2.get(i))) { + return false; + } + } + return true; + } + + private <T extends Node> boolean nodeEquals(final T n1, final T n2) { + if (n1 == n2) { + return true; + } + if (n1 == null) { + if (n2 == null) { + return true; + } + return false; + } else if (n2 == null) { + return false; + } + if (n1.getClass() != n2.getClass()) { + return false; + } + if (!commonNodeEquality(n1, n2)){ + return false; + } + return n1.accept(this, n2).booleanValue(); + } + + private boolean objEquals(final Object n1, final Object n2) { + if (n1 == n2) { + return true; + } + if (n1 == null) { + if (n2 == null) { + return true; + } + return false; + } else if (n2 == null) { + return false; + } + return n1.equals(n2); + } + + @Override public Boolean visit(final CompilationUnit n1, final Node arg) { + final CompilationUnit n2 = (CompilationUnit) arg; + + if (!nodeEquals(n1.getPackage(), n2.getPackage())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getImports(), n2.getImports())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypes(), n2.getTypes())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getComments(), n2.getComments())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final PackageDeclaration n1, final Node arg) { + final PackageDeclaration n2 = (PackageDeclaration) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ImportDeclaration n1, final Node arg) { + final ImportDeclaration n2 = (ImportDeclaration) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final TypeParameter n1, final Node arg) { + final TypeParameter n2 = (TypeParameter) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeBound(), n2.getTypeBound())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final LineComment n1, final Node arg) { + final LineComment n2 = (LineComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getBeginLine(), n2.getBeginLine())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BlockComment n1, final Node arg) { + final BlockComment n2 = (BlockComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getBeginLine(), n2.getBeginLine())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ClassOrInterfaceDeclaration n1, final Node arg) { + final ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (n1.isInterface() != n2.isInterface()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getExtends(), n2.getExtends())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getImplements(), n2.getImplements())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EnumDeclaration n1, final Node arg) { + final EnumDeclaration n2 = (EnumDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getImplements(), n2.getImplements())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getEntries(), n2.getEntries())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EmptyTypeDeclaration n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final EnumConstantDeclaration n1, final Node arg) { + final EnumConstantDeclaration n2 = (EnumConstantDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getClassBody(), n2.getClassBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AnnotationDeclaration n1, final Node arg) { + final AnnotationDeclaration n2 = (AnnotationDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getMembers(), n2.getMembers())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AnnotationMemberDeclaration n1, final Node arg) { + final AnnotationMemberDeclaration n2 = (AnnotationMemberDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getDefaultValue(), n2.getDefaultValue())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final FieldDeclaration n1, final Node arg) { + final FieldDeclaration n2 = (FieldDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getVariables(), n2.getVariables())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final VariableDeclarator n1, final Node arg) { + final VariableDeclarator n2 = (VariableDeclarator) arg; + + if (!nodeEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getInit(), n2.getInit())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final VariableDeclaratorId n1, final Node arg) { + final VariableDeclaratorId n2 = (VariableDeclaratorId) arg; + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ConstructorDeclaration n1, final Node arg) { + final ConstructorDeclaration n2 = (ConstructorDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getThrows(), n2.getThrows())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final MethodDeclaration n1, final Node arg) { + final MethodDeclaration n2 = (MethodDeclaration) arg; + + // javadoc are checked at CompilationUnit + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getThrows(), n2.getThrows())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + if(n1.isDefault() != n2.isDefault()){ + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final Parameter n1, final Node arg) { + final Parameter n2 = (Parameter) arg; + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + return visit((BaseParameter) n1, arg); + } + + @Override public Boolean visit(MultiTypeParameter n1, Node arg) { + MultiTypeParameter n2 = (MultiTypeParameter) arg; + if (n1.getTypes().size() != n2.getTypes().size()) { + return Boolean.FALSE; + } + Iterator<Type> n1types = n1.getTypes().iterator(); + Iterator<Type> n2types = n2.getTypes().iterator(); + while (n1types.hasNext() && n2types.hasNext()) { + if (!nodeEquals(n1types.next(), n2types.next())) { + return Boolean.FALSE; + } + } + return visit((BaseParameter) n1, arg); + } + + protected Boolean visit(final BaseParameter n1, final Node arg) { + final BaseParameter n2 = (BaseParameter) arg; + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EmptyMemberDeclaration n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final InitializerDeclaration n1, final Node arg) { + final InitializerDeclaration n2 = (InitializerDeclaration) arg; + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final JavadocComment n1, final Node arg) { + final JavadocComment n2 = (JavadocComment) arg; + + if (!objEquals(n1.getContent(), n2.getContent())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ClassOrInterfaceType n1, final Node arg) { + final ClassOrInterfaceType n2 = (ClassOrInterfaceType) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final PrimitiveType n1, final Node arg) { + final PrimitiveType n2 = (PrimitiveType) arg; + + if (n1.getType() != n2.getType()) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final ReferenceType n1, final Node arg) { + final ReferenceType n2 = (ReferenceType) arg; + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + List<List<AnnotationExpr>> n1a = n1.getArraysAnnotations(); + List<List<AnnotationExpr>> n2a = n2.getArraysAnnotations(); + + if (n1a !=null && n2a!= null) { + if(n1a.size() != n2a.size()){ + return Boolean.FALSE; + } + else{ + int i = 0; + for(List<AnnotationExpr> aux: n1a){ + if(!nodesEquals(aux, n2a.get(i))){ + return Boolean.FALSE; + } + i++; + } + } + } + else if (n1a != n2a){ + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + public Boolean visit(VoidType n1, Node arg) { + VoidType n2 = (VoidType) arg; + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final WildcardType n1, final Node arg) { + final WildcardType n2 = (WildcardType) arg; + + if (!nodeEquals(n1.getExtends(), n2.getExtends())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getSuper(), n2.getSuper())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final UnknownType n1, final Node arg) { + final WildcardType n2 = (WildcardType) arg; + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final ArrayAccessExpr n1, final Node arg) { + final ArrayAccessExpr n2 = (ArrayAccessExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getIndex(), n2.getIndex())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ArrayCreationExpr n1, final Node arg) { + final ArrayCreationExpr n2 = (ArrayCreationExpr) arg; + + if (n1.getArrayCount() != n2.getArrayCount()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getInitializer(), n2.getInitializer())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getDimensions(), n2.getDimensions())) { + return Boolean.FALSE; + } + List<List<AnnotationExpr>> n1a = n1.getArraysAnnotations(); + List<List<AnnotationExpr>> n2a = n2.getArraysAnnotations(); + + if (n1a !=null && n2a!= null) { + if(n1a.size() != n2a.size()){ + return Boolean.FALSE; + } + else{ + int i = 0; + for(List<AnnotationExpr> aux: n1a){ + if(!nodesEquals(aux, n2a.get(i))){ + return Boolean.FALSE; + } + i++; + } + } + } + else if (n1a != n2a){ + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override public Boolean visit(final ArrayInitializerExpr n1, final Node arg) { + final ArrayInitializerExpr n2 = (ArrayInitializerExpr) arg; + + if (!nodesEquals(n1.getValues(), n2.getValues())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AssignExpr n1, final Node arg) { + final AssignExpr n2 = (AssignExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getTarget(), n2.getTarget())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BinaryExpr n1, final Node arg) { + final BinaryExpr n2 = (BinaryExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getLeft(), n2.getLeft())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getRight(), n2.getRight())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final CastExpr n1, final Node arg) { + final CastExpr n2 = (CastExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ClassExpr n1, final Node arg) { + final ClassExpr n2 = (ClassExpr) arg; + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ConditionalExpr n1, final Node arg) { + final ConditionalExpr n2 = (ConditionalExpr) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getThenExpr(), n2.getThenExpr())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getElseExpr(), n2.getElseExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EnclosedExpr n1, final Node arg) { + final EnclosedExpr n2 = (EnclosedExpr) arg; + + if (!nodeEquals(n1.getInner(), n2.getInner())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final FieldAccessExpr n1, final Node arg) { + final FieldAccessExpr n2 = (FieldAccessExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getField(), n2.getField())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final InstanceOfExpr n1, final Node arg) { + final InstanceOfExpr n2 = (InstanceOfExpr) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final StringLiteralExpr n1, final Node arg) { + final StringLiteralExpr n2 = (StringLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final IntegerLiteralExpr n1, final Node arg) { + final IntegerLiteralExpr n2 = (IntegerLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final LongLiteralExpr n1, final Node arg) { + final LongLiteralExpr n2 = (LongLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final IntegerLiteralMinValueExpr n1, final Node arg) { + final IntegerLiteralMinValueExpr n2 = (IntegerLiteralMinValueExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final LongLiteralMinValueExpr n1, final Node arg) { + final LongLiteralMinValueExpr n2 = (LongLiteralMinValueExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final CharLiteralExpr n1, final Node arg) { + final CharLiteralExpr n2 = (CharLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final DoubleLiteralExpr n1, final Node arg) { + final DoubleLiteralExpr n2 = (DoubleLiteralExpr) arg; + + if (!objEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BooleanLiteralExpr n1, final Node arg) { + final BooleanLiteralExpr n2 = (BooleanLiteralExpr) arg; + + if (n1.getValue() != n2.getValue()) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final NullLiteralExpr n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final MethodCallExpr n1, final Node arg) { + final MethodCallExpr n2 = (MethodCallExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final NameExpr n1, final Node arg) { + final NameExpr n2 = (NameExpr) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ObjectCreationExpr n1, final Node arg) { + final ObjectCreationExpr n2 = (ObjectCreationExpr) arg; + + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnonymousClassBody(), n2.getAnonymousClassBody())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final QualifiedNameExpr n1, final Node arg) { + final QualifiedNameExpr n2 = (QualifiedNameExpr) arg; + + if (!nodeEquals(n1.getQualifier(), n2.getQualifier())) { + return Boolean.FALSE; + } + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ThisExpr n1, final Node arg) { + final ThisExpr n2 = (ThisExpr) arg; + + if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SuperExpr n1, final Node arg) { + final SuperExpr n2 = (SuperExpr) arg; + + if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final UnaryExpr n1, final Node arg) { + final UnaryExpr n2 = (UnaryExpr) arg; + + if (n1.getOperator() != n2.getOperator()) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final VariableDeclarationExpr n1, final Node arg) { + final VariableDeclarationExpr n2 = (VariableDeclarationExpr) arg; + + if (n1.getModifiers() != n2.getModifiers()) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getType(), n2.getType())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getVars(), n2.getVars())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final MarkerAnnotationExpr n1, final Node arg) { + final MarkerAnnotationExpr n2 = (MarkerAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SingleMemberAnnotationExpr n1, final Node arg) { + final SingleMemberAnnotationExpr n2 = (SingleMemberAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getMemberValue(), n2.getMemberValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final NormalAnnotationExpr n1, final Node arg) { + final NormalAnnotationExpr n2 = (NormalAnnotationExpr) arg; + + if (!nodeEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getPairs(), n2.getPairs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final MemberValuePair n1, final Node arg) { + final MemberValuePair n2 = (MemberValuePair) arg; + + if (!objEquals(n1.getName(), n2.getName())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getValue(), n2.getValue())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ExplicitConstructorInvocationStmt n1, final Node arg) { + final ExplicitConstructorInvocationStmt n2 = (ExplicitConstructorInvocationStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getArgs(), n2.getArgs())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final TypeDeclarationStmt n1, final Node arg) { + final TypeDeclarationStmt n2 = (TypeDeclarationStmt) arg; + + if (!nodeEquals(n1.getTypeDeclaration(), n2.getTypeDeclaration())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final AssertStmt n1, final Node arg) { + final AssertStmt n2 = (AssertStmt) arg; + + if (!nodeEquals(n1.getCheck(), n2.getCheck())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getMessage(), n2.getMessage())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BlockStmt n1, final Node arg) { + final BlockStmt n2 = (BlockStmt) arg; + + if (!nodesEquals(n1.getStmts(), n2.getStmts())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final LabeledStmt n1, final Node arg) { + final LabeledStmt n2 = (LabeledStmt) arg; + + if (!nodeEquals(n1.getStmt(), n2.getStmt())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final EmptyStmt n1, final Node arg) { + return Boolean.TRUE; + } + + @Override public Boolean visit(final ExpressionStmt n1, final Node arg) { + final ExpressionStmt n2 = (ExpressionStmt) arg; + + if (!nodeEquals(n1.getExpression(), n2.getExpression())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SwitchStmt n1, final Node arg) { + final SwitchStmt n2 = (SwitchStmt) arg; + + if (!nodeEquals(n1.getSelector(), n2.getSelector())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getEntries(), n2.getEntries())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SwitchEntryStmt n1, final Node arg) { + final SwitchEntryStmt n2 = (SwitchEntryStmt) arg; + + if (!nodeEquals(n1.getLabel(), n2.getLabel())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getStmts(), n2.getStmts())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final BreakStmt n1, final Node arg) { + final BreakStmt n2 = (BreakStmt) arg; + + if (!objEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ReturnStmt n1, final Node arg) { + final ReturnStmt n2 = (ReturnStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final IfStmt n1, final Node arg) { + final IfStmt n2 = (IfStmt) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getThenStmt(), n2.getThenStmt())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getElseStmt(), n2.getElseStmt())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final WhileStmt n1, final Node arg) { + final WhileStmt n2 = (WhileStmt) arg; + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ContinueStmt n1, final Node arg) { + final ContinueStmt n2 = (ContinueStmt) arg; + + if (!objEquals(n1.getId(), n2.getId())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final DoStmt n1, final Node arg) { + final DoStmt n2 = (DoStmt) arg; + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getCondition(), n2.getCondition())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ForeachStmt n1, final Node arg) { + final ForeachStmt n2 = (ForeachStmt) arg; + + if (!nodeEquals(n1.getVariable(), n2.getVariable())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getIterable(), n2.getIterable())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ForStmt n1, final Node arg) { + final ForStmt n2 = (ForStmt) arg; + + if (!nodesEquals(n1.getInit(), n2.getInit())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getCompare(), n2.getCompare())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getUpdate(), n2.getUpdate())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final ThrowStmt n1, final Node arg) { + final ThrowStmt n2 = (ThrowStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final SynchronizedStmt n1, final Node arg) { + final SynchronizedStmt n2 = (SynchronizedStmt) arg; + + if (!nodeEquals(n1.getExpr(), n2.getExpr())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getBlock(), n2.getBlock())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final TryStmt n1, final Node arg) { + final TryStmt n2 = (TryStmt) arg; + + if (!nodeEquals(n1.getTryBlock(), n2.getTryBlock())) { + return Boolean.FALSE; + } + + if (!nodesEquals(n1.getCatchs(), n2.getCatchs())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getFinallyBlock(), n2.getFinallyBlock())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override public Boolean visit(final CatchClause n1, final Node arg) { + final CatchClause n2 = (CatchClause) arg; + + if (!nodeEquals(n1.getExcept(), n2.getExcept())) { + return Boolean.FALSE; + } + + if (!nodeEquals(n1.getCatchBlock(), n2.getCatchBlock())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override + public Boolean visit(LambdaExpr n1, Node arg) { + LambdaExpr n2 = (LambdaExpr) arg; + if (!nodesEquals(n1.getParameters(), n2.getParameters())) { + return Boolean.FALSE; + } + if(n1.isParametersEnclosed() != n2.isParametersEnclosed()){ + return Boolean.FALSE; + } + if (!nodeEquals(n1.getBody(), n2.getBody())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override + public Boolean visit(MethodReferenceExpr n1, Node arg) { + MethodReferenceExpr n2 = (MethodReferenceExpr) arg; + if (!nodeEquals(n1.getScope(), n2.getScope())) { + return Boolean.FALSE; + } + if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) { + return Boolean.FALSE; + } + if (!objEquals(n1.getIdentifier(), n2.getIdentifier())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @Override + public Boolean visit(TypeExpr n, Node arg) { + TypeExpr n2 = (TypeExpr) arg; + if (!nodeEquals(n.getType(), n2.getType())) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitor.java new file mode 100644 index 000000000..58fbf6db9 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitor.java @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * A visitor that has a return value. + * + * @author Julio Vilmar Gesser + */ +public interface GenericVisitor<R, A> { + + //- Compilation Unit ---------------------------------- + + public R visit(CompilationUnit n, A arg); + + public R visit(PackageDeclaration n, A arg); + + public R visit(ImportDeclaration n, A arg); + + public R visit(TypeParameter n, A arg); + + public R visit(LineComment n, A arg); + + public R visit(BlockComment n, A arg); + + //- Body ---------------------------------------------- + + public R visit(ClassOrInterfaceDeclaration n, A arg); + + public R visit(EnumDeclaration n, A arg); + + public R visit(EmptyTypeDeclaration n, A arg); + + public R visit(EnumConstantDeclaration n, A arg); + + public R visit(AnnotationDeclaration n, A arg); + + public R visit(AnnotationMemberDeclaration n, A arg); + + public R visit(FieldDeclaration n, A arg); + + public R visit(VariableDeclarator n, A arg); + + public R visit(VariableDeclaratorId n, A arg); + + public R visit(ConstructorDeclaration n, A arg); + + public R visit(MethodDeclaration n, A arg); + + public R visit(Parameter n, A arg); + + public R visit(MultiTypeParameter n, A arg); + + public R visit(EmptyMemberDeclaration n, A arg); + + public R visit(InitializerDeclaration n, A arg); + + public R visit(JavadocComment n, A arg); + + //- Type ---------------------------------------------- + + public R visit(ClassOrInterfaceType n, A arg); + + public R visit(PrimitiveType n, A arg); + + public R visit(ReferenceType n, A arg); + + public R visit(VoidType n, A arg); + + public R visit(WildcardType n, A arg); + + public R visit(UnknownType n, A arg); + + //- Expression ---------------------------------------- + + public R visit(ArrayAccessExpr n, A arg); + + public R visit(ArrayCreationExpr n, A arg); + + public R visit(ArrayInitializerExpr n, A arg); + + public R visit(AssignExpr n, A arg); + + public R visit(BinaryExpr n, A arg); + + public R visit(CastExpr n, A arg); + + public R visit(ClassExpr n, A arg); + + public R visit(ConditionalExpr n, A arg); + + public R visit(EnclosedExpr n, A arg); + + public R visit(FieldAccessExpr n, A arg); + + public R visit(InstanceOfExpr n, A arg); + + public R visit(StringLiteralExpr n, A arg); + + public R visit(IntegerLiteralExpr n, A arg); + + public R visit(LongLiteralExpr n, A arg); + + public R visit(IntegerLiteralMinValueExpr n, A arg); + + public R visit(LongLiteralMinValueExpr n, A arg); + + public R visit(CharLiteralExpr n, A arg); + + public R visit(DoubleLiteralExpr n, A arg); + + public R visit(BooleanLiteralExpr n, A arg); + + public R visit(NullLiteralExpr n, A arg); + + public R visit(MethodCallExpr n, A arg); + + public R visit(NameExpr n, A arg); + + public R visit(ObjectCreationExpr n, A arg); + + public R visit(QualifiedNameExpr n, A arg); + + public R visit(ThisExpr n, A arg); + + public R visit(SuperExpr n, A arg); + + public R visit(UnaryExpr n, A arg); + + public R visit(VariableDeclarationExpr n, A arg); + + public R visit(MarkerAnnotationExpr n, A arg); + + public R visit(SingleMemberAnnotationExpr n, A arg); + + public R visit(NormalAnnotationExpr n, A arg); + + public R visit(MemberValuePair n, A arg); + + //- Statements ---------------------------------------- + + public R visit(ExplicitConstructorInvocationStmt n, A arg); + + public R visit(TypeDeclarationStmt n, A arg); + + public R visit(AssertStmt n, A arg); + + public R visit(BlockStmt n, A arg); + + public R visit(LabeledStmt n, A arg); + + public R visit(EmptyStmt n, A arg); + + public R visit(ExpressionStmt n, A arg); + + public R visit(SwitchStmt n, A arg); + + public R visit(SwitchEntryStmt n, A arg); + + public R visit(BreakStmt n, A arg); + + public R visit(ReturnStmt n, A arg); + + public R visit(IfStmt n, A arg); + + public R visit(WhileStmt n, A arg); + + public R visit(ContinueStmt n, A arg); + + public R visit(DoStmt n, A arg); + + public R visit(ForeachStmt n, A arg); + + public R visit(ForStmt n, A arg); + + public R visit(ThrowStmt n, A arg); + + public R visit(SynchronizedStmt n, A arg); + + public R visit(TryStmt n, A arg); + + public R visit(CatchClause n, A arg); + + public R visit(LambdaExpr n, A arg); + + public R visit(MethodReferenceExpr n, A arg); + + public R visit(TypeExpr n, A arg); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java new file mode 100644 index 000000000..eac9cab40 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/GenericVisitorAdapter.java @@ -0,0 +1,1613 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class GenericVisitorAdapter<R, A> implements GenericVisitor<R, A> { + + @Override + public R visit(final AnnotationDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final AnnotationMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getDefaultValue() != null) { + { + R result = n.getDefaultValue().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ArrayAccessExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getIndex().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ArrayCreationExpr n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getDimensions() != null) { + for (final Expression dim : n.getDimensions()) { + { + R result = dim.accept(this, arg); + if (result != null) { + return result; + } + } + } + } else { + { + R result = n.getInitializer().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ArrayInitializerExpr n, final A arg) { + if (n.getValues() != null) { + for (final Expression expr : n.getValues()) { + { + R result = expr.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final AssertStmt n, final A arg) { + { + R result = n.getCheck().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getMessage() != null) { + { + R result = n.getMessage().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final AssignExpr n, final A arg) { + { + R result = n.getTarget().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getValue().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final BinaryExpr n, final A arg) { + { + R result = n.getLeft().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getRight().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final BlockStmt n, final A arg) { + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + { + R result = s.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + + } + + @Override + public R visit(final BooleanLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final BreakStmt n, final A arg) { + return null; + } + + @Override + public R visit(final CastExpr n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final CatchClause n, final A arg) { + { + R result = n.getExcept().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getCatchBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + + } + + @Override + public R visit(final CharLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final ClassExpr n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ClassOrInterfaceDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getExtends() != null) { + for (final ClassOrInterfaceType c : n.getExtends()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ClassOrInterfaceType n, final A arg) { + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final CompilationUnit n, final A arg) { + if (n.getPackage() != null) { + { + R result = n.getPackage().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getImports() != null) { + for (final ImportDeclaration i : n.getImports()) { + { + R result = i.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypes() != null) { + for (final TypeDeclaration typeDeclaration : n.getTypes()) { + { + R result = typeDeclaration.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ConditionalExpr n, final A arg) { + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getThenExpr().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getElseExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ConstructorDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + { + R result = p.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + { + R result = name.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ContinueStmt n, final A arg) { + return null; + } + + @Override + public R visit(final DoStmt n, final A arg) { + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final DoubleLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final EmptyMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final EmptyStmt n, final A arg) { + return null; + } + + @Override + public R visit(final EmptyTypeDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final EnclosedExpr n, final A arg) { + { + R result = n.getInner().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final EnumConstantDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getClassBody() != null) { + for (final BodyDeclaration member : n.getClassBody()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final EnumDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getEntries() != null) { + for (final EnumConstantDeclaration e : n.getEntries()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ExplicitConstructorInvocationStmt n, final A arg) { + if (!n.isThis()) { + if (n.getExpr() != null) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final ExpressionStmt n, final A arg) { + { + R result = n.getExpression().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final FieldAccessExpr n, final A arg) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final FieldDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + for (final VariableDeclarator var : n.getVariables()) { + { + R result = var.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ForeachStmt n, final A arg) { + { + R result = n.getVariable().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getIterable().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ForStmt n, final A arg) { + if (n.getInit() != null) { + for (final Expression e : n.getInit()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getCompare() != null) { + { + R result = n.getCompare().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getUpdate() != null) { + for (final Expression e : n.getUpdate()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final IfStmt n, final A arg) { + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getThenStmt().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getElseStmt() != null) { + { + R result = n.getElseStmt().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ImportDeclaration n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final InitializerDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final InstanceOfExpr n, final A arg) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final IntegerLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final IntegerLiteralMinValueExpr n, final A arg) { + return null; + } + + @Override + public R visit(final JavadocComment n, final A arg) { + return null; + } + + @Override + public R visit(final LabeledStmt n, final A arg) { + { + R result = n.getStmt().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final LongLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final LongLiteralMinValueExpr n, final A arg) { + return null; + } + + @Override + public R visit(final MarkerAnnotationExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final MemberValuePair n, final A arg) { + { + R result = n.getValue().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final MethodCallExpr n, final A arg) { + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final MethodDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + { + R result = n.getJavaDoc().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + { + R result = p.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + { + R result = name.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getBody() != null) { + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final NameExpr n, final A arg) { + return null; + } + + @Override + public R visit(final NormalAnnotationExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getPairs() != null) { + for (final MemberValuePair m : n.getPairs()) { + { + R result = m.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final NullLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final ObjectCreationExpr n, final A arg) { + if (n.getScope() != null) { + { + R result = n.getScope().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + { + R result = t.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getAnonymousClassBody() != null) { + for (final BodyDeclaration member : n.getAnonymousClassBody()) { + { + R result = member.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final PackageDeclaration n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final Parameter n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getId().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final MultiTypeParameter n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + for (final Type type : n.getTypes()) { + R result = type.accept(this, arg); + if (result != null) { + return result; + } + } + } + { + R result = n.getId().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final PrimitiveType n, final A arg) { + return null; + } + + @Override + public R visit(final QualifiedNameExpr n, final A arg) { + { + R result = n.getQualifier().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ReferenceType n, final A arg) { + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ReturnStmt n, final A arg) { + if (n.getExpr() != null) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final SingleMemberAnnotationExpr n, final A arg) { + { + R result = n.getName().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getMemberValue().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final StringLiteralExpr n, final A arg) { + return null; + } + + @Override + public R visit(final SuperExpr n, final A arg) { + if (n.getClassExpr() != null) { + { + R result = n.getClassExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final SwitchEntryStmt n, final A arg) { + if (n.getLabel() != null) { + { + R result = n.getLabel().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + { + R result = s.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final SwitchStmt n, final A arg) { + { + R result = n.getSelector().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getEntries() != null) { + for (final SwitchEntryStmt e : n.getEntries()) { + { + R result = e.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + + } + + @Override + public R visit(final SynchronizedStmt n, final A arg) { + { + if (n.getExpr() != null) { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + { + R result = n.getBlock().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final ThisExpr n, final A arg) { + if (n.getClassExpr() != null) { + { + R result = n.getClassExpr().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final ThrowStmt n, final A arg) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final TryStmt n, final A arg) { + if (n.getResources() != null) { + for (final VariableDeclarationExpr v : n.getResources()) { + { + R result = v.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getTryBlock().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + if (n.getFinallyBlock() != null) { + { + R result = n.getFinallyBlock().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final TypeDeclarationStmt n, final A arg) { + { + R result = n.getTypeDeclaration().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final TypeParameter n, final A arg) { + if (n.getTypeBound() != null) { + for (final ClassOrInterfaceType c : n.getTypeBound()) { + { + R result = c.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + return null; + } + + @Override + public R visit(final UnaryExpr n, final A arg) { + { + R result = n.getExpr().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final UnknownType n, final A arg) { + return null; + } + + @Override + public R visit(final VariableDeclarationExpr n, final A arg) { + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + { + R result = a.accept(this, arg); + if (result != null) { + return result; + } + } + } + } + { + R result = n.getType().accept(this, arg); + if (result != null) { + return result; + } + } + for (final VariableDeclarator v : n.getVars()) { + { + R result = v.accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final VariableDeclarator n, final A arg) { + { + R result = n.getId().accept(this, arg); + if (result != null) { + return result; + } + } + if (n.getInit() != null) { + { + R result = n.getInit().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(final VariableDeclaratorId n, final A arg) { + return null; + } + + @Override + public R visit(final VoidType n, final A arg) { + return null; + } + + @Override + public R visit(final WhileStmt n, final A arg) { + { + R result = n.getCondition().accept(this, arg); + if (result != null) { + return result; + } + } + { + R result = n.getBody().accept(this, arg); + if (result != null) { + return result; + } + } + return null; + } + + @Override + public R visit(final WildcardType n, final A arg) { + if (n.getExtends() != null) { + { + R result = n.getExtends().accept(this, arg); + if (result != null) { + return result; + } + } + } + if (n.getSuper() != null) { + { + R result = n.getSuper().accept(this, arg); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public R visit(LambdaExpr n, A arg) { + return null; + } + + @Override + public R visit(MethodReferenceExpr n, A arg){ + return null; + } + + @Override + public R visit(TypeExpr n, A arg){ + return null; + } + + @Override + public R visit(final BlockComment n, final A arg) { + return null; + } + + @Override + public R visit(final LineComment n, final A arg) { + return null; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java new file mode 100644 index 000000000..3d23cea5a --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/ModifierVisitorAdapter.java @@ -0,0 +1,973 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BaseParameter; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.AnnotationExpr; +import com.github.javaparser.ast.expr.ArrayAccessExpr; +import com.github.javaparser.ast.expr.ArrayCreationExpr; +import com.github.javaparser.ast.expr.ArrayInitializerExpr; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.BinaryExpr; +import com.github.javaparser.ast.expr.BooleanLiteralExpr; +import com.github.javaparser.ast.expr.CastExpr; +import com.github.javaparser.ast.expr.CharLiteralExpr; +import com.github.javaparser.ast.expr.ClassExpr; +import com.github.javaparser.ast.expr.ConditionalExpr; +import com.github.javaparser.ast.expr.DoubleLiteralExpr; +import com.github.javaparser.ast.expr.EnclosedExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.FieldAccessExpr; +import com.github.javaparser.ast.expr.InstanceOfExpr; +import com.github.javaparser.ast.expr.IntegerLiteralExpr; +import com.github.javaparser.ast.expr.IntegerLiteralMinValueExpr; +import com.github.javaparser.ast.expr.LambdaExpr; +import com.github.javaparser.ast.expr.LongLiteralExpr; +import com.github.javaparser.ast.expr.LongLiteralMinValueExpr; +import com.github.javaparser.ast.expr.MarkerAnnotationExpr; +import com.github.javaparser.ast.expr.MemberValuePair; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.MethodReferenceExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.NormalAnnotationExpr; +import com.github.javaparser.ast.expr.NullLiteralExpr; +import com.github.javaparser.ast.expr.ObjectCreationExpr; +import com.github.javaparser.ast.expr.QualifiedNameExpr; +import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.expr.SuperExpr; +import com.github.javaparser.ast.expr.ThisExpr; +import com.github.javaparser.ast.expr.TypeExpr; +import com.github.javaparser.ast.expr.UnaryExpr; +import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import java.util.LinkedList; +import java.util.List; + +/** + * This visitor adapter can be used to save time when some specific nodes needs + * to be changed. To do that just extend this class and override the methods + * from the nodes who needs to be changed, returning the changed node. + * + * @author Julio Vilmar Gesser + */ +public abstract class ModifierVisitorAdapter<A> implements GenericVisitor<Node, A> { + + private void removeNulls(final List<?> list) { + for (int i = list.size() - 1; i >= 0; i--) { + if (list.get(i) == null) { + list.remove(i); + } + } + } + + @Override public Node visit(final AnnotationDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<BodyDeclaration> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final AnnotationMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + if (n.getDefaultValue() != null) { + n.setDefaultValue((Expression) n.getDefaultValue().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ArrayAccessExpr n, final A arg) { + n.setName((Expression) n.getName().accept(this, arg)); + n.setIndex((Expression) n.getIndex().accept(this, arg)); + return n; + } + + @Override public Node visit(final ArrayCreationExpr n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + if (n.getDimensions() != null) { + final List<Expression> dimensions = n.getDimensions(); + if (dimensions != null) { + for (int i = 0; i < dimensions.size(); i++) { + dimensions.set(i, (Expression) dimensions.get(i).accept(this, arg)); + } + removeNulls(dimensions); + } + } else { + n.setInitializer((ArrayInitializerExpr) n.getInitializer().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ArrayInitializerExpr n, final A arg) { + if (n.getValues() != null) { + final List<Expression> values = n.getValues(); + if (values != null) { + for (int i = 0; i < values.size(); i++) { + values.set(i, (Expression) values.get(i).accept(this, arg)); + } + removeNulls(values); + } + } + return n; + } + + @Override public Node visit(final AssertStmt n, final A arg) { + n.setCheck((Expression) n.getCheck().accept(this, arg)); + if (n.getMessage() != null) { + n.setMessage((Expression) n.getMessage().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final AssignExpr n, final A arg) { + n.setTarget((Expression) n.getTarget().accept(this, arg)); + n.setValue((Expression) n.getValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final BinaryExpr n, final A arg) { + n.setLeft((Expression) n.getLeft().accept(this, arg)); + n.setRight((Expression) n.getRight().accept(this, arg)); + return n; + } + + @Override public Node visit(final BlockStmt n, final A arg) { + final List<Statement> stmts = n.getStmts(); + if (stmts != null) { + for (int i = 0; i < stmts.size(); i++) { + stmts.set(i, (Statement) stmts.get(i).accept(this, arg)); + } + removeNulls(stmts); + } + return n; + } + + @Override public Node visit(final BooleanLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final BreakStmt n, final A arg) { + return n; + } + + @Override public Node visit(final CastExpr n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final CatchClause n, final A arg) { + n.setExcept((MultiTypeParameter) n.getExcept().accept(this, arg)); + n.setCatchBlock((BlockStmt) n.getCatchBlock().accept(this, arg)); + return n; + + } + + @Override public Node visit(final CharLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final ClassExpr n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final ClassOrInterfaceDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + final List<ClassOrInterfaceType> extendz = n.getExtends(); + if (extendz != null) { + for (int i = 0; i < extendz.size(); i++) { + extendz.set(i, (ClassOrInterfaceType) extendz.get(i).accept(this, arg)); + } + removeNulls(extendz); + } + final List<ClassOrInterfaceType> implementz = n.getImplements(); + if (implementz != null) { + for (int i = 0; i < implementz.size(); i++) { + implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg)); + } + removeNulls(implementz); + } + final List<BodyDeclaration> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final ClassOrInterfaceType n, final A arg) { + if (n.getScope() != null) { + n.setScope((ClassOrInterfaceType) n.getScope().accept(this, arg)); + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + return n; + } + + @Override public Node visit(final CompilationUnit n, final A arg) { + if (n.getPackage() != null) { + n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg)); + } + final List<ImportDeclaration> imports = n.getImports(); + if (imports != null) { + for (int i = 0; i < imports.size(); i++) { + imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg)); + } + removeNulls(imports); + } + final List<TypeDeclaration> types = n.getTypes(); + if (types != null) { + for (int i = 0; i < types.size(); i++) { + types.set(i, (TypeDeclaration) types.get(i).accept(this, arg)); + } + removeNulls(types); + } + return n; + } + + @Override public Node visit(final ConditionalExpr n, final A arg) { + n.setCondition((Expression) n.getCondition().accept(this, arg)); + n.setThenExpr((Expression) n.getThenExpr().accept(this, arg)); + n.setElseExpr((Expression) n.getElseExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final ConstructorDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + final List<Parameter> parameters = n.getParameters(); + if (parameters != null) { + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + } + final List<NameExpr> throwz = n.getThrows(); + if (throwz != null) { + for (int i = 0; i < throwz.size(); i++) { + throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg)); + } + removeNulls(throwz); + } + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final ContinueStmt n, final A arg) { + return n; + } + + @Override public Node visit(final DoStmt n, final A arg) { + n.setBody((Statement) n.getBody().accept(this, arg)); + n.setCondition((Expression) n.getCondition().accept(this, arg)); + return n; + } + + @Override public Node visit(final DoubleLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final EmptyMemberDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final EmptyStmt n, final A arg) { + return n; + } + + @Override public Node visit(final EmptyTypeDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final EnclosedExpr n, final A arg) { + n.setInner((Expression) n.getInner().accept(this, arg)); + return n; + } + + @Override public Node visit(final EnumConstantDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + final List<BodyDeclaration> classBody = n.getClassBody(); + if (classBody != null) { + for (int i = 0; i < classBody.size(); i++) { + classBody.set(i, (BodyDeclaration) classBody.get(i).accept(this, arg)); + } + removeNulls(classBody); + } + return n; + } + + @Override public Node visit(final EnumDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<ClassOrInterfaceType> implementz = n.getImplements(); + if (implementz != null) { + for (int i = 0; i < implementz.size(); i++) { + implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg)); + } + removeNulls(implementz); + } + final List<EnumConstantDeclaration> entries = n.getEntries(); + if (entries != null) { + for (int i = 0; i < entries.size(); i++) { + entries.set(i, (EnumConstantDeclaration) entries.get(i).accept(this, arg)); + } + removeNulls(entries); + } + final List<BodyDeclaration> members = n.getMembers(); + if (members != null) { + for (int i = 0; i < members.size(); i++) { + members.set(i, (BodyDeclaration) members.get(i).accept(this, arg)); + } + removeNulls(members); + } + return n; + } + + @Override public Node visit(final ExplicitConstructorInvocationStmt n, final A arg) { + if (!n.isThis()) { + if (n.getExpr() != null) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + } + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + return n; + } + + @Override public Node visit(final ExpressionStmt n, final A arg) { + n.setExpression((Expression) n.getExpression().accept(this, arg)); + return n; + } + + @Override public Node visit(final FieldAccessExpr n, final A arg) { + n.setScope((Expression) n.getScope().accept(this, arg)); + return n; + } + + @Override public Node visit(final FieldDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + final List<VariableDeclarator> variables = n.getVariables(); + for (int i = 0; i < variables.size(); i++) { + variables.set(i, (VariableDeclarator) variables.get(i).accept(this, arg)); + } + removeNulls(variables); + return n; + } + + @Override public Node visit(final ForeachStmt n, final A arg) { + n.setVariable((VariableDeclarationExpr) n.getVariable().accept(this, arg)); + n.setIterable((Expression) n.getIterable().accept(this, arg)); + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final ForStmt n, final A arg) { + final List<Expression> init = n.getInit(); + if (init != null) { + for (int i = 0; i < init.size(); i++) { + init.set(i, (Expression) init.get(i).accept(this, arg)); + } + removeNulls(init); + } + if (n.getCompare() != null) { + n.setCompare((Expression) n.getCompare().accept(this, arg)); + } + final List<Expression> update = n.getUpdate(); + if (update != null) { + for (int i = 0; i < update.size(); i++) { + update.set(i, (Expression) update.get(i).accept(this, arg)); + } + removeNulls(update); + } + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final IfStmt n, final A arg) { + n.setCondition((Expression) n.getCondition().accept(this, arg)); + n.setThenStmt((Statement) n.getThenStmt().accept(this, arg)); + if (n.getElseStmt() != null) { + n.setElseStmt((Statement) n.getElseStmt().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ImportDeclaration n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final InitializerDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final InstanceOfExpr n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final IntegerLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final IntegerLiteralMinValueExpr n, final A arg) { + return n; + } + + @Override public Node visit(final JavadocComment n, final A arg) { + return n; + } + + @Override public Node visit(final LabeledStmt n, final A arg) { + n.setStmt((Statement) n.getStmt().accept(this, arg)); + return n; + } + + @Override public Node visit(final LongLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final LongLiteralMinValueExpr n, final A arg) { + return n; + } + + @Override public Node visit(final MarkerAnnotationExpr n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final MemberValuePair n, final A arg) { + n.setValue((Expression) n.getValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final MethodCallExpr n, final A arg) { + if (n.getScope() != null) { + n.setScope((Expression) n.getScope().accept(this, arg)); + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + return n; + } + + @Override public Node visit(final MethodDeclaration n, final A arg) { + if (n.getJavaDoc() != null) { + n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg)); + } + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + final List<TypeParameter> typeParameters = n.getTypeParameters(); + if (typeParameters != null) { + for (int i = 0; i < typeParameters.size(); i++) { + typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg)); + } + removeNulls(typeParameters); + } + n.setType((Type) n.getType().accept(this, arg)); + final List<Parameter> parameters = n.getParameters(); + if (parameters != null) { + for (int i = 0; i < parameters.size(); i++) { + parameters.set(i, (Parameter) parameters.get(i).accept(this, arg)); + } + removeNulls(parameters); + } + final List<NameExpr> throwz = n.getThrows(); + if (throwz != null) { + for (int i = 0; i < throwz.size(); i++) { + throwz.set(i, (NameExpr) throwz.get(i).accept(this, arg)); + } + removeNulls(throwz); + } + if (n.getBody() != null) { + n.setBody((BlockStmt) n.getBody().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final NameExpr n, final A arg) { + return n; + } + + @Override public Node visit(final NormalAnnotationExpr n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + final List<MemberValuePair> pairs = n.getPairs(); + if (pairs != null) { + for (int i = 0; i < pairs.size(); i++) { + pairs.set(i, (MemberValuePair) pairs.get(i).accept(this, arg)); + } + removeNulls(pairs); + } + return n; + } + + @Override public Node visit(final NullLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final ObjectCreationExpr n, final A arg) { + if (n.getScope() != null) { + n.setScope((Expression) n.getScope().accept(this, arg)); + } + final List<Type> typeArgs = n.getTypeArgs(); + if (typeArgs != null) { + for (int i = 0; i < typeArgs.size(); i++) { + typeArgs.set(i, (Type) typeArgs.get(i).accept(this, arg)); + } + removeNulls(typeArgs); + } + n.setType((ClassOrInterfaceType) n.getType().accept(this, arg)); + final List<Expression> args = n.getArgs(); + if (args != null) { + for (int i = 0; i < args.size(); i++) { + args.set(i, (Expression) args.get(i).accept(this, arg)); + } + removeNulls(args); + } + final List<BodyDeclaration> anonymousClassBody = n.getAnonymousClassBody(); + if (anonymousClassBody != null) { + for (int i = 0; i < anonymousClassBody.size(); i++) { + anonymousClassBody.set(i, (BodyDeclaration) anonymousClassBody.get(i).accept(this, arg)); + } + removeNulls(anonymousClassBody); + } + return n; + } + + @Override public Node visit(final PackageDeclaration n, final A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setName((NameExpr) n.getName().accept(this, arg)); + return n; + } + + @Override public Node visit(final Parameter n, final A arg) { + visit((BaseParameter) n, arg); + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(MultiTypeParameter n, A arg) { + visit((BaseParameter) n, arg); + List<Type> types = new LinkedList<Type>(); + for (Type type : n.getTypes()) { + types.add((Type) type.accept(this, arg)); + } + n.setTypes(types); + return n; + } + + protected Node visit(final BaseParameter n, final A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + + n.setId((VariableDeclaratorId) n.getId().accept(this, arg)); + return n; + } + + @Override public Node visit(final PrimitiveType n, final A arg) { + return n; + } + + @Override public Node visit(final QualifiedNameExpr n, final A arg) { + n.setQualifier((NameExpr) n.getQualifier().accept(this, arg)); + return n; + } + + @Override public Node visit(final ReferenceType n, final A arg) { + n.setType((Type) n.getType().accept(this, arg)); + return n; + } + + @Override public Node visit(final ReturnStmt n, final A arg) { + if (n.getExpr() != null) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final SingleMemberAnnotationExpr n, final A arg) { + n.setName((NameExpr) n.getName().accept(this, arg)); + n.setMemberValue((Expression) n.getMemberValue().accept(this, arg)); + return n; + } + + @Override public Node visit(final StringLiteralExpr n, final A arg) { + return n; + } + + @Override public Node visit(final SuperExpr n, final A arg) { + if (n.getClassExpr() != null) { + n.setClassExpr((Expression) n.getClassExpr().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final SwitchEntryStmt n, final A arg) { + if (n.getLabel() != null) { + n.setLabel((Expression) n.getLabel().accept(this, arg)); + } + final List<Statement> stmts = n.getStmts(); + if (stmts != null) { + for (int i = 0; i < stmts.size(); i++) { + stmts.set(i, (Statement) stmts.get(i).accept(this, arg)); + } + removeNulls(stmts); + } + return n; + } + + @Override public Node visit(final SwitchStmt n, final A arg) { + n.setSelector((Expression) n.getSelector().accept(this, arg)); + final List<SwitchEntryStmt> entries = n.getEntries(); + if (entries != null) { + for (int i = 0; i < entries.size(); i++) { + entries.set(i, (SwitchEntryStmt) entries.get(i).accept(this, arg)); + } + removeNulls(entries); + } + return n; + + } + + @Override public Node visit(final SynchronizedStmt n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + n.setBlock((BlockStmt) n.getBlock().accept(this, arg)); + return n; + } + + @Override public Node visit(final ThisExpr n, final A arg) { + if (n.getClassExpr() != null) { + n.setClassExpr((Expression) n.getClassExpr().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final ThrowStmt n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final TryStmt n, final A arg) { + n.setTryBlock((BlockStmt) n.getTryBlock().accept(this, arg)); + final List<CatchClause> catchs = n.getCatchs(); + if (catchs != null) { + for (int i = 0; i < catchs.size(); i++) { + catchs.set(i, (CatchClause) catchs.get(i).accept(this, arg)); + } + removeNulls(catchs); + } + if (n.getFinallyBlock() != null) { + n.setFinallyBlock((BlockStmt) n.getFinallyBlock().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final TypeDeclarationStmt n, final A arg) { + n.setTypeDeclaration((TypeDeclaration) n.getTypeDeclaration().accept(this, arg)); + return n; + } + + @Override public Node visit(final TypeParameter n, final A arg) { + final List<ClassOrInterfaceType> typeBound = n.getTypeBound(); + if (typeBound != null) { + for (int i = 0; i < typeBound.size(); i++) { + typeBound.set(i, (ClassOrInterfaceType) typeBound.get(i).accept(this, arg)); + } + removeNulls(typeBound); + } + return n; + } + + @Override public Node visit(final UnaryExpr n, final A arg) { + n.setExpr((Expression) n.getExpr().accept(this, arg)); + return n; + } + + @Override public Node visit(final UnknownType n, final A arg) { + return n; + } + + @Override public Node visit(final VariableDeclarationExpr n, final A arg) { + final List<AnnotationExpr> annotations = n.getAnnotations(); + if (annotations != null) { + for (int i = 0; i < annotations.size(); i++) { + annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); + } + removeNulls(annotations); + } + n.setType((Type) n.getType().accept(this, arg)); + final List<VariableDeclarator> vars = n.getVars(); + for (int i = 0; i < vars.size(); i++) { + vars.set(i, (VariableDeclarator) vars.get(i).accept(this, arg)); + } + removeNulls(vars); + return n; + } + + @Override public Node visit(final VariableDeclarator n, final A arg) { + n.setId((VariableDeclaratorId) n.getId().accept(this, arg)); + if (n.getInit() != null) { + n.setInit((Expression) n.getInit().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final VariableDeclaratorId n, final A arg) { + return n; + } + + @Override public Node visit(final VoidType n, final A arg) { + return n; + } + + @Override public Node visit(final WhileStmt n, final A arg) { + n.setCondition((Expression) n.getCondition().accept(this, arg)); + n.setBody((Statement) n.getBody().accept(this, arg)); + return n; + } + + @Override public Node visit(final WildcardType n, final A arg) { + if (n.getExtends() != null) { + n.setExtends((ReferenceType) n.getExtends().accept(this, arg)); + } + if (n.getSuper() != null) { + n.setSuper((ReferenceType) n.getSuper().accept(this, arg)); + } + return n; + } + + @Override public Node visit(final LambdaExpr n, final A arg) { + return n; + } + + @Override public Node visit(final MethodReferenceExpr n, final A arg){ + return n; + } + + @Override public Node visit(final TypeExpr n, final A arg){ + return n; + } + + @Override public Node visit(final BlockComment n, final A arg) { + return n; + } + + @Override public Node visit(final LineComment n, final A arg) { + return n; + } + +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitor.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitor.java new file mode 100644 index 000000000..b85bd55a7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitor.java @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +/** + * A visitor that does not return anything. + * + * @author Julio Vilmar Gesser + */ +public interface VoidVisitor<A> { + + //- Compilation Unit ---------------------------------- + + void visit(CompilationUnit n, A arg); + + void visit(PackageDeclaration n, A arg); + + void visit(ImportDeclaration n, A arg); + + void visit(TypeParameter n, A arg); + + void visit(LineComment n, A arg); + + void visit(BlockComment n, A arg); + + //- Body ---------------------------------------------- + + void visit(ClassOrInterfaceDeclaration n, A arg); + + void visit(EnumDeclaration n, A arg); + + void visit(EmptyTypeDeclaration n, A arg); + + void visit(EnumConstantDeclaration n, A arg); + + void visit(AnnotationDeclaration n, A arg); + + void visit(AnnotationMemberDeclaration n, A arg); + + void visit(FieldDeclaration n, A arg); + + void visit(VariableDeclarator n, A arg); + + void visit(VariableDeclaratorId n, A arg); + + void visit(ConstructorDeclaration n, A arg); + + void visit(MethodDeclaration n, A arg); + + void visit(Parameter n, A arg); + + void visit(MultiTypeParameter n, A arg); + + void visit(EmptyMemberDeclaration n, A arg); + + void visit(InitializerDeclaration n, A arg); + + void visit(JavadocComment n, A arg); + + //- Type ---------------------------------------------- + + void visit(ClassOrInterfaceType n, A arg); + + void visit(PrimitiveType n, A arg); + + void visit(ReferenceType n, A arg); + + void visit(VoidType n, A arg); + + void visit(WildcardType n, A arg); + + void visit(UnknownType n, A arg); + + //- Expression ---------------------------------------- + + void visit(ArrayAccessExpr n, A arg); + + void visit(ArrayCreationExpr n, A arg); + + void visit(ArrayInitializerExpr n, A arg); + + void visit(AssignExpr n, A arg); + + void visit(BinaryExpr n, A arg); + + void visit(CastExpr n, A arg); + + void visit(ClassExpr n, A arg); + + void visit(ConditionalExpr n, A arg); + + void visit(EnclosedExpr n, A arg); + + void visit(FieldAccessExpr n, A arg); + + void visit(InstanceOfExpr n, A arg); + + void visit(StringLiteralExpr n, A arg); + + void visit(IntegerLiteralExpr n, A arg); + + void visit(LongLiteralExpr n, A arg); + + void visit(IntegerLiteralMinValueExpr n, A arg); + + void visit(LongLiteralMinValueExpr n, A arg); + + void visit(CharLiteralExpr n, A arg); + + void visit(DoubleLiteralExpr n, A arg); + + void visit(BooleanLiteralExpr n, A arg); + + void visit(NullLiteralExpr n, A arg); + + void visit(MethodCallExpr n, A arg); + + void visit(NameExpr n, A arg); + + void visit(ObjectCreationExpr n, A arg); + + void visit(QualifiedNameExpr n, A arg); + + void visit(ThisExpr n, A arg); + + void visit(SuperExpr n, A arg); + + void visit(UnaryExpr n, A arg); + + void visit(VariableDeclarationExpr n, A arg); + + void visit(MarkerAnnotationExpr n, A arg); + + void visit(SingleMemberAnnotationExpr n, A arg); + + void visit(NormalAnnotationExpr n, A arg); + + void visit(MemberValuePair n, A arg); + + //- Statements ---------------------------------------- + + void visit(ExplicitConstructorInvocationStmt n, A arg); + + void visit(TypeDeclarationStmt n, A arg); + + void visit(AssertStmt n, A arg); + + void visit(BlockStmt n, A arg); + + void visit(LabeledStmt n, A arg); + + void visit(EmptyStmt n, A arg); + + void visit(ExpressionStmt n, A arg); + + void visit(SwitchStmt n, A arg); + + void visit(SwitchEntryStmt n, A arg); + + void visit(BreakStmt n, A arg); + + void visit(ReturnStmt n, A arg); + + void visit(IfStmt n, A arg); + + void visit(WhileStmt n, A arg); + + void visit(ContinueStmt n, A arg); + + void visit(DoStmt n, A arg); + + void visit(ForeachStmt n, A arg); + + void visit(ForStmt n, A arg); + + void visit(ThrowStmt n, A arg); + + void visit(SynchronizedStmt n, A arg); + + void visit(TryStmt n, A arg); + + void visit(CatchClause n, A arg); + + void visit(LambdaExpr n, A arg); + + void visit(MethodReferenceExpr n, A arg); + + void visit(TypeExpr n, A arg); +} diff --git a/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java new file mode 100644 index 000000000..ddad12fb7 --- /dev/null +++ b/javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_src/proper_source/com/github/javaparser/ast/visitor/VoidVisitorAdapter.java @@ -0,0 +1,846 @@ +/* + * Copyright (C) 2007-2010 Júlio Vilmar Gesser. + * Copyright (C) 2011, 2013-2015 The JavaParser Team. + * + * This file is part of JavaParser. + * + * JavaParser can be used either under the terms of + * a) the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * b) the terms of the Apache License + * + * You should have received a copy of both licenses in LICENCE.LGPL and + * LICENCE.APACHE. Please refer to those files for details. + * + * JavaParser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +package com.github.javaparser.ast.visitor; + +import com.github.javaparser.ast.comments.BlockComment; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.ImportDeclaration; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.PackageDeclaration; +import com.github.javaparser.ast.TypeParameter; +import com.github.javaparser.ast.body.AnnotationDeclaration; +import com.github.javaparser.ast.body.AnnotationMemberDeclaration; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.EmptyMemberDeclaration; +import com.github.javaparser.ast.body.EmptyTypeDeclaration; +import com.github.javaparser.ast.body.EnumConstantDeclaration; +import com.github.javaparser.ast.body.EnumDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.InitializerDeclaration; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.MultiTypeParameter; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.body.VariableDeclaratorId; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.stmt.AssertStmt; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.BreakStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ContinueStmt; +import com.github.javaparser.ast.stmt.DoStmt; +import com.github.javaparser.ast.stmt.EmptyStmt; +import com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt; +import com.github.javaparser.ast.stmt.ExpressionStmt; +import com.github.javaparser.ast.stmt.ForStmt; +import com.github.javaparser.ast.stmt.ForeachStmt; +import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.LabeledStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.stmt.SwitchEntryStmt; +import com.github.javaparser.ast.stmt.SwitchStmt; +import com.github.javaparser.ast.stmt.SynchronizedStmt; +import com.github.javaparser.ast.stmt.ThrowStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.stmt.TypeDeclarationStmt; +import com.github.javaparser.ast.stmt.WhileStmt; +import com.github.javaparser.ast.type.*; + +import static com.github.javaparser.ast.internal.Utils.isNullOrEmpty; + +/** + * @author Julio Vilmar Gesser + */ +public abstract class VoidVisitorAdapter<A> implements VoidVisitor<A> { + + @Override public void visit(final AnnotationDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final AnnotationMemberDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + if (n.getDefaultValue() != null) { + n.getDefaultValue().accept(this, arg); + } + } + + @Override public void visit(final ArrayAccessExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + n.getIndex().accept(this, arg); + } + + @Override public void visit(final ArrayCreationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + if (!isNullOrEmpty(n.getDimensions())) { + for (final Expression dim : n.getDimensions()) { + dim.accept(this, arg); + } + } else { + n.getInitializer().accept(this, arg); + } + } + + @Override public void visit(final ArrayInitializerExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getValues() != null) { + for (final Expression expr : n.getValues()) { + expr.accept(this, arg); + } + } + } + + @Override public void visit(final AssertStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getCheck().accept(this, arg); + if (n.getMessage() != null) { + n.getMessage().accept(this, arg); + } + } + + @Override public void visit(final AssignExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getTarget().accept(this, arg); + n.getValue().accept(this, arg); + } + + @Override public void visit(final BinaryExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getLeft().accept(this, arg); + n.getRight().accept(this, arg); + } + + @Override public void visit(final BlockComment n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final BlockStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + } + } + } + + @Override public void visit(final BooleanLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final BreakStmt n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final CastExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final CatchClause n, final A arg) { + visitComment(n.getComment(), arg); + n.getExcept().accept(this, arg); + n.getCatchBlock().accept(this, arg); + } + + @Override public void visit(final CharLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final ClassExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + } + + @Override public void visit(final ClassOrInterfaceDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + if (n.getExtends() != null) { + for (final ClassOrInterfaceType c : n.getExtends()) { + c.accept(this, arg); + } + } + + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + c.accept(this, arg); + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final ClassOrInterfaceType n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + } + + @Override public void visit(final CompilationUnit n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getPackage() != null) { + n.getPackage().accept(this, arg); + } + if (n.getImports() != null) { + for (final ImportDeclaration i : n.getImports()) { + i.accept(this, arg); + } + } + if (n.getTypes() != null) { + for (final TypeDeclaration typeDeclaration : n.getTypes()) { + typeDeclaration.accept(this, arg); + } + } + } + + @Override public void visit(final ConditionalExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + n.getThenExpr().accept(this, arg); + n.getElseExpr().accept(this, arg); + } + + @Override public void visit(final ConstructorDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + p.accept(this, arg); + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + name.accept(this, arg); + } + } + n.getBlock().accept(this, arg); + } + + @Override public void visit(final ContinueStmt n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final DoStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getBody().accept(this, arg); + n.getCondition().accept(this, arg); + } + + @Override public void visit(final DoubleLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final EmptyMemberDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + } + + @Override public void visit(final EmptyStmt n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final EmptyTypeDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + } + + @Override public void visit(final EnclosedExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getInner().accept(this, arg); + } + + @Override public void visit(final EnumConstantDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + if (n.getClassBody() != null) { + for (final BodyDeclaration member : n.getClassBody()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final EnumDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getImplements() != null) { + for (final ClassOrInterfaceType c : n.getImplements()) { + c.accept(this, arg); + } + } + if (n.getEntries() != null) { + for (final EnumConstantDeclaration e : n.getEntries()) { + e.accept(this, arg); + } + } + if (n.getMembers() != null) { + for (final BodyDeclaration member : n.getMembers()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final ExplicitConstructorInvocationStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (!n.isThis()) { + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + } + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + } + + @Override public void visit(final ExpressionStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpression().accept(this, arg); + } + + @Override public void visit(final FieldAccessExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getScope().accept(this, arg); + } + + @Override public void visit(final FieldDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + for (final VariableDeclarator var : n.getVariables()) { + var.accept(this, arg); + } + } + + @Override public void visit(final ForeachStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getVariable().accept(this, arg); + n.getIterable().accept(this, arg); + n.getBody().accept(this, arg); + } + + @Override public void visit(final ForStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getInit() != null) { + for (final Expression e : n.getInit()) { + e.accept(this, arg); + } + } + if (n.getCompare() != null) { + n.getCompare().accept(this, arg); + } + if (n.getUpdate() != null) { + for (final Expression e : n.getUpdate()) { + e.accept(this, arg); + } + } + n.getBody().accept(this, arg); + } + + @Override public void visit(final IfStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + n.getThenStmt().accept(this, arg); + if (n.getElseStmt() != null) { + n.getElseStmt().accept(this, arg); + } + } + + @Override public void visit(final ImportDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + } + + @Override public void visit(final InitializerDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + n.getBlock().accept(this, arg); + } + + @Override public void visit(final InstanceOfExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + n.getType().accept(this, arg); + } + + @Override public void visit(final IntegerLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final IntegerLiteralMinValueExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final JavadocComment n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final LabeledStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getStmt().accept(this, arg); + } + + @Override public void visit(final LineComment n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final LongLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final LongLiteralMinValueExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final MarkerAnnotationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + } + + @Override public void visit(final MemberValuePair n, final A arg) { + visitComment(n.getComment(), arg); + n.getValue().accept(this, arg); + } + + @Override public void visit(final MethodCallExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + } + + @Override public void visit(final MethodDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getJavaDoc() != null) { + n.getJavaDoc().accept(this, arg); + } + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + if (n.getTypeParameters() != null) { + for (final TypeParameter t : n.getTypeParameters()) { + t.accept(this, arg); + } + } + n.getType().accept(this, arg); + if (n.getParameters() != null) { + for (final Parameter p : n.getParameters()) { + p.accept(this, arg); + } + } + if (n.getThrows() != null) { + for (final NameExpr name : n.getThrows()) { + name.accept(this, arg); + } + } + if (n.getBody() != null) { + n.getBody().accept(this, arg); + } + } + + @Override public void visit(final NameExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final NormalAnnotationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + if (n.getPairs() != null) { + for (final MemberValuePair m : n.getPairs()) { + m.accept(this, arg); + } + } + } + + @Override public void visit(final NullLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final ObjectCreationExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + if (n.getTypeArgs() != null) { + for (final Type t : n.getTypeArgs()) { + t.accept(this, arg); + } + } + n.getType().accept(this, arg); + if (n.getArgs() != null) { + for (final Expression e : n.getArgs()) { + e.accept(this, arg); + } + } + if (n.getAnonymousClassBody() != null) { + for (final BodyDeclaration member : n.getAnonymousClassBody()) { + member.accept(this, arg); + } + } + } + + @Override public void visit(final PackageDeclaration n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getName().accept(this, arg); + } + + @Override public void visit(final Parameter n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + n.getId().accept(this, arg); + } + + @Override public void visit(final MultiTypeParameter n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + for (final Type type : n.getTypes()) { + type.accept(this, arg); + } + n.getId().accept(this, arg); + } + + @Override public void visit(final PrimitiveType n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final QualifiedNameExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getQualifier().accept(this, arg); + } + + @Override public void visit(final ReferenceType n, final A arg) { + visitComment(n.getComment(), arg); + n.getType().accept(this, arg); + } + + @Override public void visit(final ReturnStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getExpr() != null) { + n.getExpr().accept(this, arg); + } + } + + @Override public void visit(final SingleMemberAnnotationExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getName().accept(this, arg); + n.getMemberValue().accept(this, arg); + } + + @Override public void visit(final StringLiteralExpr n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final SuperExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + } + } + + @Override public void visit(final SwitchEntryStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getLabel() != null) { + n.getLabel().accept(this, arg); + } + if (n.getStmts() != null) { + for (final Statement s : n.getStmts()) { + s.accept(this, arg); + } + } + } + + @Override public void visit(final SwitchStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getSelector().accept(this, arg); + if (n.getEntries() != null) { + for (final SwitchEntryStmt e : n.getEntries()) { + e.accept(this, arg); + } + } + } + + @Override public void visit(final SynchronizedStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + n.getBlock().accept(this, arg); + } + + @Override public void visit(final ThisExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getClassExpr() != null) { + n.getClassExpr().accept(this, arg); + } + } + + @Override public void visit(final ThrowStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final TryStmt n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getResources() != null) { + for (final VariableDeclarationExpr v : n.getResources()) { + v.accept(this, arg); + } + } + n.getTryBlock().accept(this, arg); + if (n.getCatchs() != null) { + for (final CatchClause c : n.getCatchs()) { + c.accept(this, arg); + } + } + if (n.getFinallyBlock() != null) { + n.getFinallyBlock().accept(this, arg); + } + } + + @Override public void visit(final TypeDeclarationStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getTypeDeclaration().accept(this, arg); + } + + @Override public void visit(final TypeParameter n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getTypeBound() != null) { + for (final ClassOrInterfaceType c : n.getTypeBound()) { + c.accept(this, arg); + } + } + } + + @Override public void visit(final UnaryExpr n, final A arg) { + visitComment(n.getComment(), arg); + n.getExpr().accept(this, arg); + } + + @Override public void visit(final UnknownType n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final VariableDeclarationExpr n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getAnnotations() != null) { + for (final AnnotationExpr a : n.getAnnotations()) { + a.accept(this, arg); + } + } + n.getType().accept(this, arg); + for (final VariableDeclarator v : n.getVars()) { + v.accept(this, arg); + } + } + + @Override public void visit(final VariableDeclarator n, final A arg) { + visitComment(n.getComment(), arg); + n.getId().accept(this, arg); + if (n.getInit() != null) { + n.getInit().accept(this, arg); + } + } + + @Override public void visit(final VariableDeclaratorId n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final VoidType n, final A arg) { + visitComment(n.getComment(), arg); + } + + @Override public void visit(final WhileStmt n, final A arg) { + visitComment(n.getComment(), arg); + n.getCondition().accept(this, arg); + n.getBody().accept(this, arg); + } + + @Override public void visit(final WildcardType n, final A arg) { + visitComment(n.getComment(), arg); + if (n.getExtends() != null) { + n.getExtends().accept(this, arg); + } + if (n.getSuper() != null) { + n.getSuper().accept(this, arg); + } + } + + @Override + public void visit(LambdaExpr n, final A arg) { + if (n.getParameters() != null) { + for (final Parameter a : n.getParameters()) { + a.accept(this, arg); + } + } + if (n.getBody() != null) { + n.getBody().accept(this, arg); + } + } + + @Override + public void visit(MethodReferenceExpr n, final A arg) { + if (n.getTypeParameters() != null) { + for (final TypeParameter a : n.getTypeParameters()) { + a.accept(this, arg); + } + } + if (n.getScope() != null) { + n.getScope().accept(this, arg); + } + } + + @Override + public void visit(TypeExpr n, final A arg) { + if (n.getType() != null) { + n.getType().accept(this, arg); + } + } + + private void visitComment(final Comment n, final A arg) { + if (n != null) { + n.accept(this, arg); + } + } +} |