| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.incremental_scanner; | 5 library engine.incremental_scanner; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 | 8 |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'scanner.dart'; | 10 import 'scanner.dart'; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 oldRightToken = stream; | 129 oldRightToken = stream; |
| 130 } else { | 130 } else { |
| 131 oldLast = stream.previous; | 131 oldLast = stream.previous; |
| 132 oldRightToken = stream; | 132 oldRightToken = stream; |
| 133 } | 133 } |
| 134 // | 134 // |
| 135 // Compute the range of characters that are known to need to be rescanned. | 135 // Compute the range of characters that are known to need to be rescanned. |
| 136 // If the index is within an existing token, then we need to start at the | 136 // If the index is within an existing token, then we need to start at the |
| 137 // beginning of the token. | 137 // beginning of the token. |
| 138 // | 138 // |
| 139 int scanStart = math.max(oldFirst.previous.end, 0); | 139 int scanStart = math.max(oldLeftToken.end, 0); |
| 140 int scanEnd = oldLast.end + delta; | 140 int scanEnd = oldRightToken.offset + delta; |
| 141 // | 141 // |
| 142 // Rescan the characters that need to be rescanned. | 142 // Rescan the characters that need to be rescanned. |
| 143 // | 143 // |
| 144 Token replacementStart = _scanRange(scanStart, scanEnd); | 144 Token replacementStart = _scanRange(scanStart, scanEnd); |
| 145 oldLeftToken.setNext(replacementStart); | 145 oldLeftToken.setNext(replacementStart); |
| 146 Token replacementEnd = _findEof(replacementStart).previous; | 146 Token replacementEnd = _findEof(replacementStart).previous; |
| 147 replacementEnd.setNext(stream); | 147 replacementEnd.setNext(stream); |
| 148 // | 148 // |
| 149 // Apply the delta to the tokens after the last new token. | 149 // Apply the delta to the tokens after the last new token. |
| 150 // | 150 // |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 while (comment != null) { | 235 while (comment != null) { |
| 236 comment.offset += delta; | 236 comment.offset += delta; |
| 237 comment = comment.next; | 237 comment = comment.next; |
| 238 } | 238 } |
| 239 token = token.next; | 239 token = token.next; |
| 240 } | 240 } |
| 241 _tokenMap.put(token, token); | 241 _tokenMap.put(token, token); |
| 242 token.offset += delta; | 242 token.offset += delta; |
| 243 } | 243 } |
| 244 } | 244 } |
| OLD | NEW |