analysis 0.0.1-alpha.6 copy "analysis: ^0.0.1-alpha.6" to clipboard
analysis: ^0.0.1-alpha.6 copied to clipboard

Dart 1 only

A set of utility classes to make common use cases of using the Dart analyzer.

analysis #

Build Status

A set of utility classes to make common use cases of using the Dart analyzer package simpler and without needing intimate knowledge of the internals.

SourceResolver #

Creating a resolver. #

// Create a default source resolver.
new SourceResolver();

// Create a source resolver with custom Dart package roots.
new SourceResolver(['/generated-files'])

Resolving a file to it's absolute location. #

// Example output: ~/git/analysis/packages/analysis/src/resolver.dart
sourceResolver.find(Uri.parse('package:analysis/src/resolver.dart'));

Finding the package location #

// Example output: package:analysis/src/resolver.dart
sourceResolver.resolve('~/git/analysis/packages/analysis/src/resolver.dart');

SourceVisitor #

Creating a visitor. #

// Create a default source crawler.
new SourceVisitor();

Crawl a file for libraries. #

// Example output: [
//   new Library(..., 'package:analysis/src/test_data/test_data.dart'),
//   new Library(..., 'dart:collection'),
//   new Library(..., 'package:analysis/src/test_data/test_import.dart')
// ]
var uri = Uri.parse('package:analysis/src/test_data/test_data.dart');
sourceVisitor.visit(uri: uri)

SourceCrawler #

Similar to SourceVisitor; recursively searches into imports of the visited file, and returns an iterable of every library parsed.

// Example output: [
//   Library(name: foo.bar),
//   Library(name: foo.baz)
// ]
sourceCrawler.crawl('package:foo/foo.dart')

Anthology #

Experimental API for application-wide analysis. Instead of using both SourceVisitor and/or SourceCrawler directly, Anthology helps build a collection of analyzed libraries.

// Create a new Anthology.
new Anthology(resolver: ...)

It exposes both the SourceVisitor and SourceCrawler APIs, but also caches results whenever possible to make visiting and crawling the same packages cheaper.

It's also possible to trace a type back to it's library:

anthology.getLibraryOfType(classAst.element.type)
0
likes
25
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

A set of utility classes to make common use cases of using the Dart analyzer.

Homepage

License

MIT (license)

Dependencies

analyzer, quiver

More

Packages that depend on analysis