int paramCount = pc.getParamCount();
List paramLocs = null;
if (paramCount>0) {
paramLocs = new ArrayList(paramCount);
}
Highlighter h = tc.getHighlighter();
try {
// Get the range in which the caret can move before we hide
// this tooltip.
minPos = dot;
maxPos = tc.getDocument().createPosition(dot-sb.length());
int firstParamLen = 0;
// Create the text to insert (keep it one completion for
// performance and simplicity of undo/redo).
int start = dot;
for (int i=0; i<paramCount; i++) {
FunctionCompletion.Parameter param = pc.getParam(i);
String paramText = getParamText(param);
if (i==0) {
firstParamLen = paramText.length();
}
sb.append(paramText);
int end = start + paramText.length();
paramLocs.add(new Point(start, end));
if (i<paramCount-1) {
sb.append(pc.getProvider().getParameterListSeparator());
start = end + 2;
}
}
sb.append(pc.getProvider().getParameterListEnd());
// Insert the parameter text and add highlights around the
// parameters.
tc.replaceSelection(sb.toString());
for (int i=0; i<paramCount; i++) {
Point pt = (Point)paramLocs.get(i);
// "-1" is a workaround for Java Highlight issues.
tags.add(h.addHighlight(pt.x-1, pt.y, p));
}
// Go back and start at the first parameter.
tc.setCaretPosition(dot);
if (pc.getParamCount()>0) {