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; |
| 10 import 'package:analyzer/src/generated/constant.dart' show EvaluationResult; |
9 import 'package:analyzer/src/generated/element.dart'; | 11 import 'package:analyzer/src/generated/element.dart'; |
10 import 'package:barback/barback.dart'; | 12 import 'package:barback/barback.dart'; |
11 import 'package:source_maps/refactor.dart'; | 13 import 'package:source_maps/refactor.dart'; |
12 import 'package:source_maps/span.dart' show SourceFile, Span; | 14 import 'package:source_maps/span.dart' show SourceFile, Span; |
13 | 15 |
14 | 16 |
15 /// Class for working with a barback based resolved AST. | 17 /// Class for working with a barback based resolved AST. |
16 abstract class Resolver { | 18 abstract class Resolver { |
17 /// Update the status of all the sources referenced by the entry points and | 19 /// Update the status of all the sources referenced by the entry points and |
18 /// update the resolved library. If [entryPoints] is omitted, the primary | 20 /// update the resolved library. If [entryPoints] is omitted, the primary |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 /// potential library name conflicts the name is not guaranteed to be unique. | 63 /// potential library name conflicts the name is not guaranteed to be unique. |
62 Element getLibraryVariable(String variableName); | 64 Element getLibraryVariable(String variableName); |
63 | 65 |
64 /// Resolves a fully-qualified top-level library function | 66 /// Resolves a fully-qualified top-level library function |
65 /// (library_name.functionName). | 67 /// (library_name.functionName). |
66 /// | 68 /// |
67 /// This will resolve the first instance of [functionName], because of | 69 /// This will resolve the first instance of [functionName], because of |
68 /// potential library name conflicts the name is not guaranteed to be unique. | 70 /// potential library name conflicts the name is not guaranteed to be unique. |
69 Element getLibraryFunction(String functionName); | 71 Element getLibraryFunction(String functionName); |
70 | 72 |
| 73 /// Gets the result of evaluating the constant [expression] in the context of |
| 74 /// a [library]. |
| 75 EvaluationResult evaluateConstant( |
| 76 LibraryElement library, Expression expression); |
| 77 |
71 /// Gets an URI appropriate for importing the specified library. | 78 /// Gets an URI appropriate for importing the specified library. |
72 /// | 79 /// |
73 /// Returns null if the library cannot be imported via an absolute URI or | 80 /// Returns null if the library cannot be imported via an absolute URI or |
74 /// from [from] (if provided). | 81 /// from [from] (if provided). |
75 Uri getImportUri(LibraryElement lib, {AssetId from}); | 82 Uri getImportUri(LibraryElement lib, {AssetId from}); |
76 | 83 |
77 /// Get the asset ID of the file containing the asset. | 84 /// Get the asset ID of the file containing the asset. |
78 AssetId getSourceAssetId(Element element); | 85 AssetId getSourceAssetId(Element element); |
79 | 86 |
80 /// Get the source span where the specified element was defined or null if | 87 /// Get the source span where the specified element was defined or null if |
81 /// the element came from the Dart SDK. | 88 /// the element came from the Dart SDK. |
82 Span getSourceSpan(Element element); | 89 Span getSourceSpan(Element element); |
83 | 90 |
84 /// Get a [SourceFile] with the contents of the file that defines [element], | 91 /// Get a [SourceFile] with the contents of the file that defines [element], |
85 /// or null if the element came from the Dart SDK. | 92 /// or null if the element came from the Dart SDK. |
86 SourceFile getSourceFile(Element element); | 93 SourceFile getSourceFile(Element element); |
87 | 94 |
88 /// Creates a text edit transaction for the given element if it is able | 95 /// Creates a text edit transaction for the given element if it is able |
89 /// to be edited, returns null otherwise. | 96 /// to be edited, returns null otherwise. |
90 /// | 97 /// |
91 /// The transaction contains the entire text of the source file where the | 98 /// The transaction contains the entire text of the source file where the |
92 /// element originated. If the element was from a library part then the | 99 /// element originated. If the element was from a library part then the |
93 /// source file is the part file rather than the library. | 100 /// source file is the part file rather than the library. |
94 TextEditTransaction createTextEditTransaction(Element element); | 101 TextEditTransaction createTextEditTransaction(Element element); |
95 } | 102 } |
OLD | NEW |