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

fix bug 72713: [Open Declaration] F3 on a method definition goes nowhere

This commit is contained in:
Andrew Niefer 2004-09-24 20:42:16 +00:00
parent 59a54c9689
commit 1943c247b2
2 changed files with 24 additions and 2 deletions

View file

@ -439,5 +439,18 @@ public class SelectionParseTest extends SelectionParseBaseTest {
assertTrue( node instanceof IASTFunction );
assertEquals( ((IASTFunction)node).getName(), "f_SD" ); //$NON-NLS-1$
}
public void testBug72713() throws Exception{
Writer writer = new StringWriter();
writer.write( "class Deck{ void initialize(); }; \n"); //$NON-NLS-1$
writer.write( "void Deck::initialize(){} \n"); //$NON-NLS-1$
String code = writer.toString();
int startIndex = code.indexOf( ":initialize" ); //$NON-NLS-1$
IASTNode node = parse( code, startIndex + 1, startIndex + 11 );
assertTrue( node instanceof IASTMethod );
assertFalse( ((IASTMethod)node).previouslyDeclared() );
assertEquals( ((IASTMethod) node).getNameOffset(), code.indexOf( " initialize();" ) + 1 ); //$NON-NLS-1$
}
}

View file

@ -79,6 +79,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.ast.complete.CompleteParseASTFactory;
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
@ -6594,8 +6595,16 @@ public class Parser implements IParserData, IParser
if( contextNode instanceof IASTQualifiedNameElement )
{
String [] elementQualifiedName = ((IASTQualifiedNameElement)contextNode).getFullyQualifiedName();
if( Arrays.equals( elementQualifiedName, finalDuple.toQualifiedName() ) )
return contextNode;
if( Arrays.equals( elementQualifiedName, finalDuple.toQualifiedName() ) ){
IASTNode declNode = null;
if( contextNode instanceof ISymbolOwner ){
ISymbolOwner owner = (ISymbolOwner) contextNode;
if( owner.getSymbol() != null && owner.getSymbol().getASTExtension() != null ){
declNode = owner.getSymbol().getASTExtension().getPrimaryDeclaration();
}
}
return (declNode != null) ? declNode : contextNode;
}
}
try {
if( ourKind == IASTCompletionNode.CompletionKind.NEW_TYPE_REFERENCE )