| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library code_transformer.src.resolver; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:analyzer/src/generated/ast.dart' show Expression; | |
| 10 import 'package:analyzer/src/generated/constant.dart' show EvaluationResult; | |
| 11 import 'package:analyzer/src/generated/element.dart'; | |
| 12 import 'package:barback/barback.dart'; | |
| 13 import 'package:source_maps/refactor.dart'; | |
| 14 import 'package:source_span/source_span.dart'; | |
| 15 | |
| 16 | |
| 17 /// Class for working with a barback based resolved AST. | |
| 18 abstract class Resolver { | |
| 19 /// Update the status of all the sources referenced by the entry points and | |
| 20 /// update the resolved library. If [entryPoints] is omitted, the primary | |
| 21 /// asset of [transform] is used as the only entry point. | |
| 22 /// | |
| 23 /// [release] must be called when done handling this Resolver to allow it | |
| 24 /// to be used by later phases. | |
| 25 Future<Resolver> resolve(Transform transform, [List<AssetId> entryPoints]); | |
| 26 | |
| 27 /// Release this resolver so it can be updated by following transforms. | |
| 28 void release(); | |
| 29 | |
| 30 /// Gets the resolved Dart library for an asset, or null if the AST has not | |
| 31 /// been resolved. | |
| 32 /// | |
| 33 /// If the AST has not been resolved then this normally means that the | |
| 34 /// transformer hosting this needs to be in an earlier phase. | |
| 35 LibraryElement getLibrary(AssetId assetId); | |
| 36 | |
| 37 /// Gets all libraries accessible from the entry point, recursively. | |
| 38 /// | |
| 39 /// This includes all Dart SDK libraries as well. | |
| 40 Iterable<LibraryElement> get libraries; | |
| 41 | |
| 42 /// Finds the first library identified by [libraryName], or null if no | |
| 43 /// library can be found. | |
| 44 LibraryElement getLibraryByName(String libraryName); | |
| 45 | |
| 46 /// Finds the first library identified by [libraryName], or null if no | |
| 47 /// library can be found. | |
| 48 /// | |
| 49 /// [uri] must be an absolute URI of the form | |
| 50 /// `[dart:|package:]path/file.dart`. | |
| 51 LibraryElement getLibraryByUri(Uri uri); | |
| 52 | |
| 53 /// Resolves a fully-qualified type name (library_name.ClassName). | |
| 54 /// | |
| 55 /// This will resolve the first instance of [typeName], because of potential | |
| 56 /// library name conflicts the name is not guaranteed to be unique. | |
| 57 ClassElement getType(String typeName); | |
| 58 | |
| 59 /// Resolves a fully-qualified top-level library variable | |
| 60 /// (library_name.variableName). | |
| 61 /// | |
| 62 /// This will resolve the first instance of [variableName], because of | |
| 63 /// potential library name conflicts the name is not guaranteed to be unique. | |
| 64 Element getLibraryVariable(String variableName); | |
| 65 | |
| 66 /// Resolves a fully-qualified top-level library function | |
| 67 /// (library_name.functionName). | |
| 68 /// | |
| 69 /// This will resolve the first instance of [functionName], because of | |
| 70 /// potential library name conflicts the name is not guaranteed to be unique. | |
| 71 Element getLibraryFunction(String functionName); | |
| 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 | |
| 78 /// Gets an URI appropriate for importing the specified library. | |
| 79 /// | |
| 80 /// Returns null if the library cannot be imported via an absolute URI or | |
| 81 /// from [from] (if provided). | |
| 82 Uri getImportUri(LibraryElement lib, {AssetId from}); | |
| 83 | |
| 84 /// Get the asset ID of the file containing the asset. | |
| 85 AssetId getSourceAssetId(Element element); | |
| 86 | |
| 87 /// Get the source span where the specified element was defined or null if | |
| 88 /// the element came from the Dart SDK. | |
| 89 SourceSpan getSourceSpan(Element element); | |
| 90 | |
| 91 /// Get a [SourceFile] with the contents of the file that defines [element], | |
| 92 /// or null if the element came from the Dart SDK. | |
| 93 SourceFile getSourceFile(Element element); | |
| 94 | |
| 95 /// Creates a text edit transaction for the given element if it is able | |
| 96 /// to be edited, returns null otherwise. | |
| 97 /// | |
| 98 /// The transaction contains the entire text of the source file where the | |
| 99 /// element originated. If the element was from a library part then the | |
| 100 /// source file is the part file rather than the library. | |
| 101 TextEditTransaction createTextEditTransaction(Element element); | |
| 102 } | |
| OLD | NEW |