analyzer library

Static analysis and AST inspection utilities for Dart code tools.

Classes

AnalysisContextHelper
Helper for initializing analyzer AnalysisContextCollection instances and safely resolving compilation units.
CommentDirectiveParser
Generic token-based suppression parser for // <tool>:ignore and // <tool>:ignore_for_file comment suppression directives.
WildcardPattern
Zero-dependency wildcard matching supporting * and ? patterns.

Functions

extractNodeName(AstNode node) String?
Extracts a string name from an AST node safely.
getTopLevelElement(Element elem) → Element?
Finds the enclosing top-level element for a given element by climbing the enclosing hierarchy until reaching the library element or null.
hasAnnotation(AnnotatedNode node, String annotationName) bool
Checks if an AnnotatedNode contains an annotation with the given annotationName (e.g. 'visibleForTesting', 'pragma', 'Native').
hasAnyAnnotation(AnnotatedNode node, Iterable<String> annotationNames) bool
Checks if an AnnotatedNode has any of the given annotationNames.
isExcludedPath(String relativePath) bool
Whether relativePath sits inside a directory that should never be scanned (.dart_tool, .git, or build output).
isNativeOrEntryPoint(AnnotatedNode node) bool
Checks if an AST node has native or runtime entrypoint annotations (@Native, @native, or explicit entrypoint @pragma like @pragma('vm:entry-point') or @pragma('vm:isolate-unsendable')).
isTestSupportDeclaration(AnnotatedNode node, [String? name]) bool
Checks if an element or AST node has test support annotations or conventions.