use of org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition in project arduino-eclipse-plugin by Sloeber.
the class PdePreprocessor method extendMethodDeclarationsForFile.
private static String extendMethodDeclarationsForFile(String body, IIndex index, ITranslationUnit tu) throws CoreException {
// add declarations made in ino files.
String localBody = body;
IASTTranslationUnit asttu = tu.getAST(index, ITranslationUnit.AST_SKIP_FUNCTION_BODIES | ITranslationUnit.AST_SKIP_ALL_HEADERS);
IASTNode[] astNodes = asttu.getChildren();
for (IASTNode astNode : astNodes) {
if (astNode instanceof CPPASTFunctionDefinition) {
String addString = astNode.getRawSignature();
addString = addString.replaceAll("\r\n", NEWLINE);
addString = addString.replaceAll("\r", NEWLINE);
addString = addString.replaceAll("//[^\n]+\n", " ");
addString = addString.replaceAll("\n", " ");
addString = addString.replaceAll("\\{.*\\}", "");
if (addString.contains("=") || addString.contains("::")) {
// ignore when there are assignments in the
// declaration
// or when it is a class function
} else {
localBody += addString + ';' + NEWLINE;
}
}
}
return localBody;
}
Aggregations