| 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; | 5 library code_transformer.src.resolver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
| 10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
| 11 import 'package:source_maps/refactor.dart'; | 11 import 'package:source_maps/refactor.dart'; |
| 12 import 'package:source_maps/span.dart' show SourceFile, Span; | 12 import 'package:source_maps/span.dart' show SourceFile, Span; |
| 13 | 13 |
| 14 | 14 |
| 15 /// Class for working with a barback based resolved AST. | 15 /// Class for working with a barback based resolved AST. |
| 16 abstract class Resolver { | 16 abstract class Resolver { |
| 17 /// The Dart entry point file where parsing begins. | 17 /// Update the status of all the sources referenced by the entry points and |
| 18 AssetId get entryPoint; | 18 /// update the resolved library. If [entryPoints] is omitted, the primary |
| 19 | 19 /// asset of [transform] is used as the only entry point. |
| 20 /// Update the status of all the sources referenced by the entryPoint and | |
| 21 /// update the resolved library. | |
| 22 /// | 20 /// |
| 23 /// [release] must be called when done handling this Resolver to allow it | 21 /// [release] must be called when done handling this Resolver to allow it |
| 24 /// to be used by later phases. | 22 /// to be used by later phases. |
| 25 Future<Resolver> resolve(Transform transform); | 23 Future<Resolver> resolve(Transform transform, [List<AssetId> entryPoints]); |
| 26 | 24 |
| 27 /// Release this resolver so it can be updated by following transforms. | 25 /// Release this resolver so it can be updated by following transforms. |
| 28 void release(); | 26 void release(); |
| 29 | 27 |
| 30 /// Gets the resolved Dart library for the entry asset, or null if | 28 /// Gets the resolved Dart library for an asset, or null if the AST has not |
| 31 /// the AST has not been resolved. | 29 /// been resolved. |
| 32 /// | 30 /// |
| 33 /// If the AST has not been resolved then this normally means that the | 31 /// If the AST has not been resolved then this normally means that the |
| 34 /// transformer hosting this needs to be in an earlier phase. | 32 /// transformer hosting this needs to be in an earlier phase. |
| 35 LibraryElement get entryLibrary; | 33 LibraryElement getLibrary(AssetId assetId); |
| 36 | 34 |
| 37 /// Gets all libraries accessible from the entry point, recursively. | 35 /// Gets all libraries accessible from the entry point, recursively. |
| 38 /// | 36 /// |
| 39 /// This includes all Dart SDK libraries as well. | 37 /// This includes all Dart SDK libraries as well. |
| 40 Iterable<LibraryElement> get libraries; | 38 Iterable<LibraryElement> get libraries; |
| 41 | 39 |
| 42 /// Finds the first library identified by [libraryName], or null if no | 40 /// Finds the first library identified by [libraryName], or null if no |
| 43 /// library can be found. | 41 /// library can be found. |
| 44 LibraryElement getLibraryByName(String libraryName); | 42 LibraryElement getLibraryByName(String libraryName); |
| 45 | 43 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 76 /// from [from] (if provided). | 74 /// from [from] (if provided). |
| 77 Uri getImportUri(LibraryElement lib, {AssetId from}); | 75 Uri getImportUri(LibraryElement lib, {AssetId from}); |
| 78 | 76 |
| 79 /// Get the asset ID of the file containing the asset. | 77 /// Get the asset ID of the file containing the asset. |
| 80 AssetId getSourceAssetId(Element element); | 78 AssetId getSourceAssetId(Element element); |
| 81 | 79 |
| 82 /// Get the source span where the specified element was defined or null if | 80 /// Get the source span where the specified element was defined or null if |
| 83 /// the element came from the Dart SDK. | 81 /// the element came from the Dart SDK. |
| 84 Span getSourceSpan(Element element); | 82 Span getSourceSpan(Element element); |
| 85 | 83 |
| 84 /// Get a [SourceFile] with the contents of the file that defines [element], |
| 85 /// or null if the element came from the Dart SDK. |
| 86 SourceFile getSourceFile(Element element); |
| 87 |
| 86 /// Creates a text edit transaction for the given element if it is able | 88 /// Creates a text edit transaction for the given element if it is able |
| 87 /// to be edited, returns null otherwise. | 89 /// to be edited, returns null otherwise. |
| 88 /// | 90 /// |
| 89 /// The transaction contains the entire text of the source file where the | 91 /// The transaction contains the entire text of the source file where the |
| 90 /// element originated. If the element was from a library part then the | 92 /// element originated. If the element was from a library part then the |
| 91 /// source file is the part file rather than the library. | 93 /// source file is the part file rather than the library. |
| 92 TextEditTransaction createTextEditTransaction(Element element); | 94 TextEditTransaction createTextEditTransaction(Element element); |
| 93 } | 95 } |
| OLD | NEW |