private void handleParseProblems(EcmascriptNode<? extends AstNode> node) { if (node instanceof TrailingCommaNode) { TrailingCommaNode trailingCommaNode = (TrailingCommaNode) node; int nodeStart = node.getNode().getAbsolutePosition(); int nodeEnd = nodeStart + node.getNode().getLength() - 1; for (ParseProblem parseProblem : parseProblems) { // The node overlaps the comma (i.e. end of the problem)? int problemStart = parseProblem.getFileOffset(); int commaPosition = problemStart + parseProblem.getLength() - 1; if (nodeStart <= commaPosition && commaPosition <= nodeEnd) { if ("Trailing comma is not legal in an ECMA-262 object initializer" .equals(parseProblem.getMessage())) { // Report on the shortest code block containing the // problem (i.e. inner most code in nested structures). EcmascriptNode<?> currentNode = (EcmascriptNode<?>) parseProblemToNode.get(parseProblem); if (currentNode == null || node.getNode().getLength() < currentNode.getNode().getLength()) { parseProblemToNode.put(parseProblem, trailingCommaNode); } } } } } }
void calculateLineNumbers(SourceCodePositioner positioner) { int startOffset = node.getAbsolutePosition(); int endOffset = startOffset + node.getLength(); this.beginLine = positioner.lineNumberFromOffset(startOffset); this.beginColumn = positioner.columnFromOffset(this.beginLine, startOffset); this.endLine = positioner.lineNumberFromOffset(endOffset); // end column is inclusive this.endColumn = positioner.columnFromOffset(this.endLine, endOffset) - 1; if (this.endColumn < 0) { this.endColumn = 0; } }
/** * Constructs a new {@code ExpressionStatement} wrapping * the specified expression. Sets this node's position to the * position of the wrapped node, and sets the wrapped node's * position to zero. Sets this node's length to the length of * the wrapped node. * @param expr the wrapped expression */ public ExpressionStatement(AstNode expr) { this(expr.getPosition(), expr.getLength(), expr); }
public ParenthesizedExpression(AstNode expr) { this(expr != null ? expr.getPosition() : 0, expr != null ? expr.getLength() : 1, expr); }
/** * Constructs a new {@code ExpressionStatement} wrapping * the specified expression. Sets this node's position to the * position of the wrapped node, and sets the wrapped node's * position to zero. Sets this node's length to the length of * the wrapped node. * @param expr the wrapped expression */ public ExpressionStatement(AstNode expr) { this(expr.getPosition(), expr.getLength(), expr); }
public ParenthesizedExpression(AstNode expr) { this(expr != null ? expr.getPosition() : 0, expr != null ? expr.getLength() : 1, expr); }
/** * Constructs a new {@code ExpressionStatement} wrapping * the specified expression. Sets this node's position to the * position of the wrapped node, and sets the wrapped node's * position to zero. Sets this node's length to the length of * the wrapped node. * @param expr the wrapped expression */ public ExpressionStatement(AstNode expr) { this(expr.getPosition(), expr.getLength(), expr); }
public ThrowStatement(int pos, AstNode expr) { super(pos, expr.getLength()); setExpression(expr); }
public ParenthesizedExpression(AstNode expr) { this(expr != null ? expr.getPosition() : 0, expr != null ? expr.getLength() : 1, expr); }
/** * Constructs a new {@code ExpressionStatement} wrapping * the specified expression. Sets this node's position to the * position of the wrapped node, and sets the wrapped node's * position to zero. Sets this node's length to the length of * the wrapped node. * @param expr the wrapped expression */ public ExpressionStatement(AstNode expr) { this(expr.getPosition(), expr.getLength(), expr); }
private boolean canProcessNode(AstNode node) { int start = node.getAbsolutePosition(); int offset = start + node.getLength(); return dot >= start && dot < offset; }
public ParenthesizedExpression(AstNode expr) { this(expr != null ? expr.getPosition() : 0, expr != null ? expr.getLength() : 1, expr); }
/** * Sets loop body. Sets the parent of the body to this loop node, * and updates its offset to be relative. Extends the length of this * node to include the body. */ public void setBody(AstNode body) { this.body = body; int end = body.getPosition() + body.getLength(); this.setLength(end - this.getPosition()); body.setParent(this); }
/** * Sets loop body. Sets the parent of the body to this loop node, * and updates its offset to be relative. Extends the length of this * node to include the body. */ public void setBody(AstNode body) { this.body = body; int end = body.getPosition() + body.getLength(); this.setLength(end - this.getPosition()); body.setParent(this); }
/** * Sets loop body. Sets the parent of the body to this loop node, * and updates its offset to be relative. Extends the length of this * node to include the body. */ public void setBody(AstNode body) { this.body = body; int end = body.getPosition() + body.getLength(); this.setLength(end - this.getPosition()); body.setParent(this); }
/** * Sets loop body. Sets the parent of the body to this loop node, * and updates its offset to be relative. Extends the length of this * node to include the body. */ public void setBody(AstNode body) { this.body = body; int end = body.getPosition() + body.getLength(); this.setLength(end - this.getPosition()); body.setParent(this); }
private ITree buildTree(AstNode node) { ITree t = context.createTree(node.getType(), ITree.NO_LABEL, Token.typeToName(node.getType())); t.setPos(node.getAbsolutePosition()); t.setLength(node.getLength()); trees.put(node, t); return t; }
public void setLeftAndRight(AstNode left, AstNode right) { assertNotNull(left); assertNotNull(right); // compute our bounds while children have absolute positions int beg = left.getPosition(); int end = right.getPosition() + right.getLength(); setBounds(beg, end); // this updates their positions to be parent-relative setLeft(left); setRight(right); }
public void setLeftAndRight(AstNode left, AstNode right) { assertNotNull(left); assertNotNull(right); // compute our bounds while children have absolute positions int beg = left.getPosition(); int end = right.getPosition() + right.getLength(); setBounds(beg, end); // this updates their positions to be parent-relative setLeft(left); setRight(right); }
public void setLeftAndRight(AstNode left, AstNode right) { assertNotNull(left); assertNotNull(right); // compute our bounds while children have absolute positions int beg = left.getPosition(); int end = right.getPosition() + right.getLength(); setBounds(beg, end); // this updates their positions to be parent-relative setLeft(left); setRight(right); }