/**
   * Invoke content assist on the given viewer at the given offset, for the given number of pages
   * and return the results of each page
   *
   * @param viewer
   * @param offset
   * @param pageCount
   * @return
   * @throws Exception
   */
  private static ICompletionProposal[][] getProposals(
      StructuredTextViewer viewer, int offset, int pageCount) throws Exception {
    // setup the viewer
    StructuredTextViewerConfigurationHTML configuration =
        new StructuredTextViewerConfigurationHTML();
    ContentAssistant contentAssistant =
        (ContentAssistant) configuration.getContentAssistant(viewer);
    viewer.configure(configuration);
    viewer.setSelectedRange(offset, 0);

    // get the processor
    String partitionTypeID = viewer.getDocument().getPartition(offset).getType();
    IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);

    // fire content assist session about to start
    Method privateFireSessionBeginEventMethod =
        ContentAssistant.class.getDeclaredMethod(
            "fireSessionBeginEvent", new Class[] {boolean.class});
    privateFireSessionBeginEventMethod.setAccessible(true);
    privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] {Boolean.TRUE});

    // get content assist suggestions
    ICompletionProposal[][] pages = new ICompletionProposal[pageCount][];
    for (int p = 0; p < pageCount; ++p) {
      pages[p] = processor.computeCompletionProposals(viewer, offset);
    }

    // fire content assist session ending
    Method privateFireSessionEndEventMethod =
        ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null);
    privateFireSessionEndEventMethod.setAccessible(true);
    privateFireSessionEndEventMethod.invoke(contentAssistant, null);

    return pages;
  }
コード例 #2
0
 public ICompletionProposal[] computeCompletionProposals(
     final ITextViewer viewer, final int offset) {
   final List proposals = new ArrayList();
   final ICompletionProposal[] hippieProposals = hippie.computeCompletionProposals(viewer, offset);
   for (int i = 0; i < hippieProposals.length; i++) proposals.add(hippieProposals[i]);
   return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[0]);
 }
コード例 #3
0
 public String getErrorMessage() {
   return hippie.getErrorMessage();
 }
コード例 #4
0
 public IContextInformationValidator getContextInformationValidator() {
   return hippie.getContextInformationValidator();
 }
コード例 #5
0
 public char[] getContextInformationAutoActivationCharacters() {
   return hippie.getContextInformationAutoActivationCharacters();
 }
コード例 #6
0
 public char[] getCompletionProposalAutoActivationCharacters() {
   return hippie.getCompletionProposalAutoActivationCharacters();
 }
コード例 #7
0
 public IContextInformation[] computeContextInformation(
     final ITextViewer viewer, final int offset) {
   return hippie.computeContextInformation(viewer, offset);
 }