DartFileIndex class final

What a rendered Dart file of the generated app declares and uses, as data.

The contract test harness builds an index for every Dart file it renders, by parsing it without resolving types. StructuralRules of roles and the RequiredSymbols of role interfaces are checked against these indexes, so roles need no analyzer and the harness knows no role.

Names are as written in the source: without type resolution, Foo() is an invocation of Foo whether Foo is a function or a class.

Constructors

DartFileIndex({required String path, List<IndexedImport> imports = const [], List<IndexedImport> exports = const [], List<IndexedDeclaration> declarations = const [], List<IndexedInvocation> invocations = const [], List<IndexedReference> references = const [], List<IndexedMemberAccess> memberAccesses = const []})
Creates the index of the file at path.
const

Properties

declarations → List<IndexedDeclaration>
The top-level declarations, in source order.
final
exports → List<IndexedImport>
The export directives, in source order; an export has no prefix.
final
hashCode → int
The hash code for this object.
no setterinherited
imports → List<IndexedImport>
The import directives, in source order.
final
invocations → List<IndexedInvocation>
The function, method and constructor invocations, in source order.
final
memberAccesses → List<IndexedMemberAccess>
Property accesses, such as context.nav or nav.home, in source order.
final
path → String
The path of the file relative to the project root, with forward slashes, such as lib/main.dart.
final
references → List<IndexedReference>
Identifiers used without being invoked, such as tear-offs and reads of variables, in source order. Declarations and the names of invoked functions are not included.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

declaration(String name) → IndexedDeclaration?
The top-level declaration named name, if the file has one.
importsUri(String uri) → bool
Whether the file imports uri.
invocationsOf(String name, {String? within}) → Iterable<IndexedInvocation>
The invocations of name, optionally only those inside the top-level declaration within.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
uses(String name) → bool
Whether the file uses name at all: invokes it, refers to it, or accesses it as a property.

Operators

operator ==(Object other) → bool
The equality operator.
inherited