Skip to content

Commit fc45056

Browse files
Auto append brackets when auto complete function in DEBUG CONSOLE view (microsoft#308)
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
1 parent 89808a1 commit fc45056

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/CompletionProposalRequestor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.logging.Level;
2222
import java.util.logging.Logger;
2323

24+
import org.apache.commons.lang3.StringUtils;
2425
import org.eclipse.core.runtime.CoreException;
2526
import org.eclipse.core.runtime.IPath;
2627
import org.eclipse.jdt.core.CompletionContext;
@@ -152,10 +153,20 @@ public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
152153
data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, String.valueOf(index));
153154
$.setData(data);
154155
this.descriptionProvider.updateDescription(proposal, $);
156+
adjustCompleteItem($);
155157
$.setSortText(SortTextHelper.computeSortText(proposal));
156158
return $;
157159
}
158160

161+
private void adjustCompleteItem(CompletionItem item) {
162+
if (item.getKind() == CompletionItemKind.Function) {
163+
String text = item.getInsertText();
164+
if (StringUtils.isNotBlank(text) && !text.endsWith(")")) {
165+
item.setInsertText(text + "()");
166+
}
167+
}
168+
}
169+
159170
@Override
160171
public void acceptContext(CompletionContext context) {
161172
super.acceptContext(context);

0 commit comments

Comments
 (0)