1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Patch for Devin Steffler.

Further UI indicator infrastructure for testing DOM AST.
This commit is contained in:
John Camelon 2005-02-03 15:26:27 +00:00
parent 7e45886b28
commit 24d6abba7f
6 changed files with 24 additions and 17 deletions

View file

@ -246,9 +246,8 @@ public class AST2KnRTests extends AST2BaseTest {
// test tu.getDeclarations(IBinding)
IASTName[] decls = tu.getDeclarations(x3.resolveBinding());
assertEquals( decls.length, 2 );
assertEquals( decls[0], x0 );
assertEquals( decls[1], x2 );
assertEquals( decls.length, 1 );
assertEquals( decls[0], x2 );
assertNotNull( ((ICScope)tu.getScope()).getBinding(ICScope.NAMESPACE_TYPE_OTHER, new String("c").toCharArray()) ); //$NON-NLS-1$
assertNotNull( ((ICScope)tu.getScope()).getBinding(ICScope.NAMESPACE_TYPE_OTHER, new String("isroot").toCharArray()) ); //$NON-NLS-1$
@ -538,9 +537,8 @@ public class AST2KnRTests extends AST2BaseTest {
// test tu.getDeclarations(IBinding)
IASTName[] decls = tu.getDeclarations(x2.resolveBinding());
assertEquals( decls.length, 2 );
assertEquals( decls[0], x0 );
assertEquals( decls[1], x2 );
assertEquals( decls.length, 1 );
assertEquals( decls[0], x2 );
assertNotNull( ((ICScope)tu.getScope()).getBinding(ICScope.NAMESPACE_TYPE_TAG, new String("A_struct").toCharArray()) ); //$NON-NLS-1$
assertNotNull( ((ICScope)tu.getScope()).getBinding(ICScope.NAMESPACE_TYPE_OTHER, new String("A").toCharArray()) ); //$NON-NLS-1$

View file

@ -2099,10 +2099,10 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(decls.length, 1);
assertEquals(decls[0], def2.getDeclarator().getName());
decls = tu.getDeclarations(def3.getDeclarator().getName()
decls = tu.getDeclarations(def3.getDeclarator().getNestedDeclarator().getName()
.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], def3.getDeclarator().getName());
assertEquals(decls[0], def3.getDeclarator().getNestedDeclarator().getName());
}
// any parameter to type function returning T is adjusted to be pointer to

View file

@ -301,14 +301,14 @@ public class CVisitor {
public int processDeclarator(IASTDeclarator declarator) {
//GCC allows declarations in expressions, so we have to continue from the
//declarator in case there is something in the initializer expression
if ( declarator == null ) return PROCESS_CONTINUE;
if ( declarator == null || declarator.getName() == null || declarator.getName().toCharArray().length == 0 ) return PROCESS_CONTINUE;
//if the binding is something not declared in a declarator, continue
if( binding instanceof ICompositeType ) return PROCESS_CONTINUE;
if( binding instanceof IEnumeration ) return PROCESS_CONTINUE;
IASTNode parent = declarator.getParent();
while (parent != null && !(parent instanceof IASTDeclaration))
while (parent != null && !(parent instanceof IASTDeclaration || parent instanceof IASTParameterDeclaration))
parent = parent.getParent();
if ( parent instanceof IASTDeclaration ) {
@ -318,14 +318,14 @@ public class CVisitor {
}
} else if ( parent instanceof IASTSimpleDeclaration ) {
// prototype parameter with no identifier isn't a declaration of the K&R C parameter
if ( binding instanceof CKnRParameter && declarator.getName().toCharArray().length == 0 )
return PROCESS_CONTINUE;
// if ( binding instanceof CKnRParameter && declarator.getName().toCharArray().length == 0 )
// return PROCESS_CONTINUE;
if ( (declarator.getName() != null && declarator.getName().resolveBinding() == binding) ) {
addName(declarator.getName());
}
}
} else if ( parent instanceof IASTParameterDeclaration && binding instanceof IParameter ) {
} else if ( parent instanceof IASTParameterDeclaration ) {
if ( declarator.getName() != null && declarator.getName().resolveBinding() == binding ) {
addName(declarator.getName());
}
@ -1612,6 +1612,8 @@ public class CVisitor {
return true;
}
public static boolean visitExpression( IASTExpression expression, CBaseVisitorAction action ){
if (expression == null) return true;
if( action.processExpressions ){
switch( action.processExpression( expression ) ){
case CPPBaseVisitorAction.PROCESS_ABORT : return false;

View file

@ -63,6 +63,8 @@ public class CPPPopulateASTViewAction extends CPPBaseVisitorAction implements IP
}
private void addRoot(IASTNode node) {
if (node == null) return;
TreeParent parent = root.findParentOfNode(node);
if ( parent != null ) {

View file

@ -59,6 +59,8 @@ public class CPopulateASTViewAction extends CBaseVisitorAction implements IPopul
}
private void addRoot(IASTNode node) {
if (node == null) return;
IASTNodeLocation[] nodeLocations = node.getNodeLocations();
if (!(nodeLocations.length > 0 &&
nodeLocations[0].getNodeOffset() >= 0 &&

View file

@ -82,10 +82,13 @@ public class DOMQuery extends CSearchQuery implements ISearchQuery {
path = new Path(fileName);
file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
start = names[i].getNodeLocations()[0].getNodeOffset();
end = names[i].getNodeLocations()[0].getNodeOffset() + names[i].getNodeLocations()[0].getNodeLength();
collector.acceptMatch( createMatch(file, start, end, names[i], path ) );
if (names[i].getNodeLocations().length > 0) { // fix for 84223
start = names[i].getNodeLocations()[0].getNodeOffset();
end = names[i].getNodeLocations()[0].getNodeOffset() + names[i].getNodeLocations()[0].getNodeLength();
collector.acceptMatch( createMatch(file, start, end, names[i], path ) );
}
}
} catch (CoreException ce) {}
}