Search in sources :

Example 1 with ICompletionProposalExtension4

use of org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension4 in project che by eclipse.

the class CodeAssist method convertProposals.

private Proposals convertProposals(int offset, ICompilationUnit compilationUnit, TextViewer viewer, List<ICompletionProposal> proposals) {
    Proposals result = DtoFactory.getInstance().createDto(Proposals.class);
    String sessionId = UUID.randomUUID().toString();
    result.setSessionId(sessionId);
    ArrayList<ProposalPresentation> presentations = new ArrayList<>();
    for (int i = 0; i < proposals.size(); i++) {
        ProposalPresentation presentation = DtoFactory.getInstance().createDto(ProposalPresentation.class);
        ICompletionProposal proposal = proposals.get(i);
        presentation.setIndex(i);
        presentation.setDisplayString(proposal.getDisplayString());
        String image = proposal.getImage() == null ? null : proposal.getImage().getImg();
        presentation.setImage(image);
        if (proposal instanceof ICompletionProposalExtension4) {
            presentation.setAutoInsertable(((ICompletionProposalExtension4) proposal).isAutoInsertable());
        }
        if (proposal instanceof CheActionAcces) {
            String actionId = ((CheActionAcces) proposal).getActionId();
            if (actionId != null) {
                presentation.setActionId(actionId);
            }
        }
        presentations.add(presentation);
    }
    result.setProposals(presentations);
    cache.put(sessionId, new CodeAssistContext(viewer, offset, proposals, compilationUnit));
    return result;
}
Also used : CheActionAcces(org.eclipse.che.jdt.ui.CheActionAcces) ProposalPresentation(org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation) ICompletionProposal(org.eclipse.che.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) Proposals(org.eclipse.che.ide.ext.java.shared.dto.Proposals) ICompletionProposalExtension4(org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension4) Point(org.eclipse.swt.graphics.Point)

Aggregations

ArrayList (java.util.ArrayList)1 ProposalPresentation (org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation)1 Proposals (org.eclipse.che.ide.ext.java.shared.dto.Proposals)1 CheActionAcces (org.eclipse.che.jdt.ui.CheActionAcces)1 ICompletionProposal (org.eclipse.che.jface.text.contentassist.ICompletionProposal)1 ICompletionProposalExtension4 (org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension4)1 Point (org.eclipse.swt.graphics.Point)1