KT-927 prepare
This commit is contained in:
@@ -4,22 +4,8 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js;
|
package com.google.dart.compiler.backend.js;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsArrayAccess;
|
import com.google.dart.compiler.backend.js.ast.*;
|
||||||
import com.google.dart.compiler.backend.js.ast.JsArrayLiteral;
|
import com.google.dart.compiler.backend.js.ast.JsExpressionStatement;
|
||||||
import com.google.dart.compiler.backend.js.ast.JsBinaryOperation;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsConditional;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsContext;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsExprStmt;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsExpression;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsFunction;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsInvocation;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsNameRef;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsNew;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsObjectLiteral;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsPostfixOperation;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsPrefixOperation;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsRegExp;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsVisitor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if an expression statement needs to be surrounded by parentheses.
|
* Determines if an expression statement needs to be surrounded by parentheses.
|
||||||
@@ -45,7 +31,7 @@ import com.google.dart.compiler.backend.js.ast.JsVisitor;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public class JsFirstExpressionVisitor extends JsVisitor {
|
public class JsFirstExpressionVisitor extends JsVisitor {
|
||||||
public static boolean exec(JsExprStmt statement) {
|
public static boolean exec(JsExpressionStatement statement) {
|
||||||
JsExpression expression = statement.getExpression();
|
JsExpression expression = statement.getExpression();
|
||||||
// Pure function declarations do not need parentheses
|
// Pure function declarations do not need parentheses
|
||||||
if (expression instanceof JsFunction) {
|
if (expression instanceof JsFunction) {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class JsPrecedenceVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(JsExprStmt x, JsContext ctx) {
|
public boolean visit(JsExpressionStatement x, JsContext ctx) {
|
||||||
throw new RuntimeException("Only expressions have precedence.");
|
throw new RuntimeException("Only expressions have precedence.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,25 +4,8 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js;
|
package com.google.dart.compiler.backend.js;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsBlock;
|
import com.google.dart.compiler.backend.js.ast.*;
|
||||||
import com.google.dart.compiler.backend.js.ast.JsBreak;
|
import com.google.dart.compiler.backend.js.ast.JsExpressionStatement;
|
||||||
import com.google.dart.compiler.backend.js.ast.JsContext;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsDebugger;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsDoWhile;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsEmpty;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsExprStmt;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsFor;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsForIn;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsIf;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsLabel;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsReturn;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsStatement;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsSwitch;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsThrow;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsTry;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsVars;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsVisitor;
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsWhile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a statement at the end of a block requires a semicolon.
|
* Determines if a statement at the end of a block requires a semicolon.
|
||||||
@@ -78,7 +61,7 @@ public class JsRequiresSemiVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(JsExprStmt x, JsContext ctx) {
|
public boolean visit(JsExpressionStatement x, JsContext ctx) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(JsExprStmt x, JsContext ctx) {
|
public boolean visit(JsExpressionStatement x, JsContext ctx) {
|
||||||
boolean surroundWithParentheses = JsFirstExpressionVisitor.exec(x);
|
boolean surroundWithParentheses = JsFirstExpressionVisitor.exec(x);
|
||||||
if (surroundWithParentheses) {
|
if (surroundWithParentheses) {
|
||||||
leftParen();
|
leftParen();
|
||||||
@@ -1022,7 +1022,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
* a newline instead of a semi.
|
* a newline instead of a semi.
|
||||||
*/
|
*/
|
||||||
boolean functionStmt =
|
boolean functionStmt =
|
||||||
statement instanceof JsExprStmt && ((JsExprStmt) statement).getExpression() instanceof JsFunction;
|
statement instanceof JsExpressionStatement && ((JsExpressionStatement) statement).getExpression() instanceof JsFunction;
|
||||||
/*
|
/*
|
||||||
* Special treatment of the last statement in a block: only a few
|
* Special treatment of the last statement in a block: only a few
|
||||||
* statements at the end of a block require semicolons.
|
* statements at the end of a block require semicolons.
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
|
import com.google.dart.compiler.backend.js.JsToStringGenerationVisitor;
|
||||||
|
import com.google.dart.compiler.common.HasSourceInfo;
|
||||||
|
import com.google.dart.compiler.util.TextOutputImpl;
|
||||||
|
|
||||||
|
abstract class AbstractNode implements JsNode, HasSourceInfo {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
TextOutputImpl out = new TextOutputImpl();
|
||||||
|
new JsToStringGenerationVisitor(out).accept(this);
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.Source;
|
|
||||||
import com.google.dart.compiler.common.SourceInfo;
|
import com.google.dart.compiler.common.SourceInfo;
|
||||||
|
|
||||||
public class ChameleonJsExpression implements JsExpression {
|
public class ChameleonJsExpression implements JsExpression {
|
||||||
@@ -61,34 +60,4 @@ public class ChameleonJsExpression implements JsExpression {
|
|||||||
public void setSourceInfo(SourceInfo info) {
|
public void setSourceInfo(SourceInfo info) {
|
||||||
expression.setSourceInfo(info);
|
expression.setSourceInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSourceLocation(Source source, int line, int column, int startPosition, int length) {
|
|
||||||
expression.setSourceLocation(source, line, column, startPosition, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Source getSource() {
|
|
||||||
return expression.getSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLine() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumn() {
|
|
||||||
return expression.getColumn();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStart() {
|
|
||||||
return expression.getStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return expression.getLength();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.HasSourceInfo;
|
import com.google.dart.compiler.common.HasSourceInfo;
|
||||||
import com.google.dart.compiler.common.SourceInfo;
|
|
||||||
|
|
||||||
public interface JsExpression extends JsNode, SourceInfo, HasSourceInfo, JsVisitable {
|
public interface JsExpression extends JsNode, HasSourceInfo, JsVisitable {
|
||||||
/**
|
/**
|
||||||
* Determines whether the expression can cause side effects.
|
* Determines whether the expression can cause side effects.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ abstract class JsExpressionImpl extends JsNodeImpl implements JsExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsStatement makeStmt() {
|
public JsStatement makeStmt() {
|
||||||
return new JsExprStmt(this);
|
return new JsExpressionStatement(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-8
@@ -4,23 +4,23 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
public final class JsExprStmt extends JsNodeImpl implements JsStatement {
|
import com.google.dart.compiler.common.SourceInfo;
|
||||||
private JsExpression expr;
|
|
||||||
|
|
||||||
public JsExprStmt(JsExpression expr) {
|
public final class JsExpressionStatement extends AbstractNode implements JsStatement {
|
||||||
super();
|
private JsExpression expression;
|
||||||
this.expr = expr;
|
|
||||||
this.setSourceInfo(expr);
|
public JsExpressionStatement(JsExpression expression) {
|
||||||
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsExpression getExpression() {
|
public JsExpression getExpression() {
|
||||||
return expr;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void traverse(JsVisitor v, JsContext context) {
|
public void traverse(JsVisitor v, JsContext context) {
|
||||||
if (v.visit(this, context)) {
|
if (v.visit(this, context)) {
|
||||||
expr = v.accept(expr);
|
expression = v.accept(expression);
|
||||||
}
|
}
|
||||||
v.endVisit(this, context);
|
v.endVisit(this, context);
|
||||||
}
|
}
|
||||||
@@ -29,4 +29,14 @@ public final class JsExprStmt extends JsNodeImpl implements JsStatement {
|
|||||||
public NodeKind getKind() {
|
public NodeKind getKind() {
|
||||||
return NodeKind.EXPRESSION_STMT;
|
return NodeKind.EXPRESSION_STMT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourceInfo getSourceInfo() {
|
||||||
|
return expression.getSourceInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSourceInfo(SourceInfo info) {
|
||||||
|
expression.setSourceInfo(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.SourceInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <code>for</code> statement. If specified at all, the initializer part is
|
* A <code>for</code> statement. If specified at all, the initializer part is
|
||||||
* either a declaration of one or more variables, in which case
|
* either a declaration of one or more variables, in which case
|
||||||
@@ -86,12 +84,6 @@ public class JsFor extends JsNodeImpl implements JsStatement {
|
|||||||
v.endVisit(this, context);
|
v.endVisit(this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsFor setSourceRef(SourceInfo info) {
|
|
||||||
super.setSourceRef(info);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeKind getKind() {
|
public NodeKind getKind() {
|
||||||
return NodeKind.FOR;
|
return NodeKind.FOR;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.SourceInfo;
|
|
||||||
import com.google.dart.compiler.common.Symbol;
|
import com.google.dart.compiler.common.Symbol;
|
||||||
import com.intellij.util.SmartList;
|
import com.intellij.util.SmartList;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -28,7 +27,7 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
|
|
||||||
private JsFunction(JsScope parentScope, @Nullable JsName name) {
|
private JsFunction(JsScope parentScope, @Nullable JsName name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.scope = new JsScope(parentScope, name == null ? null : name.getIdent());
|
scope = new JsScope(parentScope, name == null ? null : name.getIdent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsBlock getBody() {
|
public JsBlock getBody() {
|
||||||
@@ -99,12 +98,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
|||||||
v.endVisit(this, context);
|
v.endVisit(this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsFunction setSourceRef(SourceInfo info) {
|
|
||||||
super.setSourceRef(info);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeKind getKind() {
|
public NodeKind getKind() {
|
||||||
return NodeKind.FUNCTION;
|
return NodeKind.FUNCTION;
|
||||||
|
|||||||
@@ -1,30 +1,20 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.JsToStringGenerationVisitor;
|
|
||||||
import com.google.dart.compiler.common.AbstractNode;
|
|
||||||
import com.google.dart.compiler.common.SourceInfo;
|
import com.google.dart.compiler.common.SourceInfo;
|
||||||
import com.google.dart.compiler.util.TextOutputImpl;
|
|
||||||
|
|
||||||
abstract class JsNodeImpl extends AbstractNode implements JsNode {
|
abstract class JsNodeImpl extends AbstractNode {
|
||||||
|
private SourceInfo sourceInfo;
|
||||||
|
|
||||||
protected JsNodeImpl() {
|
protected JsNodeImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public SourceInfo getSourceInfo() {
|
||||||
TextOutputImpl out = new TextOutputImpl();
|
return sourceInfo;
|
||||||
new JsToStringGenerationVisitor(out).accept(this);
|
|
||||||
return out.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SourceInfo getSourceInfo() {
|
public void setSourceInfo(SourceInfo info) {
|
||||||
return this;
|
sourceInfo = info;
|
||||||
}
|
|
||||||
|
|
||||||
public JsNode setSourceRef(SourceInfo info) {
|
|
||||||
if (info != null) {
|
|
||||||
setSourceInfo(info);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.SourceInfo;
|
|
||||||
import com.google.dart.compiler.common.Symbol;
|
import com.google.dart.compiler.common.Symbol;
|
||||||
import com.intellij.util.SmartList;
|
import com.intellij.util.SmartList;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -91,12 +90,6 @@ public class JsVars extends JsNodeImpl implements JsStatement, Iterable<JsVars.J
|
|||||||
v.endVisit(this, context);
|
v.endVisit(this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsVar setSourceRef(SourceInfo info) {
|
|
||||||
super.setSourceRef(info);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeKind getKind() {
|
public NodeKind getKind() {
|
||||||
return NodeKind.VAR;
|
return NodeKind.VAR;
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstracts the idea that a class can be traversed.
|
|
||||||
*/
|
|
||||||
public interface JsVisitable {
|
public interface JsVisitable {
|
||||||
/**
|
/**
|
||||||
* Causes this object to have the visitor visit itself and its children.
|
* Causes this object to have the visitor visit itself and its children.
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class JsVisitor {
|
|||||||
public void endVisit(JsEmpty x, JsContext ctx) {
|
public void endVisit(JsEmpty x, JsContext ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endVisit(JsExprStmt x, JsContext ctx) {
|
public void endVisit(JsExpressionStatement x, JsContext ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endVisit(JsFor x, JsContext ctx) {
|
public void endVisit(JsFor x, JsContext ctx) {
|
||||||
@@ -285,7 +285,7 @@ public class JsVisitor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean visit(JsExprStmt x, JsContext ctx) {
|
public boolean visit(JsExpressionStatement x, JsContext ctx) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package com.google.dart.compiler.common;
|
|
||||||
|
|
||||||
import com.google.dart.compiler.Source;
|
|
||||||
|
|
||||||
public class AbstractNode implements SourceInfo, HasSourceInfo {
|
|
||||||
protected SourceInfo sourceInfo;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Source getSource() {
|
|
||||||
return sourceInfo.getSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLine() {
|
|
||||||
return sourceInfo.getLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumn() {
|
|
||||||
return sourceInfo.getColumn();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStart() {
|
|
||||||
return sourceInfo.getStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return sourceInfo.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SourceInfo getSourceInfo() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSourceInfo(SourceInfo info) {
|
|
||||||
sourceInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void setSourceLocation(Source source, int line, int column, int startPosition, int length) {
|
|
||||||
sourceInfo = new SourceInfoImpl(source, line, column, startPosition, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setSourceRange(int startPosition, int length) {
|
|
||||||
//Preconditions.checkArgument(startPosition != -1 && length >= 0 || startPosition == -1 && length == 0);
|
|
||||||
//sourceInfo.sourceStart = startPosition;
|
|
||||||
//sourceInfo.sourceLength = length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,52 +4,15 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.common;
|
package com.google.dart.compiler.common;
|
||||||
|
|
||||||
import com.google.dart.compiler.Source;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract view of a class that has source info.
|
|
||||||
*/
|
|
||||||
public interface HasSourceInfo {
|
public interface HasSourceInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the source info associated with this object.
|
* Return the source info associated with this object.
|
||||||
*/
|
*/
|
||||||
SourceInfo getSourceInfo();
|
SourceInfo getSourceInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the source info associated with this object. May only be called once.
|
* Set the source info associated with this object.
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
void setSourceInfo(SourceInfo info);
|
void setSourceInfo(SourceInfo info);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the source range of the original source file where the source fragment
|
|
||||||
* corresponding to this node was found.
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Each node in the subtree (other than the contrived nodes) carries source
|
|
||||||
* range(s) information relating back to positions in the given source (the
|
|
||||||
* given source itself is not remembered with the AST). The source range
|
|
||||||
* usually begins at the first character of the first token corresponding to
|
|
||||||
* the node; leading whitespace and comments are <b>not</b> included. The
|
|
||||||
* source range usually extends through the last character of the last token
|
|
||||||
* corresponding to the node; trailing whitespace and comments are <b>not</b>
|
|
||||||
* included. There are a handful of exceptions (including the various body
|
|
||||||
* declarations). Source ranges nest properly: the source range for a child is
|
|
||||||
* always within the source range of its parent, and the source ranges of
|
|
||||||
* sibling nodes never overlap.
|
|
||||||
*
|
|
||||||
* @param source the associated source
|
|
||||||
* @param line the 1-based line index, or <code>-1</code>, if no source
|
|
||||||
* location is available
|
|
||||||
* @param column the 1-based column index, or <code>-1</code>, if no source
|
|
||||||
* location is available
|
|
||||||
* @param startPosition a 0-based character index, or <code>-1</code>, if no
|
|
||||||
* source location is available
|
|
||||||
* @param length a (possibly 0) length, or <code>-1</code>, if no source
|
|
||||||
* location is available
|
|
||||||
* @see SourceInfo#getStart()
|
|
||||||
* @see SourceInfo#getLength()
|
|
||||||
*/
|
|
||||||
void setSourceLocation(Source source, int line, int column, int startPosition, int length);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user