Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » validation invocation from the generator.Main
validation invocation from the generator.Main [message #772646] Fri, 30 December 2011 09:20 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

the generated Main class for invoking the generator of the DSL uses

@Inject
private IResourceValidator validator;

and calls validation as follows

// validate the resource
List<Issue> issues = validator.validate(resource, CheckMode.ALL,
CancelIndicator.NullImpl);

however, this will not use validation performed by the declarative
DSLJavaValidator

is that intentional?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #772650 is a reply to message #772646] Fri, 30 December 2011 09:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Hi Lorenzo,

i cannot reproduce this one.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #772655 is a reply to message #772650] Fri, 30 December 2011 09:53 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 10:40 AM, Christian Dietrich wrote:
> Hi Lorenzo,
>
> i cannot reproduce this one.
>
> ~Christian

Christian

do you mean that also the Java validator is invoked in your case?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #772657 is a reply to message #772655] Fri, 30 December 2011 10:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Jepp

here is what i get for the domain model example

WARNING:Name should start with a capital (test.mydsl line : 1)


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #772668 is a reply to message #772657] Fri, 30 December 2011 10:22 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 11:02 AM, Christian Dietrich wrote:
> Jepp
>
> here is what i get for the domain model example
>
> WARNING:Name should start with a capital (test.mydsl line : 1)
>
> ~Christian

Hi

then probably something is wrong in Junit tests (I'm experiencing this
problem in Junit tests): I do

@Override
protected void setUp() throws Exception {
super.setUp();
with(MyDslStandaloneSetup.class);
generator = get(Main.class);
}

but probably in Junit tests the Java validator is not registred
explicitly, is it? That's why for testing validators in Junit test we
must use ValidatorTester?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #772672 is a reply to message #772668] Fri, 30 December 2011 10:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Hi,

no this works good as well.

public class DummyTest extends AbstractXtextTests {
	
	private Main generator;

	@Override
	protected void setUp() throws Exception {
	super.setUp();
	with(MyDslStandaloneSetup.class);
	generator = get(Main.class);
	}
	
	@Test
	public void testIt() {
		generator.runGenerator("test.mydsl");
	}

}


but be careful, sometimes you destroy emf registries (e.g. the one for the validator)
accitentially in your tests. there where some bugs arround this too.
can you share a complete test case?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #772698 is a reply to message #772672] Fri, 30 December 2011 11:27 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 11:34 AM, Christian Dietrich wrote:
> Hi,
>
> no this works good as well.
>
> public class DummyTest extends AbstractXtextTests {
>
> private Main generator;
>
> @Override
> protected void setUp() throws Exception {
> super.setUp();
> with(MyDslStandaloneSetup.class);
> generator = get(Main.class);
> }
>
> @Test
> public void testIt() {
> generator.runGenerator("test.mydsl");
> }
>
> }
>
> but be careful, sometimes you destroy emf registries (e.g. the one for
> the validator)
> accitentially in your tests. there where some bugs arround this too.
> can you share a complete test case?

Hi

I'll try to provide enough information: I have a base class for tests

public class XtypesAbstractTests extends AbstractXtextTests {


@Override
protected void setUp() throws Exception {
super.setUp();
with(XtypesStandaloneSetup.class);
}

and then I have

public class XtypesGeneratorRunnerTests extends XtypesAbstractTests {
Main generator;

static {
System.setProperty("line.separator", "\n");
}

@Override
protected void setUp() throws Exception {
super.setUp();
generator = get(Main.class);
generator.setOutputPath(null);
}

Do you think it's the derived class which might destroy something?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #772703 is a reply to message #772698] Fri, 30 December 2011 11:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Nope,

this works as well. so can you share a complete test scenario that fails with the Greeting example.
a hint: try to debug the validation / the registry - is
there a point there stuff is removed from the registries?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #772704 is a reply to message #772703] Fri, 30 December 2011 11:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
P.s: with abstract xtext tests e.g. only one test method will work.
two will not.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #772705 is a reply to message #772704] Fri, 30 December 2011 11:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
PPs: when working on the same model

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #772744 is a reply to message #772704] Fri, 30 December 2011 13:34 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 12:41 PM, Christian Dietrich wrote:
> P.s: with abstract xtext tests e.g. only one test method will work.
> two will not.

Christian, I feel so stupid: I was running the test with a valid input
file, instead of the input file with errors... :)

so the problem is not there anymore... though I don't understand your
current answer...

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #772754 is a reply to message #772744] Fri, 30 December 2011 13:50 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 02:34 PM, Lorenzo Bettini wrote:
> On 12/30/2011 12:41 PM, Christian Dietrich wrote:
>> P.s: with abstract xtext tests e.g. only one test method will work.
>> two will not.
>
> Christian, I feel so stupid: I was running the test with a valid input
> file, instead of the input file with errors... :)
>
> so the problem is not there anymore... though I don't understand your
> current answer...

probably it's related to this: on another junit test, instead of using
AbstractXtextTests I'm using this class

@SuppressWarnings("all")
@InjectWith(XtypesInjectorProvider.class)
@RunWith(XtextRunner.class)
public class GeneratedJavaCodeTest ...

and I noted that by running a single test method my Java validator is
used, while running all test methods my Java validator is not used... I
don't have any setup method here...

is it related to what you said?

thanks in advance
Lorenzo


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #772809 is a reply to message #772754] Fri, 30 December 2011 16:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Yes,

would be nice if you file a ticket

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: validation invocation from the generator.Main [message #773100 is a reply to message #772809] Sat, 31 December 2011 13:38 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 05:45 PM, Christian Dietrich wrote:
> Yes,
>
> would be nice if you file a ticket
>
> ~Christian

I will, but I noted this behavior only with this usage

@InjectWith(XtypesInjectorProvider.class)
@RunWith(XtextRunner.class)
public class GeneratedJavaCodeTest ...

while you were referring to AbstractXtextTests too?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: validation invocation from the generator.Main [message #773102 is a reply to message #772809] Sat, 31 December 2011 13:44 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 12/30/2011 05:45 PM, Christian Dietrich wrote:
> Yes,
>
> would be nice if you file a ticket
>
> ~Christian

here it is

https://bugs.eclipse.org/bugs/show_bug.cgi?id=367679

cheers
Lore

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:arbitrary returns
Next Topic:How to generate annotations like @Table(name="MY_TABLE")
Goto Forum:
  


Current Time: Fri Apr 26 18:10:42 GMT 2024

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

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

Back to the top