Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Error with copy rule(Error message saying variable reference cannot be resolved)
Error with copy rule [message #1063814] Fri, 14 June 2013 11:11 Go to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 132
Registered: April 2013
Senior Member
Hello again,

trying to use the copy rule, I get the error message "Variable Reference 'DomainSpecificProblemStatement' cannot be resolved". The variable "DomainSpecificProblemStatement" is bound during a pattern matching that takes places before the copy statement, see the subsequent listing.

Thanks for any appreciated hints and kind regards, Alexander

---
namespace uml.models;
import uml.metamodel.uml;

machine SalaryStatementPCM2PCPTransformation
{
	rule main(in Model) =
	let DomainSpecificProblemContextModel = undef,
	    XDomainProblemContextPatternModel = undef,
	    Y                                 = undef in seq{
	new (Model(XDomainProblemContextPatternModel) in uml.models);
	rename(XDomainProblemContextPatternModel, "Cross-domain Problem Context Pattern Model");
	print("'Cross-domain Problem Context Pattern Model' created\n");
	choose DomainSpecificProblemStatement below uml.models
	 with find
	  isProblemStatement(DomainSpecificProblemStatement)
	 do print("Domain-specific problem statement '"
	          + name(DomainSpecificProblemStatement)
	          + "' in source model found");
copy(DomainSpecificProblemStatement,XDomainProblemContextPatternModel,Y,copy_boundary_edges);  
//    print(  "Domain-specific problem statement '"
//          + "name(DomainSpecificProblemStatement)'"
//          + " copied to '" + name(XDomainProblemContextPatternModel));  
    }
       
    pattern isProblemStatement(DomainSpecificProblemStatement) =
	{
	uml.metamodel.uml.Element(DomainSpecificProblemStatement);
	uml.metamodel.uml.Stereotype(StType);
    check(name(StType) == "PSL problem statement");
    uml.metamodel.uml.Element.appliedStereotype(AppliedST,DomainSpecificProblemStatement,StType);
	
	}	
} 

[Updated on: Fri, 14 June 2013 11:14]

Report message to a moderator

Re: Error with copy rule [message #1063821 is a reply to message #1063814] Fri, 14 June 2013 11:29 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
The variable declared in a choose ASM construct is local to the context of that choose. Your copy is outside that context and therefore even if the variable is the same name, it does not exist at that point.

You can do the following (put the copy inside the choose):
choose DomainSpecificProblemStatement below uml.models
 with find isProblemStatement(DomainSpecificProblemStatement)
 do seq{ // execute a sequence of ASM rules
  print("Domain-specific problem statement '"
    + name(DomainSpecificProblemStatement)+ "' in source model found");
  copy(DomainSpecificProblemStatement,XDomainProblemContextPatternModel,
    Y,copy_boundary_edges);  
}

or (save the variable of choose)
let TempVar = undef in seq{
  choose DomainSpecificProblemStatement below uml.models
    with find isProblemStatement(DomainSpecificProblemStatement)
   do seq{ // execute a sequence of ASM rules
     print("Domain-specific problem statement '"
      + name(DomainSpecificProblemStatement)+ "' in source model found");
     update TempVar = DomainSpecificProblemStatement;
  }
  copy(TempVar,XDomainProblemContextPatternModel,
    Y,copy_boundary_edges); 
}
Re: Error with copy rule [message #1063836 is a reply to message #1063821] Fri, 14 June 2013 12:31 Go to previous messageGo to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 132
Registered: April 2013
Senior Member
Hi Ábel,


thanks for the explanation and the solution proposal - it works fine. There is a remaining issue, namely concerning the copied relations: Not all edges have been taken over. I am especially missing the relation "appliedStereotype" in my target model. Is this intended? If yes, what is the logic for this?

Thanks and kind regards, Alex
Re: Error with copy rule [message #1063843 is a reply to message #1063836] Fri, 14 June 2013 13:00 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
The copy rule with the semantics (copy_boundary_edges) selected by you should copy all relations.
Can you please check the following:
1, Are only relations of the copied element missing and not relations of any subelements?
2, Is only the appliedStereotype relation missing?

While the appliedStereotype relation should not be handled any differently, in any case a reproducable occurrence may indicate a bug in VIATRA2.
Re: Error with copy rule [message #1064154 is a reply to message #1063843] Mon, 17 June 2013 20:47 Go to previous messageGo to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 132
Registered: April 2013
Senior Member
Hello Ábel,

here are my check results:
1.) No, there are also relations of any subelements missing.
2.) No, besides this appliedStereotype relation also "owner", "namespace" as well as "ownedElement", "member", "ownedMember" and "packagedElement" are missing relations

Of course it would be very convenient to be able to get these relations with the copy.

Kind regards, Alex
Re: Error with copy rule [message #1064197 is a reply to message #1064154] Tue, 18 June 2013 08:23 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Hi Alex,

looking at the code, I found two things:
- the copy rule was not tested in the testing framework
- there seems to be an off-by-one error, where copy_boundary_edges is actually handled as skip_boundary_edges and the other way around

Can you try your transformation with the other value?
If that gives the expected results, I can change the code and you will be able to update when the build completes (if you use the nightly update site).

[Updated on: Tue, 18 June 2013 08:40] by Moderator

Report message to a moderator

Re: Error with copy rule [message #1066034 is a reply to message #1064197] Sat, 29 June 2013 08:02 Go to previous messageGo to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 132
Registered: April 2013
Senior Member
Hi Ábel,

I tried my transformation with the other value - and it looks good! It seems to give the complete expected results. Hence, it would be great if you changed the code.

Thanks in advance and kind regards, Alex
Re: Error with copy rule [message #1066061 is a reply to message #1066034] Sat, 29 June 2013 16:18 Go to previous message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Hi,

I have changed the code and the CI update sight should already include the fixed version.

Cheers
Previous Topic:Question concerning my use case for pattern search via EMF-IncQuery
Next Topic:Problems with another pattern I need to implement
Goto Forum:
  


Current Time: Fri Mar 29 07:58:35 GMT 2024

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

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

Back to the top