Skip to main content



      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 08:21 Go to next message
Eclipse UserFriend

I am currently working on building an IDE for ATS (www.ats-lang.org). 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 "http://www.Test1.org"

program:
	m1=ent1
	m2=ent2
;

ent1:
	m=ab
;

ent2:
	m=cd
;

ab:
	'a'|'b'
;

cd:
	'c'|'d'
;
=======================

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 10:28 Go to previous message
Eclipse UserFriend
Hi,

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.

Alex
Previous Topic:Beginner problem
Next Topic:Cross referencing from Xtext to Xmi
Goto Forum:
  


Current Time: Sun Jul 06 09:41:03 EDT 2025

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

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

Back to the top