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/ast.dart' show Expression; | 9 import 'package:analyzer/dart/ast/ast.dart' show Expression; |
10 import 'package:analyzer/src/generated/constant.dart' show EvaluationResult; | 10 import 'package:analyzer/src/generated/constant.dart' show EvaluationResult; |
11 import 'package:analyzer/src/generated/element.dart'; | 11 import 'package:analyzer/dart/element/element.dart'; |
12 import 'package:barback/barback.dart'; | 12 import 'package:barback/barback.dart'; |
13 import 'package:source_maps/refactor.dart'; | 13 import 'package:source_maps/refactor.dart'; |
14 import 'package:source_span/source_span.dart'; | 14 import 'package:source_span/source_span.dart'; |
15 | 15 |
16 /// Class for working with a barback based resolved AST. | 16 /// Class for working with a barback based resolved AST. |
17 abstract class Resolver { | 17 abstract class Resolver { |
18 /// Update the status of all the sources referenced by the entry points and | 18 /// Update the status of all the sources referenced by the entry points and |
19 /// update the resolved library. If [entryPoints] is omitted, the primary | 19 /// update the resolved library. If [entryPoints] is omitted, the primary |
20 /// asset of [transform] is used as the only entry point. | 20 /// asset of [transform] is used as the only entry point. |
21 /// | 21 /// |
22 /// [release] must be called when done handling this Resolver to allow it | 22 /// [release] must be called when done handling this Resolver to allow it |
23 /// to be used by later phases. | 23 /// to be used by later phases. |
24 Future<Resolver> resolve(Transform transform, [List<AssetId> entryPoints]); | 24 /// |
| 25 /// If [resolveAllLibraries] is [false], then transitive imports will not |
| 26 /// be resolved. This will result in faster resolution, but you will need to |
| 27 /// manually call something like |
| 28 /// `libary.context.computeLibraryElement(library.definingCompilationUnit.sour
ce);` |
| 29 /// for each [LibraryElement] that you want to ensure is fully resolved. The |
| 30 /// default value is [true]. |
| 31 Future<Resolver> resolve(Transform transform, |
| 32 [List<AssetId> entryPoints, bool resolveAllLibraries]); |
25 | 33 |
26 /// Release this resolver so it can be updated by following transforms. | 34 /// Release this resolver so it can be updated by following transforms. |
27 void release(); | 35 void release(); |
28 | 36 |
| 37 /// Whether [assetId] represents an Dart library file. |
| 38 /// |
| 39 /// This will be false in the case where the file is not Dart source code, or |
| 40 /// is a 'part of' file. |
| 41 bool isLibrary(AssetId assetId); |
| 42 |
29 /// Gets the resolved Dart library for an asset, or null if the AST has not | 43 /// Gets the resolved Dart library for an asset, or null if the AST has not |
30 /// been resolved. | 44 /// been resolved. |
31 /// | 45 /// |
32 /// If the AST has not been resolved then this normally means that the | 46 /// If the AST has not been resolved then this normally means that the |
33 /// transformer hosting this needs to be in an earlier phase. | 47 /// transformer hosting this needs to be in an earlier phase. |
34 LibraryElement getLibrary(AssetId assetId); | 48 LibraryElement getLibrary(AssetId assetId); |
35 | 49 |
36 /// Gets all libraries accessible from the entry point, recursively. | 50 /// Gets all libraries accessible from the entry point, recursively. |
37 /// | 51 /// |
38 /// This includes all Dart SDK libraries as well. | 52 /// This includes all Dart SDK libraries as well. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 SourceFile getSourceFile(Element element); | 106 SourceFile getSourceFile(Element element); |
93 | 107 |
94 /// Creates a text edit transaction for the given element if it is able | 108 /// Creates a text edit transaction for the given element if it is able |
95 /// to be edited, returns null otherwise. | 109 /// to be edited, returns null otherwise. |
96 /// | 110 /// |
97 /// The transaction contains the entire text of the source file where the | 111 /// The transaction contains the entire text of the source file where the |
98 /// element originated. If the element was from a library part then the | 112 /// element originated. If the element was from a library part then the |
99 /// source file is the part file rather than the library. | 113 /// source file is the part file rather than the library. |
100 TextEditTransaction createTextEditTransaction(Element element); | 114 TextEditTransaction createTextEditTransaction(Element element); |
101 } | 115 } |
OLD | NEW |