Search in sources :

Example 1 with ProposalPresentation

use of org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation in project che by eclipse.

the class JavaCodeAssistProcessor method showProposals.

private void showProposals(final CodeAssistCallback callback, final Proposals respons) {
    List<ProposalPresentation> presentations = respons.getProposals();
    final List<CompletionProposal> proposals = new ArrayList<>(presentations.size());
    HasLinkedMode linkedEditor = editor instanceof HasLinkedMode ? (HasLinkedMode) editor : null;
    for (final ProposalPresentation proposal : presentations) {
        final CompletionProposal completionProposal = new JavaCompletionProposal(proposal.getIndex(), insertStyle(resources, proposal.getDisplayString()), getIcon(proposal.getImage()), client, respons.getSessionId(), linkedEditor, refactoringUpdater, editorAgent);
        proposals.add(completionProposal);
    }
    callback.proposalComputed(proposals);
}
Also used : CompletionProposal(org.eclipse.che.ide.api.editor.codeassist.CompletionProposal) HasLinkedMode(org.eclipse.che.ide.api.editor.link.HasLinkedMode) ProposalPresentation(org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation) ArrayList(java.util.ArrayList)

Example 2 with ProposalPresentation

use of org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation in project che by eclipse.

the class JavaQuickAssistProcessor method showProposals.

private void showProposals(final CodeAssistCallback callback, final Proposals responds, TextEditor editor) {
    List<ProposalPresentation> presentations = responds.getProposals();
    final List<CompletionProposal> proposals = new ArrayList<>(presentations.size());
    HasLinkedMode linkedEditor = editor instanceof HasLinkedMode ? (HasLinkedMode) editor : null;
    for (ProposalPresentation proposal : presentations) {
        CompletionProposal completionProposal;
        String actionId = proposal.getActionId();
        if (actionId != null) {
            ProposalAction action = proposalActions.get(actionId);
            completionProposal = new ActionCompletionProposal(insertStyle(javaResources, proposal.getDisplayString()), actionId, action, JavaCodeAssistProcessor.getIcon(proposal.getImage()));
        } else {
            completionProposal = new JavaCompletionProposal(proposal.getIndex(), insertStyle(javaResources, proposal.getDisplayString()), JavaCodeAssistProcessor.getIcon(proposal.getImage()), client, responds.getSessionId(), linkedEditor, refactoringUpdater, editorAgent);
        }
        proposals.add(completionProposal);
    }
    callback.proposalComputed(proposals);
}
Also used : ProposalAction(org.eclipse.che.ide.ext.java.client.action.ProposalAction) CompletionProposal(org.eclipse.che.ide.api.editor.codeassist.CompletionProposal) HasLinkedMode(org.eclipse.che.ide.api.editor.link.HasLinkedMode) ProposalPresentation(org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation) ArrayList(java.util.ArrayList)

Example 3 with ProposalPresentation

use of org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation 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)3 ProposalPresentation (org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation)3 CompletionProposal (org.eclipse.che.ide.api.editor.codeassist.CompletionProposal)2 HasLinkedMode (org.eclipse.che.ide.api.editor.link.HasLinkedMode)2 ProposalAction (org.eclipse.che.ide.ext.java.client.action.ProposalAction)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