Exemplo n.º 1
0
 public void accept(ICompletionProposal proposal) {
   if (proposal instanceof ConfigurableCompletionProposal) {
     Keyword keyword = XtextFactory.eINSTANCE.createKeyword();
     keyword.setValue(proposal.getDisplayString());
     ((ConfigurableCompletionProposal) proposal).setAdditionalProposalInfo(keyword);
     ((ConfigurableCompletionProposal) proposal).setHover(STextProposalProvider.this.getHover());
   }
   delegate.accept(proposal);
 }
Exemplo n.º 2
0
  @Override
  public void complete_HEX(
      EObject model,
      RuleCall ruleCall,
      ContentAssistContext context,
      ICompletionProposalAcceptor acceptor) {
    ICompletionProposalAcceptor priorityOptimizer = getCustomAcceptor(model, "integer", acceptor);

    String proposalText = "0x1";
    ICompletionProposal proposal =
        createCompletionProposal(
            proposalText, proposalText + " - " + ruleCall.getRule().getName(), null, context);

    if (proposal instanceof ConfigurableCompletionProposal) {
      ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
      configurable.setSelectionStart(configurable.getReplacementOffset() + 2);
      configurable.setSelectionLength(proposalText.length() - 2);
      configurable.setAutoInsertable(false);
      configurable.setSimpleLinkedMode(context.getViewer(), '\t', ' ');
    }

    priorityOptimizer.accept(proposal);
  }
Exemplo n.º 3
0
 private void alterPriority(ICompletionProposal proposal, int delta) {
   if (proposal == null || !(proposal instanceof ConfigurableCompletionProposal)) return;
   ConfigurableCompletionProposal castedProposal = (ConfigurableCompletionProposal) proposal;
   castedProposal.setPriority(castedProposal.getPriority() + delta);
 }