MacroVariableDeclaration class

Represents a variable declaration with its macro configuration.

This is a generic data class used by any macro that needs to process top-level variables or class fields. Macro-specific data should be stored in the data map.

Usage

final declaration = MacroVariableDeclaration(
  libraryId: 123,
  variableId: 'myVar:abc',
  configs: [macroConfig],
  importPrefix: '',
  variableName: 'myVar',
  startLine: 10,
  endLine: 12,
  modifier: MacroModifier.create(isFinal: true),
  data: {'customKey': 'customValue'},
);

Constructors

MacroVariableDeclaration({required int libraryId, required String variableId, required List<MacroConfig> configs, required String importPrefix, required String variableName, required int startLine, required int endLine, required MacroModifier modifier, String? isFieldOf, String? fieldType, Map<String, dynamic> data = const {}})
const

Properties

configs List<MacroConfig>
List of macro configurations applied to this variable.
final
data Map<String, dynamic>
Macro-specific data map.
final
endLine int
The end line of the variable declaration in the source file.
final
fieldType String?
The type annotation of the field if isFieldOf is set.
final
hashCode int
The hash code for this object.
no setterinherited
importPrefix String
The import prefix used when importing this variable (empty string if none).
final
isFieldOf String?
The class name if this variable is a class field, null for top-level variables.
final
libraryId int
The ID of the library where this variable is declared.
final
modifier MacroModifier
Declaration modifiers.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startLine int
The start line of the variable declaration in the source file.
final
variableId String
Unique identifier for this variable declaration.
final
variableName String
The name of the variable (e.g., _versionMacro).
final

Methods

copyWith({int? libraryId, String? variableId, List<MacroConfig>? configs, Map<String, dynamic>? data}) MacroVariableDeclaration
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

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

Static Methods

fromJson(Map<String, dynamic> json) MacroVariableDeclaration