Ejemplo n.º 1
0
  /** Compute a hover result for a content assist proposal at the given offset. */
  public HoverResult getHover(
      final XtextWebDocumentAccess document,
      final String proposal,
      final ITextRegion selection,
      final int offset)
      throws InvalidRequestException {
    final CancelableUnitOfWork<HoverResult, IXtextWebDocument> _function =
        new CancelableUnitOfWork<HoverResult, IXtextWebDocument>() {
          @Override
          public HoverResult exec(final IXtextWebDocument it, final CancelIndicator cancelIndicator)
              throws Exception {
            HoverResult _xblockexpression = null;
            {
              final ContentAssistContext[] contexts =
                  HoverService.this.contentAssistService.getContexts(it, selection, offset);
              final Wrapper<Object> proposedElement = new Wrapper<Object>();
              IdeContentProposalProvider _proposalProvider =
                  HoverService.this.contentAssistService.getProposalProvider();
              _proposalProvider.createProposals(
                  ((Collection<ContentAssistContext>) Conversions.doWrapArray(contexts)),
                  new IIdeContentProposalAcceptor() {
                    @Override
                    public void accept(final ContentAssistEntry entry, final int priority) {
                      HoverService.this._operationCanceledManager.checkCanceled(cancelIndicator);
                      if ((((entry != null) && (entry.getSource() != null))
                          && Objects.equal(entry.getProposal(), proposal))) {
                        Object _source = entry.getSource();
                        proposedElement.set(_source);
                      }
                    }

                    @Override
                    public boolean canAcceptMoreProposals() {
                      Object _get = proposedElement.get();
                      return (_get == null);
                    }
                  });
              Object _get = proposedElement.get();
              String _stateId = it.getStateId();
              _xblockexpression = HoverService.this.createHover(_get, _stateId, cancelIndicator);
            }
            return _xblockexpression;
          }
        };
    return document.<HoverResult>readOnly(_function);
  }
Ejemplo n.º 2
0
 /** Compute a hover result at the given offset in the document. */
 public HoverResult getHover(final XtextWebDocumentAccess document, final int offset)
     throws InvalidRequestException {
   final CancelableUnitOfWork<HoverResult, IXtextWebDocument> _function =
       new CancelableUnitOfWork<HoverResult, IXtextWebDocument>() {
         @Override
         public HoverResult exec(final IXtextWebDocument it, final CancelIndicator cancelIndicator)
             throws Exception {
           HoverResult _xblockexpression = null;
           {
             XtextResource _resource = it.getResource();
             final EObject element =
                 HoverService.this._elementAtOffsetUtil.getElementAt(_resource, offset);
             String _stateId = it.getStateId();
             _xblockexpression = HoverService.this.createHover(element, _stateId, cancelIndicator);
           }
           return _xblockexpression;
         }
       };
   return document.<HoverResult>readOnly(_function);
 }