| 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_resolver; | 5 library engine.incremental_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'ast.dart'; | 10 import 'ast.dart'; |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 _resolveApiChanges = resolveApiChanges; | 1179 _resolveApiChanges = resolveApiChanges; |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 /** | 1182 /** |
| 1183 * Attempts to update [oldUnit] to the state corresponding to [newCode]. | 1183 * Attempts to update [oldUnit] to the state corresponding to [newCode]. |
| 1184 * Returns `true` if success, or `false` otherwise. | 1184 * Returns `true` if success, or `false` otherwise. |
| 1185 * The [oldUnit] might be damaged. | 1185 * The [oldUnit] might be damaged. |
| 1186 */ | 1186 */ |
| 1187 bool resolve(CompilationUnit oldUnit, String newCode) { | 1187 bool resolve(CompilationUnit oldUnit, String newCode) { |
| 1188 logger.enter('diff/resolve $_unitSource'); | 1188 logger.enter('diff/resolve $_unitSource'); |
| 1189 logger.log(oldUnit != null ? 'has oldUnit' : 'oldUnit is null'); | |
| 1190 try { | 1189 try { |
| 1191 _unitElement = oldUnit.element; | 1190 _unitElement = oldUnit.element; |
| 1192 CompilationUnit newUnit = _parseUnit(newCode); | 1191 CompilationUnit newUnit = _parseUnit(newCode); |
| 1193 _TokenPair firstPair = | 1192 _TokenPair firstPair = |
| 1194 _findFirstDifferentToken(oldUnit.beginToken, newUnit.beginToken); | 1193 _findFirstDifferentToken(oldUnit.beginToken, newUnit.beginToken); |
| 1195 _TokenPair lastPair = | 1194 _TokenPair lastPair = |
| 1196 _findLastDifferentToken(oldUnit.endToken, newUnit.endToken); | 1195 _findLastDifferentToken(oldUnit.endToken, newUnit.endToken); |
| 1197 if (firstPair != null && lastPair != null) { | 1196 if (firstPair != null && lastPair != null) { |
| 1198 int firstOffsetOld = firstPair.oldToken.offset; | 1197 int firstOffsetOld = firstPair.oldToken.offset; |
| 1199 int firstOffsetNew = firstPair.newToken.offset; | 1198 int firstOffsetNew = firstPair.newToken.offset; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 String toString() => name; | 1790 String toString() => name; |
| 1792 } | 1791 } |
| 1793 | 1792 |
| 1794 | 1793 |
| 1795 class _TokenPair { | 1794 class _TokenPair { |
| 1796 final _TokenDifferenceKind kind; | 1795 final _TokenDifferenceKind kind; |
| 1797 final Token oldToken; | 1796 final Token oldToken; |
| 1798 final Token newToken; | 1797 final Token newToken; |
| 1799 _TokenPair(this.kind, this.oldToken, this.newToken); | 1798 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1800 } | 1799 } |
| OLD | NEW |