Skip to content

Commit

Permalink
Code completion: Use fully qualified name as needed in DEBUG CONSOLE (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
testforstephen authored Aug 15, 2023
1 parent 5174aa3 commit 0e03327
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.eclipse.jdt.ls.core.internal.handlers.CompletionResponses;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.CompletionItemKind;
import org.eclipse.lsp4j.CompletionItemLabelDetails;

import com.google.common.collect.ImmutableSet;
import com.microsoft.java.debug.core.Configuration;
Expand Down Expand Up @@ -159,13 +160,26 @@ public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, String.valueOf(index));
$.setData(data);
this.descriptionProvider.updateDescription(proposal, $);
// Use fully qualified name as needed.
$.setInsertText(String.valueOf(proposal.getCompletion()));
adjustCompleteItem($);
$.setSortText(SortTextHelper.computeSortText(proposal));
return $;
}

private void adjustCompleteItem(CompletionItem item) {
if (item.getKind() == CompletionItemKind.Function) {
// Merge the label details into the label property
// because the completion provider in DEBUG CONSOLE
// doesn't support the label details.
CompletionItemLabelDetails labelDetails = item.getLabelDetails();
if (labelDetails != null && StringUtils.isNotBlank(labelDetails.getDetail())) {
item.setLabel(item.getLabel() + labelDetails.getDetail());
}
if (labelDetails != null && StringUtils.isNotBlank(labelDetails.getDescription())) {
item.setLabel(item.getLabel() + " : " + labelDetails.getDescription());
}

String text = item.getInsertText();
if (StringUtils.isNotBlank(text) && !text.endsWith(")")) {
item.setInsertText(text + "()");
Expand Down

0 comments on commit 0e03327

Please sign in to comment.