private ScriptCompletionProposal generateTwigProposal(CompletionProposal typeProposal) {

    String completion = new String(typeProposal.getCompletion());
    int replaceStart = typeProposal.getReplaceStart();
    int length = getLength(typeProposal);
    Image image =
        getImage(
            ((TwigCompletionProposalLabelProvider) getLabelProvider())
                .createTypeImageDescriptor(typeProposal));

    String displayString =
        ((TwigCompletionProposalLabelProvider) getLabelProvider())
            .createTypeProposalLabel(typeProposal);

    ScriptCompletionProposal scriptProposal =
        new EmptyCompletionProposal(completion, replaceStart, length, image, displayString, 0);

    return scriptProposal;
  }
コード例 #2
0
 protected void printDebug(CompletionProposal proposal) {
   StringBuffer buffer = new StringBuffer();
   buffer.append("COMPLETION - "); // $NON-NLS-1$
   switch (proposal.getKind()) {
     case CompletionProposal.FIELD_REF:
       buffer.append("FIELD_REF"); // $NON-NLS-1$
       break;
     case CompletionProposal.KEYWORD:
       buffer.append("KEYWORD"); // $NON-NLS-1$
       break;
     case CompletionProposal.LABEL_REF:
       buffer.append("LABEL_REF"); // $NON-NLS-1$
       break;
     case CompletionProposal.LOCAL_VARIABLE_REF:
       buffer.append("LOCAL_VARIABLE_REF"); // $NON-NLS-1$
       break;
     case CompletionProposal.METHOD_DECLARATION:
       buffer.append("METHOD_DECLARATION"); // $NON-NLS-1$
       break;
     case CompletionProposal.METHOD_REF:
       buffer.append("METHOD_REF"); // $NON-NLS-1$
       break;
     case CompletionProposal.PACKAGE_REF:
       buffer.append("PACKAGE_REF"); // $NON-NLS-1$
       break;
     case CompletionProposal.TYPE_REF:
       buffer.append("TYPE_REF"); // $NON-NLS-1$
       break;
     case CompletionProposal.VARIABLE_DECLARATION:
       buffer.append("VARIABLE_DECLARATION"); // $NON-NLS-1$
       break;
     case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
       buffer.append("POTENTIAL_METHOD_DECLARATION"); // $NON-NLS-1$
       break;
     case CompletionProposal.METHOD_NAME_REFERENCE:
       buffer.append("METHOD_NAME_REFERENCE"); // $NON-NLS-1$
       break;
     default:
       buffer.append("PROPOSAL"); // $NON-NLS-1$
       break;
   }
   if (VERBOSE) {
     buffer.append("{\n"); // $NON-NLS-1$
     buffer
         .append("\tCompletion[")
         .append(proposal.getCompletion() == null ? "null" : proposal.getCompletion())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     buffer
         .append("\tDeclarationKey[")
         .append(proposal.getDeclarationKey() == null ? "null" : proposal.getDeclarationKey())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     buffer
         .append("\tKey[")
         .append(proposal.getKey() == null ? "null" : proposal.getKey())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     buffer
         .append("\tName[")
         .append(proposal.getName() == null ? "null" : proposal.getName())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     buffer
         .append("\tCompletionLocation[")
         .append(proposal.getCompletionLocation())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$
     int start = proposal.getReplaceStart();
     int end = proposal.getReplaceEnd();
     buffer.append("\tReplaceStart[").append(start).append("]"); // $NON-NLS-1$ //$NON-NLS-2$
     buffer.append("-ReplaceEnd[").append(end).append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$
     if (this.source != null)
       buffer
           .append("\tReplacedText[")
           .append(this.source, start, end - start)
           .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$
     buffer
         .append("\tTokenStart[")
         .append(proposal.getTokenStart())
         .append("]"); // $NON-NLS-1$ //$NON-NLS-2$
     buffer
         .append("-TokenEnd[")
         .append(proposal.getTokenEnd())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$
     buffer
         .append("\tRelevance[")
         .append(proposal.getRelevance())
         .append("]\n"); // $NON-NLS-1$ //$NON-NLS-2$
     buffer.append("}\n"); // $NON-NLS-1$
   } else {
     if (proposal.getCompletion() != null) {
       buffer.append(' ').append('"').append(proposal.getCompletion()).append('"');
     }
   }
   System.out.println(buffer.toString());
 }