Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Annyoing XText model (hyper)linking(How to customize/disable XText (hyper)linking behavior)
icon8.gif  Annyoing XText model (hyper)linking [message #1295558] Mon, 14 April 2014 07:20 Go to next message
Michel de Blok is currently offline Michel de Blok
Messages: 6
Registered: February 2010
Junior Member
Hi all,

I generate JUnit test skeletons from my XText model using a JvmBuilder.

If I run these generated unit tests in Eclipse and I double-click a test in Eclipse's "JUnit View" then it opens the XText model instead of the generated Java source of the unit test.

Same applies to parent classes that are generated by XText: if I'm in the Java source of a class that extends a generated parent and I use "control-click" to open the parent in Eclipse, it jumps to the model instead of the Java source.

I find this default behavior of XText very annoying and like to disable it completely: If I click a class in the Java editor or JUnit view in Eclipse, I always want to jump to the Java source and never to the model.

How can I easily do this?

Regards,
Michel de Blok

Re: Annyoing XText model (hyper)linking [message #1312712 is a reply to message #1295558] Thu, 24 April 2014 09:02 Go to previous message
Holger Schill is currently offline Holger Schill
Messages: 68
Registered: July 2009
Member
You can do the following:

use your own Matcher that extends from JavaEditorInputMatcher.

public class MyMatcher extends JavaEditorInputMatcher {

private static final Logger logger = Logger.getLogger(MyMatcher.class);

@Inject
private XtextEditorInfo editorInfo;

@Inject
private XbaseEditorInputRedirector editorInputRedirector;

@Override
public boolean matches(IEditorReference editorRef, IEditorInput
inputToCheck) {
try {
if (!editorInfo.getEditorId().equals(editorRef.getId())) {
return false;
}
IEditorInput newInput =
editorInputRedirector.findOriginalSourceForOuputFolderCopy(inputToCheck);
IEditorInput currentInput = editorRef.getEditorInput();
if (newInput.equals(currentInput)) {
return true;
}
return false;
} catch(Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
}

The use it in the plugin.xml of your UI bundle of your language:

<extension
point="org.eclipse.ui.editors">
<editor

class="org.eclipse.xtext.example.domainmodel.ui.DomainmodelExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"

contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
default="true"
extensions="dmodel"
id="org.eclipse.xtext.example.domainmodel.Domainmodel"

matchingStrategy="org.eclipse.xtext.example.domainmodel.ui.DomainmodelExecutableExtensionFactory:org.eclipse.xtext.example.domainmodel.ui.MyMatcher"
name="Domainmodel Editor">
</editor>
</extension>


That's it.



On 14.04.14 13:20, Michel de Blok wrote:
> Hi all,
>
> I generate JUnit test skeletons from my XText model using a JvmBuilder.
>
> If I run these generated unit tests in Eclipse and I double-click a test
> in Eclipse's "JUnit View" then it opens the XText model instead of the
> generated Java source of the unit test.
>
> Same applies to parent classes that are generated by XText: if I'm in
> the Java source of a class that extends a generated parent and I use
> "control-click" to open the parent in Eclipse, it jumps to the model
> instead of the Java source.
>
> I find this default behavior of XText very annoying and like to disable
> it completely: If I click a class in the Java editor or JUnit view in
> Eclipse, I always want to jump to the Java source and never to the model.
>
> How can I easily do this?
>
> Regards,
> Michel de Blok
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:reference whitespace issue
Next Topic:How to extend xbase::XBlockExpression?
Goto Forum:
  


Current Time: Fri Jul 25 19:14:23 EDT 2014

Powered by FUDForum. Page generated in 0.01945 seconds