eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[uml] static operation ignored #1812

Closed eclipse-ocl-bot closed 1 month ago

eclipse-ocl-bot commented 1 month ago

| --- | --- | | Bugzilla Link | 512553 | | Status | RESOLVED FIXED | | Importance | P3 normal | | Reported | Feb 22, 2017 04:48 EDT | | Modified | Mar 17, 2017 13:12 EDT | | Reporter | Ed Willink |

Description

From the OCL newsgroup: Custom static operation


Here is the sample model:

<?xml version="1.0" encoding="UTF-8"?>\

\ \ \ \ \ \ \ OCL\ Person.isFound('John')\ \ \ \ \ \ \ \ \ \ \ \ The class Person has static operation isFound. I open Xtext OCL console and write the following expressions: Evaluating:\ test::Person.isFound('John')\ Results:\ Parsing failure 1: Unresolved Static Operation 'test::Person::isFound('John')' Why is the operation unresolved? Evaluating:\ test::Person::isFound('John')\ Results:\ Failed to evaluate 'test::Person::isFound(String[1]) : Boolean[1]' for 'Person' and 'self.isFound('John')'\ java.lang.UnsupportedOperationException The operation isn't implemented so I get the exception. But why is the operation interpreted as non-static 'self.isFound('John')'?
eclipse-ocl-bot commented 1 month ago

By Ed Willink on Feb 22, 2017 05:35

Main problem is that, oops, UML2AS does not copy the isStatic attribute so there isu actually a non-static isFound method when OCL syntax/semantic checks.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Feb 22, 2017 05:56

Once the isStatic copying is added to UML2AS (and AS2UML) for Operations (and Properties), and a body is added to the test the testConsole_Bug512553() JUnit test demonstrates that the operation is parsed and executes too.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Feb 22, 2017 07:45

Pushed to master for M6.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Mar 17, 2017 07:35

(In reply to Ed Willink from comment #2)

JUnit test demonstrates that the operation is parsed and executes too.

But on closer inspection the "::" / "." is wrong.

test::Person::isFound('John')

is a correct static invocation (test checks for parse fail)

test::Person.isFound('John')

which the test checks is a compatibility static invocation that enables allInstances() to work.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Mar 17, 2017 13:12

Problem is that null rather than the static type is passed to EssentialOCLCSLeft2RightVisitor.getInvocations as the fallback static typeValue.

Pushed to master for M7.