1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Patch by Devin Steffler

Fixed 72710 [Search] Field Reference incorrectly reported as variable ref
This commit is contained in:
John Camelon 2004-10-07 17:31:07 +00:00
parent e98111fb62
commit 6830aea7d7
2 changed files with 22 additions and 0 deletions

View file

@ -498,5 +498,23 @@ public class SelectionParseTest extends SelectionParseBaseTest {
assertTrue( node instanceof IASTClassSpecifier );
assertEquals( ((IASTClassSpecifier)node).getName(), "AAA" ); //$NON-NLS-1$
}
public void testBug72710() throws Exception
{
Writer writer = new StringWriter();
writer.write( "class Card{\n" ); //$NON-NLS-1$
writer.write( " Card( int rank );\n" ); //$NON-NLS-1$
writer.write( " int rank;\n" ); //$NON-NLS-1$
writer.write( "};\n" ); //$NON-NLS-1$
writer.write( "Card::Card( int rank ) {\n" ); //$NON-NLS-1$
writer.write( "this->rank = rank;\n" ); //$NON-NLS-1$
writer.write( "}\n" ); //$NON-NLS-1$
String code = writer.toString();
int index = code.indexOf( "this->rank") + 6; //$NON-NLS-1$
IASTNode node = parse( code, index, index + 4 );
assertTrue( node instanceof IASTField );
IASTField rank = (IASTField) node;
assertEquals( rank.getName(), "rank"); //$NON-NLS-1$
}
}

View file

@ -82,6 +82,10 @@ public abstract class AbstractToken implements IToken, ITokenDuple {
return false;
if( !CharArrayUtils.equals( ((IToken)other).getCharImage(), getCharImage() ) )
return false;
if( getOffset() != ((IToken)other).getOffset() )
return false;
if( getEndOffset() != ((IToken)other).getEndOffset() )
return false;
return true;
}