Chromium Code Reviews| 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' 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, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 source.updateDependencies(contents); | 129 source.updateDependencies(contents); |
| 130 toUpdate.add(new _PendingUpdate(source, contents)); | 130 toUpdate.add(new _PendingUpdate(source, contents)); |
| 131 source.dependentAssets.where((id) => !visited.contains(id)) | 131 source.dependentAssets.where((id) => !visited.contains(id)) |
| 132 .forEach(processAsset); | 132 .forEach(processAsset); |
| 133 }, onError: (e) { | 133 }, onError: (e) { |
| 134 var source = sources[assetId]; | 134 var source = sources[assetId]; |
| 135 if (source != null && source.exists()) { | 135 if (source != null && source.exists()) { |
| 136 _context.applyChanges( | 136 _context.applyChanges( |
| 137 new ChangeSet()..removedSource(source)); | 137 new ChangeSet()..removedSource(source)); |
| 138 sources[assetId].updateContents(null); | 138 sources[assetId].updateContents(null); |
| 139 } else if (source == null) { | |
| 140 transform.logger.warning('Asset not found: $assetId'); | |
|
Siggi Cherem (dart-lang)
2014/04/10 20:05:47
we already compute the span inside dependentsAsset
| |
| 139 } | 141 } |
| 140 })); | 142 })); |
| 141 } | 143 } |
| 142 entryPoints.forEach(processAsset); | 144 entryPoints.forEach(processAsset); |
| 143 | 145 |
| 144 // Once we have all asset sources updated with the new contents then | 146 // Once we have all asset sources updated with the new contents then |
| 145 // resolve everything. | 147 // resolve everything. |
| 146 return visiting.future.then((_) { | 148 return visiting.future.then((_) { |
| 147 var changeSet = new ChangeSet(); | 149 var changeSet = new ChangeSet(); |
| 148 toUpdate.forEach((pending) => pending.apply(changeSet)); | 150 toUpdate.forEach((pending) => pending.apply(changeSet)); |
| 149 var unreachableAssets = sources.keys.toSet() | 151 var unreachableAssets = sources.keys.toSet() |
| 150 .difference(visited) | 152 .difference(visited) |
| 151 .map((id) => sources[id]); | 153 .map((id) => sources[id]); |
| 152 for (var unreachable in unreachableAssets) { | 154 for (var unreachable in unreachableAssets) { |
| 153 changeSet.removedSource(unreachable); | 155 changeSet.removedSource(unreachable); |
| 154 unreachable.updateContents(null); | 156 unreachable.updateContents(null); |
| 155 sources.remove(unreachable.assetId); | 157 sources.remove(unreachable.assetId); |
| 156 } | 158 } |
| 157 | 159 |
| 158 // Update the analyzer context with the latest sources | 160 // Update the analyzer context with the latest sources |
| 159 _context.applyChanges(changeSet); | 161 _context.applyChanges(changeSet); |
| 160 // Force resolve each entry point (the getter will ensure the library is | 162 // Force resolve each entry point (the getter will ensure the library is |
| 161 // computed first). | 163 // computed first). |
| 162 _entryLibraries = entryPoints | 164 _entryLibraries = entryPoints.map((id) { |
| 163 .map((id) => _context.computeLibraryElement(sources[id])).toList(); | 165 var source = sources[id]; |
| 166 if (source == null) return null; | |
| 167 return _context.computeLibraryElement(source); | |
| 168 }).toList(); | |
| 164 }); | 169 }); |
| 165 } | 170 } |
| 166 | 171 |
| 167 Iterable<LibraryElement> get libraries { | 172 Iterable<LibraryElement> get libraries { |
| 168 if (_libraries == null) { | 173 if (_libraries == null) { |
| 169 // Note: we don't use `lib.visibleLibraries` because that excludes the | 174 // Note: we don't use `lib.visibleLibraries` because that excludes the |
| 170 // exports seen in the entry libraries. | 175 // exports seen in the entry libraries. |
| 171 _libraries = new Set<LibraryElement>(); | 176 _libraries = new Set<LibraryElement>(); |
| 172 _entryLibraries.forEach(_collectLibraries); | 177 _entryLibraries.forEach(_collectLibraries); |
| 173 } | 178 } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 | 628 |
| 624 void apply(ChangeSet changeSet) { | 629 void apply(ChangeSet changeSet) { |
| 625 if (!source.updateContents(content)) return; | 630 if (!source.updateContents(content)) return; |
| 626 if (source._revision == 1 && source._contents != null) { | 631 if (source._revision == 1 && source._contents != null) { |
| 627 changeSet.addedSource(source); | 632 changeSet.addedSource(source); |
| 628 } else { | 633 } else { |
| 629 changeSet.changedSource(source); | 634 changeSet.changedSource(source); |
| 630 } | 635 } |
| 631 } | 636 } |
| 632 } | 637 } |
| OLD | NEW |