applyIncludeMacro function
Implementation
String applyIncludeMacro(File file, String content) {
var lines = LineSplitter.split(content).toList();
var result = Lines();
lines = removeGeneratedBlocks(lines, 'include');
lines.read((line, skip) {
result.add(line);
if (!skip && line.isMacro("include")) {
var path = line.macroContent.split(' ')[1];
var includeFile = File('${file.parent.path}/$path');
if (includeFile.existsSync()) {
result.addAll(_readIncludeFile(includeFile));
result.add(_endComment);
} else {
throw 'Error in ${file.path}: File to include ${includeFile.path} not found';
}
}
});
return result.data().join('\n');
}