Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extending OCL MDT using Xtext(Import problem)
Extending OCL MDT using Xtext [message #908955] Thu, 06 September 2012 05:46 Go to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Dear all,
I try to extend OCL MDT (in my specific context) using xtext.
Briefly,
I define this grammar (I make just the import part)
grammar fa.zy.myocl.MyOCL with org.eclipse.ocl.examples.xtext.completeocl.CompleteOCL

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/ocl/3.1.0/Pivot" as pivot
import "http://www.eclipse.org/ocl/3.1.0/EssentialOCLCST" as essentialocl
import "http://www.eclipse.org/ocl/3.1.0/CompleteOCLCST" as completeocl
import "platform:/resource/fa.zy.myocl/model/MyOCLCST.ecore"


in the workflow, I define:

Workflow {
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
registerGeneratedEPackage = "org.eclipse.ocl.examples.pivot.PivotPackage"
registerGeneratedEPackage = "org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.EssentialOCLCSTPackage"
registerGeneratedEPackage = "org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.CompleteOCLCSTPackage"
registerGenModelFile = "platform:/resource/fa.zy.myocl/model/MyOCLCST.genmodel"
}

I have this famous problem:
2257 [main] ERROR ipse.xtext.generator.LanguageConfig  - [
TransformationDiagnostic: null:11 Cannot find compatible feature oImport in sealed EClass MyOCLDocumentCS from imported package http://www.eclipse.org/myocl/MyOCLCST: The type 'MyOCLDocumentCS' does not have a feature 'oImport'. (ErrorCode: CannotCreateTypeInSealedMetamodel), 
--It repeated for each model element--
2265 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems instantiating module org.xtext.ocl.temporalocl.TemporalOCL: java.lang.reflect.InvocationTargetException 


Please Help me
thanks
Re: Extending OCL MDT using Xtext [message #908967 is a reply to message #908955] Thu, 06 September 2012 06:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

You seem to have replicated the OCL editors build quite closely, but you
have omitted something like

registerGeneratedEPackage = "fa.zy.myocl.myOCLCST.MyOCLCSTPackage"

Regards

Ed Willink


On 06/09/2012 10:46, Fy Za wrote:
> Dear all,
> I try to extend OCL MDT (in my specific context) using xtext.
> Briefly,
> I define this grammar (I make just the import part)
>
> grammar fa.zy.myocl.MyOCL with
> org.eclipse.ocl.examples.xtext.completeocl.CompleteOCL
>
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
> import "http://www.eclipse.org/ocl/3.1.0/Pivot" as pivot
> import "http://www.eclipse.org/ocl/3.1.0/EssentialOCLCST" as essentialocl
> import "http://www.eclipse.org/ocl/3.1.0/CompleteOCLCST" as completeocl
> import "platform:/resource/fa.zy.myocl/model/MyOCLCST.ecore"
>
>
> in the workflow, I define:
>
> Workflow {
> bean = StandaloneSetup {
> scanClassPath = true
> platformUri = "${runtimeProject}/.."
> registerGeneratedEPackage =
> "org.eclipse.ocl.examples.pivot.PivotPackage"
> registerGeneratedEPackage =
> "org.eclipse.ocl.examples.xtext.essentialocl.essentialOCLCST.EssentialOCLCSTPackage"
> registerGeneratedEPackage =
> "org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.CompleteOCLCSTPackage"
> registerGenModelFile =
> "platform:/resource/fa.zy.myocl/model/MyOCLCST.genmodel"
> }
>
> I have this famous problem:
>
> 2257 [main] ERROR ipse.xtext.generator.LanguageConfig - [
> TransformationDiagnostic: null:11 Cannot find compatible feature
> oImport in sealed EClass MyOCLDocumentCS from imported package
> http://www.eclipse.org/myocl/MyOCLCST: The type 'MyOCLDocumentCS' does
> not have a feature 'oImport'. (ErrorCode:
> CannotCreateTypeInSealedMetamodel), --It repeated for each model
> element--
> 2265 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems
> instantiating module org.xtext.ocl.temporalocl.TemporalOCL:
> java.lang.reflect.InvocationTargetException
>
> Please Help me
> thanks
>
Re: Extending OCL MDT using Xtext [message #909056 is a reply to message #908967] Thu, 06 September 2012 09:13 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Thanks you for reply.
I add the registerGeneratedEPackage:
registerGeneratedEPackage = "myOCLCST.MyOCLCSTPackage"


and I has this good info:
491  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'temporalOCLCST.TemporalOCLCSTPackage'
839  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/tocl/TemporalOCLCST' from 'platform:/resource/fr.enseeiht.temporalocl/model/TemporalOCLCST.genmodel'

which means that the EPAckage was found.

However, the problem still exists Sad

In my grammar, I have some elements that don't exist in the imported ecore "MyOCLCST.ecore"
So, for each one, I have this message:
TransformationDiagnostic: null:11 Cannot find compatible feature elementImport in sealed EClass MyOCLDocumentCS from imported package http://www.eclipse.org/myocl/MyOCLCST: The type 'MyOCLDocumentCS' does not have a feature 'elementImport'. (ErrorCode: CannotCreateTypeInSealedMetamodel),


How can I resolve this problem without touching the grammar?

Please help me
Thanks

Re: Extending OCL MDT using Xtext [message #909071 is a reply to message #909056] Thu, 06 September 2012 09:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

On 06/09/2012 14:13, Fy Za wrote:
>
> In my grammar, I have some elements that don't exist in the imported
> ecore "MyOCLCST.ecore"
> So, for each one, I have this message:
>
That doesn't make sense. Your grammar must use the 'same' meta-model as
the rest of the tooling.

The error messages are therefore correct. You must add the elements you use.

Regards

Ed Willink
Re: Extending OCL MDT using Xtext [message #909478 is a reply to message #909071] Fri, 07 September 2012 03:55 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Thank you for reply.
However, In the CompleteOCL of OCL MDT,
I find in the grammar some elements that don't exist in metamodel.
for example, I find the following rule:

CompleteOCLDocumentCS returns CompleteOCLDocumentCS:
	(ownedImport+=ImportCS | ownedInclude+=IncludeCS | ownedLibrary+=LibraryCS)*
	(packages+=PackageDeclarationCS | contexts+=ContextDeclCS)*;


but, in the CompleteOCL.ecore, we have:
  <eClassifiers xsi:type="ecore:EClass" name="CompleteOCLDocumentCS" eSuperTypes="../../org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore#//PackageCS ../../org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore#//RootCS">
    <eStructuralFeatures xsi:type="ecore:EReference" name="packages" upperBound="-1"
        eType="#//PackageDeclarationCS" containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="contexts" upperBound="-1"
        eType="#//ContextDeclCS" containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="ownedInclude" upperBound="-1"
        eType="#//IncludeCS" containment="true"/>
  </eClassifiers>


So the grammar use the ecore and extend it. And this is what I would like to do.

Thanks
Re: Extending OCL MDT using Xtext [message #909504 is a reply to message #909478] Fri, 07 September 2012 04:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

I think you mean CompleteOCLCST.ecore which extends BaseCST.ecore.

CompleteOCLDocumentCS has PackageCS and RootCS as supertypes. These
provide the 'missing' features.

So as you can see CompleteOCLCST.ecore extends EssentialOCLCST.ecore
which extends BaseCST.ecore.

You can extend further or differently.

Regards

Ed Willink

On 07/09/2012 08:55, Fy Za wrote:
> Thank you for reply.
> However, In the CompleteOCL of OCL MDT,
> I find in the grammar some elements that don't exist in metamodel.
> for example, I find the following rule:
>
>
> CompleteOCLDocumentCS returns CompleteOCLDocumentCS:
> (ownedImport+=ImportCS | ownedInclude+=IncludeCS |
> ownedLibrary+=LibraryCS)*
> (packages+=PackageDeclarationCS | contexts+=ContextDeclCS)*;
>
>
> but, in the CompleteOCL.ecore, we have:
>
> <eClassifiers xsi:type="ecore:EClass" name="CompleteOCLDocumentCS"
> eSuperTypes="../../org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore#//PackageCS
> ../../org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore#//RootCS">
> <eStructuralFeatures xsi:type="ecore:EReference" name="packages"
> upperBound="-1"
> eType="#//PackageDeclarationCS" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="contexts"
> upperBound="-1"
> eType="#//ContextDeclCS" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="ownedInclude" upperBound="-1"
> eType="#//IncludeCS" containment="true"/>
> </eClassifiers>
>
>
> So the grammar use the ecore and extend it. And this is what I would
> like to do.
>
> Thanks
>
Re: Extending OCL MDT using Xtext [message #909533 is a reply to message #909504] Fri, 07 September 2012 05:33 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Thank you for reply.
I don't understand what are essential steps to extend CompleteOCL using Xtext
with the same appraoch that completeOCL extend essentialOCL!!!!
Can you please explain to me some ideas?

I should create an emf project (MyOCL)??
I should create an simple xtext project(not importing ecore)??
etc.

Thanks

Re: Extending OCL MDT using Xtext [message #909607 is a reply to message #909533] Fri, 07 September 2012 08:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

I deleted my original reply to your question because on re-reading you
had done nearly everything right. But perhaps you are encountering
https://bugs.eclipse.org/bugs/show_bug.cgi?id=366476.

For my development I use only the platform:/resource form of import
since I can control the URI resolution.

For the nsURI style

import "http://www.eclipse.org/ocl/3.1.0/Pivot" as pivot

there is an opportunity for Xtext to be helpful and resolve the nsURI
automatically. Sadly this kind of help is often counterproductive in the
long term. You have to struggle with incompatibilities between one
uncontrollable algorithm in the editor and a different controllable
algorithm in the builder.

I recommend that you check out the OCL Xtext projects from GIT so that
you can use platform:/resource.

For instance for QVTcore that is an independent project the imports are

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import
"platform:/resource/org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore"
as base
import
"platform:/resource/org.eclipse.ocl.examples.xtext.essentialocl/model/EssentialOCLCST.ecore"
as essentialocl
import
"platform:/resource/org.eclipse.ocl.examples.pivot/model/Pivot.ecore" as
pivot
import
"platform:/resource/org.eclipse.qvtd.pivot.qvtbase/model/QVTbase.ecore"
as qvtbase
import
"platform:/resource/org.eclipse.qvtd.pivot.qvtcore/model/QVTcore.ecore"
as qvtcore
import
"platform:/resource/org.eclipse.qvtd.xtext.qvtcore/model/QVTcoreCST.ecore"

Regards

Ed Willink




On 07/09/2012 10:33, Fy Za wrote:
> Thank you for reply.
> I don't understand what are essential steps to extend CompleteOCL
> using Xtext with the same appraoch that completeOCL extend
> essentialOCL!!!!
> Can you please explain to me some ideas?
>
> I should create an emf project (MyOCL)??
> I should create an simple xtext project(not importing ecore)??
> etc.
>
> Thanks
>
>
Re: Extending OCL MDT using Xtext [message #910719 is a reply to message #909607] Mon, 10 September 2012 05:21 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Dear Ed,
thank you for reply.
I tried to use exactly the same approach as developing CompleteOCL,
In Eclipse Juno, I

1) create xtext project

2)import plugins dependencies (org....completeocl_3.2.0, org.essentialocl_3.2.0,
org........base_3.2.0 and org......pivot_3.2.0)

3)create a new folder named model and I put in my .ecore

4)I generate the gen model

and when I try to generate the model code, many errors in the generator mwe2 are shown like (Couldn't resolve reference to JvmType 'Generator' and Couldn't resolve reference to JvmIdentifiableElement 'pathRtProject'.)

I join the main project in this message
please help me to correct these errors and generate my editor code.

Thanks
Re: Extending OCL MDT using Xtext [message #910779 is a reply to message #910719] Mon, 10 September 2012 07:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

Currently only the OCLstdlib editor uses JVM references, so only the
OCLstdlib plugins and build script have the necessary declarations.

I found them slightly difficult to get right.

So either diff the OCLstdlib and CompleteOCL
manifest/plugin/.classpath/.project/*.mwe to see the differences

Or search the OCLstdlib artefacts for "jvm"

Or follow advice in the Xtext documentation, and messages on this newsgroup

to activate JVM references.

Regards

Ed Willink

On 10/09/2012 10:21, Fy Za wrote:
> Dear Ed,
> thank you for reply.
> I tried to use exactly the same approach as developing CompleteOCL,
> In Eclipse Juno, I
>
> 1) create xtext project
>
> 2)import plugins dependencies (org....completeocl_3.2.0, org.essentialocl_3.2.0,
> org........base_3.2.0 and org......pivot_3.2.0)
>
> 3)create a new folder named model and I put in my .ecore
>
> 4)I generate the gen model
>
> and when I try to generate the model code, many errors in the generator mwe2 are shown like (Couldn't resolve reference to JvmType 'Generator' and Couldn't resolve reference to JvmIdentifiableElement 'pathRtProject'.)
>
> I join the main project in this message
> please help me to correct these errors and generate my editor code.
>
> Thanks
Re: Extending OCL MDT using Xtext [message #1043269 is a reply to message #910719] Wed, 17 April 2013 09:44 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising name
Messages: 500
Registered: June 2011
Senior Member
Hi Fi Fi,

I am also working to extends OCL grammar.

I want to add some extra operations in grammar and for example factorial operation with Integer as parameter and Integer as return type....


Can you please describe me the process in steps

e.g. 1 - create xtext project, 2 - import plugins dependencies etc

thanks!

Regards,
Re: Extending OCL MDT using Xtext [message #1043363 is a reply to message #1043269] Wed, 17 April 2013 11:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

That sounds like a job for an extended OCL Standard Library not an
extended OCL grammar. Look at
GIT\org.eclipse.ocl\examples\org.eclipse.ocl.examples.library\model\OCL-2.4.oclstdlib

Regards

Ed Willink

On 17/04/2013 14:44, ModelGeek Mising name wrote:
> Hi Fi Fi,
>
> I am also working to extends OCL grammar.
>
> I want to add some extra operations in grammar and for example
> factorial operation with Integer as parameter and Integer as return
> type....
>
>
> Can you please describe me the process in steps
>
> e.g. 1 - create xtext project, 2 - import plugins dependencies etc
>
> thanks!
>
> Regards,
>
Re: Extending OCL MDT using Xtext [message #1043856 is a reply to message #1043363] Thu, 18 April 2013 03:44 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising name
Messages: 500
Registered: June 2011
Senior Member
after adding specific operation to Standard library, i would like OCL editor to recognize newly added operations(intellisense) and i would also like to validate the ocl statement which will use newly added operations.

So to implement above mentioned functionality, do you think i will need extension of OCL grammer?

thanks for support!

Regards,
Re: Extending OCL MDT using Xtext [message #1171891 is a reply to message #908955] Tue, 05 November 2013 10:04 Go to previous messageGo to next message
Stefan Mijatov is currently offline Stefan Mijatov
Messages: 44
Registered: March 2010
Location: Vienna, Austria
Member
I have somewhat similar problem. I am developing a DSL for testing UML models and need to be able to include an OCL invariant in an element of my DSL.
My initial idea is to declare all my invariants in a separate OCL file, and then just refer to a concrete invariant from a model of my OCL..

I have added import declaration into my xtext file for completeOCL:
import "http://www.eclipse.org/ocl/3.1.0/CompleteOCLCST" as completeocl

Also I have added package declaration into MWE file:
registerGeneratedEPackage = "org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.CompleteOCLCSTPackage"

Finally, I have added dependency to completeOCL plugin to my MANIFEST.MF file.

Now problem is, when I run MWE file, I get exception that genmodel for CompleteOCLCSTPackage cannot be found..

Can anyone please help with this? Thanks! Smile
Re: Extending OCL MDT using Xtext [message #1172021 is a reply to message #1171891] Tue, 05 November 2013 11:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

You might want to look at the MWE scripts in the
org.eclipse.ocl.examples.build plugin where many of these tools are
developed/used.

e.g.

bean = StandaloneSetup {
scanClassPath = true
platformUri = ".."
registerGeneratedEPackage =
"org.eclipse.ocl.examples.xtext.completeocl.completeoclcs.CompleteOCLCSPackage"
registerGenModelFile =
"platform:/resource/org.eclipse.ocl.examples.xtext.completeocl/model/CompleteOCLCS.genmodel"
}

NB. The above is from GIT master. There were some package path renames a
couple of months ago.

Regards

Ed Willink

On 05/11/2013 15:04, Stefan Mijatov wrote:
> I have somewhat similar problem. I am developing a DSL for testing UML
> models and need to be able to include an OCL invariant in an element
> of my DSL.
> My initial idea is to declare all my invariants in a separate OCL
> file, and then just refer to a concrete invariant from a model of my
> OCL..
>
> I have added import declaration into my xtext file for completeOCL:
> import "http://www.eclipse.org/ocl/3.1.0/CompleteOCLCST" as completeocl
>
> Also I have added package declaration into MWE file:
> registerGeneratedEPackage =
> "org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.CompleteOCLCSTPackage"
>
> Finally, I have added dependency to completeOCL plugin to my
> MANIFEST.MF file.
>
> Now problem is, when I run MWE file, I get exception that genmodel for
> CompleteOCLCSTPackage cannot be found..
>
> Can anyone please help with this? Thanks! :)
Re: Extending OCL MDT using Xtext [message #1173521 is a reply to message #1172021] Wed, 06 November 2013 10:29 Go to previous messageGo to next message
Stefan Mijatov is currently offline Stefan Mijatov
Messages: 44
Registered: March 2010
Location: Vienna, Austria
Member
Dear Ed,

thanks a lot for a quick and simple reply!
It works perfect, with the renames I found in eclipse installation..

Thanks a lot!!
Best wishes,
Stefan
Re: Extending OCL MDT using Xtext [message #1220524 is a reply to message #1173521] Thu, 12 December 2013 05:56 Go to previous messageGo to next message
Stefan Mijatov is currently offline Stefan Mijatov
Messages: 44
Registered: March 2010
Location: Vienna, Austria
Member
Hi Ed,

is there a way to integrate OCL grammar into my own,
so that I can define an OCL constraint directly in my language,
instead of having a reference to one in an *.ocl file?

And how could I do that, if possible?

Thanks a lot in advance,
Stefan
Re: Extending OCL MDT using Xtext [message #1220536 is a reply to message #1220524] Thu, 12 December 2013 07:18 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

Please use the OCL newsgropup for OCL queries.

The Essential OCL grammar is extended by:
- the OCL Stnadard Library grammar
- the Complete OCL grammar
- the OCL in Ecore grammar
- the QVT core grammar
- the QVT imp[erative grammar
- the QVT relations grammar

any of which can be examined for examples.

The QVTd examples are probably moe appropriate for you since you want a
separate project.

The OCL grammar APIs are not yet stable or documented and sadly not yet
nearly as easy to use as Xbase...

Regards

Ed Willink

On 12/12/2013 10:56, Stefan Mijatov wrote:
> Hi Ed,
>
> is there a way to integrate OCL grammar into my own, so that I can
> define an OCL constraint directly in my language, instead of having a
> reference to one in an *.ocl file?
>
> And how could I do that, if possible?
>
> Thanks a lot in advance,
> Stefan
Previous Topic:How to support a such a different overloading which is different from Java
Next Topic:Xtext 2.5. is released
Goto Forum:
  


Current Time: Sat Aug 02 04:43:55 EDT 2014

Powered by FUDForum. Page generated in 0.04767 seconds