analysis_plugin_test_helper library

Utilities to help write tests for the analyzer plugins.

Classes

DartUnitResolver
A test utility that resolves Dart source strings into fully resolved ResolvedUnitResult instances, enabling access to resolved elements, constant values, and type information.

Functions

findAnnotation<D extends CompilationUnitMember>(CompilationUnit unit, {required String annotationName}) → Annotation?
Returns the first Annotation whose resolved type name matches annotationName on any D declaration in unit, or null if none is found.
findConstructorDeclaration(CompilationUnit unit, String? name) → ConstructorDeclaration?
Returns the first ConstructorDeclaration whose name matches name in unit, or null if none is found. Pass null for name to find the default constructor.
findFactoryConstructorDeclaration(CompilationUnit unit, String? name) → ConstructorDeclaration?
Returns the first factory ConstructorDeclaration whose name matches name in unit, or null if none is found. Pass null for name to find the default factory constructor.
findImportDirective(CompilationUnit unit) → ImportDirective?
Returns the first ImportDirective, or null if none is found.
findMethodDeclaration(CompilationUnit unit, String name) → MethodDeclaration?
Returns the first MethodDeclaration whose name matches name, or null if none is found.
getAnnotation<D extends CompilationUnitMember>(CompilationUnit unit, {required String annotationName}) → Annotation
Returns the first Annotation whose resolved type name matches annotationName on any D declaration in unit, failing the test if absent.
getConstructorDeclaration(CompilationUnit unit, String? name) → ConstructorDeclaration
Returns the first ConstructorDeclaration whose name matches name in unit, failing the test if absent. Pass null for name to find the default constructor.
getFactoryConstructorDeclaration(CompilationUnit unit, String? name) → ConstructorDeclaration
Returns the first factory ConstructorDeclaration whose name matches name in unit, failing the test if absent. Pass null for name to find the default factory constructor.
getImportDirective(CompilationUnit unit) → ImportDirective
Returns the first ImportDirective, failing the test if absent.
getMethodDeclaration(CompilationUnit unit, String name) → MethodDeclaration
Returns the first MethodDeclaration whose name matches name, failing the test if absent.