Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Documenting the Grammar to use it in the DSL-Editor
Documenting the Grammar to use it in the DSL-Editor [message #1081526] Wed, 07 August 2013 06:31 Go to next message
Eclipse UserFriend
Hello,

I want to document the rules of the grammar (comparable with JavaDoc). Then I want to use this documentation in the way that someone using the DSL-Editor can see the documentation, e. g. if he moves the mouse over the corresponding keyword (e. g. Hover-Effect).

Using the IEObjectDocumentationProvider is not what I want because there is no dependency to the grammar.

Greets Björn
Re: Documenting the Grammar to use it in the DSL-Editor [message #1081550 is a reply to message #1081526] Wed, 07 August 2013 07:20 Go to previous messageGo to next message
Eclipse UserFriend
You have to build that yourself, like
- Load the grammar xtext file and access the comments using the
IEObjectDocumentationProvider for the Xtext grammar language to extract
the comments on the rules. The generated GrammarAccess will not help
you, as it loads a compressed form of the grammar.
- Build your own IEObjectHoverProvider that distinguishes between the
keywords and the other parts of the text. NodeModelUtils will help you
find deal with the regions. The nodes themselves contain information on
the called rules and keywords.

You could also consider generating the whole thing from the grammar by
writing your own IGneratorFragment and adding it to the MWE2 workflow.

I'd expect this behavior to become quite confusing, as different hovers
will pop up in on the same element depending on if the mouse is on a
keyword or another part of the corresponding text. But that's a matter
of taste.

Am 07.08.13 12:31, schrieb Björn Rellesch:
> Hello,
>
> I want to document the rules of the grammar (comparable with JavaDoc).
> Then I want to use this documentation in the way that someone using the
> DSL-Editor can see the documentation, e. g. if he moves the mouse over
> the corresponding keyword (e. g. Hover-Effect).
>
> Using the IEObjectDocumentationProvider is not what I want because there
> is no dependency to the grammar.
>
> Greets Björn
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Documenting the Grammar to use it in the DSL-Editor [message #1142305 is a reply to message #1081550] Thu, 17 October 2013 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I tried to follow the following post:
http://blogs.itemis.de/stundzig/archives/868

I get the hover, when I move my mouse over the keyword.
The right information is shown.
This information is a String in HTML-format.
But the pop-up includes only text (with the escaped tags.)

I get this:
<!DOCTYPE html>
<html>
<body>
<b>Some very good Description</b>
<p>
...

But I want this:
Some very good Description
...

How can I achieve this?

((If I use the same html-formatted-information within a IEObjectDocumentationProvider
- see http://christiandietrich.wordpress.com/2011/07/16/hover-support-in-xtext-2-0-tutorial/ -
the information is shown as a HTML-document. But the IEObjectDocumentationProvider pops up, when I move my mouse over a EObject, but I want a hover-effect on my keywords.))

Greets Björn

[Updated on: Fri, 18 October 2013 03:01] by Moderator

Re: Documenting the Grammar to use it in the DSL-Editor [message #1142419 is a reply to message #1081550] Thu, 17 October 2013 12:06 Go to previous messageGo to next message
Eclipse UserFriend
No Message Body

[Updated on: Thu, 17 October 2013 12:30] by Moderator

Re: Documenting the Grammar to use it in the DSL-Editor [message #1142498 is a reply to message #1142419] Thu, 17 October 2013 13:14 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

i do not understand your problem

org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider.getHoverInfo(EObject, IRegion, XtextBrowserInformationControlInput)
is the point to calc the hover.

the other problem is: the mechanism has to be called at all.
this is prohibited by org.eclipse.xtext.ui.editor.hover.AbstractEObjectHover.getXtextElementAt(XtextResource, int)
since it calls org.eclipse.xtext.resource.ILocationInFileProvider.getSignificantTextRegion(EObject)
and the significant region is the name place only.
Re: Documenting the Grammar to use it in the DSL-Editor [message #1143856 is a reply to message #1081526] Fri, 18 October 2013 09:21 Go to previous message
Eclipse UserFriend
Hi,

I fixed the Problem.

As I mentinoned before I followed the posting:
http://blogs.itemis.de/stundzig/archives/868

To get a documentation formatted in html I added the following line in my DispatchingEObjectTextHover based on the example:

@Override
protected Pair<EObject, IRegion> getXtextElementAt(XtextResource resource,
int offset) {
//not a very good solution
Iterator<Object> iter = EcoreUtil.getAllContents(resource, false);
while (iter.hasNext()) {
if (iter .next() != null) {
someEObject= (EObject)iter.next();
break;
}
}

...

@Override
public Object getHoverInfo(EObject first, ITextViewer textViewer,
IRegion hoverRegion) {
if(first instanceof Keyword){
//not a very good solution
super.getHoverInfo(someEObject, oTextViewer, hoverRegion);

return getHoverInfoForKeyword((Keyword)first);
}else{
return super.getHoverInfo(first, textViewer, hoverRegion);
}
}



Greets Björn

[Updated on: Fri, 18 October 2013 09:22] by Moderator

Previous Topic:How should an inferrer fail correctly?
Next Topic:JvmModelInferrer: Serializing a JvmTypeReference and Generating a method body
Goto Forum:
  


Current Time: Wed Jul 23 14:25:20 EDT 2025

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

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

Back to the top