Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Why there is an additional .smap file when code are automatically generated?(xtext Code file .smap )
icon5.gif  Why there is an additional .smap file when code are automatically generated? [message #1032250] Tue, 02 April 2013 19:23 Go to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I am following the "domain-model" tutorial.I create the ".dmodel" file in the run-time eclipse, after I save the ".dmodel" file, some files are automatically generated in the src_gen directory. But why there is an additional file ".smap" file in the same file directory? Is everything normal, or there are some mistakes in my projects?

The content of the ".dmodel" file is as follows:

import java.util.List

package my.model {

entity Person {
name: String
firstName: String
friends: List<Person>
address : Address
op getFullName() : String {
var age = 15;
if (age > 12)
{
age =10;
}

return firstName + " " + name;
}

op getFriendsSortedByFullName() : List<Person> {
return friends.sortBy[ f | f.fullName ]
}
}

entity Address {
street: String
zip: String
city: String
}
}


The automatically generated "Person.java" file is as follows:

package my.model;

import java.util.List;
import my.model.Address;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.util.ToStringHelper;

public class Person {
public Person() {
}

public Person(final Procedure1<Person> initializer) {
initializer.apply(this);
}

private String name;

public String getName() {
return this.name;
}

public void setName(final String name) {
this.name = name;
}

private String firstName;

public String getFirstName() {
return this.firstName;
}

public void setFirstName(final String firstName) {
this.firstName = firstName;
}

private List<Person> friends;

public List<Person> getFriends() {
return this.friends;
}

public void setFriends(final List<Person> friends) {
this.friends = friends;
}

private Address address;

public Address getAddress() {
return this.address;
}

public void setAddress(final Address address) {
this.address = address;
}

public String getFullName() {

int age = 15;
boolean _greaterThan = (age > 12);
if (_greaterThan) {
age = 10;
}
String _plus = (this.firstName + " ");
return (_plus + this.name);
}

public List<Person> getFriendsSortedByFullName() {

final Function1<Person,String> _function = new Function1<Person,String>() {
public String apply(final Person f) {
String _fullName = f.getFullName();
return _fullName;
}
};
return IterableExtensions.<Person, String>sortBy(this.friends, _function);
}

@Override
public String toString() {
String result = new ToStringHelper().toString(this);
return result;
}
}


The additonal "Person.smap" file as as follows:

SMAP
Person.java
Domainmodel
*S Domainmodel
*F
+ 0 NewTryFile.dmodel
src/NewTryFile.dmodel
*L
11:60
12:61,2
14:63
12:64
17:65,2
21:71,7
*E

Thank you in advance!

Re: Why there is an additional .smap file when code are automatically generated? [message #1032254 is a reply to message #1032250] Tue, 02 April 2013 19:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

this allows you to debug the dsl file.

~Christian
Re: Why there is an additional .smap file when code are automatically generated? [message #1032630 is a reply to message #1032254] Wed, 03 April 2013 08:27 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you very much for your reply!
Do you mean the "dsl file" the ".text" files?
Could you please provide more information how to use the ".smap" file to debug the "dsl file"
Re: Why there is an additional .smap file when code are automatically generated? [message #1032654 is a reply to message #1032630] Wed, 03 April 2013 09:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Sorry this is too much to explain

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Why there is an additional .smap file when code are automatically generated? [message #1032662 is a reply to message #1032654] Wed, 03 April 2013 09:13 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
OK! Anyway, at the moment, I do not need to debug the files.
Maybe I can understand much more when I need to use it.
Re: Why there is an additional .smap file when code are automatically generated? [message #1036689 is a reply to message #1032662] Mon, 08 April 2013 17:32 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 601
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 03.04.13 02.13, Hao Zhang wrote:
> OK! Anyway, at the moment, I do not need to debug the files.
> Maybe I can understand much more when I need to use it.

The smap file provides a mapping from (DSL) source code lines to the
Java (byte) code in a standard way. I think the Eclipse debug system
supports this, so it can refer to the proper source when stepping
through (what essentially is) Java byte code.

Hallvard
Re: Why there is an additional .smap file when code are automatically generated? [message #1036737 is a reply to message #1036689] Mon, 08 April 2013 18:46 Go to previous message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Hi Hallvard

Thank you!
Sounds cool, although I haven't had chance to debug the dsl file and the java code file together.
Previous Topic:XbaseCompiler creating new objects for this access
Next Topic:Use Tab and Enter for Scobe
Goto Forum:
  


Current Time: Sun Dec 21 01:57:07 GMT 2014

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

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