Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.jdt.core.CompletionContext;
import org.eclipse.jdt.core.CompletionProposal;
import org.eclipse.jdt.core.CompletionRequestor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaElement;
Expand Down Expand Up @@ -154,7 +155,7 @@ public List<CompletionItem> getCompletionItems() {
*/
public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
final CompletionItem $ = new CompletionItem();
$.setKind(mapKind(proposal.getKind()));
$.setKind(mapKind(proposal.getKind(), proposal.getFlags()));
Map<String, String> data = new HashMap<>();
data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID, String.valueOf(response.getId()));
data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, String.valueOf(index));
Expand All @@ -168,7 +169,15 @@ public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
}

private void adjustCompleteItem(CompletionItem item) {
if (item.getKind() == CompletionItemKind.Function) {
CompletionItemKind itemKind = item.getKind();
if (itemKind == CompletionItemKind.Class || itemKind == CompletionItemKind.Interface
|| itemKind == CompletionItemKind.Enum) {
// Display the package name in the label property.
CompletionItemLabelDetails labelDetails = item.getLabelDetails();
if (labelDetails != null && StringUtils.isNotBlank(labelDetails.getDescription())) {
item.setLabel(item.getLabel() + " - " + labelDetails.getDescription());
}
} else if (itemKind == CompletionItemKind.Function) {
// Merge the label details into the label property
// because the completion provider in DEBUG CONSOLE
// doesn't support the label details.
Expand All @@ -195,7 +204,7 @@ public void acceptContext(CompletionContext context) {
this.descriptionProvider = new CompletionProposalDescriptionProvider(context);
}

private CompletionItemKind mapKind(final int kind) {
private CompletionItemKind mapKind(final int kind, final int flags) {
// When a new CompletionItemKind is added, don't forget to update
// SUPPORTED_KINDS
switch (kind) {
Expand All @@ -204,6 +213,11 @@ private CompletionItemKind mapKind(final int kind) {
return CompletionItemKind.Constructor;
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.TYPE_REF:
if (Flags.isInterface(flags)) {
return CompletionItemKind.Interface;
} else if (Flags.isEnum(flags)) {
return CompletionItemKind.Enum;
}
return CompletionItemKind.Class;
case CompletionProposal.FIELD_IMPORT:
case CompletionProposal.METHOD_IMPORT:
Expand All @@ -213,6 +227,9 @@ private CompletionItemKind mapKind(final int kind) {
return CompletionItemKind.Module;
case CompletionProposal.FIELD_REF:
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
if (Flags.isStatic(flags) && Flags.isFinal(flags)) {
return CompletionItemKind.Constant;
}
return CompletionItemKind.Field;
case CompletionProposal.KEYWORD:
return CompletionItemKind.Keyword;
Expand Down