Skip to main content

cobalt_analyzer 1.7.0 copy "cobalt_analyzer: ^1.7.0" to clipboard
cobalt_analyzer: ^1.7.0 copied to clipboard

Internal analysis layer of cobalt_generator and cobalt_lint — parses Cobalt annotations once for both. Not covered by semver; depend on those packages instead.

example/example.md

cobalt_analyzer example #

Not used directly by applications. It is the parsing layer cobalt_generator and cobalt_lint share, so the build and the IDE agree on what a declaration means.

import 'package:cobalt_analyzer/cobalt_analyzer.dart';

const parser = CobaltInjectableParser();

// `clazz` is a resolved ClassElement from package:analyzer.
if (parser.declares(clazz)) {
  final declaration = parser.parseClass(clazz);

  print(declaration.exposedType);   // Repository<User>
  print(declaration.lifetime);      // CobaltLifetime.lazySingleton
  print(declaration.environments);  // {prod, stage}
}

The IR round-trips through JSON, which is what lets the generator run in two phases: a build step sees one library at a time, so cobalt_scan writes per-library IR and cobalt_container aggregates it.

CobaltTypeRef.signature is the single definition of registration identity — type arguments are part of it, nullability is not.

0
likes
160
points
1.6k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Internal analysis layer of cobalt_generator and cobalt_lint — parses Cobalt annotations once for both. Not covered by semver; depend on those packages instead.

Repository (GitHub)
View/report issues
Contributing

Topics

#dependency-injection #analyzer #codegen #static-analysis

License

MIT (license)

Dependencies

analyzer, cobalt, cobalt_annotations, collection, meta, path

More

Packages that depend on cobalt_analyzer