-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Labels
type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
This is code that is super tough to get right, and I imagine most of the time most generators that use part files just disallow using prefixes to import code because of it. In AngularDart we still need to support this right now, and our code is brittle.
Adding this feature would also make analyzer changes more visible.
class LibraryReader {
/// Returns the identifier prefix if [element] is referenced by one.
///
/// For example in the following file:
/// ```dart
/// import 'bar.dart' as bar;
///
/// const b = const bar.Bar();
/// ```
///
/// If there is no prefix, one could not be computed, or the [element] is
/// in a library different from the current one this will return `null`.
String prefixFor(Element element);
}prefixFor could return bar for the top-level field b.
Other considerations:
- If the element is outside the current library, always return
null. This consideration is important because in implementations such asbazel_codegen, the underlying function we will need to use,computeNode(), fails on files provided only by summaries.
/cc @natebosch to spot check this feature's acceptability :)
/cc @MichaelRFairhurst who helped me identify why this fails in Angular (summary file)
Metadata
Metadata
Assignees
Labels
type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug