use of org.eclipse.xtext.ide.server.hover.HoverContext in project xtext-core by eclipse.
the class HoverService method hover.
@Override
public Hover hover(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) {
final int offset = document.getOffSet(params.getPosition());
final HoverContext context = this.createContext(document, resource, offset);
return this.hover(context);
}
use of org.eclipse.xtext.ide.server.hover.HoverContext in project xtext-core by eclipse.
the class HoverService method createContext.
protected HoverContext createContext(final Document document, final XtextResource resource, final int offset) {
final EObject crossLinkedEObject = this._eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, offset);
if ((crossLinkedEObject != null)) {
boolean _eIsProxy = crossLinkedEObject.eIsProxy();
if (_eIsProxy) {
return null;
}
final IParseResult parseResult = resource.getParseResult();
if ((parseResult == null)) {
return null;
}
ILeafNode leafNode = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset);
if ((((leafNode != null) && leafNode.isHidden()) && (leafNode.getOffset() == offset))) {
leafNode = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), (offset - 1));
}
if ((leafNode == null)) {
return null;
}
final ITextRegion leafRegion = leafNode.getTextRegion();
return new HoverContext(document, resource, offset, leafRegion, crossLinkedEObject);
}
final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(resource, offset);
if ((element == null)) {
return null;
}
final ITextRegion region = this._iLocationInFileProvider.getSignificantTextRegion(element);
return new HoverContext(document, resource, offset, region, element);
}
Aggregations