|
|
Re: unit test language with JavaVMTypes [message #754897 is a reply to message #754886] |
Fri, 04 November 2011 20:19 |
|
Hi,
how does your test class look like? this works for me
@RunWith(XtextRunner.class)
@InjectWith(MyDslInjectorProvider.class)
public class TheTest {
@Inject
private ParseHelper<Model> parseHelper;
@Test
public void test() throws Exception {
Model model = parseHelper.parse("map string to java.lang.String");
for (Mapping mapping : model.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
as well as this
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new
MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("src/test.mydsl"), true);
r.load(null);
Model m = (Model) r.getContents().get(0);
for (Mapping mapping : m.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
with
grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
Model:
mappings+=Mapping*;
Mapping:
'map' name=ID 'to' ref=[jvmTypes::JvmType|FQN];
FQN: ID ("." ID)*;
using Xtext 2.1.0 and a project created with the wizard.
~Christian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: unit test language with JavaVMTypes [message #754898 is a reply to message #754886] |
Fri, 04 November 2011 20:19 |
|
Hi,
how does your test class look like? this works for me
@RunWith(XtextRunner.class)
@InjectWith(MyDslInjectorProvider.class)
public class TheTest {
@Inject
private ParseHelper<Model> parseHelper;
@Test
public void test() throws Exception {
Model model = parseHelper.parse("map string to java.lang.String");
for (Mapping mapping : model.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
as well as this
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new
MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("src/test.mydsl"), true);
r.load(null);
Model m = (Model) r.getContents().get(0);
for (Mapping mapping : m.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
with
grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
Model:
mappings+=Mapping*;
Mapping:
'map' name=ID 'to' ref=[jvmTypes::JvmType|FQN];
FQN: ID ("." ID)*;
using Xtext 2.1.0 and a project created with the wizard.
~Christian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: unit test language with JavaVMTypes [message #754899 is a reply to message #754886] |
Fri, 04 November 2011 20:19 |
|
Hi,
how does your test class look like? this works for me
@RunWith(XtextRunner.class)
@InjectWith(MyDslInjectorProvider.class)
public class TheTest {
@Inject
private ParseHelper<Model> parseHelper;
@Test
public void test() throws Exception {
Model model = parseHelper.parse("map string to java.lang.String");
for (Mapping mapping : model.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
as well as this
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new
MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("src/test.mydsl"), true);
r.load(null);
Model m = (Model) r.getContents().get(0);
for (Mapping mapping : m.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
with
grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
Model:
mappings+=Mapping*;
Mapping:
'map' name=ID 'to' ref=[jvmTypes::JvmType|FQN];
FQN: ID ("." ID)*;
using Xtext 2.1.0 and a project created with the wizard.
~Christian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: unit test language with JavaVMTypes [message #754900 is a reply to message #754886] |
Fri, 04 November 2011 20:19 |
|
Hi,
how does your test class look like? this works for me
@RunWith(XtextRunner.class)
@InjectWith(MyDslInjectorProvider.class)
public class TheTest {
@Inject
private ParseHelper<Model> parseHelper;
@Test
public void test() throws Exception {
Model model = parseHelper.parse("map string to java.lang.String");
for (Mapping mapping : model.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
as well as this
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new
MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("src/test.mydsl"), true);
r.load(null);
Model m = (Model) r.getContents().get(0);
for (Mapping mapping : m.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
with
grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
Model:
mappings+=Mapping*;
Mapping:
'map' name=ID 'to' ref=[jvmTypes::JvmType|FQN];
FQN: ID ("." ID)*;
using Xtext 2.1.0 and a project created with the wizard.
~Christian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: unit test language with JavaVMTypes [message #754901 is a reply to message #754886] |
Fri, 04 November 2011 20:19 |
|
Hi,
how does your test class look like? this works for me
@RunWith(XtextRunner.class)
@InjectWith(MyDslInjectorProvider.class)
public class TheTest {
@Inject
private ParseHelper<Model> parseHelper;
@Test
public void test() throws Exception {
Model model = parseHelper.parse("map string to java.lang.String");
for (Mapping mapping : model.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
as well as this
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new
MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("src/test.mydsl"), true);
r.load(null);
Model m = (Model) r.getContents().get(0);
for (Mapping mapping : m.getMappings()) {
System.out.println(mapping.getName() + " => " +
mapping.getRef().getQualifiedName());
}
}
}
with
grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
Model:
mappings+=Mapping*;
Mapping:
'map' name=ID 'to' ref=[jvmTypes::JvmType|FQN];
FQN: ID ("." ID)*;
using Xtext 2.1.0 and a project created with the wizard.
~Christian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04925 seconds