use of org.eclipse.cdt.core.dom.ast.IASTTranslationUnit 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;
}
use of org.eclipse.cdt.core.dom.ast.IASTTranslationUnit in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class NodeWidget method displayBindings.
private void displayBindings(final TreeItem parent, final IASTNode node, final IBinding binding) throws CoreException {
final IASTTranslationUnit ast = node.getTranslationUnit();
for (final IASTName decl : ast.getDeclarationsInAST(binding)) {
createTreeItem(parent, "declaration;" + decl);
}
for (final IASTName def : ast.getDefinitionsInAST(binding)) {
createTreeItem(parent, "definition;" + def);
}
for (final IASTName ref : ast.getReferences(binding)) {
createTreeItem(parent, "reference;" + ref);
}
displayTypeIfPresent(parent, binding);
final TreeItem typeHierarchy = createTreeItem(parent, "Type Hierarchy;");
displayTypeHierarchy(typeHierarchy, binding);
final TreeItem fields = createTreeItem(parent, "Fields;");
displayFields(fields, binding);
final TreeItem methods = createTreeItem(parent, "Methods;");
displayMethods(methods, binding);
}
use of org.eclipse.cdt.core.dom.ast.IASTTranslationUnit in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class ILTISDummyRenameRefactoring method collectModifications.
@Override
protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException {
IASTTranslationUnit ast = refactoringContext.getAST(tu, pm);
IASTSimpleDeclaration funcDeclaration = (IASTSimpleDeclaration) ast.getDeclarations()[0];
IASTFunctionDeclarator declarator = (IASTFunctionDeclarator) funcDeclaration.getDeclarators()[0];
IASTFunctionDeclarator newDeclarator = declarator.copy();
IASTName newName = CPPNodeFactory.getDefault().newName("b".toCharArray());
newDeclarator.setName(newName);
ASTRewrite rewrite = collector.rewriterForTranslationUnit(ast);
rewrite.replace(declarator, newDeclarator, new TextEditGroup(""));
}
use of org.eclipse.cdt.core.dom.ast.IASTTranslationUnit in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class TestRefactoring method collectModifications.
@Override
protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException {
IASTTranslationUnit ast = refactoringContext.getAST(tu, pm);
collectModificationsCalled = ast != null;
}
use of org.eclipse.cdt.core.dom.ast.IASTTranslationUnit in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class ILTISTestRefactoring method collectModifications.
@Override
protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException {
IASTTranslationUnit ast = refactoringContext.getAST(tu, pm);
collectModificationsCalled = ast != null;
}
Aggregations