Typesystem for own DSL [message #1283279] |
Thu, 03 April 2014 08:31 |
Alexander R Messages: 211 Registered: July 2013 |
Senior Member |
|
|
Hello everyone,
I am looking for a comfortable way to implement or integrate a typesystem for my DSL. After some research I found the following page:
http://code.google.com/a/eclipselabs.org/p/xtext-typesystem/
But I'm not really sure if it is possible to integrate this framework in my DSL without changing the whole grammer. My metamodel is about 80 metaclasses big and the grammer contains ~500 lines of code.
Maybe someone has any experiences with this framework and can give me a hint how to begin.
Regards,
Alex
[Updated on: Thu, 03 April 2014 09:16] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Typesystem for own DSL [message #1312856 is a reply to message #1310880] |
Thu, 24 April 2014 14:47 |
Alexander R Messages: 211 Registered: July 2013 |
Senior Member |
|
|
Hello,
I implemented an own solution for the getDescription()-operation. To achieve the same behavior I just implemented an own hover (see here: http://christiandietrich.wordpress.com/2011/07/16/hover-support-in-xtext-2-0-tutorial/). The hover action calculates me the same information as the (old) method mentioned before.
Here my solution:
@Inject
private ITypesystem ts;
@Inject
private IQualifiedNameProvider qfnp;
@Override
public String getDocumentation(EObject o) {
if (o instanceof MyTypes) {
HashMap<String, String> info = new HashMap<String, String>();
String traceString = "", finalString = "<ul>";
info.put("QName: ", qfnp.getFullyQualifiedName(o).getLastSegment());
info.put("Metaclass: ", o.eClass().getName());
TypeCalculationTrace trace = new TypeCalculationTrace();
EObject type = ts.typeof(o, trace);
if (type != null) {
info.put("Runtime Type: ", ts.typeString(type));
} else {
info.put("Runtime Type: ", "<no type>");
}
// trace calculation
for (String s : trace.toStringArray()) {
traceString += s;
}
// add the trace string
info.put("nTrace: ", traceString);
for (String key : info.keySet()) {
finalString += "<li>" + key + " " + info.get(key) + "</li>";
}
finalString += "</ul>";
return finalString;
}
return null;
}
~ Alex
|
|
|
Powered by
FUDForum. Page generated in 0.04427 seconds