Java Code Examples for org.eclipse.lsp4j.CompletionItem#setData()
The following examples show how to use
org.eclipse.lsp4j.CompletionItem#setData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DdlCompletionItemLoader.java From syndesis with Apache License 2.0 | 6 votes |
/** * Clones a {@link CompletionItem} for the given label from the supplied items * * @param targetLabel * @return a completion item */ private static CompletionItem cloneCompletionItem(List<CompletionItem> items, String targetLabel) { for (CompletionItem item : items) { if (item.getLabel().equalsIgnoreCase(targetLabel)) { CompletionItem clone = new CompletionItem(targetLabel); clone.setAdditionalTextEdits(item.getAdditionalTextEdits()); clone.setCommand(item.getCommand()); clone.setData(item.getData()); clone.setDetail(item.getDetail()); clone.setFilterText(item.getFilterText()); clone.setInsertText(item.getInsertText()); clone.setInsertTextFormat(item.getInsertTextFormat()); clone.setDocumentation(item.getDocumentation()); clone.setDeprecated(item.getDeprecated()); clone.setKind(item.getKind()); clone.setSortText(item.getSortText()); clone.setPreselect(item.getPreselect()); clone.setTextEdit(item.getTextEdit()); return clone; } } return null; }
Example 2
Source File: TableBodyCompletionProvider.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getColumnCompletionItem(int data) { CompletionItem ci = new CompletionItem(); ci.setLabel("column definition"); ci.setInsertText("${1:column_name} ${2:datatype}"); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); ci.setSortText("1100"); return ci; }
Example 3
Source File: TableBodyCompletionProvider.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getPrimaryKeyCompletionItem(int data) { CompletionItem ci = new CompletionItem(); ci.setLabel("PRIMARY KEY (column, ...)"); ci.setInsertText("PRIMARY KEY (${1:column})"); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); ci.setSortText("1120"); return ci; }
Example 4
Source File: TableBodyCompletionProvider.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getQueryExpressionSnippet(int data) { CompletionItem ci = new CompletionItem(); ci.setLabel("AS SELECT * FROM ..."); ci.setInsertText(" AS SELECT * FROM ${4:table_name};"); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); return ci; }
Example 5
Source File: TableBodyCompletionProvider.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getAs(int data) { CompletionItem ci = new CompletionItem(); ci.setLabel("AS"); ci.setKind(CompletionItemKind.Keyword); ci.setData(data); ci.setPreselect(true); return ci; }
Example 6
Source File: DdlCompletionItemLoader.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getCreateViewCompletionItem(int data, String sortValue) { CompletionItem ci = new CompletionItem(); ci.setLabel("CREATE VIEW..."); ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_INSERT_TEXT); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDetail("Simple CREATE VIEW statement"); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); ci.setSortText(sortValue); return ci; }
Example 7
Source File: DdlCompletionItemLoader.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getCreateViewInnerJoinCompletionItem(int data, String sortValue) { CompletionItem ci = new CompletionItem(); ci.setLabel("CREATE VIEW with INNER JOIN"); ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_INNER_JOIN_INSERT_TEXT); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDetail(" CREATE VIEW with inner join"); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); ci.setSortText(sortValue); return ci; }
Example 8
Source File: DdlCompletionItemLoader.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getCreateViewJoinCompletionItem(int data, String sortValue) { CompletionItem ci = new CompletionItem(); ci.setLabel("CREATE VIEW with JOIN"); ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_LEFT_OUTER_JOIN_INSERT_TEXT); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDetail(" CREATE VIEW with left join"); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); ci.setSortText(sortValue); return ci; }
Example 9
Source File: DdlCompletionItemLoader.java From syndesis with Apache License 2.0 | 5 votes |
public CompletionItem getCreateViewUnionCompletionItem(int data, String sortValue) { CompletionItem ci = new CompletionItem(); ci.setLabel("CREATE VIEW with UNION"); ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_UNION_INSERT_TEXT); ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDetail(" Union of two tables from single source"); ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText())); ci.setData(data); ci.setPreselect(true); ci.setSortText(sortValue); return ci; }
Example 10
Source File: CompletionProposalRequestor.java From java-debug with Eclipse Public License 1.0 | 5 votes |
/** * To completion item. * @param proposal proposal * @param index index * @return CompletionItem */ public CompletionItem toCompletionItem(CompletionProposal proposal, int index) { final CompletionItem $ = new CompletionItem(); $.setKind(mapKind(proposal.getKind())); 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)); $.setData(data); this.descriptionProvider.updateDescription(proposal, $); adjustCompleteItem($); $.setSortText(SortTextHelper.computeSortText(proposal)); return $; }
Example 11
Source File: SnippetCompletionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static void setFields(CompletionItem ci, ICompilationUnit cu) { ci.setKind(CompletionItemKind.Snippet); ci.setInsertTextFormat(InsertTextFormat.Snippet); ci.setDocumentation(SnippetUtils.beautifyDocument(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); }
Example 12
Source File: TextDocumentServiceImpl.java From netbeans with Apache License 2.0 | 4 votes |
private void setCompletionData(CompletionItem ci, Element el) { if (SUPPORTED_ELEMENT_KINDS.contains(el.getKind().name())) { ci.setData(new CompletionData(uri, el.getKind().name(), SourceUtils.getJVMSignature(ElementHandle.create(el)))); } }
Example 13
Source File: JavadocCompletionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public List<CompletionItem> getProposals(ICompilationUnit cu, int offset, CompletionProposalRequestor collector, IProgressMonitor monitor) throws JavaModelException { if (cu == null) { throw new IllegalArgumentException("Compilation unit must not be null"); //$NON-NLS-1$ } List<CompletionItem> result = new ArrayList<>(); IDocument d = JsonRpcHelpers.toDocument(cu.getBuffer()); if (offset < 0 || d.getLength() == 0) { return result; } try { int p = (offset == d.getLength() ? offset - 1 : offset); IRegion line = d.getLineInformationOfOffset(p); String lineStr = d.get(line.getOffset(), line.getLength()).trim(); if (!lineStr.startsWith("/**")) { return result; } if (!hasEndJavadoc(d, offset)) { return result; } String text = collector.getContext().getToken() == null ? "" : new String(collector.getContext().getToken()); StringBuilder buf = new StringBuilder(text); IRegion prefix = findPrefixRange(d, line); String indentation = d.get(prefix.getOffset(), prefix.getLength()); int lengthToAdd = Math.min(offset - prefix.getOffset(), prefix.getLength()); buf.append(indentation.substring(0, lengthToAdd)); String lineDelimiter = TextUtilities.getDefaultLineDelimiter(d); ICompilationUnit unit = cu; try { unit.reconcile(ICompilationUnit.NO_AST, false, null, null); String string = createJavaDocTags(d, offset, indentation, lineDelimiter, unit); if (string != null && !string.trim().equals(ASTERISK)) { buf.append(string); } else { return result; } int nextNonWS = findEndOfWhiteSpace(d, offset, d.getLength()); if (!Character.isWhitespace(d.getChar(nextNonWS))) { buf.append(lineDelimiter); } } catch (CoreException e) { // ignore } final CompletionItem ci = new CompletionItem(); Range range = JDTUtils.toRange(unit, offset, 0); boolean isSnippetSupported = JavaLanguageServerPlugin.getPreferencesManager().getClientPreferences().isCompletionSnippetsSupported(); String replacement = prepareTemplate(buf.toString(), lineDelimiter, isSnippetSupported); ci.setTextEdit(new TextEdit(range, replacement)); ci.setFilterText(JAVA_DOC_COMMENT); ci.setLabel(JAVA_DOC_COMMENT); 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) { documentation = documentation.replaceFirst(lineDelimiter, ""); } ci.setDocumentation(documentation); 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); result.add(ci); } catch (BadLocationException excp) { // stop work } return result; }