Java Code Examples for org.eclipse.lsp4j.CompletionItem#setPreselect()
The following examples show how to use
org.eclipse.lsp4j.CompletionItem#setPreselect() .
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: DdlCompletionItemLoader.java From syndesis with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private List<CompletionItem> loadItemsFromFile(String fileName) { List<CompletionItem> items = new ArrayList<CompletionItem>(); try (InputStream stream = this.getClass().getResourceAsStream(fileName)) { JSONParser parser = new JSONParser(stream); // A JSON object. Key value pairs are unordered. JSONObject supports // java.util.Map interface. LinkedHashMap<String, Object> jsonObject = parser.object(); // A JSON array. JSONObject supports java.util.List interface. ArrayList<?> completionItemArray = (ArrayList<?>) jsonObject.get("items"); if (completionItemArray != null) { for (Object item : completionItemArray) { LinkedHashMap<String, Object> itemInfo = (LinkedHashMap<String, Object>) item; CompletionItem newItem = new CompletionItem(); newItem.setLabel((String) itemInfo.get("label")); newItem.setKind(STRING_TO_KIND_MAP.get(((String) itemInfo.get("kind")).toUpperCase(Locale.US))); String detail = (String) itemInfo.get("detail"); if (detail != null) { newItem.setDetail(detail); } String documentation = (String) itemInfo.get("documentation"); if (documentation != null) { newItem.setDocumentation(documentation); } newItem.setDeprecated(Boolean.parseBoolean((String) itemInfo.get("deprecated"))); newItem.setPreselect(Boolean.parseBoolean((String) itemInfo.get("preselect"))); String sortText = (String) itemInfo.get("sortText"); if (sortText != null) { newItem.setSortText(sortText); } String insertText = (String) itemInfo.get("insertText"); if (insertText != null) { insertText = insertText.replaceAll("\\n", "\n"); insertText = insertText.replaceAll("\\t", "\t"); newItem.setInsertText(insertText); } String insertTextFormat = (String) itemInfo.get("insertTextFormat"); if (insertTextFormat != null) { if (newItem.getKind().equals(CompletionItemKind.Snippet)) { newItem.setInsertTextFormat(InsertTextFormat.Snippet); } else { newItem.setInsertTextFormat(InsertTextFormat.PlainText); } } // TODO: Implement quick fixes // newItem.setTextEdit((TextEdit)itemInfo.get("textEdit")); // newItem.setAdditionalTextEdits((List<TextEdit>)itemInfo.get("additionalTextEdits")); // newItem.setCommitCharacters((List<String>)itemInfo.get("commitCharacters")); String category = (String) itemInfo.get("category"); if (category != null && !category.isEmpty()) { addItemByCategory(category, newItem); } else { items.add(newItem); } } } } catch (IOException | ParseException e) { throw new IllegalArgumentException("Unable to parse given file: " + fileName, e); } return items; }