/*
   * Turns the vector into an Array of ICompletionProposal objects
   */
  protected ICompletionProposal[] turnProposalVectorIntoAdaptedArray(WordPartDetector word) {
    ICompletionProposal[] result = new ICompletionProposal[proposalList.size()];

    int index = 0;

    for (Iterator i = proposalList.iterator(); i.hasNext(); ) {
      String keyWord = (String) i.next();

      IContextInformation info = new ContextInformation(keyWord, getContentInfoString(keyWord));
      // Creates a new completion proposal.
      result[index] =
          new CompletionProposal(
              keyWord, // replacementString
              word.getOffset(),
              // replacementOffset the offset of the text to be replaced
              word.getString().length(),
              // replacementLength the length of the text to be replaced
              keyWord.length(),
              // cursorPosition the position of the cursor following the insert relative to
              // replacementOffset
              null, // image to display
              keyWord, // displayString the string to be displayed for the proposal
              info,
              // contntentInformation the context information associated with this proposal
              getContentInfoString(keyWord));
      index++;
    }
    // System.out.println("result : " + result.length);
    proposalList.removeAllElements();
    return result;
  }
  /**
   * This method returns a list of completion proposals as ICompletionProposal objects. The
   * proposals are based on the word at the offset in the document where the cursor is positioned.
   * In this implementation, we find the word at the document offset and compare it to our list of
   * SQL reserved words. The list is a subset, of those words that match what the user has entered.
   * For example, the text or proposes the SQL keywords OR and ORDER. The list is returned as an
   * array of completion proposals.
   *
   * @see
   *     org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(ITextViewer,
   *     int)
   */
  @Override
  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {

    WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset);

    // iterate over all the different categories
    for (int i = 0; i < SqlSyntax.ALL_WORDS.size(); i++) {
      if ((SqlSyntax.ALL_WORDS.get(i)).startsWith(wordPart.getString().toUpperCase()))
        proposalList.add(SqlSyntax.ALL_WORDS.get(i));
    }

    return turnProposalVectorIntoAdaptedArray(wordPart);
  }