getModifiers abstract method
Returns the list of modifiers associated with this source element.
A modifier in JetLeaf represents a keyword that alters the behavior,
visibility, or semantics of a language element — similar to modifiers in
Dart such as public, private, static, final, abstract.
JetLeaf Context
Every reflective entity (Class, Field, Method, Parameter,
or Constructor) inherits from Source and therefore supports querying
modifiers for meta-analysis and dynamic weaving.
Modifiers are typically derived from parsed annotations, metadata, or language-level declarations available via JetLeaf’s reflection system.
Example
void inspectModifiers(Source source) {
final modifiers = source.getModifiers();
print('Source name: ${source.getName()}');
print('Modifiers: ${modifiers.join(', ')}');
if (modifiers.contains('static')) {
print('This element is static.');
}
if (modifiers.contains('final')) {
print('This element cannot be reassigned.');
}
}
final field = Class<MyService>().getField('repository');
inspectModifiers(field);
// Output:
// Source name: repository
// Modifiers: private, final
// This element cannot be reassigned.
Return
A list of modifier names as strings, in declaration order.
Returns an empty list if the element has no explicit modifiers.
Usage Notes
- For classes, modifiers may include:
abstract,final,sealed,base. - For methods:
async,override,static,final. - For fields:
const,static,late,final, or visibility modifiers. - For constructors:
factory,const,private. - For parameters:
required,named,positional, etc.
Implementation
List<String> getModifiers();