CompileContext class abstract final

Execution-local static state for the current compilation.

Such state includes:

  • Various flags or modes that are conditionally enabled.
  • Ability to report diagnostics related to the current compilation.

When the compiler is running as a worker (i.e. long-running), this context refers to the current compilation occuring (where multiple may occur over the lifecycle of the compiler).

When the compiler or components of the compiler are running in a test it is required to statically initialize one by using overrideForTesting.

Constructors

CompileContext(AssetId libraryPath, {required Map<String, Set<String>> policyExceptions, required Map<String, Set<String>> policyExceptionsInPackages, required bool enableDevTools})
Creates a CompileContext for the provided libraryPath.
factory
CompileContext.forTesting({bool isDevToolsEnabled, bool validateMissingDirectives})
Creates a standalone CompileContext with pre-configured flags.
const
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isDevToolsEnabled bool
Whether to emit code that supports developer tooling.
no setter
path String
Path of the file being compiled.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validateMissingDirectives bool
Whether to issue a compile-time error when directives appear missing.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reportAndRecover(BuildError error) → void
Reports an error or exception that does not need to suspend compilation.
throwRecoverableErrors() → void
Throws any errors collected via reportAndRecover.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

current CompileContext
Currently executing context based on Zone.current[CompileContext].
no setter

Static Methods

overrideForTesting([CompileContext context = const _TestCompileContext()]) → void
Overrides CompileContext.current to return context.
removeTestingOverride() → void
Unsets the overrideForTesting instance, defaulting to normal behavior.