mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix lookup in parents while doing content assist on list out of <list>
This commit is contained in:
parent
6df42f9ccf
commit
d7664718ae
5 changed files with 48 additions and 1 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-04-07 Andrew Niefer
|
||||||
|
added CompletionParseTest.testCompletionWithTemplateInstanceAsParent()
|
||||||
|
|
||||||
2004-04-07 Andrew Niefer
|
2004-04-07 Andrew Niefer
|
||||||
fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=44338
|
fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=44338
|
||||||
- added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.testBug44338()
|
- added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.testBug44338()
|
||||||
|
|
|
@ -807,4 +807,27 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCompletionWithTemplateInstanceAsParent() throws Exception
|
||||||
|
{
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
writer.write( "template < class T > class A { public : int a_member; }; ");
|
||||||
|
writer.write( "template < class T > class B : public A< T > { public : int b_member; }; ");
|
||||||
|
writer.write( "void f() { ");
|
||||||
|
writer.write( " B< int > b; ");
|
||||||
|
writer.write( " b.SP ");
|
||||||
|
|
||||||
|
String code = writer.toString();
|
||||||
|
IASTCompletionNode node = parse( code, code.indexOf( "SP" ) );
|
||||||
|
|
||||||
|
ILookupResult result = node.getCompletionScope().lookup( "",
|
||||||
|
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||||
|
node.getCompletionContext() );
|
||||||
|
assertEquals( result.getResultsSize(), 2 );
|
||||||
|
|
||||||
|
Iterator i = result.getNodes();
|
||||||
|
|
||||||
|
IASTField bmember = (IASTField) i.next();
|
||||||
|
IASTField amember = (IASTField) i.next();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2004-04-07 Andrew Niefer
|
||||||
|
fix lookup in parents when the parent is a deferred template instance, enables content assist on list (from <list>)
|
||||||
|
|
||||||
2004-04-07 Andrew Niefer
|
2004-04-07 Andrew Niefer
|
||||||
fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=44338
|
fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=44338
|
||||||
|
|
||||||
|
|
|
@ -850,6 +850,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
ASTAccessVisibility visibility;
|
ASTAccessVisibility visibility;
|
||||||
|
|
||||||
visibility = ParserSymbolTable.getVisibility( symbol, qualifyingSymbol );
|
visibility = ParserSymbolTable.getVisibility( symbol, qualifyingSymbol );
|
||||||
|
if( visibility == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
if( visibility == ASTAccessVisibility.PUBLIC ){
|
if( visibility == ASTAccessVisibility.PUBLIC ){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -650,6 +650,11 @@ public class ParserSymbolTable {
|
||||||
//is circular inheritance
|
//is circular inheritance
|
||||||
if( ! data.inheritanceChain.contains( parent ) ){
|
if( ! data.inheritanceChain.contains( parent ) ){
|
||||||
//is this name define in this scope?
|
//is this name define in this scope?
|
||||||
|
if( parent instanceof IDeferredTemplateInstance ){
|
||||||
|
parent = ((IDeferredTemplateInstance)parent).getTemplate().getTemplatedSymbol();
|
||||||
|
} else if( parent instanceof ITemplateSymbol ){
|
||||||
|
parent = ((ITemplateSymbol)parent).getTemplatedSymbol();
|
||||||
|
}
|
||||||
if( parent instanceof IDerivableContainerSymbol ){
|
if( parent instanceof IDerivableContainerSymbol ){
|
||||||
temp = lookupInContained( data, (IDerivableContainerSymbol) parent );
|
temp = lookupInContained( data, (IDerivableContainerSymbol) parent );
|
||||||
} else {
|
} else {
|
||||||
|
@ -2275,7 +2280,18 @@ public class ParserSymbolTable {
|
||||||
while( iter.hasNext() ){
|
while( iter.hasNext() ){
|
||||||
parent = (IParentSymbol) iter.next();
|
parent = (IParentSymbol) iter.next();
|
||||||
parentAccess = parent.getAccess();
|
parentAccess = parent.getAccess();
|
||||||
symbolAccess = getVisibility( symbol, (IContainerSymbol) parent.getParent() );
|
|
||||||
|
ISymbol tmp = parent.getParent();
|
||||||
|
if( tmp instanceof IDeferredTemplateInstance )
|
||||||
|
tmp = ((IDeferredTemplateInstance)tmp).getTemplate().getTemplatedSymbol();
|
||||||
|
else if( tmp instanceof ITemplateSymbol ){
|
||||||
|
tmp = ((ITemplateSymbol)tmp).getTemplatedSymbol();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( tmp instanceof IContainerSymbol ) )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
symbolAccess = getVisibility( symbol, (IContainerSymbol) tmp );
|
||||||
|
|
||||||
if( symbolAccess != null ){
|
if( symbolAccess != null ){
|
||||||
symbolAccess = ( parentAccess.isGreaterThan( symbolAccess ) ) ? parentAccess : symbolAccess;
|
symbolAccess = ( parentAccess.isGreaterThan( symbolAccess ) ) ? parentAccess : symbolAccess;
|
||||||
|
|
Loading…
Add table
Reference in a new issue