Files
packages.dart/deprecated/flutter_ast/lib/src/core.dart
T
2026-01-15 14:38:46 -08:00

50 lines
1.1 KiB
Dart

import 'package:flutter_ast_core/flutter_ast_core.dart';
import 'analyzer.dart';
extension LiteralImplUtils on LiteralImpl {
DartCore toDartCore() {
final value = this;
if (value is BooleanLiteralImpl) {
return DartCore(
type: 'bool',
value: value.value.toString(),
);
}
if (value is IntegerLiteralImpl) {
return DartCore(
type: 'int',
value: value.value.toString(),
);
}
if (value is DoubleLiteralImpl) {
return DartCore(
type: 'double',
value: value.value.toString(),
);
}
if (value is StringLiteralImpl) {
return DartCore(
type: 'String',
value: value.stringValue.toString(),
);
}
if (value is SetOrMapLiteralImpl) {
return DartCore(
type: 'Map',
value: value.toString(),
);
}
if (value is ListLiteralImpl) {
return DartCore(
type: 'List',
value: value.toString(),
);
}
return DartCore(
type: null,
value: value.toString(),
);
}
}