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 analysis_server.src.services.correction.fix_internal; | 5 library analysis_server.src.services.correction.fix_internal; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:core'; | 9 import 'dart:core'; |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 | 133 |
134 DartType get coreTypeBool => _getCoreType('bool'); | 134 DartType get coreTypeBool => _getCoreType('bool'); |
135 | 135 |
136 /** | 136 /** |
137 * Returns the EOL to use for this [CompilationUnit]. | 137 * Returns the EOL to use for this [CompilationUnit]. |
138 */ | 138 */ |
139 String get eol => utils.endOfLine; | 139 String get eol => utils.endOfLine; |
140 | 140 |
141 Future<List<Fix>> compute() async { | 141 Future<List<Fix>> compute() async { |
| 142 // If the source was changed between the constructor and running |
| 143 // this asynchronous method, it is not safe to use the unit. |
| 144 if (context.getModificationStamp(unitSource) != fileStamp) { |
| 145 return const <Fix>[]; |
| 146 } |
| 147 |
142 try { | 148 try { |
143 utils = new CorrectionUtils(unit); | 149 utils = new CorrectionUtils(unit); |
144 } catch (e) { | 150 } catch (e) { |
145 throw new CancelCorrectionException(exception: e); | 151 throw new CancelCorrectionException(exception: e); |
146 } | 152 } |
147 | 153 |
148 errorOffset = error.offset; | 154 errorOffset = error.offset; |
149 errorLength = error.length; | 155 errorLength = error.length; |
150 errorEnd = errorOffset + errorLength; | 156 errorEnd = errorOffset + errorLength; |
151 errorRange = new SourceRange(errorOffset, errorLength); | 157 errorRange = new SourceRange(errorOffset, errorLength); |
(...skipping 2793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2945 } | 2951 } |
2946 } | 2952 } |
2947 } | 2953 } |
2948 | 2954 |
2949 void _updateList(Iterable<Element> elements) { | 2955 void _updateList(Iterable<Element> elements) { |
2950 for (Element element in elements) { | 2956 for (Element element in elements) { |
2951 _update(element); | 2957 _update(element); |
2952 } | 2958 } |
2953 } | 2959 } |
2954 } | 2960 } |
OLD | NEW |