explainModel static method
String
explainModel({
- required Lib lib,
- required SharedOptions options,
- required String content,
- required void callback(
- AssetItem asset
Implementation
static String explainModel({
required Lib lib,
required SharedOptions options,
required String content,
required void Function(AssetItem asset) callback
}) {
// 解析AssetItem参数
final String reArg = '[\\n\\s\'"]*([^\\s\\,\'"]+)[\\s\'"]*,?';
// 解析AssetItem备注
final String reMark = '[\\n\\s]*\\/\\*\\s*([^\\s]+)\\s+(Y|N)\\s*\\*\\/';
// 解析AssetItem数据
final String reAssetItem = '$reMark[\\n\\s]+static\\s+const\\s+$className\\s+([\\w\\d]+)\\s+\\=\\s+$className\\($reArg[\\n\\s]*\\);';
return content.replaceAllMapped(RegExp(reAssetItem), (Match match) {
final String hash = match.group(1)!;
final String name = match.group(3)!;
final String path = match.group(4)!;
callback(
AssetItem(
path: path,
name: name,
hash: hash,
lib: lib,
options: options,
),
);
return '';
});
}