Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:31 Go to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
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 11:20 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Documenting the Grammar to use it in the DSL-Editor [message #1142305 is a reply to message #1081550] Thu, 17 October 2013 14:32 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
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 07:01]

Report message to a moderator

Re: Documenting the Grammar to use it in the DSL-Editor [message #1142419 is a reply to message #1081550] Thu, 17 October 2013 16:06 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
No Message Body

[Updated on: Thu, 17 October 2013 16:30]

Report message to a moderator

Re: Documenting the Grammar to use it in the DSL-Editor [message #1142498 is a reply to message #1142419] Thu, 17 October 2013 17:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Documenting the Grammar to use it in the DSL-Editor [message #1143856 is a reply to message #1081526] Fri, 18 October 2013 13:21 Go to previous message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
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 13:22]

Report message to a moderator

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


Current Time: Tue Apr 16 23:57:55 GMT 2024

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

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

Back to the top