|
|
Re: Hyperlinking [message #854214 is a reply to message #854140] |
Mon, 23 April 2012 19:31 |
Antonio Metallo Messages: 24 Registered: March 2012 |
Junior Member |
|
|
I'm trying to have CTRL click on a VariableName to a VariableDeclaration. I bind the DefaultHyperlinkDetector
public Class<? extends DefaultHyperlinkDetector> bindDefaultHyperlinkDetector() { return MyLinkerService.class; }
this is MyLinkerService:
public class MyLinkerService extends DefaultHyperlinkDetector {
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
this.setHelper(new MyHyperlink());
return super.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
}
}
in MyLinkerService i set the helper to MyHyperlinkHelper:
public class MyHyperlinkHelper extends HyperlinkHelper {
@Override
public void createHyperlinksByOffset(XtextResource resource, int offset,
IHyperlinkAcceptor acceptor) {
super.createHyperlinksByOffset(resource, offset, acceptor);
TextLocation loc = new TextLocation();
EObject eObject = EObjectAtOffsetHelper.resolveElementAt(resource, offset, loc);
if (eObject instanceof VariableName) {
VariableName varName = (VariableName) eObject;
CompositeNode adapter = NodeUtil.getNode(varName);
XtextHyperlink hyperlink = new XtextHyperlink();
hyperlink.setHyperlinkText("Variable");
hyperlink.setHyperlinkRegion(new Region(adapter.getOffset(), adapter.getLength()));
acceptor.accept(hyperlink);
}
}
}
XtextHyperlink have a setURI() method but I want a link to the VariableDeclaration in the same file, how can I have this?
|
|
|
|
|
|
Re: Hyperlinking [message #854299 is a reply to message #854292] |
Mon, 23 April 2012 21:33 |
|
Hi,
the method is of cource only called if YOU call it or you have a real cross ref and thus is called by the framework (in its out of the box config)
besides you missed an important point
@Override
public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() {
return MyDslHyperlinkHelper.class;
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Hyperlinking [message #854313 is a reply to message #854299] |
Mon, 23 April 2012 21:49 |
Antonio Metallo Messages: 24 Registered: March 2012 |
Junior Member |
|
|
I don't have a real cross ref and if I use the IHyperLinkHelper in binding I get this error:
1) A binding to org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper was already configured at org.eclipse.xtext.service.BindModule.configure(BindModule.java:36).
at org.eclipse.xtext.service.BindModule.configure(BindModule.java:36)
1 error
com.google.inject.CreationException: Guice creation errors:
1) A binding to org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper was already configured at org.eclipse.xtext.service.BindModule.configure(BindModule.java:36).
at org.eclipse.xtext.service.BindModule.configure(BindModule.java:36)
Is there a way to create an Hyperlink without a real cross ref?
[Updated on: Mon, 23 April 2012 22:02] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03135 seconds