Fixed chaining semantics after outdent

This commit is contained in:
xixixao 2014-01-21 21:49:01 +00:00
parent 21db08a23d
commit 39cb8815f7
3 changed files with 14 additions and 16 deletions

View File

@ -290,15 +290,9 @@
startImplicitObject(s, !!startsLine);
return forward(2);
}
if (inImplicitCall() && __indexOf.call(CALL_CLOSERS, tag) >= 0) {
if (prevTag === 'OUTDENT') {
endImplicitCall();
return forward(1);
}
if (prevToken.newLine) {
endAllImplicitCalls();
return forward(1);
}
if (inImplicitCall() && __indexOf.call(CALL_CLOSERS, tag) >= 0 && (prevTag === 'OUTDENT' || prevToken.newLine)) {
endAllImplicitCalls();
return forward(1);
}
if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) {
stackTop()[2].sameLine = false;

View File

@ -286,13 +286,10 @@ class exports.Rewriter
# .g b
# .h a
#
if inImplicitCall() and tag in CALL_CLOSERS
if prevTag is 'OUTDENT'
endImplicitCall()
return forward(1)
if prevToken.newLine
endAllImplicitCalls()
return forward(1)
if inImplicitCall() and tag in CALL_CLOSERS and
(prevTag is 'OUTDENT' or prevToken.newLine)
endAllImplicitCalls()
return forward(1)
stackTop()[2].sameLine = no if inImplicitObject() and tag in LINEBREAKS

View File

@ -98,6 +98,13 @@ test "#1495, method call chaining", ->
).join ', '
eq 'a, b, c', result
test "chaining after outdent", ->
str = 'abc'
zero = parseInt str.replace /\w/, (letter) ->
0
.toString()
eq '0', zero
# Operators
test "newline suppression for operators", ->