private static void setFields(CompletionItem ci, ICompilationUnit cu) { ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDocumentation(ci.getInsertText()); Map<String, String> data = new HashMap<>(3); data.put(CompletionResolveHandler.DATA_FIELD_URI, JDTUtils.toURI(cu)); data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID, "0"); data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, "0"); ci.setData(data); }
private static void setMeta(CompletionItem item, BInvokableSymbol bSymbol) { item.setInsertTextFormat(InsertTextFormat.Snippet); item.setDetail(ItemResolverConstants.FUNCTION_TYPE); item.setKind(CompletionItemKind.Function); if (bSymbol != null && bSymbol.markdownDocumentation != null) { item.setDocumentation(bSymbol.markdownDocumentation.description); } }
private void resolveEdits(TextDocument doc, ICompletionProposal completion, CompletionItem item) { Optional<TextEdit> mainEdit = adaptEdits(doc, completion.getTextEdit()); if (mainEdit.isPresent()) { item.setTextEdit(mainEdit.get()); item.setInsertTextFormat(completion.getInsertTextFormat()); } else { item.setInsertText(""); } completion.getAdditionalEdit().ifPresent(edit -> { adaptEdits(doc, edit).ifPresent(extraEdit -> { item.setAdditionalTextEdits(ImmutableList.of(extraEdit)); }); }); }
/** * Create a given completionItem's insert text. * * @param completionItem CompletionItem to modify * @param isSnippetSupported Whether snippet is expected or plain text expected * @return modified Completion Item */ public CompletionItem build(CompletionItem completionItem, boolean isSnippetSupported) { if (isSnippetSupported) { completionItem.setInsertText(this.snippet); completionItem.setInsertTextFormat(InsertTextFormat.Snippet); } else { completionItem.setInsertText(getPlainTextSnippet()); completionItem.setInsertTextFormat(InsertTextFormat.PlainText); } if (!label.isEmpty()) { completionItem.setLabel(label); } if (!detail.isEmpty()) { completionItem.setDetail(detail); } completionItem.setKind(getKind()); return completionItem; }
/** * Get completion items list for struct fields. * * @param structFields List of struct fields * @return {@link List} List of completion items for the struct fields */ public static List<CompletionItem> getStructFieldCompletionItems(List<BField> structFields) { List<CompletionItem> completionItems = new ArrayList<>(); structFields.forEach(bStructField -> { StringBuilder insertText = new StringBuilder(bStructField.getName().getValue() + ": "); if (bStructField.getType() instanceof BStructureType) { insertText.append("{").append(LINE_SEPARATOR).append("\t${1}").append(LINE_SEPARATOR).append("}"); } else { insertText.append("${1:").append(getDefaultValueForType(bStructField.getType())).append("}"); } CompletionItem fieldItem = new CompletionItem(); fieldItem.setInsertText(insertText.toString()); fieldItem.setInsertTextFormat(InsertTextFormat.Snippet); fieldItem.setLabel(bStructField.getName().getValue()); fieldItem.setDetail(ItemResolverConstants.FIELD_TYPE); fieldItem.setKind(CompletionItemKind.Field); fieldItem.setSortText(Priority.PRIORITY120.toString()); completionItems.add(fieldItem); }); return completionItems; }
private CompletionItem getMatchFieldSnippetCompletion(String snippet, String label) { CompletionItem completionItem = new CompletionItem(); completionItem.setInsertText(snippet); completionItem.setLabel(label); completionItem.setInsertTextFormat(InsertTextFormat.Snippet); completionItem.setDetail(ItemResolverConstants.SNIPPET_TYPE); completionItem.setKind(CompletionItemKind.Snippet); return completionItem; } }
private CompletionItem getVariableCompletionItem(BVarSymbol varSymbol, String matchFieldSnippet, String label) { CompletionItem completionItem = BVariableCompletionItemBuilder.build(varSymbol, label, varSymbol.type.toString()); completionItem.setInsertText(varSymbol.getName().getValue() + " " + matchFieldSnippet); completionItem.setInsertTextFormat(InsertTextFormat.Snippet); return completionItem; }
memberItem.setInsertText(entry.getValue()); memberItem.setKind(CompletionItemKind.Snippet); memberItem.setInsertTextFormat(InsertTextFormat.Snippet); memberItem.setSortText(Priority.PRIORITY130.toString()); completionItems.add(memberItem); allFillerItem.setDetail(ItemResolverConstants.SNIPPET_TYPE); allFillerItem.setKind(CompletionItemKind.Snippet); allFillerItem.setInsertTextFormat(InsertTextFormat.Snippet); allFillerItem.setSortText(Priority.PRIORITY110.toString()); anyFillerItem.setDetail(ItemResolverConstants.SNIPPET_TYPE); anyFillerItem.setKind(CompletionItemKind.Snippet); anyFillerItem.setInsertTextFormat(InsertTextFormat.Snippet); anyFillerItem.setSortText(Priority.PRIORITY120.toString());
ci.setSortText(SortTextHelper.convertRelevance(0)); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(isSnippetSupported ? InsertTextFormat.Snippet : InsertTextFormat.PlainText); String documentation = prepareTemplate(buf.toString(), lineDelimiter, false); if (documentation.indexOf(lineDelimiter) == 0) {
annotationItem.setLabel(label); annotationItem.setInsertText(insertText); annotationItem.setInsertTextFormat(InsertTextFormat.Snippet); annotationItem.setDetail(ItemResolverConstants.ANNOTATION_TYPE); annotationItem.setKind(CompletionItemKind.Property);
private static CompletionItem createExpandedAbbr(String abbr, Range abbreviationRange, String abbreviation, String syntax, String filter, ExpandOptions expandOptions) { String expandedText = null; try { expandedText = expand(abbr, expandOptions); } catch (Exception e) { } if (expandedText != null && isExpandedTextNoise(syntax, abbr, expandedText)) { expandedText = ""; } if (expandedText != null) { CompletionItem expandedAbbr = new CompletionItem(abbr); expandedAbbr.setTextEdit( new TextEdit(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(expandedText)))); expandedAbbr.setDocumentation(replaceTabStopsWithCursors(expandedText)); expandedAbbr.setInsertTextFormat(InsertTextFormat.Snippet); expandedAbbr.setDetail("Emmet Abbreviation"); expandedAbbr.setLabel(abbreviation + (filter != null ? "|" + filter.replaceAll(",", "|") : "")); return expandedAbbr; } return null; }
boolean _equals = Objects.equal(_kind, ContentAssistEntry.KIND_SNIPPET); if (_equals) { completionItem.setInsertTextFormat(InsertTextFormat.Snippet);
completionItems.forEach(completionItem -> completionItem.setInsertTextFormat(InsertTextFormat.Snippet));
item.setInsertTextFormat(InsertTextFormat.Snippet); }else{ item.setInsertTextFormat(InsertTextFormat.PlainText);