KT-927
This commit is contained in:
@@ -48,7 +48,7 @@ public class JsConstructExpressionVisitor extends RecursiveJsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitInvocation(JsInvocation x) {
|
public void visitInvocation(JsInvocation invocation) {
|
||||||
containsInvocation = true;
|
containsInvocation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ public class JsFirstExpressionVisitor extends RecursiveJsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitInvocation(JsInvocation x) {
|
public void visitInvocation(JsInvocation invocation) {
|
||||||
accept(x.getQualifier());
|
accept(invocation.getQualifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class JsPrecedenceVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitInvocation(JsInvocation x) {
|
public void visitInvocation(JsInvocation invocation) {
|
||||||
answer = 16;
|
answer = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -583,11 +583,11 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitInvocation(JsInvocation x) {
|
public void visitInvocation(JsInvocation invocation) {
|
||||||
printPair(x, x.getQualifier());
|
printPair(invocation, invocation.getQualifier());
|
||||||
|
|
||||||
leftParen();
|
leftParen();
|
||||||
printExpressions(x.getArguments());
|
printExpressions(invocation.getArguments());
|
||||||
rightParen();
|
rightParen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,9 +621,15 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
|||||||
}
|
}
|
||||||
p.print('.');
|
p.print('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.maybeIndent();
|
||||||
|
beforeNodePrinted(nameRef);
|
||||||
p.print(nameRef.getIdent());
|
p.print(nameRef.getIdent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void beforeNodePrinted(JsNode node) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitNew(JsNew x) {
|
public void visitNew(JsNew x) {
|
||||||
p.print(CHARS_NEW);
|
p.print(CHARS_NEW);
|
||||||
|
|||||||
@@ -35,12 +35,17 @@ public class ChameleonJsExpression implements JsExpression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSourceInfo() {
|
public Object getSource() {
|
||||||
return expression.getSourceInfo();
|
return expression.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSourceInfo(Object info) {
|
public void setSource(Object info) {
|
||||||
expression.setSourceInfo(info);
|
expression.setSource(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsExpression source(Object info) {
|
||||||
|
return expression.source(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.HasSourceInfo;
|
public interface JsExpression extends JsNode {
|
||||||
|
|
||||||
public interface JsExpression extends JsNode, HasSourceInfo {
|
|
||||||
boolean isLeaf();
|
boolean isLeaf();
|
||||||
|
|
||||||
JsStatement makeStmt();
|
JsStatement makeStmt();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
JsExpression source(Object info);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,10 @@ abstract class JsExpressionImpl extends SourceInfoAwareJsNode implements JsExpre
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsExpression source(Object info) {
|
||||||
|
setSource(info);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,17 @@ public final class JsExpressionStatement extends AbstractNode implements JsState
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSourceInfo() {
|
public Object getSource() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSourceInfo(Object info) {
|
public void setSource(Object info) {
|
||||||
|
throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsNode source(Object info) {
|
||||||
throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
|
throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a JavaScript invocation.
|
|
||||||
*/
|
|
||||||
public final class JsInvocation extends JsExpressionImpl.JsExpressionHasArguments {
|
public final class JsInvocation extends JsExpressionImpl.JsExpressionHasArguments {
|
||||||
private JsExpression qualifier;
|
private JsExpression qualifier;
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,27 @@
|
|||||||
|
|
||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
import com.google.dart.compiler.common.HasSourceInfo;
|
public interface JsNode {
|
||||||
|
|
||||||
public interface JsNode extends HasSourceInfo {
|
|
||||||
/**
|
/**
|
||||||
* Causes this object to have the visitor visit itself and its children.
|
* Causes this object to have the visitor visit itself and its children.
|
||||||
*
|
*
|
||||||
* @param visitor the visitor that should traverse this node
|
* @param visitor the visitor that should traverse this node
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void accept(JsVisitor visitor);
|
void accept(JsVisitor visitor);
|
||||||
|
|
||||||
void acceptChildren(JsVisitor visitor);
|
void acceptChildren(JsVisitor visitor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the source info associated with this object.
|
||||||
|
*/
|
||||||
|
Object getSource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the source info associated with this object.
|
||||||
|
*
|
||||||
|
* @param info
|
||||||
|
*/
|
||||||
|
void setSource(Object info);
|
||||||
|
|
||||||
|
JsNode source(Object info);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ public abstract class JsVisitor {
|
|||||||
visitElement(x);
|
visitElement(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitInvocation(JsInvocation x) {
|
public void visitInvocation(JsInvocation invocation) {
|
||||||
visitElement(x);
|
visitElement(invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitLabel(JsLabel x) {
|
public void visitLabel(JsLabel x) {
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
package com.google.dart.compiler.backend.js.ast;
|
package com.google.dart.compiler.backend.js.ast;
|
||||||
|
|
||||||
abstract class SourceInfoAwareJsNode extends AbstractNode {
|
abstract class SourceInfoAwareJsNode extends AbstractNode {
|
||||||
private Object sourceInfo;
|
private Object source;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSourceInfo() {
|
public Object getSource() {
|
||||||
return sourceInfo;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSourceInfo(Object info) {
|
public void setSource(Object info) {
|
||||||
sourceInfo = info;
|
source = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void acceptChildren(JsVisitor visitor) {
|
public void acceptChildren(JsVisitor visitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsNode source(Object info) {
|
||||||
|
source = info;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +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;
|
|
||||||
|
|
||||||
public interface HasSourceInfo {
|
|
||||||
/**
|
|
||||||
* Return the source info associated with this object.
|
|
||||||
*/
|
|
||||||
Object getSourceInfo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the source info associated with this object.
|
|
||||||
* @param info
|
|
||||||
*/
|
|
||||||
void setSourceInfo(Object info);
|
|
||||||
}
|
|
||||||
@@ -42,6 +42,8 @@ public interface TextOutput {
|
|||||||
|
|
||||||
void setOutListener(OutListener outListener);
|
void setOutListener(OutListener outListener);
|
||||||
|
|
||||||
|
void maybeIndent();
|
||||||
|
|
||||||
public interface OutListener {
|
public interface OutListener {
|
||||||
void newLined();
|
void newLined();
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ public class TextOutputImpl implements TextOutput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeIndent() {
|
@Override
|
||||||
|
public void maybeIndent() {
|
||||||
if (justNewlined && !compact) {
|
if (justNewlined && !compact) {
|
||||||
printAndCount(indents[identLevel]);
|
printAndCount(indents[identLevel]);
|
||||||
justNewlined = false;
|
justNewlined = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user