resolver 0.1.1 resolver: ^0.1.1 copied to clipboard
Simple frontend for resolving Dart code
resolver
#
WARNING: This is not an official Google or Dart project
A very simple frontend for resolving Dart code using package:analyzer
.
As the API for using these mostly Dart-internal packages improves, this
package will become obsolete.
Until then, it exists to help new and experienced Dart developers alike get started with tooling they want to write that requires a resolved AST (i.e. with types, imports, metadata available).
This package is not meant to be used to do source/code generation - you should look at package:source_gen or the lower-level package:build, which already has a very simplified model for resolving code.
Getting Started #
This package is meant to be used along with package:analyzer
, so
you'll likely want to import both packages when writing a tool. So, for
a quick-start example:
import 'package:analyzer/analyzer.dart';
import 'package:resolver/resolver.dart';
main() async {
final resolver = new Resolver();
final library = await resolver.resolveAbsoluteUri('local/file.dart');
...
}
To be able to resolve files that include package:
, use forPackage
:
import 'package:analyzer/analyzer.dart';
import 'package:resolver/resolver.dart';
main() async {
final resolver = new Resolver.forPackage('local/path/package');
final library = await resolver.resolvePackageUri(
'package',
'file.dart',
);
...
}