Java Code Examples for org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry#setKind()
The following examples show how to use
org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry#setKind() .
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: ImportsAwareReferenceProposalCreator.java From n4js with Eclipse Public License 1.0 | 6 votes |
private ContentAssistEntry convertResolutionToContentAssistEntry(ReferenceResolution resolution, N4JSResource resource, ContentAssistContext context) { ContentAssistEntry cae = new ContentAssistEntry(); cae.setPrefix(context.getPrefix()); cae.setProposal(resolution.proposal); cae.setLabel(resolution.label); cae.setDescription(resolution.description); if (resolution.importToBeAdded != null) { ReplaceRegion textReplacement = importHelper.getReplacementForImport(resource.getScript(), resolution.importToBeAdded); cae.getTextReplacements().add(textReplacement); } cae.setSource(resolution.referencedElement); cae.setKind(getKind(resolution)); return cae; }
Example 2
Source File: JSONIdeContentProposalProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void addTemplateProposal( String proposal, String label, String description, String kind, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) { if (getProposalCreator().isValidProposal(label, context.getPrefix(), context)) { ContentAssistEntry entry = new ContentAssistEntry(); entry.setProposal(proposal); entry.setPrefix(context.getPrefix()); entry.setKind(ContentAssistEntry.KIND_SNIPPET + ":" + kind); entry.setLabel(label); entry.setDescription(description); acceptor.accept(entry, getProposalPriorities().getDefaultPriority(entry)); } }
Example 3
Source File: XContentAssistService.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Convert to a completion item. */ protected CompletionItem toCompletionItem(ContentAssistEntry entry, int caretOffset, Position caretPosition, Document document) { CompletionItem result = new CompletionItem(); String label = null; if (entry.getLabel() != null) { label = entry.getLabel(); } else { label = entry.getProposal(); } result.setLabel(label); result.setDetail(entry.getDescription()); result.setDocumentation(entry.getDocumentation()); String prefix = null; if (entry.getPrefix() != null) { prefix = entry.getPrefix(); } else { prefix = ""; } Position prefixPosition = document.getPosition(caretOffset - prefix.length()); result.setTextEdit(new TextEdit(new Range(prefixPosition, caretPosition), entry.getProposal())); if (!entry.getTextReplacements().isEmpty()) { if (result.getAdditionalTextEdits() == null) { result.setAdditionalTextEdits(new ArrayList<>(entry.getTextReplacements().size())); } entry.getTextReplacements().forEach(it -> { result.getAdditionalTextEdits().add(toTextEdit(it, document)); }); } if (entry.getKind().startsWith(ContentAssistEntry.KIND_SNIPPET + ":")) { result.setInsertTextFormat(InsertTextFormat.Snippet); entry.setKind(entry.getKind().substring(ContentAssistEntry.KIND_SNIPPET.length() + 1)); } else if (Objects.equal(entry.getKind(), ContentAssistEntry.KIND_SNIPPET)) { result.setInsertTextFormat(InsertTextFormat.Snippet); } result.setKind(translateKind(entry)); return result; }
Example 4
Source File: PatchedContentAssistService.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected CompletionItem toCompletionItem(ContentAssistEntry entry, int caretOffset, Position caretPosition, Document document) { CompletionItem result = super.toCompletionItem(entry, caretOffset, caretPosition, document); if (entry.getKind().startsWith(ContentAssistEntry.KIND_SNIPPET + ":")) { result.setInsertTextFormat(InsertTextFormat.Snippet); entry.setKind(entry.getKind().substring(ContentAssistEntry.KIND_SNIPPET.length() + 1)); } else if (Objects.equal(entry.getKind(), ContentAssistEntry.KIND_SNIPPET)) { result.setInsertTextFormat(InsertTextFormat.Snippet); } result.setKind(translateKind(entry)); return result; }