Home » Modeling » OCL » "misplaced contructs" using second import statement
| |
Re: "misplaced contructs" using second import statement [message #1187855 is a reply to message #1081628] |
Fri, 15 November 2013 10:06 |
Stefan Mijatov Messages: 59 Registered: March 2010 Location: Vienna, Austria |
Member |
|
|
@Edit
Hi Ed, Hi Jens,
I have found the problem: I omitted the package declaration.
Furthermore, I also forgot to give complete qualified name declaration of the context class.
Now everything works perfect, and I include new version of the project for anyone who might end up with similar or same problem..
Best regards,
Stefan
------------------------------------------------------------------------------------
Hi Ed, Hi Jens,
I am not sure I understand the solution to this problem
I am using Eclipse Juno and have the simple project where I am loading my dinamic instance model from XMI file and OCL constraint from an ocl file.
I Included the whole project here.
What the problem is, is that when I call parse() method of OCL class on my input ocl file, I get the error with the import declaration being the problem:
StackTrace:
org.eclipse.ocl.SyntaxException: 1:1:1:55 "import 'platform:/resource/example/model/example.ecore'" misplaced construct(s)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:356)
at org.eclipse.ocl.OCL.parse(OCL.java:323)
at ocl.ExampleOclUtil.getConstraints(ExampleOclUtil.java:39)
at ocl.Main.main(Main.java:19)
Could you please explain to me why and how to solve this issue?
Thanks in advance,
Stefan
[Updated on: Fri, 15 November 2013 10:48] Report message to a moderator
|
|
|
Re: "misplaced contructs" using second import statement [message #1187991 is a reply to message #1187855] |
Fri, 15 November 2013 11:36 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
Well done; a repro I can load quickly, even if I had to guess to run main.
If you open Model.ocl with the Complete OCL editor, you will see your
problem. You need to specify the package path either as
import 'platform:/resource/example/model/example.ecore'
context example::ClassA
inv bIsSet: classB->size()>0
or
import 'platform:/resource/example/model/example.ecore'
package example
context ClassA
inv bIsSet: classB->size()>0
endpackage
Unfortunately OMG OCL does not yet specify an import statement, so
import is an extension supported by the new code, based on a neutral
Pivot model that is used by the editors, or by using
org.eclipse.ocl.examples.pivot.OCL rather than
org.eclipse.ocl.ecore.OCL. The traditional code relies on a correctly
initialized registry just as your code does. For compatibility the
traditional parser ignores new-style imports. Unfortunately seemingly
only when there is an explicit package.
So if you change your Model.ocl to
import 'platform:/resource/example/model/example.ecore'
package example
context ClassA
inv bIsSet: classB->size()>0
endpackage
you're good to go.
Regards
Ed Willink
On 15/11/2013 10:06, Stefan Mijatov wrote:
> Hi Ed, Hi Jens,
>
> I am not sure I understand the solution to this problem :)
>
> I am using Eclipse Juno and have the simple project where I am loading my dinamic instance model from XMI file and OCL constraint from an ocl file.
> I Included the whole project here.
>
> What the problem is, is that when I call parse() method of OCL class on my input ocl file, I get the error with the import declaration being the problem:
>
> StackTrace:
>
> org.eclipse.ocl.SyntaxException: 1:1:1:55 "import 'platform:/resource/example/model/example.ecore'" misplaced construct(s)
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:356)
> at org.eclipse.ocl.OCL.parse(OCL.java:323)
> at ocl.ExampleOclUtil.getConstraints(ExampleOclUtil.java:39)
> at ocl.Main.main(Main.java:19)
>
> Could you please explain to me why and how to solve this issue? :)
>
> Thanks in advance,
> Stefan
|
|
| | | | |
Goto Forum:
Current Time: Thu Apr 25 17:39:26 GMT 2024
Powered by FUDForum. Page generated in 0.03813 seconds
|