mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix incorrect merging of prefix lookup results from different scopes. 72559
This commit is contained in:
parent
e37ca5ef26
commit
a0681af9ce
2 changed files with 25 additions and 4 deletions
|
@ -128,7 +128,7 @@ public class ParserSymbolTable {
|
|||
if( data.foundItems == null || data.foundItems.isEmpty() ){
|
||||
data.foundItems = map;
|
||||
} else {
|
||||
mergeResults( data, data.foundItems, map );
|
||||
mergeScopedResults( data.foundItems, map );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class ParserSymbolTable {
|
|||
if( data.foundItems == null || data.foundItems.isEmpty() ){
|
||||
data.foundItems = map;
|
||||
} else {
|
||||
mergeInheritedResults( data.foundItems, map );
|
||||
mergeScopedResults( data.foundItems, map );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ public class ParserSymbolTable {
|
|||
if( temp == null )
|
||||
temp = inherited;
|
||||
else
|
||||
mergeInheritedResults( temp, inherited );
|
||||
mergeScopedResults( temp, inherited );
|
||||
}
|
||||
} else {
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_CircularInheritance );
|
||||
|
@ -767,7 +767,7 @@ public class ParserSymbolTable {
|
|||
* @param map
|
||||
* @throws ParserSymbolTableException
|
||||
*/
|
||||
private static void mergeInheritedResults( CharArrayObjectMap resultMap, CharArrayObjectMap map ){
|
||||
private static void mergeScopedResults( CharArrayObjectMap resultMap, CharArrayObjectMap map ){
|
||||
if( resultMap == null || map == null || map.isEmpty() ){
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -193,4 +193,25 @@ public class ContentAssistTests extends TestCase {
|
|||
assertEquals( results[1].getDisplayString(), "IDIOT" ); //$NON-NLS-1$
|
||||
assertEquals( results[2].getDisplayString(), "NORMAL" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug72559() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write("void foo(){ \n"); //$NON-NLS-1$
|
||||
writer.write(" int var; \n"); //$NON-NLS-1$
|
||||
writer.write(" { \n"); //$NON-NLS-1$
|
||||
writer.write(" float var; \n"); //$NON-NLS-1$
|
||||
writer.write(" v \n"); //$NON-NLS-1$
|
||||
writer.write(" } \n"); //$NON-NLS-1$
|
||||
writer.write("} \n"); //$NON-NLS-1$
|
||||
|
||||
String code = writer.toString();
|
||||
IFile cu = importFile( "t.cpp", code ); //$NON-NLS-1$
|
||||
ICompletionProposal [] results = getResults( cu, code.indexOf( "v " ) + 1 ); //$NON-NLS-1$
|
||||
|
||||
assertEquals( results.length, 4 );
|
||||
assertEquals( results[0].getDisplayString(), "var : float" ); //$NON-NLS-1$
|
||||
assertEquals( results[1].getDisplayString(), "virtual" ); //$NON-NLS-1$
|
||||
assertEquals( results[2].getDisplayString(), "void" ); //$NON-NLS-1$
|
||||
assertEquals( results[3].getDisplayString(), "volatile" ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue