Merge branch 'master' into issue-341
# Conflicts:
# javaparser-core/src/main/java/com/github/javaparser/ast/Node.java
# javaparser-core/src/main/java/com/github/javaparser/ast/body/ConstructorDeclaration.java
# javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyTypeDeclaration.java
# javaparser-core/src/main/java/com/github/javaparser/ast/body/MultiTypeParameter.java
# javaparser-core/src/main/java/com/github/javaparser/ast/type/IntersectionType.java
diff --git a/javaparser-core/src/main/java/com/github/javaparser/Position.java b/javaparser-core/src/main/java/com/github/javaparser/Position.java
index 522411c..1a75c4e 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/Position.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/Position.java
@@ -18,36 +18,102 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
-
+
package com.github.javaparser;
import com.github.javaparser.ast.Node;
-public class Position {
- private int line;
- private int column;
+/**
+ * A position in a source file. Lines and columns start counting at 1.
+ */
+public class Position implements Comparable<Position> {
+ public final int line;
+ public final int column;
- public static final Position ABSOLUTE_START = new Position(Node.ABSOLUTE_BEGIN_LINE,-1);
- public static final Position ABSOLUTE_END = new Position(Node.ABSOLUTE_END_LINE,-1);
+ public static final Position ABSOLUTE_START = new Position(Node.ABSOLUTE_BEGIN_LINE, -1);
+ public static final Position ABSOLUTE_END = new Position(Node.ABSOLUTE_END_LINE, -1);
- public static Position beginOf(Node node){
- return new Position(node.getBeginLine(),node.getBeginColumn());
- }
+ /**
+ * The first position in the file
+ */
+ public static final Position HOME = new Position(1, 1);
+ public static final Position UNKNOWN = new Position(0, 0);
- public static Position endOf(Node node){
- return new Position(node.getEndLine(),node.getEndColumn());
- }
+ public Position(int line, int column) {
+ if (line < Node.ABSOLUTE_END_LINE) {
+ throw new IllegalArgumentException("Can't position at line " + line);
+ }
+ if (column < -1) {
+ throw new IllegalArgumentException("Can't position at column " + column);
+ }
+ this.line = line;
+ this.column = column;
+ }
- public Position(int line, int column){
- this.line = line;
- this.column = column;
- }
+ /**
+ * Convenient factory method.
+ */
+ public static Position pos(int line, int column) {
+ return new Position(line, column);
+ }
- public int getLine(){
- return this.line;
- }
+ public Position withColumn(int column) {
+ return new Position(this.line, column);
+ }
- public int getColumn(){
- return this.column;
- }
+ public Position withLine(int line) {
+ return new Position(line, this.column);
+ }
+
+ public boolean isAfter(Position position) {
+ if (position.line == Node.ABSOLUTE_BEGIN_LINE) return true;
+ if (line > position.line) {
+ return true;
+ } else if (line == position.line) {
+ return column > position.column;
+ }
+ return false;
+
+ }
+
+ public boolean isBefore(Position position) {
+ if (position.line == Node.ABSOLUTE_END_LINE) return true;
+ if (line < position.line) {
+ return true;
+ } else if (line == position.line) {
+ return column < position.column;
+ }
+ return false;
+ }
+
+ @Override
+ public int compareTo(Position o) {
+ if (isBefore(o)) {
+ return -1;
+ }
+ if (isAfter(o)) {
+ return 1;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Position position = (Position) o;
+
+ return line == position.line && column == position.column;
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * line + column;
+ }
+
+ @Override
+ public String toString() {
+ return "(line " + line + ",col " + column + ")";
+ }
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/Range.java b/javaparser-core/src/main/java/com/github/javaparser/Range.java
new file mode 100644
index 0000000..68e364a
--- /dev/null
+++ b/javaparser-core/src/main/java/com/github/javaparser/Range.java
@@ -0,0 +1,89 @@
+package com.github.javaparser;
+
+import static com.github.javaparser.Position.pos;
+
+/**
+ * A range of characters in a source file, from "begin" to "end", including the characters at "begin" and "end".
+ */
+public class Range {
+ public static final Range UNKNOWN = range(Position.UNKNOWN, Position.UNKNOWN);
+
+ public final Position begin;
+ public final Position end;
+
+ public Range(Position begin, Position end) {
+ if (begin == null) {
+ throw new IllegalArgumentException("begin can't be null");
+ }
+ if (end == null) {
+ throw new IllegalArgumentException("end can't be null");
+ }
+ this.begin = begin;
+ this.end = end;
+ }
+
+ public static Range range(Position begin, Position end) {
+ return new Range(begin, end);
+ }
+
+ public static Range range(int beginLine, int beginColumn, int endLine, int endColumn) {
+ return new Range(pos(beginLine, beginColumn), pos(endLine, endColumn));
+ }
+
+ public Range withBeginColumn(int column) {
+ return range(begin.withColumn(column), end);
+ }
+
+ public Range withBeginLine(int line) {
+ return range(begin.withLine(line), end);
+ }
+
+ public Range withEndColumn(int column) {
+ return range(begin, end.withColumn(column));
+ }
+
+ public Range withEndLine(int line) {
+ return range(begin, end.withLine(line));
+ }
+
+ public Range withBegin(Position begin) {
+ return range(begin, this.end);
+ }
+
+ public Range withEnd(Position end) {
+ return range(this.begin, end);
+ }
+
+ public boolean contains(Range other) {
+ return begin.isBefore(other.begin) && end.isAfter(other.end);
+ }
+
+ public boolean isBefore(Position position) {
+ return end.isBefore(position);
+ }
+
+ public boolean isAfter(Position position) {
+ return begin.isAfter(position);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Range range = (Range) o;
+
+ return begin.equals(range.begin) && end.equals(range.end);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * begin.hashCode() + end.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return begin+"-"+end;
+ }
+}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/CompilationUnit.java b/javaparser-core/src/main/java/com/github/javaparser/ast/CompilationUnit.java
index 1363624..5ceee38 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/CompilationUnit.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/CompilationUnit.java
@@ -21,19 +21,18 @@
package com.github.javaparser.ast;
-import com.github.javaparser.ast.body.AnnotationDeclaration;
-import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
-import com.github.javaparser.ast.body.EmptyTypeDeclaration;
-import com.github.javaparser.ast.body.EnumDeclaration;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
+import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.ast.comments.JavadocComment;
-import com.github.javaparser.ast.body.TypeDeclaration;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
-import static com.github.javaparser.ast.internal.Utils.*;
+import static com.github.javaparser.Position.pos;
+import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
/**
* <p>
@@ -67,8 +66,16 @@
setTypes(types);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public CompilationUnit(int beginLine, int beginColumn, int endLine, int endColumn, PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), pakage, imports, types);
+ }
+
+ public CompilationUnit(Range range, PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types) {
+ super(range);
setPackage(pakage);
setImports(imports);
setTypes(types);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/ImportDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/ImportDeclaration.java
index e32d381..5b7495b 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/ImportDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/ImportDeclaration.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* <p>
* This class represents a import declaration or an empty import declaration. Imports are optional for the
@@ -52,8 +56,16 @@
asterisk = false;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
private ImportDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ private ImportDeclaration(Range range) {
+ super(range);
this.isEmptyImportDeclaration = true;
static_ = false;
asterisk = false;
@@ -68,11 +80,20 @@
/**
* Create an empty import declaration specifying its position.
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public static ImportDeclaration createEmptyDeclaration(int beginLine, int beginColumn, int endLine, int endColumn){
return new ImportDeclaration(beginLine, beginColumn, endLine, endColumn);
}
+ /**
+ * Create an empty import declaration specifying its position.
+ */
+ public static ImportDeclaration createEmptyDeclaration(Range range){
+ return new ImportDeclaration(range);
+ }
+
public ImportDeclaration(NameExpr name, boolean isStatic, boolean isAsterisk) {
setAsterisk(isAsterisk);
setName(name);
@@ -80,8 +101,16 @@
this.isEmptyImportDeclaration = false;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ImportDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, NameExpr name, boolean isStatic, boolean isAsterisk) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, isStatic, isAsterisk);
+ }
+
+ public ImportDeclaration(Range range, NameExpr name, boolean isStatic, boolean isAsterisk) {
+ super(range);
setAsterisk(isAsterisk);
setName(name);
setStatic(isStatic);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/Node.java b/javaparser-core/src/main/java/com/github/javaparser/ast/Node.java
index ca86f90..66e2ebd 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/Node.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/Node.java
@@ -21,11 +21,16 @@
package com.github.javaparser.ast;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
+import com.github.javaparser.ast.comments.Comment;
+import com.github.javaparser.ast.visitor.*;
+
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import com.github.javaparser.ast.comments.Comment;
-import com.github.javaparser.ast.visitor.*;
+import static com.github.javaparser.Position.pos;
/**
* Abstract class for all nodes of the AST.
@@ -37,14 +42,7 @@
* @author Julio Vilmar Gesser
*/
public abstract class Node implements Cloneable {
-
- private int beginLine;
-
- private int beginColumn;
-
- private int endLine;
-
- private int endColumn;
+ private Range range;
private Node parentNode;
@@ -59,13 +57,19 @@
private Comment comment;
public Node() {
+ this(Range.UNKNOWN);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public Node(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- this.beginLine = beginLine;
- this.beginColumn = beginColumn;
- this.endLine = endLine;
- this.endColumn = endColumn;
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public Node(Range range) {
+ this.range = range;
}
/**
@@ -99,18 +103,22 @@
* Return the begin column of this node.
*
* @return the begin column of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final int getBeginColumn() {
- return beginColumn;
+ return range.begin.column;
}
/**
* Return the begin line of this node.
*
* @return the begin line of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final int getBeginLine() {
- return beginLine;
+ return range.begin.line;
}
/**
@@ -135,18 +143,22 @@
* Return the end column of this node.
*
* @return the end column of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final int getEndColumn() {
- return endColumn;
+ return range.end.column;
}
/**
* Return the end line of this node.
*
* @return the end line of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final int getEndLine() {
- return endLine;
+ return range.end.line;
}
/**
@@ -154,9 +166,11 @@
*
* @param beginColumn
* the begin column of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final void setBeginColumn(final int beginColumn) {
- this.beginColumn = beginColumn;
+ range = range.withBeginColumn(beginColumn);
}
/**
@@ -164,9 +178,39 @@
*
* @param beginLine
* the begin line of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final void setBeginLine(final int beginLine) {
- this.beginLine = beginLine;
+ range=range.withBeginLine(beginLine);
+ }
+
+ /**
+ * The begin position of this node in the source file.
+ */
+ public Position getBegin() {
+ return range.begin;
+ }
+
+ /**
+ * The end position of this node in the source file.
+ */
+ public Position getEnd() {
+ return range.end;
+ }
+
+ /**
+ * Sets the begin position of this node in the source file.
+ */
+ public void setBegin(Position begin) {
+ range=range.withBegin(begin);
+ }
+
+ /**
+ * Sets the end position of this node in the source file.
+ */
+ public void setEnd(Position end) {
+ range=range.withEnd(end);
}
/**
@@ -202,9 +246,11 @@
*
* @param endColumn
* the end column of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final void setEndColumn(final int endColumn) {
- this.endColumn = endColumn;
+ range = range.withEndColumn(endColumn);
}
/**
@@ -212,9 +258,11 @@
*
* @param endLine
* the end line of this node
+ * @deprecated prefer using Range objects.
*/
+ @Deprecated
public final void setEndLine(final int endLine) {
- this.endLine = endLine;
+ range = range.withEndLine(endLine);
}
/**
@@ -262,10 +310,7 @@
}
public boolean contains(Node other) {
- if (getBeginLine() > other.getBeginLine()) return false;
- if (getBeginLine() == other.getBeginLine() && getBeginColumn() > other.getBeginColumn()) return false;
- if (getEndLine() < other.getEndLine()) return false;
- return !(getEndLine() == other.getEndLine() && getEndColumn() < other.getEndColumn());
+ return range.contains(other.range);
}
public void addOrphanComment(Comment comment) {
@@ -343,26 +388,27 @@
public static final int ABSOLUTE_BEGIN_LINE = -1;
public static final int ABSOLUTE_END_LINE = -2;
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public boolean isPositionedAfter(int line, int column) {
- if (line == ABSOLUTE_BEGIN_LINE) return true;
- if (getBeginLine() > line) {
- return true;
- } else if (getBeginLine() == line) {
- return getBeginColumn() > column;
- } else {
- return false;
- }
+ return range.isAfter(pos(line, column));
}
+ public boolean isPositionedAfter(Position position) {
+ return range.isAfter(position);
+ }
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public boolean isPositionedBefore(int line, int column) {
- if (line == ABSOLUTE_END_LINE) return true;
- if (getEndLine() < line) {
- return true;
- } else if (getEndLine() == line) {
- return getEndColumn() < column;
- } else {
- return false;
- }
+ return range.isBefore(pos(line, column));
+ }
+
+ public boolean isPositionedBefore(Position position) {
+ return range.isBefore(position);
}
public boolean hasComment() {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/PackageDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/PackageDeclaration.java
index ba41306..efa0516 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/PackageDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/PackageDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.ast.internal.Utils;
@@ -29,6 +30,8 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* <p>
* This class represents the package declaration. The package declaration is
@@ -60,8 +63,16 @@
setName(name);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public PackageDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, NameExpr name) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), annotations, name);
+ }
+
+ public PackageDeclaration(Range range, List<AnnotationExpr> annotations, NameExpr name) {
+ super(range);
setAnnotations(annotations);
setName(name);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/TypeParameter.java b/javaparser-core/src/main/java/com/github/javaparser/ast/TypeParameter.java
index 57e069f..c3378f0 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/TypeParameter.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/TypeParameter.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +29,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
/**
@@ -58,9 +60,17 @@
setTypeBound(typeBound);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public TypeParameter(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String name, final List<ClassOrInterfaceType> typeBound) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final String name, final List<ClassOrInterfaceType> typeBound) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, typeBound);
+ }
+
+ public TypeParameter(Range range, final String name, final List<ClassOrInterfaceType> typeBound) {
+ super(range);
setName(name);
setTypeBound(typeBound);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationDeclaration.java
index 9750d5e..b69866c 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationDeclaration.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -43,8 +46,16 @@
super(annotations, modifiers, name, members);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public AnnotationDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) {
- super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, name, members);
+ }
+
+ public AnnotationDeclaration(Range range, int modifiers, List<AnnotationExpr> annotations, String name, List<BodyDeclaration> members) {
+ super(range, annotations, modifiers, name, members);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java
index 8b6a3f2..ca2c6e8 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/AnnotationMemberDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.DocumentableNode;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.NodeWithModifiers;
@@ -34,6 +35,8 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -65,8 +68,16 @@
setDefaultValue(defaultValue);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public AnnotationMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, type, name, defaultValue);
+ }
+
+ public AnnotationMemberDeclaration(Range range, int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) {
+ super(range, annotations);
setModifiers(modifiers);
setType(type);
setName(name);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/BaseParameter.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/BaseParameter.java
index 78a9d2e..0f67cea 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/BaseParameter.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/BaseParameter.java
@@ -23,10 +23,13 @@
import java.util.List;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.NodeWithModifiers;
import com.github.javaparser.ast.expr.AnnotationExpr;
+
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
public abstract class BaseParameter
@@ -57,8 +60,16 @@
setId(id);
}
- public BaseParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
- super(beginLine, beginColumn, endLine, endColumn);
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
+ public BaseParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, id);
+ }
+
+ public BaseParameter(final Range range, int modifiers, List<AnnotationExpr> annotations, VariableDeclaratorId id) {
+ super(range);
setModifiers(modifiers);
setAnnotations(annotations);
setId(id);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/BodyDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/BodyDeclaration.java
index a810ce7..82ae51f 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/BodyDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/BodyDeclaration.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.internal.Utils;
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -41,8 +44,16 @@
setAnnotations(annotations);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public BodyDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), annotations);
+ }
+
+ public BodyDeclaration(Range range, List<AnnotationExpr> annotations) {
+ super(range);
setAnnotations(annotations);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java
index 6e5695b..b512fef 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/ClassOrInterfaceDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypeParameter;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
@@ -29,6 +30,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
/**
@@ -64,12 +66,23 @@
setImplements(implementsList);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ClassOrInterfaceDeclaration(final int beginLine, final int beginColumn, final int endLine,
final int endColumn, final int modifiers,
final List<AnnotationExpr> annotations, final boolean isInterface, final String name,
final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList,
final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) {
- super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, isInterface, name, typeParameters, extendsList, implementsList, members);
+ }
+
+ public ClassOrInterfaceDeclaration(Range range, final int modifiers,
+ final List<AnnotationExpr> annotations, final boolean isInterface, final String name,
+ final List<TypeParameter> typeParameters, final List<ClassOrInterfaceType> extendsList,
+ final List<ClassOrInterfaceType> implementsList, final List<BodyDeclaration> members) {
+ super(range, annotations, modifiers, name, members);
setInterface(isInterface);
setTypeParameters(typeParameters);
setExtends(extendsList);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/ConstructorDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/ConstructorDeclaration.java
index 010c497..1fa10e8 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/ConstructorDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/ConstructorDeclaration.java
@@ -23,6 +23,7 @@
import java.util.List;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.*;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.expr.AnnotationExpr;
@@ -32,6 +33,7 @@
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -71,10 +73,20 @@
setBlock(block);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ConstructorDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers,
List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name,
List<Parameter> parameters, List<ReferenceType> throws_, BlockStmt block) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, typeParameters, name, parameters, throws_, block);
+ }
+
+ public ConstructorDeclaration(Range range, int modifiers,
+ List<AnnotationExpr> annotations, List<TypeParameter> typeParameters, String name,
+ List<Parameter> parameters, List<ReferenceType> throws_, BlockStmt block) {
+ super(range, annotations);
setModifiers(modifiers);
setTypeParameters(typeParameters);
setName(name);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyMemberDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyMemberDeclaration.java
index 6360a4b..1abd174 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyMemberDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyMemberDeclaration.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.DocumentableNode;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -35,8 +38,16 @@
super(null);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public EmptyMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn, null);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public EmptyMemberDeclaration(Range range) {
+ super(range, null);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyTypeDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyTypeDeclaration.java
index 1e6c5e2..05e57f4 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyTypeDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EmptyTypeDeclaration.java
@@ -21,9 +21,13 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
+import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -33,8 +37,16 @@
super(null, 0, null, null);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public EmptyTypeDeclaration(int beginLine, int beginColumn, int endLine, int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn, null, 0, null, null);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public EmptyTypeDeclaration(Range range) {
+ super(range, null, 0, null, null);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumConstantDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumConstantDeclaration.java
index aace9bb..38fdcb3 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumConstantDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumConstantDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.DocumentableNode;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.comments.JavadocComment;
@@ -31,6 +32,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
/**
@@ -58,8 +60,16 @@
setClassBody(classBody);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public EnumConstantDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), annotations, name, args, classBody);
+ }
+
+ public EnumConstantDeclaration(Range range, List<AnnotationExpr> annotations, String name, List<Expression> args, List<BodyDeclaration> classBody) {
+ super(range, annotations);
setName(name);
setArgs(args);
setClassBody(classBody);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumDeclaration.java
index 01ed252..fc863e9 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/EnumDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +29,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -52,8 +54,16 @@
setEntries(entries);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public EnumDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) {
- super(beginLine, beginColumn, endLine, endColumn, annotations, modifiers, name, members);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, name, implementsList, entries, members);
+ }
+
+ public EnumDeclaration(Range range, int modifiers, List<AnnotationExpr> annotations, String name, List<ClassOrInterfaceType> implementsList, List<EnumConstantDeclaration> entries, List<BodyDeclaration> members) {
+ super(range, annotations, modifiers, name, members);
setImplements(implementsList);
setEntries(entries);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/FieldDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/FieldDeclaration.java
index 3237939..a966e43 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/FieldDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/FieldDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.DocumentableNode;
import com.github.javaparser.ast.NodeWithModifiers;
import com.github.javaparser.ast.TypedNode;
@@ -33,6 +34,7 @@
import java.util.ArrayList;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -70,8 +72,16 @@
setVariables(variables);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public FieldDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, type, variables);
+ }
+
+ public FieldDeclaration(Range range, int modifiers, List<AnnotationExpr> annotations, Type type, List<VariableDeclarator> variables) {
+ super(range, annotations);
setModifiers(modifiers);
setType(type);
setVariables(variables);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/InitializerDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/InitializerDeclaration.java
index 10fb629..5d88850 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/InitializerDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/InitializerDeclaration.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.DocumentableNode;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.stmt.BlockStmt;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -45,8 +48,16 @@
setBlock(block);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public InitializerDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, boolean isStatic, BlockStmt block) {
- super(beginLine, beginColumn, endLine, endColumn, null);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), isStatic, block);
+ }
+
+ public InitializerDeclaration(Range range, boolean isStatic, BlockStmt block) {
+ super(range, null);
setStatic(isStatic);
setBlock(block);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/MethodDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/MethodDeclaration.java
index 1667546..7c2e606 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/MethodDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/MethodDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.*;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.expr.AnnotationExpr;
@@ -33,6 +34,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
/**
@@ -88,11 +90,22 @@
setBody(body);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public MethodDeclaration(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final int modifiers, final List<AnnotationExpr> annotations,
final List<TypeParameter> typeParameters, final Type type, final String name,
final List<Parameter> parameters, final int arrayCount, final List<ReferenceType> throws_, final BlockStmt body) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, typeParameters, type, name, parameters, arrayCount, throws_, body);
+ }
+
+ public MethodDeclaration(Range range,
+ final int modifiers, final List<AnnotationExpr> annotations,
+ final List<TypeParameter> typeParameters, final Type type, final String name,
+ final List<Parameter> parameters, final int arrayCount, final List<ReferenceType> throws_, final BlockStmt body) {
+ super(range, annotations);
setModifiers(modifiers);
setTypeParameters(typeParameters);
setType(type);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/MultiTypeParameter.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/MultiTypeParameter.java
index 67ef1d8..a9fbf85 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/MultiTypeParameter.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/MultiTypeParameter.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.type.UnionType;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +29,9 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
+import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
+
public class MultiTypeParameter extends BaseParameter {
private UnionType type;
@@ -38,8 +42,16 @@
this.type = type;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public MultiTypeParameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, UnionType type, VariableDeclaratorId id) {
- super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, type, id);
+ }
+
+ public MultiTypeParameter(Range range, int modifiers, List<AnnotationExpr> annotations, UnionType type, VariableDeclaratorId id) {
+ super(range, modifiers, annotations, id);
this.type = type;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/Parameter.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/Parameter.java
index fdfc634..4cdbbad 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/Parameter.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/Parameter.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.type.Type;
@@ -29,6 +30,8 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -50,8 +53,16 @@
setType(type);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public Parameter(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, boolean isVarArgs, VariableDeclaratorId id) {
- super(beginLine, beginColumn, endLine, endColumn, modifiers, annotations, id);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, type, isVarArgs, id);
+ }
+
+ public Parameter(final Range range, int modifiers, List<AnnotationExpr> annotations, Type type, boolean isVarArgs, VariableDeclaratorId id) {
+ super(range, modifiers, annotations, id);
setType(type);
setVarArgs(isVarArgs);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/TypeDeclaration.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/TypeDeclaration.java
index 9c35461..691ccb2 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/TypeDeclaration.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/TypeDeclaration.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.DocumentableNode;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.NodeWithModifiers;
@@ -30,6 +31,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -60,11 +62,21 @@
setMembers(members);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public TypeDeclaration(int beginLine, int beginColumn, int endLine,
int endColumn, List<AnnotationExpr> annotations,
int modifiers, String name,
List<BodyDeclaration> members) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), annotations, modifiers, name, members);
+ }
+
+ public TypeDeclaration(Range range, List<AnnotationExpr> annotations,
+ int modifiers, String name,
+ List<BodyDeclaration> members) {
+ super(range, annotations);
setName(name);
setModifiers(modifiers);
setMembers(members);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclarator.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclarator.java
index 1890d9b..0fae315 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclarator.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclarator.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -53,8 +56,16 @@
setInit(init);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public VariableDeclarator(int beginLine, int beginColumn, int endLine, int endColumn, VariableDeclaratorId id, Expression init) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), id, init);
+ }
+
+ public VariableDeclarator(Range range, VariableDeclaratorId id, Expression init) {
+ super(range);
setId(id);
setInit(init);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclaratorId.java b/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclaratorId.java
index 1e1a839..eae209b 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclaratorId.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/body/VariableDeclaratorId.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.body;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -42,8 +45,16 @@
setName(name);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public VariableDeclaratorId(int beginLine, int beginColumn, int endLine, int endColumn, String name, int arrayCount) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, arrayCount);
+ }
+
+ public VariableDeclaratorId(Range range, String name, int arrayCount) {
+ super(range);
setName(name);
setArrayCount(arrayCount);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/BlockComment.java b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/BlockComment.java
index 299493b..d6d62f1 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/BlockComment.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/BlockComment.java
@@ -21,9 +21,12 @@
package com.github.javaparser.ast.comments;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* <p>
* AST node that represent block comments.
@@ -42,8 +45,16 @@
super(content);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public BlockComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
- super(beginLine, beginColumn, endLine, endColumn, content);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), content);
+ }
+
+ public BlockComment(Range range, String content) {
+ super(range, content);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/Comment.java b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/Comment.java
index 3173c9f..720f1fd 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/Comment.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/Comment.java
@@ -21,8 +21,11 @@
package com.github.javaparser.ast.comments;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
+import static com.github.javaparser.Position.pos;
+
/**
* Abstract class for all AST nodes that represent comments.
*
@@ -43,8 +46,16 @@
this.content = content;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public Comment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), content);
+ }
+
+ public Comment(Range range, String content) {
+ super(range);
this.content = content;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/JavadocComment.java b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/JavadocComment.java
index a070321..be160a8 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/JavadocComment.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/JavadocComment.java
@@ -21,9 +21,12 @@
package com.github.javaparser.ast.comments;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -36,8 +39,16 @@
super(content);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public JavadocComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
- super(beginLine, beginColumn, endLine, endColumn, content);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), content);
+ }
+
+ public JavadocComment(Range range, String content) {
+ super(range, content);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/LineComment.java b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/LineComment.java
index bff1ae5..79fdc40 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/comments/LineComment.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/comments/LineComment.java
@@ -21,9 +21,12 @@
package com.github.javaparser.ast.comments;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* <p>
* AST node that represent line comments.
@@ -41,8 +44,16 @@
super(content);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public LineComment(int beginLine, int beginColumn, int endLine, int endColumn, String content) {
- super(beginLine, beginColumn, endLine, endColumn, content);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), content);
+ }
+
+ public LineComment(Range range, String content) {
+ super(range, content);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AnnotationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AnnotationExpr.java
index 8c65e92..01cd8ef 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AnnotationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AnnotationExpr.java
@@ -21,6 +21,10 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
+
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -30,9 +34,17 @@
public AnnotationExpr() {}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public AnnotationExpr(int beginLine, int beginColumn, int endLine,
- int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ int endColumn) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public AnnotationExpr(Range range) {
+ super(range);
}
public NameExpr getName() {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayAccessExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayAccessExpr.java
index 7026d15..170bd55 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayAccessExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayAccessExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -41,8 +44,16 @@
setIndex(index);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ArrayAccessExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression name, Expression index) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, index);
+ }
+
+ public ArrayAccessExpr(Range range, Expression name, Expression index) {
+ super(range);
setName(name);
setIndex(index);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayCreationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayCreationExpr.java
index 4672cae..a4b8dd5 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayCreationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayCreationExpr.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +29,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -55,8 +57,16 @@
setDimensions(null);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, int arrayCount, ArrayInitializerExpr initializer) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type, arrayCount, initializer);
+ }
+
+ public ArrayCreationExpr(Range range, Type type, int arrayCount, ArrayInitializerExpr initializer) {
+ super(range);
setType(type);
setArrayCount(arrayCount);
setInitializer(initializer);
@@ -70,8 +80,16 @@
setInitializer(null);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ArrayCreationExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, List<Expression> dimensions, int arrayCount) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type, dimensions, arrayCount);
+ }
+
+ public ArrayCreationExpr(Range range, Type type, List<Expression> dimensions, int arrayCount) {
+ super(range);
setType(type);
setArrayCount(arrayCount);
setDimensions(dimensions);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayInitializerExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayInitializerExpr.java
index 0409626..80c0475 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayInitializerExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ArrayInitializerExpr.java
@@ -21,11 +21,13 @@
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.Position.pos;
import static com.github.javaparser.ast.internal.Utils.ensureNotNull;
/**
@@ -42,8 +44,16 @@
setValues(values);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ArrayInitializerExpr(int beginLine, int beginColumn, int endLine, int endColumn, List<Expression> values) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), values);
+ }
+
+ public ArrayInitializerExpr(Range range, List<Expression> values) {
+ super(range);
setValues(values);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AssignExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AssignExpr.java
index b6be137..87f5064 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AssignExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/AssignExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -59,8 +62,16 @@
setOperator(op);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public AssignExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression target, Expression value, Operator op) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), target, value, op);
+ }
+
+ public AssignExpr(Range range, Expression target, Expression value, Operator op) {
+ super(range);
setTarget(target);
setValue(value);
setOperator(op);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BinaryExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BinaryExpr.java
index 2187065..3698368 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BinaryExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BinaryExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -66,8 +69,16 @@
setOperator(op);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public BinaryExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression left, Expression right, Operator op) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), left, right, op);
+ }
+
+ public BinaryExpr(Range range, Expression left, Expression right, Operator op) {
+ super(range);
setLeft(left);
setRight(right);
setOperator(op);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BooleanLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BooleanLiteralExpr.java
index e92244a..ffa56f1 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BooleanLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/BooleanLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -38,8 +41,16 @@
setValue(value);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public BooleanLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, boolean value) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), value);
+ }
+
+ public BooleanLiteralExpr(Range range, boolean value) {
+ super(range);
setValue(value);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CastExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CastExpr.java
index d4a3cdb..fbc7768 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CastExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CastExpr.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -43,8 +46,16 @@
setExpr(expr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public CastExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type, Expression expr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type, expr);
+ }
+
+ public CastExpr(Range range, Type type, Expression expr) {
+ super(range);
setType(type);
setExpr(expr);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CharLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CharLiteralExpr.java
index 061805d..82ca769 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CharLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/CharLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -36,8 +39,16 @@
super(value);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public CharLiteralExpr(int beginLine, int beginColumn, int endLine, int endColumn, String value) {
- super(beginLine, beginColumn, endLine, endColumn, value);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), value);
+ }
+
+ public CharLiteralExpr(Range range, String value) {
+ super(range, value);
}
@Override
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ClassExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ClassExpr.java
index 3407e98..ad97aef 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ClassExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ClassExpr.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* Defines an expression that accesses the class of a type.
* Example:
@@ -45,8 +48,16 @@
setType(type);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ClassExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type);
+ }
+
+ public ClassExpr(Range range, Type type) {
+ super(range);
setType(type);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ConditionalExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ConditionalExpr.java
index 31db61c..d89fd1a 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ConditionalExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ConditionalExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -44,8 +47,16 @@
setElseExpr(elseExpr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ConditionalExpr(int beginLine, int beginColumn, int endLine, int endColumn, Expression condition, Expression thenExpr, Expression elseExpr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), condition, thenExpr, elseExpr);
+ }
+
+ public ConditionalExpr(Range range, Expression condition, Expression thenExpr, Expression elseExpr) {
+ super(range);
setCondition(condition);
setThenExpr(thenExpr);
setElseExpr(elseExpr);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/DoubleLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/DoubleLiteralExpr.java
index ce6962d..85ffb01 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/DoubleLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/DoubleLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -36,9 +39,16 @@
super(value);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public DoubleLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String value) {
- super(beginLine, beginColumn, endLine, endColumn, value);
+ final String value) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), 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) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/EnclosedExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/EnclosedExpr.java
index 72f9de2..dab7f29 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/EnclosedExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/EnclosedExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -38,9 +41,17 @@
setInner(inner);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public EnclosedExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression inner) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression inner) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), inner);
+ }
+
+ public EnclosedExpr(final Range range, final Expression inner) {
+ super(range);
setInner(inner);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/Expression.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/Expression.java
index 8b36d6b..45fe842 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/Expression.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/Expression.java
@@ -21,8 +21,12 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -31,8 +35,16 @@
public Expression() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public Expression(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public Expression(Range range) {
+ super(range);
}
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/FieldAccessExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/FieldAccessExpr.java
index 6e581f6..f1d4fa4 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/FieldAccessExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/FieldAccessExpr.java
@@ -21,12 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
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.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -48,9 +50,17 @@
setField(field);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public FieldAccessExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression scope, final List<Type> typeArgs, final String field) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression scope, final List<Type> typeArgs, final String field) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, typeArgs, field);
+ }
+
+ public FieldAccessExpr(final Range range, final Expression scope, final List<Type> typeArgs, final String field) {
+ super(range);
setScope(scope);
setTypeArgs(typeArgs);
setField(field);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/InstanceOfExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/InstanceOfExpr.java
index 459c1a2..d0426d6 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/InstanceOfExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/InstanceOfExpr.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -43,9 +46,17 @@
setType(type);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public InstanceOfExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression expr, final Type type) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression expr, final Type type) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), expr, type);
+ }
+
+ public InstanceOfExpr(final Range range, final Expression expr, final Type type) {
+ super(range);
setExpr(expr);
setType(type);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralExpr.java
index b326c57..7f1e1a4 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -40,9 +43,17 @@
super(value);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public IntegerLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String value) {
- super(beginLine, beginColumn, endLine, endColumn, value);
+ final String value) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), 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) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java
index 238b564..ba7b1bf 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/IntegerLiteralMinValueExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -33,8 +36,16 @@
super(MIN_VALUE);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public IntegerLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public IntegerLiteralMinValueExpr(final Range range) {
+ super(range, MIN_VALUE);
}
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LambdaExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LambdaExpr.java
index 5cc6c00..dc62185 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LambdaExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LambdaExpr.java
@@ -21,6 +21,7 @@
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;
@@ -28,6 +29,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -46,11 +48,20 @@
public LambdaExpr() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public LambdaExpr(int beginLine, int beginColumn, int endLine,
- int endColumn, List<Parameter> parameters, Statement body,
+ int endColumn, List<Parameter> parameters, Statement body,
+ boolean parametersEnclosed) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), parameters, body, parametersEnclosed);
+ }
+
+ public LambdaExpr(Range range, List<Parameter> parameters, Statement body,
boolean parametersEnclosed) {
- super(beginLine, beginColumn, endLine, endColumn);
+ super(range);
setParameters(parameters);
setBody(body);
setParametersEnclosed(parametersEnclosed);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LiteralExpr.java
index 7827f78..a8b296e 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LiteralExpr.java
@@ -21,6 +21,10 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
+
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -29,7 +33,15 @@
public LiteralExpr() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public LiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public LiteralExpr(Range range) {
+ super(range);
}
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralExpr.java
index 15ea255..4328e31 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -40,9 +43,17 @@
super(value);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public LongLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String value) {
- super(beginLine, beginColumn, endLine, endColumn, value);
+ final String value) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), 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) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java
index f351f7a..aa1ea69 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/LongLiteralMinValueExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -33,8 +36,16 @@
super(MIN_VALUE);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public LongLiteralMinValueExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn, MIN_VALUE);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public LongLiteralMinValueExpr(final Range range) {
+ super(range, MIN_VALUE);
}
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java
index c1a3545..3457637 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MarkerAnnotationExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -36,9 +39,17 @@
setName(name);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public MarkerAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final NameExpr name) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final NameExpr name) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name);
+ }
+
+ public MarkerAnnotationExpr(final Range range, final NameExpr name) {
+ super(range);
setName(name);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MemberValuePair.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MemberValuePair.java
index 324ce7d..628b5c3 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MemberValuePair.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MemberValuePair.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -43,9 +46,17 @@
setValue(value);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public MemberValuePair(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String name, final Expression value) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final String name, final Expression value) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, value);
+ }
+
+ public MemberValuePair(final Range range, final String name, final Expression value) {
+ super(range);
setName(name);
setValue(value);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodCallExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodCallExpr.java
index 4b30715..10148ec 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodCallExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodCallExpr.java
@@ -21,12 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
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.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -56,9 +58,17 @@
setArgs(args);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public MethodCallExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, typeArgs, name, args);
+ }
+
+ public MethodCallExpr(final Range range, final Expression scope, final List<Type> typeArgs, final String name, final List<Expression> args) {
+ super(range);
setScope(scope);
setTypeArgs(typeArgs);
setName(name);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodReferenceExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodReferenceExpr.java
index 8fac124..a7493a1 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodReferenceExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/MethodReferenceExpr.java
@@ -21,12 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypeParameter;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -50,11 +52,19 @@
public MethodReferenceExpr() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public MethodReferenceExpr(int beginLine, int beginColumn, int endLine,
int endColumn, Expression scope,
List<TypeParameter> typeParameters, String identifier) {
-
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, typeParameters, identifier);
+ }
+
+ public MethodReferenceExpr(Range range, Expression scope,
+ List<TypeParameter> typeParameters, String identifier) {
+ super(range);
setIdentifier(identifier);
setScope(scope);
setTypeParameters(typeParameters);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NameExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NameExpr.java
index cd15262..36425de 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NameExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NameExpr.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +43,17 @@
this.name = name;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public NameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String name) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final String name) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name);
+ }
+
+ public NameExpr(Range range, final String name) {
+ super(range);
this.name = name;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NormalAnnotationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NormalAnnotationExpr.java
index fcd1b90..c70ff61 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NormalAnnotationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NormalAnnotationExpr.java
@@ -21,11 +21,13 @@
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.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -43,9 +45,17 @@
setPairs(pairs);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public NormalAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final NameExpr name, final List<MemberValuePair> pairs) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final NameExpr name, final List<MemberValuePair> pairs) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, pairs);
+ }
+
+ public NormalAnnotationExpr(final Range range, final NameExpr name, final List<MemberValuePair> pairs) {
+ super(range);
setName(name);
setPairs(pairs);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NullLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NullLiteralExpr.java
index c7bc177..3becbab 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NullLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/NullLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -32,8 +35,16 @@
public NullLiteralExpr() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public NullLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public NullLiteralExpr(final Range range) {
+ super(range);
}
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ObjectCreationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ObjectCreationExpr.java
index f1ea0d8..43d8d07 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ObjectCreationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ObjectCreationExpr.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.type.Type;
@@ -29,6 +30,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -68,10 +70,20 @@
setArgs(args);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ObjectCreationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
+ final Expression scope, final ClassOrInterfaceType type, final List<Type> typeArgs,
+ final List<Expression> args, final List<BodyDeclaration> anonymousBody) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, type, typeArgs, args, anonymousBody);
+ }
+
+ public ObjectCreationExpr(final Range range,
final Expression scope, final ClassOrInterfaceType type, final List<Type> typeArgs,
final List<Expression> args, final List<BodyDeclaration> anonymousBody) {
- super(beginLine, beginColumn, endLine, endColumn);
+ super(range);
setScope(scope);
setType(type);
setTypeArgs(typeArgs);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/QualifiedNameExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/QualifiedNameExpr.java
index 00a65aa..ff52f6c 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/QualifiedNameExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/QualifiedNameExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +42,17 @@
setQualifier(scope);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public QualifiedNameExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final NameExpr scope, final String name) {
- super(beginLine, beginColumn, endLine, endColumn, name);
+ final NameExpr scope, final String name) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, name);
+ }
+
+ public QualifiedNameExpr(final Range range, final NameExpr scope, final String name) {
+ super(range, name);
setQualifier(scope);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java
index bd8adb1..235f1d3 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SingleMemberAnnotationExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +42,17 @@
setMemberValue(memberValue);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public SingleMemberAnnotationExpr(final int beginLine, final int beginColumn, final int endLine,
- final int endColumn, final NameExpr name, final Expression memberValue) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endColumn, final NameExpr name, final Expression memberValue) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), name, memberValue);
+ }
+
+ public SingleMemberAnnotationExpr(final Range range, final NameExpr name, final Expression memberValue) {
+ super(range);
setName(name);
setMemberValue(memberValue);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/StringLiteralExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/StringLiteralExpr.java
index feb67d3..af46255 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/StringLiteralExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/StringLiteralExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -42,9 +45,16 @@
this.value = value;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public StringLiteralExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String value) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final String value) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), value);
+ }
+ public StringLiteralExpr(final Range range, final String value) {
+ super(range);
this.value = value;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SuperExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SuperExpr.java
index 791d28b..0e513ef 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SuperExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/SuperExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -38,9 +41,17 @@
setClassExpr(classExpr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public SuperExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression classExpr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression classExpr) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), classExpr);
+ }
+
+ public SuperExpr(final Range range, final Expression classExpr) {
+ super(range);
setClassExpr(classExpr);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ThisExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ThisExpr.java
index c269376..99d1c9b 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ThisExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/ThisExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -38,9 +41,17 @@
setClassExpr(classExpr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ThisExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final Expression classExpr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), classExpr);
+ }
+
+ public ThisExpr(final Range range, final Expression classExpr) {
+ super(range);
setClassExpr(classExpr);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/TypeExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/TypeExpr.java
index 482ca9c..8a46522 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/TypeExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/TypeExpr.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* This class is just instantiated as scopes for MethodReferenceExpr nodes to encapsulate Types.
* @author Raquel Pau
@@ -37,8 +40,16 @@
public TypeExpr(){}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public TypeExpr(int beginLine, int beginColumn, int endLine, int endColumn, Type type) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type);
+ }
+
+ public TypeExpr(Range range, Type type) {
+ super(range);
setType(type);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/UnaryExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/UnaryExpr.java
index e5f9abe..a5aa16b 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/UnaryExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/UnaryExpr.java
@@ -21,9 +21,12 @@
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 static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -52,9 +55,17 @@
setOperator(op);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public UnaryExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final Expression expr, final Operator op) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), expr, op);
+ }
+
+ public UnaryExpr(final Range range, final Expression expr, final Operator op) {
+ super(range);
setExpr(expr);
setOperator(op);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/VariableDeclarationExpr.java b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/VariableDeclarationExpr.java
index 5b2605a..12afaa9 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/expr/VariableDeclarationExpr.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/expr/VariableDeclarationExpr.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.expr;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.NodeWithModifiers;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.body.ModifierSet;
@@ -31,6 +32,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -60,10 +62,20 @@
setVars(vars);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public VariableDeclarationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final int modifiers, final List<AnnotationExpr> annotations, final Type type,
final List<VariableDeclarator> vars) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), modifiers, annotations, type, vars);
+ }
+
+ public VariableDeclarationExpr(final Range range,
+ final int modifiers, final List<AnnotationExpr> annotations, final Type type,
+ final List<VariableDeclarator> vars) {
+ super(range);
setModifiers(modifiers);
setAnnotations(annotations);
setType(type);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/internal/Utils.java b/javaparser-core/src/main/java/com/github/javaparser/ast/internal/Utils.java
index d5e7e4e..983afef 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/internal/Utils.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/internal/Utils.java
@@ -27,7 +27,6 @@
/**
* @author Federico Tomassetti
- * @since 3.0.0
*/
public class Utils {
public static <T> List<T> ensureNotNull(List<T> list) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/AssertStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/AssertStmt.java
index 60f61bc..7f578bc 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/AssertStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/AssertStmt.java
@@ -21,10 +21,15 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+import static com.github.javaparser.Range.range;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -46,9 +51,17 @@
setMessage(msg);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public AssertStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression check, final Expression msg) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression check, final Expression msg) {
+ this(range(beginLine, beginColumn, endLine, endColumn), check, msg);
+ }
+
+ public AssertStmt(final Range range, final Expression check, final Expression msg) {
+ super(range);
setCheck(check);
setMessage(msg);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BlockStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BlockStmt.java
index 74fc41f..0a2baf8 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BlockStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BlockStmt.java
@@ -21,11 +21,13 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -42,9 +44,17 @@
setStmts(stmts);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public BlockStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn, final List<Statement> stmts) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn, final List<Statement> stmts) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), stmts);
+ }
+
+ public BlockStmt(final Range range, final List<Statement> stmts) {
+ super(range);
setStmts(stmts);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BreakStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BreakStmt.java
index 1a80f3e..da23dc8 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BreakStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/BreakStmt.java
@@ -21,9 +21,13 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -38,8 +42,16 @@
this.id = id;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public BreakStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn, final String id) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), id);
+ }
+
+ public BreakStmt(final Range range, final String id) {
+ super(range);
this.id = id;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/CatchClause.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/CatchClause.java
index 49a137c..ef44ca5 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/CatchClause.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/CatchClause.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.body.Parameter;
import com.github.javaparser.ast.body.VariableDeclaratorId;
@@ -31,6 +32,8 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -48,11 +51,21 @@
setCatchBlock(catchBlock);
}
- public CatchClause(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final Type exceptTypes,
- final VariableDeclaratorId exceptId, final BlockStmt catchBlock) {
- super(beginLine, beginColumn, endLine, endColumn);
- setParam(new Parameter(beginLine, beginColumn, endLine, endColumn, exceptModifier, exceptAnnotations, exceptTypes, false, exceptId));
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
+ public CatchClause(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
+ final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final Type exceptTypes,
+ final VariableDeclaratorId exceptId, final BlockStmt catchBlock) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), exceptModifier, exceptAnnotations, exceptTypes, exceptId, catchBlock);
+ }
+
+ public CatchClause(final Range range,
+ final int exceptModifier, final List<AnnotationExpr> exceptAnnotations, final Type exceptTypes,
+ final VariableDeclaratorId exceptId, final BlockStmt catchBlock) {
+ super(range);
+ setParam(new Parameter(range, exceptModifier, exceptAnnotations, exceptTypes, false, exceptId));
setCatchBlock(catchBlock);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ContinueStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ContinueStmt.java
index 81760d0..6d8841c 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ContinueStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ContinueStmt.java
@@ -21,9 +21,13 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -38,9 +42,17 @@
this.id = id;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ContinueStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String id) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final String id) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), id);
+ }
+
+ public ContinueStmt(Range range, final String id) {
+ super(range);
this.id = id;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/DoStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/DoStmt.java
index 0a6a770..5c39a12 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/DoStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/DoStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -42,9 +46,17 @@
setCondition(condition);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public DoStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Statement body, final Expression condition) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Statement body, final Expression condition) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), body, condition);
+ }
+
+ public DoStmt(Range range, final Statement body, final Expression condition) {
+ super(range);
setBody(body);
setCondition(condition);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/EmptyStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/EmptyStmt.java
index fb16c4d..d6a261e 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/EmptyStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/EmptyStmt.java
@@ -21,9 +21,13 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -32,8 +36,16 @@
public EmptyStmt() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public EmptyStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
+ }
+
+ public EmptyStmt(Range range) {
+ super(range);
}
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java
index a275ab1..88c1062 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExplicitConstructorInvocationStmt.java
@@ -21,6 +21,8 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +30,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -53,11 +56,20 @@
setArgs(args);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ExplicitConstructorInvocationStmt(final int beginLine,
- final int beginColumn, final int endLine, final int endColumn,
- final List<Type> typeArgs, final boolean isThis,
- final Expression expr, final List<Expression> args) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int beginColumn, final int endLine, final int endColumn,
+ final List<Type> typeArgs, final boolean isThis,
+ final Expression expr, final List<Expression> args) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), typeArgs, isThis, expr, args);
+ }
+ public ExplicitConstructorInvocationStmt(Range range,
+ final List<Type> typeArgs, final boolean isThis,
+ final Expression expr, final List<Expression> args) {
+ super(range);
setTypeArgs(typeArgs);
setThis(isThis);
setExpr(expr);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExpressionStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExpressionStmt.java
index 3c441e2..7c2bfdf 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExpressionStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ExpressionStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +43,17 @@
setExpression(expr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ExpressionStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression expr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression expr) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), expr);
+ }
+ public ExpressionStmt(Range range,
+ final Expression expr) {
+ super(range);
setExpression(expr);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForStmt.java
index cef6f27..a5fbc19 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForStmt.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -53,11 +56,21 @@
setBody(body);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ForStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn,
- final List<Expression> init, final Expression compare,
- final List<Expression> update, final Statement body) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn,
+ final List<Expression> init, final Expression compare,
+ final List<Expression> update, final Statement body) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), init, compare, update, body);
+ }
+
+ public ForStmt(Range range,
+ final List<Expression> init, final Expression compare,
+ final List<Expression> update, final Statement body) {
+ super(range);
setCompare(compare);
setInit(init);
setUpdate(update);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForeachStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForeachStmt.java
index 245622f..edda7de 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForeachStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ForeachStmt.java
@@ -21,11 +21,15 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.expr.VariableDeclarationExpr;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -47,11 +51,21 @@
setBody(body);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ForeachStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn,
- final VariableDeclarationExpr var, final Expression iterable,
- final Statement body) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn,
+ final VariableDeclarationExpr var, final Expression iterable,
+ final Statement body) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), var, iterable, body);
+ }
+
+ public ForeachStmt(Range range,
+ final VariableDeclarationExpr var, final Expression iterable,
+ final Statement body) {
+ super(range);
setVariable(var);
setIterable(iterable);
setBody(body);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/IfStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/IfStmt.java
index ccddd90..23af285 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/IfStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/IfStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -45,9 +49,18 @@
setElseStmt(elseStmt);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public IfStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression condition, final Statement thenStmt, final Statement elseStmt) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression condition, final Statement thenStmt, final Statement elseStmt) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), condition, thenStmt, elseStmt);
+ }
+
+ public IfStmt(Range range,
+ final Expression condition, final Statement thenStmt, final Statement elseStmt) {
+ super(range);
setCondition(condition);
setThenStmt(thenStmt);
setElseStmt(elseStmt);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/LabeledStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/LabeledStmt.java
index 85d8e7b..aae6b9b 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/LabeledStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/LabeledStmt.java
@@ -21,9 +21,13 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -41,9 +45,17 @@
setStmt(stmt);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public LabeledStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final String label, final Statement stmt) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final String label, final Statement stmt) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), label, stmt);
+ }
+
+ public LabeledStmt(Range range, final String label, final Statement stmt) {
+ super(range);
setLabel(label);
setStmt(stmt);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ReturnStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ReturnStmt.java
index 3ac6fa6..acaec18 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ReturnStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ReturnStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +43,17 @@
setExpr(expr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ReturnStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression expr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression expr) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), expr);
+ }
+
+ public ReturnStmt(Range range, final Expression expr) {
+ super(range);
setExpr(expr);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/Statement.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/Statement.java
index 30c462d..5ab9e24 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/Statement.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/Statement.java
@@ -21,8 +21,13 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
+import static com.github.javaparser.Position.pos;
+import static com.github.javaparser.Range.*;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -31,8 +36,16 @@
public Statement() {
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public Statement(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(range(beginLine, beginColumn, endLine, endColumn));
+ }
+
+ public Statement(final Range range) {
+ super(range);
}
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchEntryStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchEntryStmt.java
index 853a79e..b1103dd 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchEntryStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchEntryStmt.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -46,10 +49,19 @@
setStmts(stmts);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public SwitchEntryStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn, final Expression label,
- final List<Statement> stmts) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn, final Expression label,
+ final List<Statement> stmts) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), label, stmts);
+ }
+
+ public SwitchEntryStmt(Range range, final Expression label,
+ final List<Statement> stmts) {
+ super(range);
setLabel(label);
setStmts(stmts);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchStmt.java
index a730b1f..4ded7be 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SwitchStmt.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -47,10 +50,19 @@
setEntries(entries);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public SwitchStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn, final Expression selector,
- final List<SwitchEntryStmt> entries) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn, final Expression selector,
+ final List<SwitchEntryStmt> entries) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), selector, entries);
+ }
+
+ public SwitchStmt(Range range, final Expression selector,
+ final List<SwitchEntryStmt> entries) {
+ super(range);
setSelector(selector);
setEntries(entries);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SynchronizedStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SynchronizedStmt.java
index e91fc0b..79c0d88 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SynchronizedStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/SynchronizedStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -42,10 +46,19 @@
setBlock(block);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public SynchronizedStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn, final Expression expr,
- final BlockStmt block) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn, final Expression expr,
+ final BlockStmt block) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), expr, block);
+ }
+
+ public SynchronizedStmt(Range range, final Expression expr,
+ final BlockStmt block) {
+ super(range);
setExpr(expr);
setBlock(block);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ThrowStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ThrowStmt.java
index 48283b1..5d30cc3 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ThrowStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/ThrowStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +43,17 @@
setExpr(expr);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ThrowStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression expr) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression expr) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), expr);
+ }
+
+ public ThrowStmt(Range range, final Expression expr) {
+ super(range);
setExpr(expr);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TryStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TryStmt.java
index f6a709a..d5bc33a 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TryStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TryStmt.java
@@ -21,12 +21,15 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import com.github.javaparser.ast.expr.VariableDeclarationExpr;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -52,10 +55,19 @@
setFinallyBlock(finallyBlock);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public TryStmt(final int beginLine, final int beginColumn,
- final int endLine, final int endColumn, List<VariableDeclarationExpr> resources,
- final BlockStmt tryBlock, final List<CatchClause> catchs, final BlockStmt finallyBlock) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final int endLine, final int endColumn, List<VariableDeclarationExpr> resources,
+ final BlockStmt tryBlock, final List<CatchClause> catchs, final BlockStmt finallyBlock) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), resources, tryBlock, catchs, finallyBlock);
+ }
+
+ public TryStmt(Range range, List<VariableDeclarationExpr> resources,
+ final BlockStmt tryBlock, final List<CatchClause> catchs, final BlockStmt finallyBlock) {
+ super(range);
setResources(resources);
setTryBlock(tryBlock);
setCatchs(catchs);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java
index 79b507a..0533cfa 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/TypeDeclarationStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.body.TypeDeclaration;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -39,9 +43,17 @@
setTypeDeclaration(typeDecl);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public TypeDeclarationStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final TypeDeclaration typeDecl) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final TypeDeclaration typeDecl) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), typeDecl);
+ }
+
+ public TypeDeclarationStmt(Range range, final TypeDeclaration typeDecl) {
+ super(range);
setTypeDeclaration(typeDecl);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/WhileStmt.java b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/WhileStmt.java
index 51b2a1a..653fc03 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/WhileStmt.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/stmt/WhileStmt.java
@@ -21,10 +21,14 @@
package com.github.javaparser.ast.stmt;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -42,9 +46,17 @@
setBody(body);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public WhileStmt(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final Expression condition, final Statement body) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final Expression condition, final Statement body) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), condition, body);
+ }
+
+ public WhileStmt(Range range, final Expression condition, final Statement body) {
+ super(range);
setCondition(condition);
setBody(body);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/ClassOrInterfaceType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/ClassOrInterfaceType.java
index d725c82..096ffd0 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/ClassOrInterfaceType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/ClassOrInterfaceType.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.type;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.NamedNode;
import com.github.javaparser.ast.TypeArguments;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +29,8 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -58,12 +61,20 @@
@Deprecated
public ClassOrInterfaceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final ClassOrInterfaceType scope, final String name, final List<Type> typeArgs) {
- this(beginLine, beginColumn, endLine, endColumn, scope, name, TypeArguments.withArguments(typeArgs));
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, name, TypeArguments.withArguments(typeArgs));
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ClassOrInterfaceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
- final ClassOrInterfaceType scope, final String name, final TypeArguments typeArguments) {
- super(beginLine, beginColumn, endLine, endColumn);
+ final ClassOrInterfaceType scope, final String name, final TypeArguments typeArgs) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), scope, name, typeArgs);
+ }
+
+ public ClassOrInterfaceType(final Range range, final ClassOrInterfaceType scope, final String name, final TypeArguments typeArguments) {
+ super(range);
setScope(scope);
setName(name);
setTypeArguments(typeArguments);
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/IntersectionType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/IntersectionType.java
index 5784b59..47e5829 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/IntersectionType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/IntersectionType.java
@@ -1,10 +1,14 @@
package com.github.javaparser.ast.type;
+import com.github.javaparser.Range;
+import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.List;
+import static com.github.javaparser.Position.pos;
+
/**
* Represents a set of types. A given value of this type has to be assignable to at all of the element types.
* As of Java 8 it is used in casts or while expressing bounds for generic types.
@@ -21,9 +25,17 @@
private List<ReferenceType> elements;
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public IntersectionType(int beginLine, int beginColumn, int endLine,
int endColumn, List<ReferenceType> elements) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), elements);
+ }
+
+ public IntersectionType(Range range, List<ReferenceType> elements) {
+ super(range);
setElements(elements);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/PrimitiveType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/PrimitiveType.java
index 7533c3c..4d2d5e9 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/PrimitiveType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/PrimitiveType.java
@@ -23,9 +23,12 @@
import java.util.HashMap;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -68,9 +71,17 @@
this.type = type;
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public PrimitiveType(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final Primitive type) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type);
+ }
+
+ public PrimitiveType(Range range, final Primitive type) {
+ super(range);
this.type = type;
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/ReferenceType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/ReferenceType.java
index 4b68eb2..0dd6655 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/ReferenceType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/ReferenceType.java
@@ -21,6 +21,7 @@
package com.github.javaparser.ast.type;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.TypedNode;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.visitor.GenericVisitor;
@@ -28,6 +29,7 @@
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -53,9 +55,17 @@
setArrayCount(arrayCount);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public ReferenceType(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final Type type, final int arrayCount) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type, arrayCount);
+ }
+
+ public ReferenceType(final Range range, final Type type, final int arrayCount) {
+ super(range);
setType(type);
setArrayCount(arrayCount);
}
@@ -64,7 +74,13 @@
int endColumn, Type type, int arrayCount,
List<AnnotationExpr> annotations,
List<List<AnnotationExpr>> arraysAnnotations) {
- super(beginLine, beginColumn, endLine, endColumn, annotations);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), type, arrayCount, annotations, arraysAnnotations);
+ }
+
+ public ReferenceType(Range range, Type type, int arrayCount,
+ List<AnnotationExpr> annotations,
+ List<List<AnnotationExpr>> arraysAnnotations) {
+ super(range, annotations);
setType(type);
setArrayCount(arrayCount);
this.arraysAnnotations = arraysAnnotations;
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/Type.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/Type.java
index fc9dbae..2d935e4 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/Type.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/Type.java
@@ -21,11 +21,14 @@
package com.github.javaparser.ast.type;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.expr.AnnotationExpr;
import java.util.List;
+import static com.github.javaparser.Position.pos;
import static com.github.javaparser.ast.internal.Utils.*;
/**
@@ -42,15 +45,20 @@
this.annotations = annotation;
}
- public Type(int beginLine, int beginColumn, int endLine, int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ public Type(Range range) {
+ super(range);
+ }
+
+ @Deprecated
+ public Type(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) {
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), annotations);
}
- public Type(int beginLine, int beginColumn, int endLine, int endColumn, List<AnnotationExpr> annotations) {
- super(beginLine, beginColumn, endLine, endColumn);
+ public Type(Range range, List<AnnotationExpr> annotations) {
+ super(range);
this.annotations = annotations;
}
-
+
public List<AnnotationExpr> getAnnotations() {
annotations = ensureNotNull(annotations);
return annotations;
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/UnionType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/UnionType.java
index 83eeee6..a3e9777 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/UnionType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/UnionType.java
@@ -1,23 +1,32 @@
package com.github.javaparser.ast.type;
+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.Position.pos;
+
/**
* Represents a set of types. A given value of this type has to be assignable to at least one of the element types.
* As of Java 8 it is only used in catch clauses.
- *
- * @since 3.0.0
*/
public class UnionType extends Type {
private List<ReferenceType> elements;
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public UnionType(int beginLine, int beginColumn, int endLine,
int endColumn, List<ReferenceType> elements) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), elements);
+ }
+
+ public UnionType(Range range, List<ReferenceType> elements) {
+ super(range);
setElements(elements);
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/VoidType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/VoidType.java
index 5dacbe1..9202239 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/VoidType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/VoidType.java
@@ -21,9 +21,13 @@
package com.github.javaparser.ast.type;
+import com.github.javaparser.Position;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -32,8 +36,16 @@
public VoidType() {
}
+ public VoidType(Range range) {
+ super(range);
+ }
+
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public VoidType(final int beginLine, final int beginColumn, final int endLine, final int endColumn) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)));
}
@Override public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/type/WildcardType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/type/WildcardType.java
index 8016ed7..3ab21b9 100644
--- a/javaparser-core/src/main/java/com/github/javaparser/ast/type/WildcardType.java
+++ b/javaparser-core/src/main/java/com/github/javaparser/ast/type/WildcardType.java
@@ -21,9 +21,12 @@
package com.github.javaparser.ast.type;
+import com.github.javaparser.Range;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
+import static com.github.javaparser.Position.pos;
+
/**
* @author Julio Vilmar Gesser
*/
@@ -45,9 +48,18 @@
setSuper(sup);
}
+ /**
+ * @deprecated prefer using Range objects.
+ */
+ @Deprecated
public WildcardType(final int beginLine, final int beginColumn, final int endLine, final int endColumn,
final ReferenceType ext, final ReferenceType sup) {
- super(beginLine, beginColumn, endLine, endColumn);
+ this(new Range(pos(beginLine, beginColumn), pos(endLine, endColumn)), ext, sup);
+ }
+
+ public WildcardType(final Range range,
+ final ReferenceType ext, final ReferenceType sup) {
+ super(range);
setExtends(ext);
setSuper(sup);
}
diff --git a/javaparser-core/src/main/javacc/java_1_8.jj b/javaparser-core/src/main/javacc/java_1_8.jj
index 6d5a574..e7f3b7f 100644
--- a/javaparser-core/src/main/javacc/java_1_8.jj
+++ b/javaparser-core/src/main/javacc/java_1_8.jj
@@ -53,6 +53,8 @@
import com.github.javaparser.ast.expr.*;
import com.github.javaparser.ast.stmt.*;
import com.github.javaparser.ast.type.*;
+import static com.github.javaparser.Range.*;
+import static com.github.javaparser.Position.*;
/**
* <p>This class was generated automatically by javacc, do not edit.</p>
@@ -1180,7 +1182,7 @@
in = EmptyImportDeclaration() { if(line==-1){line = in.getBeginLine(); column = in.getBeginColumn();} imports = add(imports, in); } )*
( tn = TypeDeclaration() { if(line==-1){line = tn.getBeginLine(); column = tn.getBeginColumn();} types = add(types, tn); } )*
(<EOF> | "\u001A" /** ctrl+z char **/)
- { return new CompilationUnit(line == -1 ? 0 : line, column, token.endLine, token.endColumn,pakage, imports, types); }
+ { return new CompilationUnit(line == -1 ? Range.UNKNOWN : range(line, column, token.endLine, token.endColumn),pakage, imports, types); }
}
ImportDeclaration EmptyImportDeclaration():
@@ -1190,7 +1192,7 @@
}
{
";"
- { return ImportDeclaration.createEmptyDeclaration(line, column, token.endLine, token.endColumn); }
+ { return ImportDeclaration.createEmptyDeclaration(range(line, column, token.endLine, token.endColumn)); }
}
PackageDeclaration PackageDeclaration():
@@ -1204,7 +1206,7 @@
{
( ann = Annotation() { annotations = add(annotations, ann); } )*
"package" {line=token.beginLine; column=token.beginColumn;} name = Name() ";"
- { return new PackageDeclaration(line, column, token.endLine, token.endColumn,annotations, name); }
+ { return new PackageDeclaration(range(line, column, token.endLine, token.endColumn),annotations, name); }
}
ImportDeclaration ImportDeclaration():
@@ -1217,7 +1219,7 @@
}
{
"import" {line=token.beginLine; column=token.beginColumn;} [ "static" { isStatic = true; } ] name = Name() [ "." "*" { isAsterisk = true; } ] ";"
- { return new ImportDeclaration(line, column, token.endLine, token.endColumn,name, isStatic, isAsterisk); }
+ { return new ImportDeclaration(range(line, column, token.endLine, token.endColumn),name, isStatic, isAsterisk); }
}
/*
@@ -1280,7 +1282,7 @@
{
{ }
(
- ";" { ret = new EmptyTypeDeclaration(token.beginLine, token.beginColumn, token.endLine, token.endColumn); }
+ ";" { ret = new EmptyTypeDeclaration(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn)); }
|
modifier = Modifiers()
(
@@ -1314,7 +1316,7 @@
[ impList = ImplementsList(isInterface) ]
members = ClassOrInterfaceBody(isInterface)
- { ClassOrInterfaceDeclaration tmp = new ClassOrInterfaceDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, isInterface, null, typePar, extList, impList, members);
+ { ClassOrInterfaceDeclaration tmp = new ClassOrInterfaceDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, isInterface, null, typePar, extList, impList, members);
tmp.setNameExpr(name);
return tmp;
}
@@ -1380,7 +1382,7 @@
"}"
{
- EnumDeclaration tmp = new EnumDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, null, impList, entries, members);
+ EnumDeclaration tmp = new EnumDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, null, impList, entries, members);
tmp.setNameExpr(name);
return tmp;
}
@@ -1404,7 +1406,7 @@
<IDENTIFIER> { name = token.image; if(line==-1){line=token.beginLine; column=token.beginColumn;} }
[ args = Arguments() ] [ classBody = ClassOrInterfaceBody(false) ]
{
- EnumConstantDeclaration tmp = new EnumConstantDeclaration(line, column, token.endLine, token.endColumn, annotations, name, args, classBody);
+ EnumConstantDeclaration tmp = new EnumConstantDeclaration(range(line, column, token.endLine, token.endColumn), annotations, name, args, classBody);
return tmp;
}
@@ -1436,7 +1438,7 @@
}
{
<IDENTIFIER> { name = token.image; line=token.beginLine; column=token.beginColumn;} [ typeBound = TypeBound() ]
- { return new TypeParameter(line, column, token.endLine, token.endColumn,name, typeBound); }
+ { return new TypeParameter(range(line, column, token.endLine, token.endColumn),name, typeBound); }
}
List TypeBound():
@@ -1526,7 +1528,7 @@
}
}
|
- ";" { ret = new EmptyMemberDeclaration(token.beginLine, token.beginColumn, token.endLine, token.endColumn); }
+ ";" { ret = new EmptyMemberDeclaration(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn)); }
)
{ return ret; }
}
@@ -1547,7 +1549,7 @@
int line = modifier.beginLine;
int column = modifier.beginColumn;
if (line == -1) { line=type.getBeginLine(); column=type.getBeginColumn(); }
- return new FieldDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, variables);
+ return new FieldDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, type, variables);
}
}
@@ -1558,7 +1560,7 @@
}
{
id = VariableDeclaratorId() [ "=" init = VariableInitializer() ]
- { return new VariableDeclarator(id.getBeginLine(), id.getBeginColumn(), token.endLine, token.endColumn, id, init); }
+ { return new VariableDeclarator(range(id.getBeginLine(), id.getBeginColumn(), token.endLine, token.endColumn), id, init); }
}
VariableDeclaratorId VariableDeclaratorId():
@@ -1570,7 +1572,7 @@
}
{
<IDENTIFIER> { name = token.image; line=token.beginLine; column=token.beginColumn;} ( "[" "]" { arrayCount++; } )*
- { return new VariableDeclaratorId(line, column, token.endLine, token.endColumn,name, arrayCount); }
+ { return new VariableDeclaratorId(range(line, column, token.endLine, token.endColumn),name, arrayCount); }
}
Expression VariableInitializer():
@@ -1595,7 +1597,7 @@
}
{
"{" {line=token.beginLine; column=token.beginColumn;} [ val = VariableInitializer() { values = add(values, val); } ( LOOKAHEAD(2) "," val = VariableInitializer() { values = add(values, val); } )* ] [ "," ] "}"
- { return new ArrayInitializerExpr(line, column, token.endLine, token.endColumn,values); }
+ { return new ArrayInitializerExpr(range(line, column, token.endLine, token.endColumn),values); }
}
MethodDeclaration MethodDeclaration(Modifier modifier):
@@ -1620,7 +1622,7 @@
("," throwType = ReferenceTypeWithAnnotations() { throws_ = add(throws_, throwType); })* ]
( block = Block() | ";" )
{
- MethodDeclaration tmp = new MethodDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, typeParameters, type, null, parameters, arrayCount, throws_, block);
+ MethodDeclaration tmp = new MethodDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, typeParameters, type, null, parameters, arrayCount, throws_, block);
tmp.setNameExpr(name);
return tmp;
}
@@ -1693,7 +1695,7 @@
int line = modifier.beginLine;
int column = modifier.beginColumn;
if(line==-1){ line=type.getBeginLine(); column=type.getBeginColumn(); }
- return new Parameter(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, isVarArg, id);
+ return new Parameter(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, type, isVarArg, id);
}
}
@@ -1727,7 +1729,7 @@
if (exConsInv != null) {
stmts = add(0, stmts, exConsInv);
}
- ConstructorDeclaration tmp = new ConstructorDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, typeParameters, null, parameters, throws_, new BlockStmt(bbLine, bbColumn, token.endLine, token.endColumn, stmts));
+ ConstructorDeclaration tmp = new ConstructorDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, typeParameters, null, parameters, throws_, new BlockStmt(range(bbLine, bbColumn, token.endLine, token.endColumn), stmts));
tmp.setNameExpr(name);
return tmp;
}
@@ -1758,7 +1760,7 @@
<SUPER> {if (line == -1) {line=token.beginLine; column=token.beginColumn;}}
args = Arguments() ";"
)
- { return new ExplicitConstructorInvocationStmt(line, column, token.endLine, token.endColumn,typeArgs, isThis, expr, args); }
+ { return new ExplicitConstructorInvocationStmt(range(line, column, token.endLine, token.endColumn),typeArgs, isThis, expr, args); }
}
List Statements():
@@ -1780,7 +1782,7 @@
}
{
[ "static" { isStatic = true; line=token.beginLine; column=token.beginColumn;} ] block = Block() {if(line==-1){line=block.getBeginLine(); column=block.getBeginColumn();}}
- { return new InitializerDeclaration(line, column, token.endLine, token.endColumn, isStatic, block); }
+ { return new InitializerDeclaration(range(line, column, token.endLine, token.endColumn), isStatic, block); }
}
@@ -1815,7 +1817,7 @@
|
type = ClassOrInterfaceType() ( LOOKAHEAD(2) (ann = Annotation() { annotations = add(annotations, ann); })* "[" "]" { arrayCount++; accum = add(accum, annotations); annotations= null;} )*
)
- { return new ReferenceType(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn, type, arrayCount, null, accum); }
+ { return new ReferenceType(range(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn), type, arrayCount, null, accum); }
}
IntersectionType IntersectionType():
@@ -1830,7 +1832,7 @@
line=elementType.getBeginLine(); column=elementType.getBeginColumn();
elements = add(elements, elementType); }
"&" (elementType=ReferenceType() { elements = add(elements, elementType); } )+
- { return new IntersectionType(line, column, token.endLine, token.endColumn, elements); }
+ { return new IntersectionType(range(line, column, token.endLine, token.endColumn), elements); }
}
ClassOrInterfaceType ClassOrInterfaceType():
@@ -1847,13 +1849,13 @@
<IDENTIFIER> {line=token.beginLine; column=token.beginColumn;} { name = token.image; }
[ LOOKAHEAD(2) typeArgs = TypeArguments() {typeArgs.remove(0);} ]
{
- ret = new ClassOrInterfaceType(line, column, token.endLine, token.endColumn,null, name, createTypeArguments(typeArgs));
+ ret = new ClassOrInterfaceType(range(line, column, token.endLine, token.endColumn),null, name, createTypeArguments(typeArgs));
}
(
LOOKAHEAD(2) "." (ann = Annotation() { annotations = add(annotations, ann);})* <IDENTIFIER> { name = token.image; }
[ LOOKAHEAD(2) typeArgs = TypeArguments() {typeArgs.remove(0);} ]
{
- ret = new ClassOrInterfaceType(line, column, token.endLine, token.endColumn,ret, name, createTypeArguments(typeArgs));
+ ret = new ClassOrInterfaceType(range(line, column, token.endLine, token.endColumn),ret, name, createTypeArguments(typeArgs));
ret.setAnnotations(annotations);
annotations = null;
}
@@ -1932,7 +1934,7 @@
}
]
{
- return new WildcardType(line, column, token.endLine, token.endColumn,ext, sup);
+ return new WildcardType(range(line, column, token.endLine, token.endColumn),ext, sup);
}
}
@@ -1942,21 +1944,21 @@
}
{
(
- "boolean" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Boolean); }
+ "boolean" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Boolean); }
|
- "char" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Char); }
+ "char" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Char); }
|
- "byte" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Byte); }
+ "byte" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Byte); }
|
- "short" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Short); }
+ "short" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Short); }
|
- "int" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Int); }
+ "int" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Int); }
|
- "long" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Long); }
+ "long" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Long); }
|
- "float" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Float); }
+ "float" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Float); }
|
- "double" { ret = new PrimitiveType(token.beginLine, token.beginColumn, token.endLine, token.endColumn, PrimitiveType.Primitive.Double); }
+ "double" { ret = new PrimitiveType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), PrimitiveType.Primitive.Double); }
)
{ return ret; }
}
@@ -1967,7 +1969,7 @@
}
{
(
- "void" { ret = new VoidType(token.beginLine, token.beginColumn, token.endLine, token.endColumn); }
+ "void" { ret = new VoidType(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn)); }
|
ret = Type()
)
@@ -1983,8 +1985,8 @@
NameExpr ret;
}
{
- <IDENTIFIER> { ret = new NameExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); }
- ( LOOKAHEAD(2) "." <IDENTIFIER> { ret = new QualifiedNameExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, token.image); } )*
+ <IDENTIFIER> { ret = new NameExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image); }
+ ( LOOKAHEAD(2) "." <IDENTIFIER> { ret = new QualifiedNameExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, token.image); } )*
{ return ret; }
}
@@ -2006,7 +2008,7 @@
NameExpr ret;
}
{
- <IDENTIFIER> { ret = new NameExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image); }
+ <IDENTIFIER> { ret = new NameExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image); }
{ return ret; }
}
@@ -2051,7 +2053,7 @@
[
(
LOOKAHEAD(2)
- op = AssignmentOperator() value = Expression() { ret = new AssignExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, value, op); }
+ op = AssignmentOperator() value = Expression() { ret = new AssignExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, value, op); }
|
"->" lambdaBody = LambdaBody()
{
@@ -2073,7 +2075,7 @@
}
| "::" [typeArgs = TypeParameters() {typeArgs.remove(0);} ] (<IDENTIFIER> | "new")
{
- ret = new MethodReferenceExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, token.image);
+ ret = new MethodReferenceExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, typeArgs, token.image);
}
)
]
@@ -2111,7 +2113,7 @@
}
{
ret = ConditionalOrExpression()
- [ "?" left = Expression() ":" right = ConditionalExpression() { ret = new ConditionalExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, left, right); } ]
+ [ "?" left = Expression() ":" right = ConditionalExpression() { ret = new ConditionalExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, left, right); } ]
{ return ret; }
}
@@ -2121,7 +2123,7 @@
Expression right;
}
{
- ret = ConditionalAndExpression() ( "||" right = ConditionalAndExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.or); } )*
+ ret = ConditionalAndExpression() ( "||" right = ConditionalAndExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, BinaryExpr.Operator.or); } )*
{ return ret; }
}
@@ -2131,7 +2133,7 @@
Expression right;
}
{
- ret = InclusiveOrExpression() ( "&&" right = InclusiveOrExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.and); } )*
+ ret = InclusiveOrExpression() ( "&&" right = InclusiveOrExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, BinaryExpr.Operator.and); } )*
{ return ret; }
}
@@ -2141,7 +2143,7 @@
Expression right;
}
{
- ret = ExclusiveOrExpression() ( "|" right = ExclusiveOrExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.binOr); } )*
+ ret = ExclusiveOrExpression() ( "|" right = ExclusiveOrExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, BinaryExpr.Operator.binOr); } )*
{ return ret; }
}
@@ -2151,7 +2153,7 @@
Expression right;
}
{
- ret = AndExpression() ( "^" right = AndExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.xor); } )*
+ ret = AndExpression() ( "^" right = AndExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, BinaryExpr.Operator.xor); } )*
{ return ret; }
}
@@ -2161,7 +2163,7 @@
Expression right;
}
{
- ret = EqualityExpression() ( "&" right = EqualityExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, BinaryExpr.Operator.binAnd); } )*
+ ret = EqualityExpression() ( "&" right = EqualityExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, BinaryExpr.Operator.binAnd); } )*
{ return ret; }
}
@@ -2176,7 +2178,7 @@
(
( "==" { op = BinaryExpr.Operator.equals; } |
"!=" { op = BinaryExpr.Operator.notEquals; }
- ) right = InstanceOfExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); }
+ ) right = InstanceOfExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, op); }
)*
{ return ret; }
}
@@ -2187,7 +2189,7 @@
Type type;
}
{
- ret = RelationalExpression() [ "instanceof" type = Type() { ret = new InstanceOfExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, type); } ]
+ ret = RelationalExpression() [ "instanceof" type = Type() { ret = new InstanceOfExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, type); } ]
{ return ret; }
}
@@ -2204,7 +2206,7 @@
">" { op = BinaryExpr.Operator.greater; } |
"<=" { op = BinaryExpr.Operator.lessEquals; } |
">=" { op = BinaryExpr.Operator.greaterEquals; }
- ) right = ShiftExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); }
+ ) right = ShiftExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, op); }
)*
{ return ret; }
}
@@ -2221,7 +2223,7 @@
( "<<" { op = BinaryExpr.Operator.lShift; } |
RSIGNEDSHIFT() { op = BinaryExpr.Operator.rSignedShift; } |
RUNSIGNEDSHIFT() { op = BinaryExpr.Operator.rUnsignedShift; }
- ) right = AdditiveExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); }
+ ) right = AdditiveExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, op); }
)*
{ return ret; }
}
@@ -2237,7 +2239,7 @@
(
( "+" { op = BinaryExpr.Operator.plus; } |
"-" { op = BinaryExpr.Operator.minus; }
- ) right = MultiplicativeExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); }
+ ) right = MultiplicativeExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, op); }
)*
{ return ret; }
}
@@ -2254,7 +2256,7 @@
( "*" { op = BinaryExpr.Operator.times; } |
"/" { op = BinaryExpr.Operator.divide; } |
"%" { op = BinaryExpr.Operator.remainder; }
- ) right = UnaryExpression() { ret = new BinaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, right, op); }
+ ) right = UnaryExpression() { ret = new BinaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, right, op); }
)*
{ return ret; }
}
@@ -2278,14 +2280,14 @@
{
if(op == UnaryExpr.Operator.negative) {
if (ret instanceof IntegerLiteralExpr && ((IntegerLiteralExpr)ret).isMinValue()) {
- ret = new IntegerLiteralMinValueExpr(line, column, token.endLine, token.endColumn);
+ ret = new IntegerLiteralMinValueExpr(range(line, column, token.endLine, token.endColumn));
} else if (ret instanceof LongLiteralExpr && ((LongLiteralExpr)ret).isMinValue()) {
- ret = new LongLiteralMinValueExpr(line, column, token.endLine, token.endColumn);
+ ret = new LongLiteralMinValueExpr(range(line, column, token.endLine, token.endColumn));
} else {
- ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, op);
+ ret = new UnaryExpr(range(line, column, token.endLine, token.endColumn),ret, op);
}
} else {
- ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, op);
+ ret = new UnaryExpr(range(line, column, token.endLine, token.endColumn),ret, op);
}
}
|
@@ -2301,7 +2303,7 @@
int column;
}
{
- "++" {line=token.beginLine; column=token.beginColumn;} ret = UnaryExpression() { ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, UnaryExpr.Operator.preIncrement); }
+ "++" {line=token.beginLine; column=token.beginColumn;} ret = UnaryExpression() { ret = new UnaryExpr(range(line, column, token.endLine, token.endColumn),ret, UnaryExpr.Operator.preIncrement); }
{ return ret; }
}
@@ -2312,7 +2314,7 @@
int column;
}
{
- "--" {line=token.beginLine; column=token.beginColumn;} ret = UnaryExpression() { ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, UnaryExpr.Operator.preDecrement); }
+ "--" {line=token.beginLine; column=token.beginColumn;} ret = UnaryExpression() { ret = new UnaryExpr(range(line, column, token.endLine, token.endColumn),ret, UnaryExpr.Operator.preDecrement); }
{ return ret; }
}
@@ -2327,7 +2329,7 @@
(
( "~" { op = UnaryExpr.Operator.inverse; line=token.beginLine; column=token.beginColumn;} |
"!" { op = UnaryExpr.Operator.not; line=token.beginLine; column=token.beginColumn;}
- ) ret = UnaryExpression() { ret = new UnaryExpr(line, column, token.endLine, token.endColumn,ret, op); }
+ ) ret = UnaryExpression() { ret = new UnaryExpr(range(line, column, token.endLine, token.endColumn),ret, op); }
|
LOOKAHEAD( CastExpression() )
ret = CastExpression()
@@ -2348,7 +2350,7 @@
LOOKAHEAD(2)
( "++" { op = UnaryExpr.Operator.posIncrement; } |
"--" { op = UnaryExpr.Operator.posDecrement; }
- ) { ret = new UnaryExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, op); }
+ ) { ret = new UnaryExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, op); }
]
{ return ret; }
}
@@ -2370,7 +2372,7 @@
(ann = Annotation() { annotations = add(annotations, ann);})*
(
LOOKAHEAD(2)
- type = PrimitiveType() ")" ret = UnaryExpression() { type.setAnnotations(annotations); ret = new CastExpr(line, column, token.endLine, token.endColumn, type, ret); }
+ type = PrimitiveType() ")" ret = UnaryExpression() { type.setAnnotations(annotations); ret = new CastExpr(range(line, column, token.endLine, token.endColumn), type, ret); }
|
type = ReferenceType() { typesOfMultiCast = add(typesOfMultiCast, type); type.setAnnotations(annotations); }
( "&" type = ReferenceType() {
@@ -2379,9 +2381,9 @@
)*
")" ret = UnaryExpressionNotPlusMinus() {
if (typesOfMultiCast.size() > 1) {
- type = new IntersectionType(line, column, token.endLine, token.endColumn, typesOfMultiCast);
+ type = new IntersectionType(range(line, column, token.endLine, token.endColumn), typesOfMultiCast);
}
- ret = new CastExpr(line, column, token.endLine, token.endColumn, type, ret);
+ ret = new CastExpr(range(line, column, token.endLine, token.endColumn), type, ret);
}
)
{ return ret; }
@@ -2427,9 +2429,9 @@
(
ret = Literal()
|
- "this" { ret = new ThisExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, null); }
+ "this" { ret = new ThisExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), null); }
|
- "super" { ret = new SuperExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, null); }
+ "super" { ret = new SuperExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), null); }
(
"."
[ typeArgs = TypeArguments() {typeArgs.remove(0);} ]
@@ -2437,11 +2439,11 @@
[ args = Arguments() {hasArgs=true;} ]
{
if (hasArgs) {
- MethodCallExpr m = new MethodCallExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, null, args);
+ MethodCallExpr m = new MethodCallExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, typeArgs, null, args);
m.setNameExpr(name);
ret = m;
} else {
- FieldAccessExpr f = new FieldAccessExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, null, null);
+ FieldAccessExpr f = new FieldAccessExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, null, null);
f.setFieldExpr(name);
ret = f;
}
@@ -2449,9 +2451,9 @@
|
"::" [typeArgs = TypeParameters() { typeArgs.remove(0); }] (<IDENTIFIER> | "new")
{
- ret = new MethodReferenceExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, token.image);
+ ret = new MethodReferenceExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, typeArgs, token.image);
}
- | args = Arguments() {new MethodCallExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, null, args);}
+ | args = Arguments() {new MethodCallExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, typeArgs, null, args);}
)
|
@@ -2463,7 +2465,7 @@
]
")"
{
- if(!isLambda) { ret = new EnclosedExpr(line, column, token.endLine, token.endColumn,ret);}
+ if(!isLambda) { ret = new EnclosedExpr(range(line, column, token.endLine, token.endColumn),ret);}
else{
if(ret != null){
if(ret instanceof NameExpr)
@@ -2474,7 +2476,7 @@
}
args = add(0, args, p);
- ret = new LambdaExpr(p.getBeginLine(), p.getBeginColumn(), token.endLine, token.endColumn, args, null, true);
+ ret = new LambdaExpr(range(p.getBeginLine(), p.getBeginColumn(), token.endLine, token.endColumn), args, null, true);
}
}
@@ -2482,13 +2484,13 @@
ret = AllocationExpression(null)
|
LOOKAHEAD( ResultType() "." "class" )
- type = ResultType() "." "class" { ret = new ClassExpr(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn, type); }
+ type = ResultType() "." "class" { ret = new ClassExpr(range(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn), type); }
| LOOKAHEAD (ResultType() "::" )
type = ResultType() "::" [typeArgs = TypeParameters() { typeArgs.remove(0); }] (<IDENTIFIER> | "new")
{
ret = new TypeExpr(type.getBeginLine(), type.getBeginColumn(), type.getEndLine(), type.getEndColumn(), type);
- ret = new MethodReferenceExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, token.image);
+ ret = new MethodReferenceExpr(range(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn), ret, typeArgs, token.image);
}
|
@@ -2496,7 +2498,7 @@
[ args = Arguments() {hasArgs=true;} ]
{
if (hasArgs) {
- MethodCallExpr m = new MethodCallExpr(line, column, token.endLine, token.endColumn, null, null, null, args);
+ MethodCallExpr m = new MethodCallExpr(range(line, column, token.endLine, token.endColumn), null, null, null, args);
m.setNameExpr(name);
ret = m;
} else {
@@ -2516,7 +2518,7 @@
LOOKAHEAD(2)
ret = PrimarySuffixWithoutSuper(scope)
|
- "." "super" { ret = new SuperExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope); }
+ "." "super" { ret = new SuperExpr(range(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn), scope); }
)
{ return ret; }
}
@@ -2533,7 +2535,7 @@
(
"."
(
- "this" { ret = new ThisExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope); }
+ "this" { ret = new ThisExpr(range(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn), scope); }
|
ret = AllocationExpression(scope)
|
@@ -2543,18 +2545,18 @@
[ args = Arguments() {hasArgs=true;} ]
{
if (hasArgs) {
- MethodCallExpr m = new MethodCallExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, typeArgs, null, args);
+ MethodCallExpr m = new MethodCallExpr(range(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn), scope, typeArgs, null, args);
m.setNameExpr(name);
ret = m;
} else {
- FieldAccessExpr f = new FieldAccessExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, typeArgs, null);
+ FieldAccessExpr f = new FieldAccessExpr(range(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn), scope, typeArgs, null);
f.setFieldExpr(name);
ret = f;
}
}
)
|
- "["ret = Expression() "]" { ret = new ArrayAccessExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, ret); }
+ "["ret = Expression() "]" { ret = new ArrayAccessExpr(range(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn), scope, ret); }
)
{ return ret; }
}
@@ -2566,23 +2568,23 @@
{
(
<INTEGER_LITERAL> {
- ret = new IntegerLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image);
+ ret = new IntegerLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image);
}
|
<LONG_LITERAL> {
- ret = new LongLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image);
+ ret = new LongLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image);
}
|
<FLOATING_POINT_LITERAL> {
- ret = new DoubleLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image);
+ ret = new DoubleLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image);
}
|
<CHARACTER_LITERAL> {
- ret = new CharLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image.substring(1, token.image.length()-1));
+ ret = new CharLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image.substring(1, token.image.length()-1));
}
|
<STRING_LITERAL> {
- ret = new StringLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, token.image.substring(1, token.image.length()-1));
+ ret = new StringLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), token.image.substring(1, token.image.length()-1));
}
|
ret = BooleanLiteral()
@@ -2598,9 +2600,9 @@
}
{
(
- "true" { ret = new BooleanLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, true); }
+ "true" { ret = new BooleanLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), true); }
|
- "false" { ret = new BooleanLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn, false); }
+ "false" { ret = new BooleanLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn), false); }
)
{ return ret; }
}
@@ -2609,7 +2611,7 @@
{}
{
"null"
- { return new NullLiteralExpr(token.beginLine, token.beginColumn, token.endLine, token.endColumn); }
+ { return new NullLiteralExpr(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn)); }
}
List Arguments():
@@ -2653,7 +2655,7 @@
type = PrimitiveType() {type.setAnnotations(annotations); }
arr = ArrayDimsAndInits()
{
- arrayExpr = new ArrayCreationExpr(line, column, token.endLine, token.endColumn, type, null, 0);
+ arrayExpr = new ArrayCreationExpr(range(line, column, token.endLine, token.endColumn), type, null, 0);
arrayExpr.setArraysAnnotations((List)arr[2]);
if (arr[0] instanceof Integer) {
arrayExpr.setArrayCount(((Integer)arr[0]).intValue());
@@ -2669,7 +2671,7 @@
type = ClassOrInterfaceType()
(
- arr = ArrayDimsAndInits() {type.setAnnotations(annotations); arrayExpr = new ArrayCreationExpr(line, column, token.endLine, token.endColumn, type, null, 0); }
+ arr = ArrayDimsAndInits() {type.setAnnotations(annotations); arrayExpr = new ArrayCreationExpr(range(line, column, token.endLine, token.endColumn), type, null, 0); }
{
arrayExpr.setArraysAnnotations((List)arr[2]);
if (arr[0] instanceof Integer) {
@@ -2683,7 +2685,7 @@
}
|
args = Arguments() [ LOOKAHEAD(2) anonymousBody = ClassOrInterfaceBody(false) ]
- { type.setAnnotations(annotations); ret = new ObjectCreationExpr(line, column, token.endLine, token.endColumn, scope, (ClassOrInterfaceType) type, typeArgs, args, anonymousBody); }
+ { type.setAnnotations(annotations); ret = new ObjectCreationExpr(range(line, column, token.endLine, token.endColumn), scope, (ClassOrInterfaceType) type, typeArgs, args, anonymousBody); }
)
)
{ return ret; }
@@ -2770,7 +2772,7 @@
}
{
"assert" {line=token.beginLine; column=token.beginColumn;} check = Expression() [ ":" msg = Expression() ] ";"
- { return new AssertStmt(line, column, token.endLine, token.endColumn,check, msg); }
+ { return new AssertStmt(range(line, column, token.endLine, token.endColumn),check, msg); }
}
LabeledStmt LabeledStatement():
@@ -2782,7 +2784,7 @@
}
{
<IDENTIFIER> {line=token.beginLine; column=token.beginColumn;} { label = token.image; } ":" stmt = Statement()
- { return new LabeledStmt(line, column, token.endLine, token.endColumn,label, stmt); }
+ { return new LabeledStmt(range(line, column, token.endLine, token.endColumn),label, stmt); }
}
BlockStmt Block():
@@ -2795,7 +2797,7 @@
"{" {beginLine=token.beginLine; beginColumn=token.beginColumn;}
stmts = Statements()
"}"
- { return new BlockStmt(beginLine, beginColumn, token.endLine, token.endColumn, stmts); }
+ { return new BlockStmt(range(beginLine, beginColumn, token.endLine, token.endColumn), stmts); }
}
/*
@@ -2813,11 +2815,11 @@
LOOKAHEAD( Modifiers() ("class" | "interface") )
{ }
modifier = Modifiers()
- typeDecl = ClassOrInterfaceDeclaration(modifier) { ret = new TypeDeclarationStmt(typeDecl.getBeginLine(), typeDecl.getBeginColumn(), token.endLine, token.endColumn, typeDecl); }
+ typeDecl = ClassOrInterfaceDeclaration(modifier) { ret = new TypeDeclarationStmt(range(typeDecl.getBeginLine(), typeDecl.getBeginColumn(), token.endLine, token.endColumn), typeDecl); }
|
LOOKAHEAD(VariableDeclarationExpression() )
expr = VariableDeclarationExpression() ";"
- { ret = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr); }
+ { ret = new ExpressionStmt(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr); }
|
ret = Statement()
)
@@ -2837,7 +2839,7 @@
int line = modifier.beginLine;
int column = modifier.beginColumn;
if(line==-1) {line=type.getBeginLine(); column=type.getBeginColumn(); }
- return new VariableDeclarationExpr(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, vars);
+ return new VariableDeclarationExpr(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, type, vars);
}
}
@@ -2845,7 +2847,7 @@
{}
{
";"
- { return new EmptyStmt(token.beginLine, token.beginColumn, token.endLine, token.endColumn); }
+ { return new EmptyStmt(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn)); }
}
Statement LambdaBody():
@@ -2857,7 +2859,7 @@
(
expr = Expression()
{
- n = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr);
+ n = new ExpressionStmt(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr);
}
| n = Block()
)
@@ -2892,12 +2894,12 @@
|
expr = PrimaryExpression()
[
- "++" { expr = new UnaryExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, UnaryExpr.Operator.posIncrement); }
+ "++" { expr = new UnaryExpr(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr, UnaryExpr.Operator.posIncrement); }
|
- "--" { expr = new UnaryExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, UnaryExpr.Operator.posDecrement); }
+ "--" { expr = new UnaryExpr(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr, UnaryExpr.Operator.posDecrement); }
|
- op = AssignmentOperator() value = Expression() { expr = new AssignExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, value, op); }
- | "::" [typeArgs = TypeParameters() { typeArgs.remove(0); } ] (<IDENTIFIER > | "new"){expr = new MethodReferenceExpr(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr, typeArgs, token.image); }
+ op = AssignmentOperator() value = Expression() { expr = new AssignExpr(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr, value, op); }
+ | "::" [typeArgs = TypeParameters() { typeArgs.remove(0); } ] (<IDENTIFIER > | "new"){expr = new MethodReferenceExpr(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr, typeArgs, token.image); }
|
"->" lambdaBody = LambdaBody()
@@ -2915,7 +2917,7 @@
]
)
";"
- { return new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr); }
+ { return new ExpressionStmt(range(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn), expr); }
}
SwitchStmt SwitchStatement():
@@ -2931,7 +2933,7 @@
( entry = SwitchEntry() { entries = add(entries, entry); } )*
"}"
- { return new SwitchStmt(line, column, token.endLine, token.endColumn,selector, entries); }
+ { return new SwitchStmt(range(line, column, token.endLine, token.endColumn),selector, entries); }
}
SwitchEntryStmt SwitchEntry():
@@ -2949,7 +2951,7 @@
)
":" stmts = Statements()
- { return new SwitchEntryStmt(line, column, token.endLine, token.endColumn,label, stmts); }
+ { return new SwitchEntryStmt(range(line, column, token.endLine, token.endColumn),label, stmts); }
}
IfStmt IfStatement():
@@ -2970,7 +2972,7 @@
{
"if" {line=token.beginLine; column=token.beginColumn;} "(" condition = Expression() ")" {} thenStmt = Statement() [ LOOKAHEAD(1) "else" {} elseStmt = Statement() ]
{
- IfStmt tmp = new IfStmt(line, column, token.endLine, token.endColumn,condition, thenStmt, elseStmt);
+ IfStmt tmp = new IfStmt(range(line, column, token.endLine, token.endColumn),condition, thenStmt, elseStmt);
thenStmt.setComment(thenCmmt);
if (elseStmt != null)
@@ -2988,7 +2990,7 @@
}
{
"while" {line=token.beginLine; column=token.beginColumn;} "(" condition = Expression() ")" body = Statement()
- { return new WhileStmt(line, column, token.endLine, token.endColumn,condition, body); }
+ { return new WhileStmt(range(line, column, token.endLine, token.endColumn),condition, body); }
}
DoStmt DoStatement():
@@ -3000,7 +3002,7 @@
}
{
"do" {line=token.beginLine; column=token.beginColumn;} body = Statement() "while" "(" condition = Expression() ")" ";"
- { return new DoStmt(line, column, token.endLine, token.endColumn,body, condition); }
+ { return new DoStmt(range(line, column, token.endLine, token.endColumn),body, condition); }
}
Statement ForStatement():
@@ -3028,9 +3030,9 @@
{
if (varExpr != null) {
- return new ForeachStmt(line, column, token.endLine, token.endColumn,varExpr, expr, body);
+ return new ForeachStmt(range(line, column, token.endLine, token.endColumn),varExpr, expr, body);
}
- return new ForStmt(line, column, token.endLine, token.endColumn,init, expr, update, body);
+ return new ForStmt(range(line, column, token.endLine, token.endColumn),init, expr, update, body);
}
}
@@ -3078,7 +3080,7 @@
}
{
"break" {line=token.beginLine; column=token.beginColumn;} [ <IDENTIFIER> { id = token.image; } ] ";"
- { return new BreakStmt(line, column, token.endLine, token.endColumn,id); }
+ { return new BreakStmt(range(line, column, token.endLine, token.endColumn),id); }
}
ContinueStmt ContinueStatement():
@@ -3089,7 +3091,7 @@
}
{
"continue" {line=token.beginLine; column=token.beginColumn;} [ <IDENTIFIER> { id = token.image; } ] ";"
- { return new ContinueStmt(line, column, token.endLine, token.endColumn,id); }
+ { return new ContinueStmt(range(line, column, token.endLine, token.endColumn),id); }
}
ReturnStmt ReturnStatement():
@@ -3100,7 +3102,7 @@
}
{
"return" {line=token.beginLine; column=token.beginColumn;} [ expr = Expression() ] ";"
- { return new ReturnStmt(line, column, token.endLine, token.endColumn,expr); }
+ { return new ReturnStmt(range(line, column, token.endLine, token.endColumn),expr); }
}
ThrowStmt ThrowStatement():
@@ -3111,7 +3113,7 @@
}
{
"throw" {line=token.beginLine; column=token.beginColumn;} expr = Expression() ";"
- { return new ThrowStmt(line, column, token.endLine, token.endColumn,expr); }
+ { return new ThrowStmt(range(line, column, token.endLine, token.endColumn),expr); }
}
SynchronizedStmt SynchronizedStatement():
@@ -3123,7 +3125,7 @@
}
{
"synchronized" {line=token.beginLine; column=token.beginColumn;} "(" expr = Expression() ")" block = Block()
- { return new SynchronizedStmt(line, column, token.endLine, token.endColumn,expr, block); }
+ { return new SynchronizedStmt(range(line, column, token.endLine, token.endColumn),expr, block); }
}
TryStmt TryStatement():
@@ -3169,14 +3171,14 @@
} else {
type = (Type)exceptTypes.get(0);
}
- catchs = add(catchs, new CatchClause(cLine, cColumn, token.endLine, token.endColumn, exceptModifier.modifiers, exceptModifier.annotations, type, exceptId, catchBlock));
+ catchs = add(catchs, new CatchClause(range(cLine, cColumn, token.endLine, token.endColumn), exceptModifier.modifiers, exceptModifier.annotations, type, exceptId, catchBlock));
exceptTypes = new LinkedList(); }
)*
[ "finally" finallyBlock = Block() ]
|
"finally" finallyBlock = Block()
)
- { return new TryStmt(line, column, token.endLine, token.endColumn, resources, tryBlock, catchs, finallyBlock); }
+ { return new TryStmt(range(line, column, token.endLine, token.endColumn), resources, tryBlock, catchs, finallyBlock); }
}
@@ -3255,7 +3257,7 @@
}
{
"@" {line=token.beginLine; column=token.beginColumn;} name = Name() "(" [ pairs = MemberValuePairs() ] ")"
- { return new NormalAnnotationExpr(line, column, token.endLine, token.endColumn,name, pairs); }
+ { return new NormalAnnotationExpr(range(line, column, token.endLine, token.endColumn),name, pairs); }
}
MarkerAnnotationExpr MarkerAnnotation():
@@ -3266,7 +3268,7 @@
}
{
"@" {line=token.beginLine; column=token.beginColumn;} name = Name()
- { return new MarkerAnnotationExpr(line, column, token.endLine, token.endColumn,name); }
+ { return new MarkerAnnotationExpr(range(line, column, token.endLine, token.endColumn),name); }
}
SingleMemberAnnotationExpr SingleMemberAnnotation():
@@ -3278,7 +3280,7 @@
}
{
"@" {line=token.beginLine; column=token.beginColumn;} name = Name() "(" memberVal = MemberValue() ")"
- { return new SingleMemberAnnotationExpr(line, column, token.endLine, token.endColumn,name, memberVal); }
+ { return new SingleMemberAnnotationExpr(range(line, column, token.endLine, token.endColumn),name, memberVal); }
}
List MemberValuePairs():
@@ -3300,7 +3302,7 @@
}
{
<IDENTIFIER> { name = token.image; line=token.beginLine; column=token.beginColumn;} "=" value = MemberValue()
- { return new MemberValuePair(line, column, token.endLine, token.endColumn,name, value); }
+ { return new MemberValuePair(range(line, column, token.endLine, token.endColumn),name, value); }
}
Expression MemberValue():
@@ -3329,7 +3331,7 @@
"{" {line=token.beginLine; column=token.beginColumn;}
( member = MemberValue() { ret.add(member); } ( LOOKAHEAD(2) "," member = MemberValue() { ret.add(member); } )* )? [ "," ]
"}"
- { return new ArrayInitializerExpr(line, column, token.endLine, token.endColumn,ret); }
+ { return new ArrayInitializerExpr(range(line, column, token.endLine, token.endColumn),ret); }
}
@@ -3347,7 +3349,7 @@
"interface" name = Name() members = AnnotationTypeBody()
{
- AnnotationDeclaration tmp = new AnnotationDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, null, members);
+ AnnotationDeclaration tmp = new AnnotationDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, null, members);
tmp.setNameExpr(name);
return tmp;
}
@@ -3372,7 +3374,7 @@
{
{ }
(
- ";" { ret = new EmptyTypeDeclaration(token.beginLine, token.beginColumn, token.endLine, token.endColumn); }
+ ";" { ret = new EmptyTypeDeclaration(range(token.beginLine, token.beginColumn, token.endLine, token.endColumn)); }
|
modifier = Modifiers()
(
@@ -3404,7 +3406,7 @@
int line = modifier.beginLine;
int column = modifier.beginColumn;
{ if (line == -1) {line=type.getBeginLine(); column=type.getBeginColumn();} }
- return new AnnotationMemberDeclaration(line, column, token.endLine, token.endColumn, modifier.modifiers, modifier.annotations, type, name, defaultVal);
+ return new AnnotationMemberDeclaration(range(line, column, token.endLine, token.endColumn), modifier.modifiers, modifier.annotations, type, name, defaultVal);
}
}
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/bdd/PositionRangeTest.java b/javaparser-testing/src/test/java/com/github/javaparser/bdd/PositionRangeTest.java
new file mode 100644
index 0000000..8cb8b82
--- /dev/null
+++ b/javaparser-testing/src/test/java/com/github/javaparser/bdd/PositionRangeTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007-2010 Júlio Vilmar Gesser.
+ * Copyright (C) 2011, 2013-2015 The JavaParser Team.
+ *
+ * This file is part of JavaParser.
+ *
+ * JavaParser can be used either under the terms of
+ * a) the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * b) the terms of the Apache License
+ *
+ * You should have received a copy of both licenses in LICENCE.LGPL and
+ * LICENCE.APACHE. Please refer to those files for details.
+ *
+ * JavaParser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+package com.github.javaparser.bdd;
+
+import com.github.javaparser.bdd.steps.PositionRangeSteps;
+import com.github.javaparser.bdd.steps.SharedSteps;
+import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;
+import org.jbehave.core.steps.InjectableStepsFactory;
+import org.jbehave.core.steps.InstanceStepsFactory;
+import org.junit.runner.RunWith;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RunWith(JUnitReportingRunner.class)
+public class PositionRangeTest extends BasicJBehaveTest {
+
+ @Override
+ public InjectableStepsFactory stepsFactory() {
+ Map<String, Object> state = new HashMap<>();
+
+ return new InstanceStepsFactory(configuration(),
+ new SharedSteps(state),
+ new PositionRangeSteps());
+ }
+
+ public PositionRangeTest() {
+ super("**/bdd/position_range*.story");
+ }
+}
+
+
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/bdd/steps/PositionRangeSteps.java b/javaparser-testing/src/test/java/com/github/javaparser/bdd/steps/PositionRangeSteps.java
new file mode 100644
index 0000000..ae4095d
--- /dev/null
+++ b/javaparser-testing/src/test/java/com/github/javaparser/bdd/steps/PositionRangeSteps.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2007-2010 Júlio Vilmar Gesser.
+ * Copyright (C) 2011, 2013-2015 The JavaParser Team.
+ *
+ * This file is part of JavaParser.
+ *
+ * JavaParser can be used either under the terms of
+ * a) the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * b) the terms of the Apache License
+ *
+ * You should have received a copy of both licenses in LICENCE.LGPL and
+ * LICENCE.APACHE. Please refer to those files for details.
+ *
+ * JavaParser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+package com.github.javaparser.bdd.steps;
+
+import com.github.javaparser.*;
+import org.jbehave.core.annotations.*;
+
+import static com.github.javaparser.Position.*;
+import static com.github.javaparser.Range.range;
+import static org.junit.Assert.*;
+
+public class PositionRangeSteps {
+
+ private Position position;
+ private Position secondPosition;
+ private Range range;
+ private Range secondRange;
+
+ @BeforeScenario
+ public void reset() {
+ position = null;
+ secondPosition = null;
+ range = null;
+ secondRange = null;
+ }
+ /*
+ * Given steps
+ */
+
+ @Given("the position $line, $column")
+ public void givenThePosition(int line, int column) {
+ this.position = pos(line, column);
+ }
+
+ @Given("the range $line1, $column1 - $line2, $column2")
+ public void givenTheRange(int line1, int column1, int line2, int column2) {
+ this.range = range(line1, column1, line2, column2);
+ }
+
+ /*
+ * When steps
+ */
+
+ @When("I compare to position $line, $column")
+ public void iCompareToPosition(int line, int column) {
+ secondPosition = pos(line, column);
+ }
+
+ @When("I compare to range $line1, $column1 - $line2, $column2")
+ public void whenICompareToRange(int line1, int column1, int line2, int column2) {
+ this.secondRange = range(line1, column1, line2, column2);
+ }
+
+ /*
+ * Then steps
+ */
+
+ @Then("the positions are equal")
+ public void thenThePositionsAreEqual() {
+ assertTrue(position.equals(secondPosition));
+ }
+
+ @Then("it is after the {first|} position")
+ public void thenItIsAfterTheFirstPosition() {
+ if (secondPosition != null) {
+ assertTrue(secondPosition.isAfter(position));
+ } else {
+ assertTrue(secondRange.isAfter(position));
+ }
+ }
+
+ @Then("it is before the {first|} position")
+ public void thenItIsBeforeTheFirstPosition() {
+ if (secondPosition != null) {
+ assertTrue(secondPosition.isBefore(position));
+ } else {
+ assertTrue(secondRange.isBefore(position));
+ }
+ }
+
+ @Then("the positions are not equal")
+ public void thenThePositionsAreNotEqual() {
+ assertFalse(position.equals(secondPosition));
+ }
+
+ @Then("it is not after the {first|} position")
+ public void thenItIsNotAfterTheFirstPosition() {
+ assertFalse(secondPosition.isAfter(position));
+ }
+
+ @Then("it is not before the {first|} position")
+ public void thenItIsNotBeforeTheFirstPosition() {
+ assertFalse(secondPosition.isBefore(position));
+ }
+
+ @Then("the ranges are equal")
+ public void theRangesAreEqual() {
+ assertTrue(range.equals(secondRange));
+ }
+
+ @Then("it is contained in the first range")
+ public void itIsContainedInTheFirstRange() {
+ assertTrue(range.contains(secondRange));
+ }
+}
diff --git a/javaparser-testing/src/test/resources/com/github/javaparser/bdd/position_range_scenarios.story b/javaparser-testing/src/test/resources/com/github/javaparser/bdd/position_range_scenarios.story
new file mode 100644
index 0000000..410e456
--- /dev/null
+++ b/javaparser-testing/src/test/resources/com/github/javaparser/bdd/position_range_scenarios.story
@@ -0,0 +1,55 @@
+Scenario: a position is equal to another position at the same place
+Given the position 10, 10
+When I compare to position 10, 10
+Then the positions are equal
+And it is not before the first position
+And it is not after the first position
+
+Scenario: a position is after another position
+Given the position 10, 10
+When I compare to position 20, 20
+Then it is after the first position
+And the positions are not equal
+And it is not before the first position
+
+Scenario: a position is directly after another position
+Given the position 10, 10
+When I compare to position 10, 11
+Then it is after the first position
+And the positions are not equal
+And it is not before the first position
+
+Scenario: a position is before another position
+Given the position 10, 10
+When I compare to position 5, 5
+Then it is before the first position
+And the positions are not equal
+And it is not after the first position
+
+Scenario: a position is directly before another position
+Given the position 10, 10
+When I compare to position 10, 9
+Then it is before the first position
+And the positions are not equal
+And it is not after the first position
+
+Scenario: a range is equal to another range
+Given the range 10, 10 - 20, 20
+When I compare to range 10, 10 - 20, 20
+Then the ranges are equal
+
+Scenario: a range is before a position
+Given the position 20, 21
+When I compare to range 10, 10 - 20, 20
+Then it is before the position
+
+Scenario: a range is after a position
+Given the position 10, 9
+When I compare to range 10, 10 - 20, 20
+Then it is after the position
+
+Scenario: a range is contained in another range
+Given the range 10, 10 - 20, 20
+When I compare to range 11, 11 - 19, 19
+Then it is contained in the first range
+