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

Shared static analysis layer for Cobalt. Parses Cobalt annotations once for both the generator and the lint plugin.

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
150
points
191
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Shared static analysis layer for Cobalt. Parses Cobalt annotations once for both the generator and the lint plugin.

Repository (GitHub)
View/report issues

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