diff options
Diffstat (limited to 'javaparser-symbol-solver-testing/src/test/test_sourcecode/javaparser_new_src/javaparser-core/com/github/javaparser/ast/expr')
38 files changed, 3089 insertions, 0 deletions
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; + } +} |