1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

fix bug 72372 : [Parser] ContextSearch declarations on a function defn: op unavailable

lookupNestedNameSpecifier didn't consider using directives.
This commit is contained in:
Andrew Niefer 2004-09-24 15:07:49 +00:00
parent f6bae1949b
commit 4ab98b6ee9
3 changed files with 36 additions and 6 deletions

View file

@ -406,4 +406,38 @@ public class SelectionParseTest extends SelectionParseBaseTest {
assertEquals( ((IASTMethod)node).getName(), "ABC" ); //$NON-NLS-1$ assertEquals( ((IASTMethod)node).getName(), "ABC" ); //$NON-NLS-1$
assertTrue( ((IASTMethod)node).isConstructor() ); assertTrue( ((IASTMethod)node).isConstructor() );
} }
public void testBug72372() throws Exception{
Writer writer = new StringWriter();
writer.write("namespace B { \n"); //$NON-NLS-1$
writer.write(" class SD_02 { void f_SD(); }; \n"); //$NON-NLS-1$
writer.write("} \n"); //$NON-NLS-1$
writer.write("using namespace B; \n"); //$NON-NLS-1$
writer.write("void SD_02::f_SD(){} \n"); //$NON-NLS-1$
String code = writer.toString();
int startIndex = code.indexOf( ":f_SD" ); //$NON-NLS-1$
IASTNode node = parse( code, startIndex + 1, startIndex + 5 );
assertTrue( node instanceof IASTMethod );
assertEquals( ((IASTMethod)node).getName(), "f_SD" ); //$NON-NLS-1$
}
public void testBug72372_2() throws Exception{
Writer writer = new StringWriter();
writer.write("namespace A { \n"); //$NON-NLS-1$
writer.write(" namespace B { \n"); //$NON-NLS-1$
writer.write(" void f_SD(); \n"); //$NON-NLS-1$
writer.write(" } \n"); //$NON-NLS-1$
writer.write("} \n"); //$NON-NLS-1$
writer.write("namespace C { \n"); //$NON-NLS-1$
writer.write(" using namespace A; \n"); //$NON-NLS-1$
writer.write("} \n"); //$NON-NLS-1$
writer.write("void C::B::f_SD(){} \n"); //$NON-NLS-1$
String code = writer.toString();
int startIndex = code.indexOf( ":f_SD" ); //$NON-NLS-1$
IASTNode node = parse( code, startIndex + 1, startIndex + 5 );
assertTrue( node instanceof IASTFunction );
assertEquals( ((IASTFunction)node).getName(), "f_SD" ); //$NON-NLS-1$
}
} }

View file

@ -2181,7 +2181,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
catch (ParserSymbolTableException e) catch (ParserSymbolTableException e)
{ {
handleProblem( e.createProblemID(), name.toCharArray()); handleProblem( e.createProblemID(), name.toCharArray(), nameOffset, nameEndOffset, nameLine, true);
} }
} else { } else {
symbol = functionDeclaration; symbol = functionDeclaration;

View file

@ -590,15 +590,11 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
final private TypeFilter typeFilter = filter; final private TypeFilter typeFilter = filter;
}; };
data.foundItems = ParserSymbolTable.lookupInContained( data, inSymbol ); ParserSymbolTable.lookup( data, inSymbol );
if( data.foundItems != null ){ if( data.foundItems != null ){
foundSymbol = getSymbolTable().resolveAmbiguities( data ); foundSymbol = getSymbolTable().resolveAmbiguities( data );
} }
if( foundSymbol == null && inSymbol.getContainingSymbol() != null ){
foundSymbol = lookupNestedNameSpecifier( name, inSymbol.getContainingSymbol() );
}
if( foundSymbol instanceof IContainerSymbol ) if( foundSymbol instanceof IContainerSymbol )
return (IContainerSymbol) foundSymbol; return (IContainerSymbol) foundSymbol;