| 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 parseDirectives; |
| 9 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/src/generated/constant.dart' show ConstantEvaluator, | 10 import 'package:analyzer/src/generated/constant.dart' show ConstantEvaluator, |
| 11 EvaluationResult; | 11 EvaluationResult; |
| 12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
| 13 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 14 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 14 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:barback/barback.dart'; | 16 import 'package:barback/barback.dart'; |
| 17 import 'package:code_transformers/assets.dart'; | 17 import 'package:code_transformers/assets.dart'; |
| 18 import 'package:path/path.dart' as native_path; | 18 import 'package:path/path.dart' as native_path; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 /// The file contents. | 307 /// The file contents. |
| 308 String _contents; | 308 String _contents; |
| 309 | 309 |
| 310 _AssetBasedSource(this.assetId, this._resolver); | 310 _AssetBasedSource(this.assetId, this._resolver); |
| 311 | 311 |
| 312 /// Update the dependencies of this source. This parses [contents] but avoids | 312 /// Update the dependencies of this source. This parses [contents] but avoids |
| 313 /// any analyzer resolution. | 313 /// any analyzer resolution. |
| 314 void updateDependencies(String contents) { | 314 void updateDependencies(String contents) { |
| 315 if (contents == _contents) return; | 315 if (contents == _contents) return; |
| 316 var unit = parseCompilationUnit(contents, suppressErrors: true); | 316 var unit = parseDirectives(contents, suppressErrors: true); |
| 317 _dependentAssets = unit.directives | 317 _dependentAssets = unit.directives |
| 318 .where((d) => (d is ImportDirective || d is PartDirective || | 318 .where((d) => (d is ImportDirective || d is PartDirective || |
| 319 d is ExportDirective)) | 319 d is ExportDirective)) |
| 320 .map((d) => _resolve(assetId, d.uri.stringValue, _logger, | 320 .map((d) => _resolve(assetId, d.uri.stringValue, _logger, |
| 321 _getSpan(d, contents))) | 321 _getSpan(d, contents))) |
| 322 .where((id) => id != null).toSet(); | 322 .where((id) => id != null).toSet(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 /// Update the contents of this file with [contents]. | 325 /// Update the contents of this file with [contents]. |
| 326 /// | 326 /// |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 539 |
| 540 void apply(ChangeSet changeSet) { | 540 void apply(ChangeSet changeSet) { |
| 541 if (!source.updateContents(content)) return; | 541 if (!source.updateContents(content)) return; |
| 542 if (source._revision == 1 && source._contents != null) { | 542 if (source._revision == 1 && source._contents != null) { |
| 543 changeSet.addedSource(source); | 543 changeSet.addedSource(source); |
| 544 } else { | 544 } else { |
| 545 changeSet.changedSource(source); | 545 changeSet.changedSource(source); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 } | 548 } |
| OLD | NEW |