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:
parent
e653b13ea5
commit
cc1b8dbe9e
2 changed files with 27 additions and 10 deletions
|
@ -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.DOMException;
|
||||
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.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -192,13 +193,21 @@ public class IndexVisitorUtil {
|
|||
if (parent instanceof ICPPASTQualifiedName) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (parent instanceof IASTDeclarator) {
|
||||
IASTDeclarator declarator = (IASTDeclarator) parent;
|
||||
String[] parameters = ASTSignatureUtil.getParameterSignatureArray(declarator);
|
||||
if (parameters.length == 0) {
|
||||
if (parent instanceof IASTFunctionDeclarator) {
|
||||
IASTFunctionDeclarator fDecl = (IASTFunctionDeclarator) parent;
|
||||
String[] parameters = ASTSignatureUtil.getParameterSignatureArray(fDecl);
|
||||
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$
|
||||
}
|
||||
char[][] rv = new char[parameters.length][];
|
||||
for (int k = 0; k < parameters.length; k++) {
|
||||
rv[k] = parameters[k].toCharArray();
|
||||
}
|
||||
|
@ -219,10 +228,12 @@ public class IndexVisitorUtil {
|
|||
IType paramType = parameters[i].getType();
|
||||
parameterList.add(ASTTypeUtil.getType(paramType).toCharArray());
|
||||
}
|
||||
if (function.takesVarArgs())
|
||||
if (function.takesVarArgs()) {
|
||||
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) {
|
||||
}
|
||||
|
|
|
@ -144,7 +144,13 @@ public class ASTSignatureUtil {
|
|||
IASTParameterDeclaration[] parms = null;
|
||||
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++) {
|
||||
if (parms[i] != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue