mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
bug 72814: [Parser] Open Declaration fails on std::vector<int> reference
This commit is contained in:
parent
30a7d6170f
commit
0ab0b97b0f
3 changed files with 31 additions and 1 deletions
|
@ -478,5 +478,25 @@ public class SelectionParseTest extends SelectionParseBaseTest {
|
|||
assertTrue( node instanceof IASTClassSpecifier );
|
||||
assertEquals( ((IASTClassSpecifier)node).getName(), "A" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug72814() throws Exception{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "namespace N{ \n"); //$NON-NLS-1$
|
||||
writer.write( " template < class T > class AAA { T _t };\n"); //$NON-NLS-1$
|
||||
writer.write( "} \n"); //$NON-NLS-1$
|
||||
writer.write( "N::AAA<int> a; \n"); //$NON-NLS-1$
|
||||
|
||||
String code = writer.toString();
|
||||
int startIndex = code.indexOf( "AAA<int>" ); //$NON-NLS-1$
|
||||
IASTNode node = parse( code, startIndex, startIndex + 3 );
|
||||
|
||||
assertTrue( node instanceof IASTClassSpecifier );
|
||||
assertEquals( ((IASTClassSpecifier)node).getName(), "AAA" ); //$NON-NLS-1$
|
||||
|
||||
node = parse( code, startIndex, startIndex + 8 );
|
||||
|
||||
assertTrue( node instanceof IASTClassSpecifier );
|
||||
assertEquals( ((IASTClassSpecifier)node).getName(), "AAA" ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6607,7 +6607,7 @@ public class Parser implements IParserData, IParser
|
|||
// duple is a sub-duple of greaterContextDuple
|
||||
if( duple.getFirstToken().equals( greaterContextDuple.getFirstToken() ))
|
||||
finalDuple = duple; // => do not use greaterContextDuple
|
||||
else if( duple.getLastToken().equals( greaterContextDuple.getLastToken() ))
|
||||
else if( duple.getLastSegment().getFirstToken().equals( greaterContextDuple.getLastSegment().getFirstToken() ))
|
||||
finalDuple = greaterContextDuple; // => use greaterContextDuple
|
||||
else
|
||||
throw new ParseError( ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME );
|
||||
|
|
|
@ -355,6 +355,16 @@ public class BasicTokenDuple implements ITokenDuple {
|
|||
IToken iter = firstToken;
|
||||
while( iter != lastToken)
|
||||
{
|
||||
if( iter.getType() == IToken.tLT ){
|
||||
iter = TokenFactory.consumeTemplateIdArguments( iter, lastToken );
|
||||
if( iter.getType() == IToken.tGT ){
|
||||
if( iter == lastToken ) break;
|
||||
iter = iter.getNext();
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if( iter.isOperator() )
|
||||
{
|
||||
iter = iter.getNext();
|
||||
|
|
Loading…
Add table
Reference in a new issue