mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer.
Core: - fix class cast exception in the symbol table while traversing the inheritance of a class. - filter the results of the prefix lookup for content assist so that those symbol without attached AST nodes aren removed so that the iterator does not later return a null. Tests: - added CompletionParseTests.testBug51260
This commit is contained in:
parent
2937f68a8c
commit
728eeb85f8
5 changed files with 69 additions and 10 deletions
|
@ -5,6 +5,9 @@
|
|||
Moved testErrorHandling_1() from failed tests to CompleteParseASTTest.
|
||||
Moved testBug44340() from failed tests to CompleteParseASTTest.
|
||||
|
||||
2004-02-06 Andrew Niefer
|
||||
Added CompletionParseTest.testBug51260
|
||||
|
||||
2004-02-04 John Camelon
|
||||
Added preliminary SelectionParseTests to test SELECTION_PARSE clients.
|
||||
Added SelectionParseTests to ParserTestSuite.
|
||||
|
|
|
@ -601,4 +601,42 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
IASTField field = (IASTField) result.getNodes().next();
|
||||
assertEquals( field.getName(), "aPrivate" );
|
||||
}
|
||||
|
||||
public void testBug51260() throws Exception{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( " class A { public: void a(); }; " );
|
||||
writer.write( " class B : public virtual A { public: void b(); };" );
|
||||
writer.write( " class C : public virtual A { public: void c(); };" );
|
||||
writer.write( " class D : public B, C { public: void d(); };" );
|
||||
|
||||
writer.write( " void A::a(){} ");
|
||||
writer.write( " void B::b(){} ");
|
||||
writer.write( " void C::c(){} ");
|
||||
writer.write( " void D::d(){ SP }" );
|
||||
|
||||
String code = writer.toString();
|
||||
int index = code.indexOf( "SP" );
|
||||
IASTCompletionNode node = parse( code, index );
|
||||
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.THIS },
|
||||
node.getCompletionContext() );
|
||||
|
||||
assertEquals( result.getResultsSize(), 4 );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
IASTMethod d = (IASTMethod) iter.next();
|
||||
IASTMethod b = (IASTMethod) iter.next();
|
||||
IASTMethod a = (IASTMethod) iter.next();
|
||||
IASTMethod c = (IASTMethod) iter.next();
|
||||
|
||||
assertFalse( iter.hasNext() );
|
||||
|
||||
assertEquals( a.getName(), "a" );
|
||||
assertEquals( b.getName(), "b" );
|
||||
assertEquals( c.getName(), "c" );
|
||||
assertEquals( d.getName(), "d" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
Fixed Bug 44340 - Inline functions fail to resolve references
|
||||
Fixed Bug 51243 - Content Assist in an empty document causes a NPE
|
||||
|
||||
2004-02-06 Andrew Niefer
|
||||
fixed bug51260 - Content Assist: Completion inside a class method silently fails with a ClassCastException
|
||||
filter symbols without attached AST nodes out of the completion results so the iterator doesn't sometimes return null.
|
||||
|
||||
2004-02-04 John Camelon
|
||||
Added preliminary (crude) bSelectionParser IParser implementation for SELECTION_PARSE clients.
|
||||
|
||||
|
|
|
@ -99,10 +99,14 @@ public class ASTNode implements IASTNode {
|
|||
if(lookupResults == null)
|
||||
return null;
|
||||
|
||||
//filter out things that are not visible and things that don't have AST nodes attached
|
||||
ListIterator iter = lookupResults.listIterator();
|
||||
while( iter.hasNext() ){
|
||||
ISymbol s = (ISymbol) iter.next();
|
||||
if( !thisContainer.isVisible( s, qualification ) ){
|
||||
if( !thisContainer.isVisible( s, qualification ) ||
|
||||
s.getASTExtension() == null ||
|
||||
s.getASTExtension().getPrimaryDeclaration() == null )
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -611,7 +611,10 @@ public class ParserSymbolTable {
|
|||
while( iter.hasNext() ){
|
||||
key = iter.next();
|
||||
if( symbol.containsKey( key ) ){
|
||||
ISymbol sym = (ISymbol) symbol.get( key );
|
||||
Object obj = symbol.get( key );
|
||||
Iterator objIter = ( obj instanceof List ) ? ((List)obj).iterator() : null;
|
||||
ISymbol sym = (ISymbol) (( objIter != null && objIter.hasNext() ) ? objIter.next() : obj);
|
||||
while( sym != null ){
|
||||
if( !checkAmbiguity( sym, temp.get( key ) ) ){
|
||||
if( data.mode == LookupMode.PREFIX ){
|
||||
if( data.ambiguities == null ){
|
||||
|
@ -622,6 +625,13 @@ public class ParserSymbolTable {
|
|||
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||
}
|
||||
}
|
||||
|
||||
if( objIter != null && objIter.hasNext() ){
|
||||
sym = (ISymbol) objIter.next();
|
||||
} else {
|
||||
sym = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
symbol.put( key, temp.get( key ) );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue