mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Make F3 work for parameters.
This commit is contained in:
parent
87e47de83b
commit
0a671b945e
4 changed files with 38 additions and 5 deletions
|
@ -17,4 +17,9 @@ package org.eclipse.cdt.core.parser.ast;
|
||||||
public interface IASTParameterDeclaration extends IASTAbstractDeclaration, IASTOffsetableNamedElement
|
public interface IASTParameterDeclaration extends IASTAbstractDeclaration, IASTOffsetableNamedElement
|
||||||
{
|
{
|
||||||
public IASTInitializerClause getDefaultValue();
|
public IASTInitializerClause getDefaultValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IASTFunction getOwnerFunctionDeclaration() throws ASTNotImplementedException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,10 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
|
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
|
||||||
|
@ -158,11 +160,19 @@ public class SelectionParser extends ContextualParser {
|
||||||
IASTNode node = lookupNode(finalDuple);
|
IASTNode node = lookupNode(finalDuple);
|
||||||
if( node == null ) return null;
|
if( node == null ) return null;
|
||||||
if( !(node instanceof IASTOffsetableNamedElement )) return null;
|
if( !(node instanceof IASTOffsetableNamedElement )) return null;
|
||||||
int indexValue = -1;
|
Integer lookupResult = ((Integer)nodeTable.get(node));
|
||||||
Object index = nodeTable.get( node );
|
int indexValue = ( lookupResult != null ) ? lookupResult.intValue() : -1;
|
||||||
if( index instanceof Integer )
|
|
||||||
indexValue = ((Integer)index).intValue();
|
|
||||||
|
|
||||||
|
if( indexValue == -1 && node instanceof IASTParameterDeclaration )
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
IASTFunction f = ((IASTParameterDeclaration)node).getOwnerFunctionDeclaration();
|
||||||
|
lookupResult = ((Integer)nodeTable.get(f));
|
||||||
|
indexValue = ( lookupResult != null ) ? lookupResult.intValue() : -1;
|
||||||
|
} catch (ASTNotImplementedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return new SelectionParseResult( (IASTOffsetableNamedElement) node, getFilenameForIndex(indexValue) );
|
return new SelectionParseResult( (IASTOffsetableNamedElement) node, getFilenameForIndex(indexValue) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +263,7 @@ public class SelectionParser extends ContextualParser {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
contextNode = declaration;
|
contextNode = declaration;
|
||||||
|
handleOffsetableNamedElement((IASTOffsetableNamedElement) declaration);
|
||||||
throw new EndOfFileException();
|
throw new EndOfFileException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,6 +327,7 @@ public class SelectionParser extends ContextualParser {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
contextNode = enumerator;
|
contextNode = enumerator;
|
||||||
|
handleOffsetableNamedElement(enumerator);
|
||||||
throw new EndOfFileException();
|
throw new EndOfFileException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,10 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
|
@ -219,4 +221,10 @@ public class ASTParameterDeclaration extends ASTSymbol implements IASTParameterD
|
||||||
public int getNameLineNumber() {
|
public int getNameLineNumber() {
|
||||||
return offsets.getNameLineNumber();
|
return offsets.getNameLineNumber();
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getOwnerFunctionDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTFunction getOwnerFunctionDeclaration() throws ASTNotImplementedException {
|
||||||
|
return (IASTFunction) getSymbol().getContainingSymbol().getASTExtension().getPrimaryDeclaration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,9 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
|
@ -138,4 +140,10 @@ public class ASTParameterDeclaration extends ASTAbstractDeclaration implements I
|
||||||
public int getNameLineNumber() {
|
public int getNameLineNumber() {
|
||||||
return offsets.getNameLineNumber();
|
return offsets.getNameLineNumber();
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration#getOwnerFunctionDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTFunction getOwnerFunctionDeclaration() throws ASTNotImplementedException {
|
||||||
|
throw new ASTNotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue