提交 34c8af29 编写于 作者: J jlaskey

8005703: Offsets miscalculated for blocks

Reviewed-by: lagergren
Contributed-by: petr.hejl@oracle.com
上级 5321dc29
......@@ -185,6 +185,9 @@ public class Block extends Node {
public void addStatement(final Node statement) {
if (statement != null) {
statements.add(statement);
if (getFinish() < statement.getFinish()) {
setFinish(statement.getFinish());
}
}
}
......
......@@ -429,6 +429,8 @@ public abstract class AbstractParser {
// Create literal node.
final Object value = getValue();
// Advance to have a correct finish
next();
LiteralNode<?> node = null;
......@@ -452,7 +454,6 @@ public abstract class AbstractParser {
assert false : "unknown type for LiteralNode: " + value.getClass();
}
next();
return node;
}
}
......@@ -938,7 +938,11 @@ loop:
// If is a statement then handle end of line.
if (isStatement) {
boolean semicolon = type == SEMICOLON;
endOfLine();
if (semicolon) {
block.setFinish(finish);
}
}
return vars;
......@@ -954,7 +958,8 @@ loop:
*/
private void emptyStatement() {
if (context._empty_statements) {
block.addStatement(new EmptyNode(source, token, Token.descPosition(token)));
block.addStatement(new EmptyNode(source, token,
Token.descPosition(token) + Token.descLength(token)));
}
// SEMICOLON checked in caller.
......@@ -988,6 +993,7 @@ loop:
if (executeNode != null) {
executeNode.setFinish(finish);
block.setFinish(finish);
}
}
......@@ -1571,6 +1577,7 @@ loop:
// Get CASE body.
final Block statements = getBlock(false);
final CaseNode caseNode = new CaseNode(source, caseToken, finish, caseExpression, statements);
statements.setFinish(finish);
if (caseExpression == null) {
defaultCase = caseNode;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册