Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to export custom hovers as plug in ?
How to export custom hovers as plug in ? [message #1841890] Wed, 02 June 2021 12:38 Go to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,


I am new to Xtext & DSL writing. I am trying to implement a debugger as an Eclipse plug in, that needs to be DSL independant. I am working on Gemoc Studio.

I would like to add custom hovers to my debugger. Following tutorials, I saw that for a 'local application', our custom hover class that extends DefaultEObjectHoverProvider needs to be binded in the language's Module like this :

public class MyDslUiModule extends AbstractMyDslUiModule {
        public MyDslUiModule(AbstractUIPlugin plugin) {
		super(plugin);
	}
	public Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
		return MyDslEObjectHoverProvider.class;
	}
}


However, I want to avoid touching the DSL's code, and want my Hover plug in to be automatically used. Is there another way to tell the DSL that it should use the plug in's custom hover ? Can I do it from the IEngineAddon ?


I hope I was clear enough,

Thanks in advance

[Updated on: Wed, 02 June 2021 12:54]

Report message to a moderator

Re: How to export custom hovers as plug in ? [message #1841897 is a reply to message #1841890] Wed, 02 June 2021 13:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i dont know if this is possible without changing or patching the dsl. maybe you can smuggle a hover in somehow but i have doubts its a good idea or if you manage to call this early enhough

ITextHover textHover = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.mydsl")).get(ITextHover.class);
if (textHover instanceof DefaultCompositeHover) {
List<ITextHover> hovers = ((DefaultCompositeHover) textHover).getHovers();
hovers.add(0, yourhover);
}



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1841916 is a reply to message #1841897] Thu, 03 June 2021 09:45 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

Thank you for replying.

When you say "calling it early enough", do you mean at plug-in starting time ? I tried to do add your code in my 'Activator' class, that extends the 'AbstractUIPlugin'. I placed the code in the method :
public void start(BundleContext context){...}

but his approach does not seem to work. I still see the DSL's original hovers.

I wondered if by adding my custom hover like this, it 'collides' with the DSL's custom/default hovers ?

Also, do you mind explaining this part ?
ITextHover textHover = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.mydsl")).get(ITextHover.class);

I am not sure I understand what is done here.

[Updated on: Thu, 03 June 2021 10:20]

Report message to a moderator

Re: How to export custom hovers as plug in ? [message #1841917 is a reply to message #1841916] Thu, 03 June 2021 11:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
This will give you the text hover of the dsl
Then when you open an editor of the dsl
GetHovers should be called on it


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1841918 is a reply to message #1841917] Thu, 03 June 2021 11:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Besides that you should debug around that places to see what happens

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1841926 is a reply to message #1841918] Thu, 03 June 2021 17:22 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello again,

I've been debugging around to see when and where the DefaultEObjectHoverProvider was initialized, to see if I can grab the object that initializes it and give it my own implementation of the hover instead.

I haven't found anything interesting enough yet, do you think this approach is possible ?
Re: How to export custom hovers as plug in ? [message #1841933 is a reply to message #1841926] Thu, 03 June 2021 19:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you debug DefaultCompositeHover

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1841964 is a reply to message #1841933] Fri, 04 June 2021 14:56 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello again,

Yes I tried debugging it, along with other components but I found nothing interesting and am stuck here.
I thought this could be a lead :
http://https://wiki.eclipse.org/FAQ_How_do_I_add_hover_support_to_my_text_editor%3F
but it does not work for me (maybe I'm implementing it wrong)

My structure is like this :
My plugin has a BehaviorManager, that extends IEngineAddon. I also have an Activator class, that extends AbstractUIPlugin. Both classes are declared in my Manifest file.
In my BehaviorManager, I override the stepExecuted()method. This method, after each debugging step, calls a Commenter class that writes a comment next to the value we are interested in.
I wrote 2 hover classes, not knowing which one I am supposed to use :
HoverProvider, that extends DefaultEObjectHoverProvider, and DebugHover, that extends ITextHover.

<plugin>
   <extension
         point="org.eclipse.gemoc.gemoc_language_workbench.engine_addon">
      <addon
            addonGroupId="Concurrent.AddonGroup"
            class="org.eclipse.gemoc.addon.xtextanimator.ui.XtextAnimatorBehaviorManager"
            default="false"
            name="Xtext Animator"
            shortDescription="Doing stuff to your text"
            id="xtext_animator">
      </addon>
   </extension>
<extension point="org.eclipse.ui.genericeditor.hoverProviders">
   <hoverProvider
       class="org.eclipse.gemoc.addon.xtextanimator.ui.hover.HoverProvider">
   </hoverProvider>
</extension>
</plugin>
Re: How to export custom hovers as plug in ? [message #1841972 is a reply to message #1841964] Fri, 04 June 2021 18:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
As I said. Xtext already implements hover
And you try to sneak in
From your message I don't see what you debugged
Is defaultcompositehover called ?
Does the DSL you try to sneak in use another impl ?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1842005 is a reply to message #1841972] Mon, 07 June 2021 06:29 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello again,

I know that Xtext implements hovers, but from what I've seen through tutorials, you can create custom hovers by extending DefaultEObjectHover, and then binding that custom hover in the language's UI Module :
https://dietrich-it.de/xtext/2011/07/16/hover-support-in-xtext-2.0-tutorial/
I want to do something like this, I want my plug in to provide custom hovers. I thought of doing it like in the tutorial, by creating a class that extends the DefaultEObjectHover. However, if I do this, I need to edit my DSL's UIModule class, and that is what I want to avoid.
When I use the DefaultEObjectHover, the DefaultCompositeHover does not seem to be called.

Is there a way to provide to a DSL the plugin's custom hovers without writing the binding method in the DSL's UIModule ?
Re: How to export custom hovers as plug in ? [message #1842007 is a reply to message #1842005] Mon, 07 June 2021 06:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

UIModule and AbstractUIModule are well engineered so that AbstractUIModule is 100% auto-generated, and UIModule is 100% manually maintained following the initial auto-generation of a stub. Editing the UIModule is the way to go; that's why it is in the src rather than src-gen tree.

If you really want to avoid editing the UIModule you can add a fragment to your MWE2 generator so that the fragment declares the 'edit' for you. Hardly worth it for a single editor. For OCL I have a family of 10 editors and so [1] has re-use value.

Regards

Ed Willink

[1[ https://git.eclipse.org/r/plugins/gitiles/ocl/org.eclipse.ocl/+/refs/heads/master/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/fragments/MarkupHoverFragment.java
Re: How to export custom hovers as plug in ? [message #1842010 is a reply to message #1842007] Mon, 07 June 2021 08:05 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

Thank you for taking the time to answer me.

The MWE2 generator you speak about, is it the DSL's ? Or should my plug in have one ?
What I am trying to avoid is editing at all the DSL's files. I want my plug in to provide hovers automatically, so that the user can add the plug in and use the debugger without having to change their DSL's files.
However, I do not know if it is possible.
Re: How to export custom hovers as plug in ? [message #1842013 is a reply to message #1842010] Mon, 07 June 2021 09:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
again the problem is:

the current impl does not allow you to change the hovers of a dsl from outside the dsl.
so you have to change the DSL code for all of them
of course you can add a custom fragment to all dsls mwe files that does the change too besides adding the new/changed bindings to all of them manually


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1842016 is a reply to message #1842013] Mon, 07 June 2021 10:38 Go to previous messageGo to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello again,

Too bad, I really hoped to find a way to do this without touching the DSL. About the custom fragment, just to confirm :
- I can create a custom fragment in my plugin
- And then I can (automatically ? ) add it to all of the DSL's MWE2 files

Is that correct ? Or should the custom fragment be part of the DSL's MWE2 files ?
Re: How to export custom hovers as plug in ? [message #1842020 is a reply to message #1842016] Mon, 07 June 2021 12:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you need to add it manually and you also need to run all mwe2
and thus you need to actively change the dsls


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to export custom hovers as plug in ? [message #1842028 is a reply to message #1842020] Mon, 07 June 2021 18:20 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It depends what you call the DSL. Obviously it includes a *.xtext file, but also it includes a *.mwe2 file where you can use fragments to reduce src tree customization, but almost certainly you will have other src customization for value converters, highlighting, scope resolution, generators, validation, outlines, serialization, quick fixes, .... so why are you so frightened about customization for hovers?

Regards

Ed Willink
Re: How to export custom hovers as plug in ? [message #1842107 is a reply to message #1842028] Wed, 09 June 2021 11:42 Go to previous message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

Thank you both for your help & advice.

Ed Willis, for my hover customization plug in, I just wanted to know if it was possible to provide hovers to the DSL without having to change the DSL's files (mwe2, module).

For know, I'm putting this gaol aside and am binding my hovers in my language's UI Module !

[Updated on: Wed, 09 June 2021 11:46]

Report message to a moderator

Previous Topic:Trying to generate DSL files using Java
Next Topic:Code coverage for Xtend (outside of maven build)
Goto Forum:
  


Current Time: Tue Apr 16 19:54:47 GMT 2024

Powered by FUDForum. Page generated in 0.36813 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top