1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +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) // test tu.getDeclarations(IBinding)
IASTName[] decls = tu.getDeclarations(x3.resolveBinding()); IASTName[] decls = tu.getDeclarations(x3.resolveBinding());
assertEquals( decls.length, 2 ); assertEquals( decls.length, 1 );
assertEquals( decls[0], x0 ); assertEquals( decls[0], x2 );
assertEquals( decls[1], 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("c").toCharArray()) ); //$NON-NLS-1$
assertNotNull( ((ICScope)tu.getScope()).getBinding(ICScope.NAMESPACE_TYPE_OTHER, new String("isroot").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) // test tu.getDeclarations(IBinding)
IASTName[] decls = tu.getDeclarations(x2.resolveBinding()); IASTName[] decls = tu.getDeclarations(x2.resolveBinding());
assertEquals( decls.length, 2 ); assertEquals( decls.length, 1 );
assertEquals( decls[0], x0 ); assertEquals( decls[0], x2 );
assertEquals( decls[1], 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_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$ 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.length, 1);
assertEquals(decls[0], def2.getDeclarator().getName()); assertEquals(decls[0], def2.getDeclarator().getName());
decls = tu.getDeclarations(def3.getDeclarator().getName() decls = tu.getDeclarations(def3.getDeclarator().getNestedDeclarator().getName()
.resolveBinding()); .resolveBinding());
assertEquals(decls.length, 1); 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 // 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) { public int processDeclarator(IASTDeclarator declarator) {
//GCC allows declarations in expressions, so we have to continue from the //GCC allows declarations in expressions, so we have to continue from the
//declarator in case there is something in the initializer expression //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 the binding is something not declared in a declarator, continue
if( binding instanceof ICompositeType ) return PROCESS_CONTINUE; if( binding instanceof ICompositeType ) return PROCESS_CONTINUE;
if( binding instanceof IEnumeration ) return PROCESS_CONTINUE; if( binding instanceof IEnumeration ) return PROCESS_CONTINUE;
IASTNode parent = declarator.getParent(); IASTNode parent = declarator.getParent();
while (parent != null && !(parent instanceof IASTDeclaration)) while (parent != null && !(parent instanceof IASTDeclaration || parent instanceof IASTParameterDeclaration))
parent = parent.getParent(); parent = parent.getParent();
if ( parent instanceof IASTDeclaration ) { if ( parent instanceof IASTDeclaration ) {
@ -318,14 +318,14 @@ public class CVisitor {
} }
} else if ( parent instanceof IASTSimpleDeclaration ) { } else if ( parent instanceof IASTSimpleDeclaration ) {
// prototype parameter with no identifier isn't a declaration of the K&R C parameter // prototype parameter with no identifier isn't a declaration of the K&R C parameter
if ( binding instanceof CKnRParameter && declarator.getName().toCharArray().length == 0 ) // if ( binding instanceof CKnRParameter && declarator.getName().toCharArray().length == 0 )
return PROCESS_CONTINUE; // return PROCESS_CONTINUE;
if ( (declarator.getName() != null && declarator.getName().resolveBinding() == binding) ) { if ( (declarator.getName() != null && declarator.getName().resolveBinding() == binding) ) {
addName(declarator.getName()); addName(declarator.getName());
} }
} }
} else if ( parent instanceof IASTParameterDeclaration && binding instanceof IParameter ) { } else if ( parent instanceof IASTParameterDeclaration ) {
if ( declarator.getName() != null && declarator.getName().resolveBinding() == binding ) { if ( declarator.getName() != null && declarator.getName().resolveBinding() == binding ) {
addName(declarator.getName()); addName(declarator.getName());
} }
@ -1612,6 +1612,8 @@ public class CVisitor {
return true; return true;
} }
public static boolean visitExpression( IASTExpression expression, CBaseVisitorAction action ){ public static boolean visitExpression( IASTExpression expression, CBaseVisitorAction action ){
if (expression == null) return true;
if( action.processExpressions ){ if( action.processExpressions ){
switch( action.processExpression( expression ) ){ switch( action.processExpression( expression ) ){
case CPPBaseVisitorAction.PROCESS_ABORT : return false; case CPPBaseVisitorAction.PROCESS_ABORT : return false;

View file

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

View file

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

View file

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