1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

fix bug 58492 - [Content Assist] No completions when function argument is 'struct <struct_name>'

This commit is contained in:
Andrew Niefer 2004-04-15 22:38:38 +00:00
parent f76a432bef
commit fed76537bb
4 changed files with 67 additions and 26 deletions

View file

@ -1,3 +1,6 @@
2004-04-15 Andrew Niefer
added parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.testBug58492()
2004-04-15 John Camelon 2004-04-15 John Camelon
Added CompleteParseASTTest::testBug39697(). Added CompleteParseASTTest::testBug39697().

View file

@ -74,6 +74,28 @@ public class CompletionParseTest extends CompleteParseBaseTest {
} }
protected IASTCompletionNode parse(String code, int offset, ParserLanguage lang ) throws Exception {
callback = new FullParseCallback();
IParser parser = null;
parser =
ParserFactory.createParser(
ParserFactory.createScanner(
new StringReader(code),
"completion-test",
new ScannerInfo(),
ParserMode.COMPLETION_PARSE,
lang,
callback,
new NullLogService(), null),
callback,
ParserMode.COMPLETION_PARSE,
lang,
null);
return parser.parse( offset );
}
public void testBaseCase_SimpleDeclaration() throws Exception public void testBaseCase_SimpleDeclaration() throws Exception
{ {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
@ -862,4 +884,27 @@ public class CompletionParseTest extends CompleteParseBaseTest {
} }
public void testBug58492() throws Exception
{
Writer writer = new StringWriter();
writer.write("struct Cube { ");
writer.write(" int nLen; ");
writer.write(" int nWidth; ");
writer.write(" int nHeight; ");
writer.write("}; ");
writer.write("int volume( struct Cube * pCube ) { ");
writer.write(" pCube->SP ");
String code = writer.toString();
IASTCompletionNode node = parse( code, code.indexOf("SP"), ParserLanguage.C );
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
new IASTNode.LookupKind[] {IASTNode.LookupKind.ALL },
node.getCompletionContext() );
assertEquals( result.getResultsSize(), 3 );
Iterator i = result.getNodes();
assertTrue( i.next() instanceof IASTField );
assertTrue( i.next() instanceof IASTField );
assertTrue( i.next() instanceof IASTField );
}
} }

View file

@ -1,3 +1,6 @@
2004-04-15 Andrew Niefer
fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=58492
2004-04-15 John Camelon 2004-04-15 John Camelon
Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=39697 Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=39697

View file

@ -2018,33 +2018,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier ) else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier )
{ {
ASTClassKind kind = ((IASTClassSpecifier)absDecl.getTypeSpecifier()).getClassKind(); type.setType( TypeInfo.t_type );
if( kind == ASTClassKind.CLASS ) type.setTypeSymbol( ((ASTClassSpecifier)absDecl.getTypeSpecifier()).getSymbol() );
type.setType(TypeInfo.t_class);
else if( kind == ASTClassKind.STRUCT )
type.setType(TypeInfo.t_struct);
else if( kind == ASTClassKind.UNION )
type.setType(TypeInfo.t_union);
// else
// assert false : this;
} }
else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier ) else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier )
{ {
type.setType(TypeInfo.t_enumeration); type.setType( TypeInfo.t_type );
type.setTypeSymbol( ((ASTEnumerationSpecifier)absDecl.getTypeSpecifier()).getSymbol() );
} }
else if( absDecl.getTypeSpecifier() instanceof IASTElaboratedTypeSpecifier ) else if( absDecl.getTypeSpecifier() instanceof IASTElaboratedTypeSpecifier )
{ {
ASTClassKind kind = ((IASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getClassKind(); type.setType( TypeInfo.t_type );
if( kind == ASTClassKind.CLASS ) type.setTypeSymbol( ((ASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol() );
type.setType(TypeInfo.t_class);
else if( kind == ASTClassKind.STRUCT )
type.setType(TypeInfo.t_struct);
else if( kind == ASTClassKind.UNION )
type.setType(TypeInfo.t_union);
else if( kind == ASTClassKind.ENUM )
type.setType(TypeInfo.t_enumeration);
// else
// assert false : this;
} }
// else // else
// assert false : this; // assert false : this;
@ -2073,9 +2058,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return; return;
// now determined by another function // now determined by another function
TypeInfo.eType type = getParameterTypeInfo(absDecl).getType(); TypeInfo info = getParameterTypeInfo( absDecl );
TypeInfo.eType type = info.getType();
ISymbol xrefSymbol = null; ISymbol xrefSymbol = info.getTypeSymbol();
List newReferences = null; List newReferences = null;
int infoBits = 0; int infoBits = 0;
if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ) if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
@ -2104,8 +2090,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
ISymbol paramSymbol = pst.newSymbol( paramName, type ); ISymbol paramSymbol = pst.newSymbol( paramName, type );
if( xrefSymbol != null ) if( xrefSymbol != null ){
paramSymbol.setTypeSymbol( xrefSymbol.getTypeSymbol() ); if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
paramSymbol.setTypeSymbol( xrefSymbol.getTypeSymbol() );
else
paramSymbol.setTypeSymbol( xrefSymbol );
}
paramSymbol.getTypeInfo().setTypeInfo( infoBits ); paramSymbol.getTypeInfo().setTypeInfo( infoBits );
paramSymbol.getTypeInfo().setBit( absDecl.isConst(), TypeInfo.isConst ); paramSymbol.getTypeInfo().setBit( absDecl.isConst(), TypeInfo.isConst );