fromMapContent static method
Loads the mapping data from content and uses it for a new
Deobfuscator instance.
Returns an empty instance if no deobfuscation mapping is found. This allows caching of stripped generic types even in this case.
Implementation
static Future<Deobfuscator> fromMapContent(String? content) async {
if (content == null) {
// An empty deobfuscator will return obfuscated names with trimmed names
// still cached.
return Deobfuscator({});
}
final map = <String, String>{};
final lines = content.split('\n');
for (final line in lines) {
final trimmedLine = line.trim();
if (trimmedLine.isEmpty || trimmedLine.startsWith('#')) {
continue;
}
final parts = trimmedLine.split('=');
if (parts.length == 2) {
final obfuscated = parts[0].trim();
final deobfuscated = parts[1].trim();
map[obfuscated] = deobfuscated;
} else {
Logger.log(
LogLevel.debug,
'Skipping malformed line in mapping file: $line',
);
}
}
return Deobfuscator(map);
}