mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
Updated function strings in DOM contrib. Also fixed the nesting in the parameter list validator so that the highlighting moves with the commas correctly.
This commit is contained in:
parent
6759040739
commit
c9fa81c5e6
2 changed files with 25 additions and 8 deletions
|
@ -85,10 +85,10 @@ public class CParameterListValidator implements IContextInformationValidator, IC
|
|||
|
||||
Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
|
||||
|
||||
int nestingLevel= 0;
|
||||
int charCount= 0;
|
||||
int nestingLevel = -1; // Set to -1 to take into account first ( for function call
|
||||
int charCount = 0;
|
||||
while (start < end) {
|
||||
char curr= document.getChar(start++);
|
||||
char curr = document.getChar(start++);
|
||||
switch (curr) {
|
||||
case '/':
|
||||
if (start < end) {
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -20,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
|
||||
|
@ -54,9 +54,12 @@ public class DOMCompletionContributor implements ICompletionContributor {
|
|||
private void handleFunction(IASTName name, IFunction function, ASTCompletionNode completionNode, int offset, ITextViewer viewer, List proposals) {
|
||||
Image image = getImage(CElementImageProvider.getFunctionImageDescriptor());
|
||||
|
||||
String repString = new String(name.toCharArray()) + "("; //$NON-NLS-1$
|
||||
StringBuffer repStringBuff = new StringBuffer();
|
||||
repStringBuff.append(function.getName());
|
||||
repStringBuff.append('(');
|
||||
|
||||
StringBuffer args = new StringBuffer();
|
||||
String returnTypeStr = null;
|
||||
try {
|
||||
IParameter[] params = function.getParameters();
|
||||
if (params != null)
|
||||
|
@ -65,19 +68,33 @@ public class DOMCompletionContributor implements ICompletionContributor {
|
|||
if (i > 0)
|
||||
args.append(',');
|
||||
|
||||
//args.append(ASTUtil.getType(paramType));
|
||||
args.append(ASTTypeUtil.getType(paramType));
|
||||
String paramName = params[i].getName();
|
||||
if (paramName != null) {
|
||||
args.append(' ');
|
||||
args.append(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
IType returnType = function.getType().getReturnType();
|
||||
if (returnType != null)
|
||||
returnTypeStr = ASTTypeUtil.getType(returnType);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
String argString = args.toString();
|
||||
|
||||
String descString = repString + argString + ")"; //$NON-NLS-1$
|
||||
repString = repString + ")"; //$NON-NLS-1$
|
||||
StringBuffer descStringBuff = new StringBuffer(repStringBuff.toString());
|
||||
descStringBuff.append(argString);
|
||||
descStringBuff.append(')');
|
||||
|
||||
if (returnTypeStr != null) {
|
||||
descStringBuff.append(' ');
|
||||
descStringBuff.append(returnTypeStr);
|
||||
}
|
||||
|
||||
repStringBuff.append(')');
|
||||
String repString = repStringBuff.toString();
|
||||
String descString = descStringBuff.toString();
|
||||
|
||||
CCompletionProposal proposal = createProposal(repString, descString, image, completionNode, offset, viewer);
|
||||
proposal.setCursorPosition(repString.length() - 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue