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

DOM indexer fix: void and elipses function parameters.

This commit is contained in:
Vladimir Hirsl 2005-07-06 20:08:46 +00:00
parent e653b13ea5
commit cc1b8dbe9e
2 changed files with 27 additions and 10 deletions

View file

@ -17,9 +17,10 @@ import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -192,13 +193,21 @@ public class IndexVisitorUtil {
if (parent instanceof ICPPASTQualifiedName) { if (parent instanceof ICPPASTQualifiedName) {
parent = parent.getParent(); parent = parent.getParent();
} }
if (parent instanceof IASTDeclarator) { if (parent instanceof IASTFunctionDeclarator) {
IASTDeclarator declarator = (IASTDeclarator) parent; IASTFunctionDeclarator fDecl = (IASTFunctionDeclarator) parent;
String[] parameters = ASTSignatureUtil.getParameterSignatureArray(declarator); String[] parameters = ASTSignatureUtil.getParameterSignatureArray(fDecl);
if (parameters.length == 0) { char[][] rv;
if (fDecl instanceof IASTStandardFunctionDeclarator &&
((IASTStandardFunctionDeclarator) fDecl).takesVarArgs()) {
rv = new char[parameters.length + 1][];
rv[parameters.length] = "...".toCharArray(); //$NON-NLS-1$
}
else {
rv = new char[parameters.length][];
}
if (rv.length == 0) {
return new char[][] { "void".toCharArray() }; //$NON-NLS-1$ return new char[][] { "void".toCharArray() }; //$NON-NLS-1$
} }
char[][] rv = new char[parameters.length][];
for (int k = 0; k < parameters.length; k++) { for (int k = 0; k < parameters.length; k++) {
rv[k] = parameters[k].toCharArray(); rv[k] = parameters[k].toCharArray();
} }
@ -219,10 +228,12 @@ public class IndexVisitorUtil {
IType paramType = parameters[i].getType(); IType paramType = parameters[i].getType();
parameterList.add(ASTTypeUtil.getType(paramType).toCharArray()); parameterList.add(ASTTypeUtil.getType(paramType).toCharArray());
} }
if (function.takesVarArgs()) if (function.takesVarArgs()) {
parameterList.add("...".toCharArray()); //$NON-NLS-1$ parameterList.add("...".toCharArray()); //$NON-NLS-1$
else if (parameters.length == 0) }
parameterList.add("void".toCharArray()); //$NON-NLS-1$ if (parameterList.isEmpty()) {
parameterList.add("void".toCharArray()); //$NON-NLS-1$
}
} }
catch (DOMException e) { catch (DOMException e) {
} }

View file

@ -144,7 +144,13 @@ public class ASTSignatureUtil {
IASTParameterDeclaration[] parms = null; IASTParameterDeclaration[] parms = null;
parms = ((IASTStandardFunctionDeclarator)decltor).getParameters(); parms = ((IASTStandardFunctionDeclarator)decltor).getParameters();
result = new String[parms.length]; if (((IASTStandardFunctionDeclarator) decltor).takesVarArgs()) {
result = new String[parms.length + 1];
result[parms.length] = "..."; //$NON-NLS-1$
}
else {
result = new String[parms.length];
}
for(int i=0; i<parms.length; i++) { for(int i=0; i<parms.length; i++) {
if (parms[i] != null) { if (parms[i] != null) {