/** {@inheritDoc} */ @Override public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) { final IParseResult parseResult = resource.getParseResult(); if (parseResult == null || parseResult.getRootNode() == null) { return; // Return, no need to call in super.createAdditionalHyperlinks } // Check if the current parse tree node represents an override keyword, in which case we want to link // to the overridden rule INode node = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset); if (node != null && isOverrideKeyword(node.getGrammarElement())) { Rule rule = (Rule) eObjectAtOffsetHelper.resolveElementAt(resource, offset); Region region = new Region(node.getOffset(), node.getLength()); List<Rule> extendedRules = getExtendedRules(rule); for (Rule extendedRule : extendedRules) { createHyperlinksTo(resource, region, extendedRule, acceptor); } } super.createHyperlinksByOffset(resource, offset, acceptor); }
@Override public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) { IEditorPart activeEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (activeEditor.getEditorInput() instanceof XtextReadonlyEditorInput) { INode crossRefNode = eObjectAtOffsetHelper.getCrossReferenceNode(resource, new TextRegion(offset, 0)); if (crossRefNode == null) { return; } EObject crossLinkedEObject = eObjectAtOffsetHelper.getCrossReferencedElement(crossRefNode); if (crossLinkedEObject != null && crossLinkedEObject.eClass().getEPackage() != CheckPackage.eINSTANCE) { return; } // if EPackage of referenced object is CheckPackage, try to provide hyperlinks: works for included catalogs } super.createHyperlinksByOffset(resource, offset, acceptor); }
protected void createPackageImportHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) { INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset); if (node != null && node.getGrammarElement() instanceof RuleCall && node.getSemanticElement() instanceof ImportScope) { NodeModelUtils.findNodesForFeature(node.getSemanticElement(), TypesPackage.Literals.PACKAGE__IMPORT); ImportScope importScope = (ImportScope) node.getSemanticElement(); EList<String> imports = importScope.getImports(); for (String pkgImport : imports) { PackageImport mappedImport = mapper.findPackageImport(resource, pkgImport); final URI targetURI = mappedImport.getUri(); XtextHyperlink result = getHyperlinkProvider().get(); result.setURI(targetURI); Region region = new Region(node.getOffset(), node.getLength()); result.setHyperlinkRegion(region); result.setHyperlinkText(targetURI.toString()); acceptor.accept(result); } } }
@Override public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) { ICompositeNode rootNode = modelQuery.getRootNode(resource); P correspondingIvmlProject = modelQuery.getProject(rootNode); if (rootNode != null) { ILeafNode leafNodeAtOffset = NodeModelUtils.findLeafNodeAtOffset(rootNode, offset); if (leafNodeAtOffset != null) { /* * Create an IvmlHyperlink for the element at the given offset. * What happens when opening this hyperlink is handled by the * IvmlHyperlink-class, see: * * IvmlHyperlink.open() */ AbstractHyperlink hyperlink = hyperlinkFactory.createHyperlink(leafNodeAtOffset, correspondingIvmlProject); // Currently not used: hyperlink.setHyperlinkText("A hyperlink // text"); hyperlink.setHyperlinkRegion(new Region(leafNodeAtOffset.getOffset(), leafNodeAtOffset.getLength())); acceptor.accept(hyperlink); } } }
@Override public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) { super.createHyperlinksByOffset(resource, offset, acceptor); EObject element = eObjectAtOffsetHelper.resolveElementAt(resource, offset); if (element!=null && element instanceof Import) { Import imp = (Import) element; INode node = NodeModelUtils.getNode(element); URI publicUri = URI.createURI(imp.getImportURI()); URI uriForPublicUri = getUriForPublicUri(publicUri, resource.getResourceSet()); if (uriForPublicUri!=null) { XtextHyperlink hyperlink = getHyperlinkProvider().get(); Region region = new Region(node.getOffset(), node.getLength()); hyperlink.setHyperlinkRegion(region); hyperlink.setURI(uriForPublicUri); hyperlink.setHyperlinkText(uriForPublicUri.toString()); acceptor.accept(hyperlink); } } }
@Override public void createHyperlinksTo(XtextResource from, Region region, EObject target, IHyperlinkAcceptor acceptor) { if (target instanceof TMember) { TMember member = (TMember) target; if (member.isComposed()) { List<TMember> constituentMembers = member.getConstituentMembers(); for (TMember constituentMember : constituentMembers) { super.createHyperlinksTo(from, region, constituentMember, acceptor); } return; } } super.createHyperlinksTo(from, region, target, acceptor); }
@Override public void createHyperlinksTo(XtextResource from, Region region, EObject target, IHyperlinkAcceptor acceptor) { if (((AbstractTypeSystem)typeSystem).getResource() == target.eResource()) { // build-in elements are defined in the resource of the type system // don't create hyperlinks to them return; } super.createHyperlinksTo(from, region, target, acceptor); }
public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) { createPackageImportHyperlinksByOffset(resource, offset, acceptor); super.createHyperlinksByOffset(resource, offset, acceptor); }