| 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 code_transformer.src.resolver_impl; | 5 library code_transformer.src.resolver_impl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:analyzer/analyzer.dart' show parseCompilationUnit; | 8 import 'package:analyzer/analyzer.dart' show parseCompilationUnit; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 /// The file contents. | 283 /// The file contents. |
| 284 String _contents; | 284 String _contents; |
| 285 | 285 |
| 286 _AssetBasedSource(this.assetId, this._resolver); | 286 _AssetBasedSource(this.assetId, this._resolver); |
| 287 | 287 |
| 288 /// Update the dependencies of this source. This parses [contents] but avoids | 288 /// Update the dependencies of this source. This parses [contents] but avoids |
| 289 /// any analyzer resolution. | 289 /// any analyzer resolution. |
| 290 void updateDependencies(String contents) { | 290 void updateDependencies(String contents) { |
| 291 if (contents == _contents) return; | 291 if (contents == _contents) return; |
| 292 var unit = parseCompilationUnit(contents); | 292 var unit = parseCompilationUnit(contents, suppressErrors: true); |
| 293 _dependentAssets = unit.directives | 293 _dependentAssets = unit.directives |
| 294 .where((d) => (d is ImportDirective || d is PartDirective || | 294 .where((d) => (d is ImportDirective || d is PartDirective || |
| 295 d is ExportDirective)) | 295 d is ExportDirective)) |
| 296 .map((d) => _resolve(assetId, d.uri.stringValue, _logger, | 296 .map((d) => _resolve(assetId, d.uri.stringValue, _logger, |
| 297 _getSpan(d, contents))) | 297 _getSpan(d, contents))) |
| 298 .where((id) => id != null).toSet(); | 298 .where((id) => id != null).toSet(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 /// Update the contents of this file with [contents]. | 301 /// Update the contents of this file with [contents]. |
| 302 /// | 302 /// |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 void apply(ChangeSet changeSet) { | 587 void apply(ChangeSet changeSet) { |
| 588 if (!source.updateContents(content)) return; | 588 if (!source.updateContents(content)) return; |
| 589 if (source._revision == 1 && source._contents != null) { | 589 if (source._revision == 1 && source._contents != null) { |
| 590 changeSet.addedSource(source); | 590 changeSet.addedSource(source); |
| 591 } else { | 591 } else { |
| 592 changeSet.changedSource(source); | 592 changeSet.changedSource(source); |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 } | 595 } |
| OLD | NEW |