analyzer library
Static analysis and AST inspection utilities for Dart code tools.
Classes
- AnalysisContextHelper
-
Helper for initializing analyzer
AnalysisContextCollectioninstances and safely resolving compilation units. - CommentDirectiveParser
-
Generic token-based suppression parser for
// <tool>:ignoreand// <tool>:ignore_for_filecomment 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
AnnotatedNodecontains an annotation with the givenannotationName(e.g.'visibleForTesting','pragma','Native'). -
hasAnyAnnotation(
AnnotatedNode node, Iterable< String> annotationNames) → bool -
Checks if an
AnnotatedNodehas any of the givenannotationNames. -
isExcludedPath(
String relativePath) → bool -
Whether
relativePathsits inside a directory that should never be scanned (.dart_tool,.git, orbuildoutput). -
isNativeOrEntryPoint(
AnnotatedNode node) → bool -
Checks if an AST node has native or runtime entrypoint annotations
(
@Native,@native, or explicit entrypoint@pragmalike@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.