Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabergia committed Nov 19, 2024
1 parent 803538a commit d9fc589
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion .java-version

This file was deleted.

4 changes: 1 addition & 3 deletions rhino/src/main/java/org/mozilla/javascript/IRFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,7 @@ private Node transformElementGet(ElementGet node) {

private Node transformExprStmt(ExpressionStatement node) {
Node expr = transform(node.getExpression());
Node exprStatementNode = new Node(node.getType(), expr);
exprStatementNode.setLineColumnNumber(node.getLineno(), node.getColumn());
return exprStatementNode;
return new Node(node.getType(), expr, node.getLineno(), node.getColumn());
}

private Node transformForInLoop(ForInLoop loop) {
Expand Down
6 changes: 2 additions & 4 deletions rhino/src/main/java/org/mozilla/javascript/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ private AstRoot parse() throws IOException {
AstRoot root = new AstRoot(pos);
currentScope = currentScriptOrFn = root;

int baseLineno = prevNameTokenLineno = ts.lineno; // line number where source starts
int baseLineno = ts.lineno; // line number where source starts
prevNameTokenLineno = ts.getLineno();
prevNameTokenColumn = ts.getTokenColumn();
int end = pos; // in case source is empty

Expand Down Expand Up @@ -1445,7 +1446,6 @@ private IfStatement ifStatement() throws IOException {
pn.setElsePart(ifFalse);
pn.setElsePosition(elsePos);
pn.setLineColumnNumber(lineno, column);

return pn;
}

Expand Down Expand Up @@ -2491,7 +2491,6 @@ private AstNode assignExpr() throws IOException {
if (isNotValidSimpleAssignmentTarget(pn))
reportError("msg.syntax.invalid.assignment.lhs");

Node left = pn;
pn = new Assignment(tt, pn, assignExpr(), opPos);

if (jsdocNode != null) {
Expand Down Expand Up @@ -2901,7 +2900,6 @@ private AstNode memberExpr(boolean allowCallSyntax) throws IOException {
} else {
consumeToken();
int pos = ts.tokenBeg, lineno = lineNumber(), column = columnNumber();
;
NewExpression nx = new NewExpression(pos);

AstNode target = memberExpr(false);
Expand Down
10 changes: 1 addition & 9 deletions rhino/src/main/java/org/mozilla/javascript/TokenStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -2452,15 +2452,7 @@ public int getLength() {
}

public int getTokenColumn() {
return getTokenColumn(tokenBeg);
}

/**
* @param tokenPosition absolute start of the token position
* @return the 1-indexed column
*/
public int getTokenColumn(int tokenPosition) {
return tokenPosition - tokenStartLastLineEnd + 1;
return tokenBeg - tokenStartLastLineEnd + 1;
}

// stuff other than whitespace since start of line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public AstNode getLeft() {
public void setLeft(AstNode left) {
assertNotNull(left);
this.left = left;
// line number should agree with source position
// line and column number should agree with source position
setLineColumnNumber(left.getLineno(), left.getColumn());
left.setParent(this);
}
Expand Down

0 comments on commit d9fc589

Please sign in to comment.