Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » beginner question about outline and label(How to turn a semantic element into string?)
beginner question about outline and label [message #696170] Wed, 13 July 2011 12:21 Go to next message
alex.ren2006 is currently offline alex.ren2006Friend
Messages: 46
Registered: June 2011

I am currently working on building an IDE for ATS ( I have a simple question about building Outline and label in Xtext. Any suggestion is highly appreciated. For clarity, the following is an example grammar.

grammar org.Test1 with org.eclipse.xtext.common.Terminals

generate test1 ""






I want to show all the information of m1 and m2 in the label of program. My first idea is to add a "tostring" method to all of those class (program, ent1, ent2, etc.). But they are generated by Xtext. The following is what I am doing now.

	String text(program ele) {
		return "program " + ele.getM1().getM() + " " + ele.getM2().getM();

The method seems a little bit tedious. What's the usual way to get all the information of a semantic element? Does Xtext support converting a semantic element back to the string?

Thanks a lot.
Re: beginner question about outline and label [message #696228 is a reply to message #696170] Wed, 13 July 2011 14:28 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member

This is the way to go. How should Xtext know, what the relevant information is? I won't suggest serialising the object as that is as stupid as it can get as an outline label.


Need training, onsite consulting or any other kind of help for Xtext?
Go visit or send a mail to
Previous Topic:Beginner problem
Next Topic:Cross referencing from Xtext to Xmi
Goto Forum:

Current Time: Sat Sep 19 12:39:13 GMT 2020

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

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

Back to the top