use icon indicating copy to clipboard operation
use copied to clipboard

UseModelApi: Lacks of `self` for attributes in OCL Expression

Open ichxorya opened this issue 1 year ago • 1 comments

Describe the bug Unable to automatically find the self of USE Class attributes.

To Reproduce Using Use Model Api:

  • Create a class.
  • Add some attributes to it.
  • Write an OCL expression related to the class (that makes use of the attributes).
  • Parse it with createPrePostCondition or createQueryOperation.

Expected behavior Any .use specification can automatically understand the context (the attributes inside the class are automatically tagged self)

But while using the api, the selfs must be defined already to be able to parse.

Screenshots image image image image

It is runnable if I add self to the constraints: image

Desktop (please complete the following information):

  • OS: Windows 10
  • Java Version: OpenJDK17
  • USE version: 7.1.0

Note

I'm developing an USE extension that parse non-use specifications.

ichxorya avatar May 08 '24 09:05 ichxorya

Thanks for submitting the issue. I was able to reproduce the behavior to confirm the bug. The ModelAPI uses the OCLCompiler to create the Pre- and Postconditions, which is wrong.

If you need to proceed with your work, before the bug has been fixed, I suggest to have a look at the method ASSLCompiler::compileInvariants. It creates invariants, but conceptually it is the same. The key point their is, it uses a Context instead of a SymTable as it is done in OCLCompiler::compileExpression

h-man2 avatar May 13 '24 15:05 h-man2

A fix is available in #78. You can try it out with the results of the build.

h-man2 avatar May 24 '24 14:05 h-man2

Thank you, I'd try if asap

ichxorya avatar May 26 '24 11:05 ichxorya