Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Trigger validator(builder) for multiple files(Trigger validator(or builder) for multiple files/ validator rules over multiple files)
Trigger validator(builder) for multiple files [message #1850343] Fri, 25 February 2022 15:35 Go to next message
Marvin Dongus is currently offline Marvin DongusFriend
Messages: 8
Registered: February 2022
Junior Member
Hello,
i have written a Validator rule that compare IDs over multiple Files. But if i edit only one of those files the Validator runs only over one file. The references that i compare between the other files can't be found if they not edited.

My grammar ist splittet into two branches. One is kind of a programm definition and the other one is linke class definitions.
My validator and all references work totally fine if i write the whole DSL in one file.

I think i could solve my problem if i could run the Validator(and or the builder) over all files (even the haven't been edited).

Re: Trigger validator(builder) for multiple files [message #1850350 is a reply to message #1850343] Fri, 25 February 2022 20:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7517
Registered: July 2009
Senior Member
Hi

I think you are looking for what I call the load-the-world approach so that whatever is needed is available for free.

Superficially this is really friendly, but only for small applications. It scales very very badly. Just imagine a 'friendlier' version of Java that didn't need import statements because everything was loaded automagically. Once a very slow startup of load-the-world had completed, and provided you don't run out of memory, you could then get down to fighting the prolific class name ambiguities by putting an explicit package qualification on every globally ambiguous reference, rather than resolving 99% of them once with an import. I have at least ten 'Element' classes in my classpath, but rarely want more than one of them. imports may be a pain but they make things deterministic and efficient.

Unfortunately Xtext / MWE2 pursue the load-the-world approach . In MWE2 a really confusing situations occurred when you cloned File1.mwe2 as File2.mwe2 but neglected to change the internal module declaration. You could run File2 but magically it looked for its own name and executed the old File1.

I cannot recommend too strongly that you use an import statement to load precisely what you need.

Regards

Ed Willink
Re: Trigger validator(builder) for multiple files [message #1850352 is a reply to message #1850350] Fri, 25 February 2022 21:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
Look at the affected calculation in iresourcedescription manager and clustering builder state as starting point

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trigger validator(builder) for multiple files [message #1850483 is a reply to message #1850352] Fri, 04 March 2022 15:12 Go to previous messageGo to next message
Marvin Dongus is currently offline Marvin DongusFriend
Messages: 8
Registered: February 2022
Junior Member
Hi,
i have done some research about the iresourcedescription manager.
I found a blog post(link below), that explains how to implement a custom IResourceDescriptionStrategy with a custom GlobalScopeProvider.

I'm now able to use an include instruction to include other DSL-files in the source folder, but my main problem isn't affected.

My cross references are only solved if both files are edited and saved. If one of the two files is not edited the cross references are not solved correct.

Maybe my scopeProvider could be the Problem.
Could the cross references influenced though my scopeProvider an cause this strange behavior?

blog post( but in German): https://blogs.itemis.com/in-5-minuten-zur-dsl-mit-transitiven-importen-in-xtext



[Updated on: Fri, 04 March 2022 15:52]

Report message to a moderator

Re: Trigger validator(builder) for multiple files [message #1850485 is a reply to message #1850483] Fri, 04 March 2022 16:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
can you please give a more concrete example on the kind of dependency you have and what the criteria is file a and file b relate to each other?
and if file a changes,
why should file b rebuilt, but file c should not.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 04 March 2022 16:04]

Report message to a moderator

Re: Trigger validator(builder) for multiple files [message #1850486 is a reply to message #1850485] Fri, 04 March 2022 16:42 Go to previous messageGo to next message
Marvin Dongus is currently offline Marvin DongusFriend
Messages: 8
Registered: February 2022
Junior Member
Hi,
they are both building correct. The only problems occur in the context of the cross references. If both files are edited and saved the cross references working fine. If on is unedited the cross references can't be found.

Grammar:
My grammar have two main branches, a programm description or a class definition.
In the programm description class methodes can be called. A scopeProvider provide the method names for the dotExpression. The classes und the methods are defined in a seperated file.

The two brances of the Grammar:
Programm:
(programm = Programmdefinition) | (classDefinitions += ClassDefinition)
;

ClassDefinition:
'define' 'class' name=ID
'{'
classBody += ClassBody;
'}'
;

ClassBody:
DefineClassFunction | .... | ClassDefinition
;

DefineClassFunction
'define' 'Function' returnType = ( Datatype | 'void') name = ID '(' ... ')'
'{'
...
'}'
;

Programmdefinition:
'call' 'Function' ref = FunctionDotExpression '(' ... ')'
;

FunctionDotExpression returns Ref:
ClassRef ({FunctionDotExpression .ref=current} "." tail=[DefineClassFunction])*
;

ClassRef returns Ref:
{ClassRef } ClassRef =[ClassDefinition]
;

The site where i got my ScopeProvider. (I have done some slightly canges for my application): https://dietrich-it.de/xtext/2013/05/18/xtext-and-dot/path-expressions/


[Updated on: Fri, 04 March 2022 16:42]

Report message to a moderator

Re: Trigger validator(builder) for multiple files [message #1850494 is a reply to message #1850486] Sat, 05 March 2022 06:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
In the Case the affected calculation should say yes.
Why does it say no


Can you give two sample models and thenexact edit operation you do


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 05 March 2022 06:14]

Report message to a moderator

Re: Trigger validator(builder) for multiple files [message #1850544 is a reply to message #1850494] Tue, 08 March 2022 09:55 Go to previous messageGo to next message
Marvin Dongus is currently offline Marvin DongusFriend
Messages: 8
Registered: February 2022
Junior Member
Hi,
what do you meant with edit operation?

If you meant my exact scope provider:

class DslScopeProvider extends AbstractDeclarativeScopeProvider
{
override getScope(EObject context, EReference reference)
{
if(reference == DslPackage.Literals.FUNCTION_DOT_EXPRESSION__TAIL){
if (context instanceof FunctionDotExpression)
{
val head = context.ref;
switch (head) {
ClassRef : {
if(null !== head.ClassRef.module){
return Scopes::scopeFor(head.ClassDefinitionRef.module.ClassBody.filter(DefineClassFunction))
}else{
return IScope::NULLSCOPE
}
}
FunctionDotExpression : {
val tail = head.tail
switch (tail) {
ClassDefinition: {
if(null !== tail.classBody){
return Scopes::scopeFor(tail.ClassBody.filter(DefineClassFunction))
}else{
return IScope::NULLSCOPE
}
}
default: return IScope::NULLSCOPE
}
}
default: return IScope::NULLSCOPE
}
}
}
return super.getScope(context, reference)
}
}

Maybe i have used the wrong reverence and context, but the scope provider is working correctly.
Re: Trigger validator(builder) for multiple files [message #1850547 is a reply to message #1850544] Tue, 08 March 2022 10:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
no

example file a, the one you edit, the thing you change
example file b, which should be rebuild
example file c, this should not be rebuild, what is difference between b and c


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trigger validator(builder) for multiple files [message #1850548 is a reply to message #1850547] Tue, 08 March 2022 10:11 Go to previous messageGo to next message
Marvin Dongus is currently offline Marvin DongusFriend
Messages: 8
Registered: February 2022
Junior Member
Hi,
oh okey that's easy. To avoid the problem with my unsolved cross references i edit one file in the way that i enter a space. The file is now "edited" an the *appere on the file titele. Because of this i don't change reely something on my DSL file.

[Updated on: Tue, 08 March 2022 13:42]

Report message to a moderator

Re: Trigger validator(builder) for multiple files [message #1850600 is a reply to message #1850548] Wed, 09 March 2022 16:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
yes but you should adjust affected calculation. but with you give zero information i cannot tell you how.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trigger validator(builder) for multiple files [message #1850615 is a reply to message #1850343] Thu, 10 March 2022 10:09 Go to previous messageGo to next message
Marvin Dongus is currently offline Marvin DongusFriend
Messages: 8
Registered: February 2022
Junior Member
Hi,
sorry. I have done some research about the affected calculation because i didn't know anything about it.
I haven't touched the IDefaultResourceDescriptionStrategy and the IResourceDescription.Manager. I use the default implementation. I didn't change any settings.

If you have to know somithing else about my project. Just tell me. I haven't delved so deeply into the xtext frameworke.
Re: Trigger validator(builder) for multiple files [message #1850619 is a reply to message #1850615] Thu, 10 March 2022 12:48 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
i want this from you

a.dsl
entity person {}


b.dsl2
thing x uses person


c.dsl2
thing y


when i now change entity person and rename it to person2, then x will get red and will be validated, this is cause it has relation to person
y will not get validated, cause there is relation to person


what is your a.dsl and b.dsl2 and c.dsl2 and why should your b.dsl2 be valiated and your c.dsl2 should not be validated


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Data annotation overrides toString from parent class
Next Topic:Language server not responding to client request
Goto Forum:
  


Current Time: Sun Sep 25 07:58:22 GMT 2022

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

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

Back to the top