Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Xtext : Personalize Description
[SOLVED] Xtext : Personalize Description [message #1763947] Tue, 23 May 2017 10:16 Go to next message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Hello,
I created a new grammar with Xtext 2.11 (it works) and I want to personnalize the autocompletion.

For example, I have two objects in my grammar

 
      Environment:
	'ENV_TYPE' name=ID
	'Description' (Description=STRING)
 
 
      Test
	'TEST_TYPE' name=ID
	'Description' (Description=STRING)
        'Environment' Environment=[Environment]



I would like in eclipse during autocompletion (on Environment attribut in TEST object) retrieving Environment'ID and in the yellow part the environment's description (cf attachment)

index.php/fa/29434/0/

How do you do that ?

Thank you
  • Attachment: auto_dev..jpg
    (Size: 28.71KB, Downloaded 257 times)

[Updated on: Wed, 24 May 2017 08:16]

Report message to a moderator

Re: Xtext : Personalize Description [message #1763950 is a reply to message #1763947] Tue, 23 May 2017 10:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
You can have a look at IEObjectDocumentationProvider.
that one is used to calculate the hover tooltip (that is used for proposals as well)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Xtext : Personalize Description [message #1763984 is a reply to message #1763950] Tue, 23 May 2017 15:51 Go to previous messageGo to next message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Thansk for your answer but I need help again.
I follow this tutorial https://christiandietrich.wordpress.com/2011/07/16/hover-support-in-xtext-2-0-tutorial/ but it does not work.

Here my code :

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;

import com.google.inject.Inject;


public class SvcIEObjectDocumentationProvider implements IEObjectDocumentationProvider {


	public SvcIEObjectDocumentationProvider() {
		// TODO Auto-generated constructor stub
	}
	
@Override
	public String getDocumentation(EObject o) {
		return "Je mets ce que je veux";
	}

}


 
/*
 * generated by Xtext 2.11.0
 */
import com.google.inject.Inject
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor

/**
 * Use this class to register components to be used within the Eclipse IDE.
 */
@FinalFieldsConstructor
class SvcUiModule extends AbstractSvcUiModule {
	
	@Inject	
   def public Class<? extends SvcIEObjectDocumentationProvider> bindIEObjectDocumentationProvider() {
        return SvcIEObjectDocumentationProvider;
    }
	
}


When Eclipse loads, I pass by bindIEObjectDocumentationProvider() but my sentence "Je mets ce que je veux" does not appear.

What have I forgotten

Thank

[Updated on: Wed, 24 May 2017 07:01]

Report message to a moderator

Re: Xtext : Personalize Description [message #1763989 is a reply to message #1763984] Tue, 23 May 2017 16:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member

@Inject
def public Class<? extends SvcIEObjectDocumentationProvider> bindIEObjectDocumentationProvider() {
return SvcIEObjectDocumentationProvider;
}

makes no sence. this is a binding not a injection

and the type is wrong
class MyDslUiModule extends AbstractMyDslUiModule {
	
    def public Class<? extends IEObjectDocumentationProvider> bindIEObjectDocumentationProvider() {
        return SvcIEObjectDocumentationProvider;
    }
}



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Xtext : Personalize Description [message #1764021 is a reply to message #1763989] Wed, 24 May 2017 06:56 Go to previous message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Thank you. You save me, it works.
Previous Topic:ScopeProvider and Linker
Next Topic:Xtext : Unicity element
Goto Forum:
  


Current Time: Mon Dec 02 09:05:16 GMT 2024

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

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

Back to the top