1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Patch for Devin Steffler.

Further updates to DOM AST View.
This commit is contained in:
John Camelon 2005-02-02 02:16:54 +00:00
parent 956abd7934
commit c2d34df02e
5 changed files with 48 additions and 8 deletions

View file

@ -28,6 +28,10 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@ -93,6 +97,20 @@ public class CPPPopulateASTViewAction extends CPPBaseVisitorAction implements IP
addRoot(mods[i]);
}
if (declarator instanceof ICPPASTFunctionDeclarator) {
ICPPASTConstructorChainInitializer[] chainInit = ((ICPPASTFunctionDeclarator)declarator).getConstructorChain();
for(int i=0; i<chainInit.length; i++) {
addRoot(chainInit[i]);
}
if( declarator instanceof ICPPASTFunctionTryBlockDeclarator ){
ICPPASTCatchHandler [] catchHandlers = ((ICPPASTFunctionTryBlockDeclarator)declarator).getCatchHandlers();
for( int i = 0; i < catchHandlers.length; i++ ){
addRoot(catchHandlers[i]);
}
}
}
return PROCESS_CONTINUE;
}

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction;
@ -44,6 +45,7 @@ public class CPopulateASTViewAction extends CBaseVisitorAction implements IPopul
processParameterDeclarations = true;
processDeclarators = true;
processDeclSpecifiers = true;
processDesignators = true;
processExpressions = true;
processStatements = true;
processTypeIds = true;
@ -99,6 +101,14 @@ public class CPopulateASTViewAction extends CBaseVisitorAction implements IPopul
return PROCESS_CONTINUE;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDesignator(org.eclipse.cdt.core.dom.ast.c.ICASTDesignator)
*/
public int processDesignator(ICASTDesignator designator) {
addRoot(designator);
return PROCESS_CONTINUE;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
*/
@ -128,12 +138,6 @@ public class CPopulateASTViewAction extends CBaseVisitorAction implements IPopul
*/
public int processInitializer(IASTInitializer initializer) {
addRoot(initializer);
if (initializer instanceof ICASTDesignatedInitializer) {
ICASTDesignator[] designators = ((ICASTDesignatedInitializer)initializer).getDesignators();
for (int i=0; i<designators.length; i++) {
addRoot(designators[i]);
}
}
return PROCESS_CONTINUE;
}

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -262,7 +263,10 @@ private static final String REFRESH_DOM_AST = "Refresh DOM AST"; //$NON-NLS-1
} else if (node instanceof IASTSimpleDeclaration) {
imageKey = DOMASTPluginImages.IMG_IASTSimpleDeclaration;
} else if (node instanceof IASTStatement) {
imageKey = DOMASTPluginImages.IMG_IASTStatement;
if (node instanceof IASTProblemStatement)
imageKey = DOMASTPluginImages.IMG_IASTProblem;
else
imageKey = DOMASTPluginImages.IMG_IASTStatement;
} else if (node instanceof IASTTranslationUnit) {
imageKey = DOMASTPluginImages.IMG_IASTTranslationUnit;
} else if (node instanceof IASTTypeId) {

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorObjectStyleMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
@ -145,7 +146,10 @@ public class TreeObject implements IAdaptable {
}
}
if ( node instanceof IASTSimpleDeclaration ) {
if ( node instanceof IASTProblemHolder ) {
buffer.append(START_OF_LIST);
buffer.append(((IASTProblemHolder)node).getProblem().getMessage());
} else if ( node instanceof IASTSimpleDeclaration ) {
String name = null;
IASTDeclarator[] decltors = ((IASTSimpleDeclaration)node).getDeclarators();

View file

@ -92,6 +92,16 @@ public class TreeParent extends TreeObject {
}
}
// try finding the best parent possible
IASTNode parent = node.getParent();
TreeParent tree = null;
while (parent != null && tree == null) {
tree = findParentOfNode(parent);
if (tree != null) return tree;
parent = parent.getParent();
}
return null; // nothing found
}