use of org.eclipse.xtext.documentation.EObjectInComment in project xtext-eclipse by eclipse.
the class XbaseDispatchingEObjectTextHover method getXtextElementAt.
@Override
protected Pair<EObject, IRegion> getXtextElementAt(XtextResource resource, int offset) {
Pair<EObject, IRegion> original = super.getXtextElementAt(resource, offset);
if (original != null) {
EObject object = eObjectAtOffsetHelper.resolveContainedElementAt(resource, offset);
if (object instanceof XAbstractFeatureCall) {
JvmIdentifiableElement feature = ((XAbstractFeatureCall) object).getFeature();
if (feature instanceof JvmExecutable || feature instanceof JvmField || feature instanceof JvmConstructor || feature instanceof XVariableDeclaration || feature instanceof JvmFormalParameter)
return Tuples.create(object, original.getSecond());
} else if (object instanceof XConstructorCall) {
return Tuples.create(object, original.getSecond());
}
}
EObjectInComment eObjectReferencedInComment = javaDocTypeReferenceProvider.computeEObjectReferencedInComment(resource, offset);
if (eObjectReferencedInComment != null) {
EObject eObject = eObjectReferencedInComment.getEObject();
ITextRegion region = eObjectReferencedInComment.getRegion();
return Tuples.create(eObject, new Region(region.getOffset(), region.getLength()));
}
return original;
}
use of org.eclipse.xtext.documentation.EObjectInComment in project xtext-core by eclipse.
the class MultiLineJavaDocTypeReferenceProvider method computeEObjectReferencedInComment.
/**
* {@inheritDoc}
*/
@Override
public EObjectInComment computeEObjectReferencedInComment(XtextResource resource, int offset) {
IParseResult parseResult = resource.getParseResult();
if (parseResult != null) {
INode rootNode = parseResult.getRootNode();
INode node = NodeModelUtils.findLeafNodeAtOffset(rootNode, offset);
EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(node);
if (semanticObject != null) {
EReference reference = getEReference(semanticObject, node, offset);
if (reference != null) {
IScope scope = getScope(semanticObject, reference, node, offset);
List<ReplaceRegion> eObjectReferences = computeTypeRefRegions(node);
for (ReplaceRegion eObjectReference : eObjectReferences) {
if (eObjectReference.getOffset() <= offset && offset <= eObjectReference.getEndOffset()) {
String eObjectReferenceText = eObjectReference.getText();
if (!Strings.isNullOrEmpty(eObjectReferenceText)) {
ITextRegion region = new TextRegion(eObjectReference.getOffset(), eObjectReference.getLength());
IEObjectDescription candidate = getElementFromScope(scope, node, region, eObjectReferenceText);
if (candidate != null) {
EObject eObject = candidate.getEObjectOrProxy();
if (eObject != null) {
return new EObjectInComment(eObject, region);
}
}
}
}
}
}
}
}
return null;
}
use of org.eclipse.xtext.documentation.EObjectInComment in project xtext-eclipse by eclipse.
the class XbaseHyperLinkHelper method createHyperlinksInJavaDoc.
/**
* Creates hyperlinks on types referenced in javadoc comments.
*
* @since 2.16
*/
protected void createHyperlinksInJavaDoc(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
EObjectInComment eObjectReferencedInComment = javaDocTypeReferenceProvider.computeEObjectReferencedInComment(resource, offset);
if (eObjectReferencedInComment != null) {
EObject target = eObjectReferencedInComment.getEObject();
ITextRegion region = eObjectReferencedInComment.getRegion();
createHyperlinksTo(resource, new Region(region.getOffset(), region.getLength()), target, acceptor);
}
}
Aggregations