[OCL Console] Access Package of model [message #999186] |
Fri, 11 January 2013 09:34  |
Eclipse User |
|
|
|
Hi,
I try to derive annotations which I attached to the root package of my ecore model. To do so I navigate from the root model element of my model to the instance of the package by using .eContainer(). From this I want to get the meta model class to retrieve the annotations from. For this I use .eClass(). This command, however, throws an Exception. How can I get around this problem.
Ralph
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.ocl.AbstractEvaluationEnvironment.callOperation(AbstractEvaluationEnvironment.java:205)
at org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperation(EcoreEvaluationEnvironment.java:165)
at org.eclipse.ocl.ecore.EcoreEvaluationEnvironment.callOperation(EcoreEvaluationEnvironment.java:1)
at org.eclipse.ocl.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:261)
at org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:390)
at org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(AbstractEvaluationVisitor.java:248)
at org.eclipse.ocl.OCL.evaluate(OCL.java:456)
at org.eclipse.ocl.examples.interpreter.console.OCLConsolePage.evaluate(OCLConsolePage.java:468)
at org.eclipse.ocl.examples.interpreter.console.OCLConsolePage$InputKeyListener.keyPressed(OCLConsolePage.java:646)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1521)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4640)
at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4528)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
|
|
|
|
|
|
|
Re: [OCL Console] Access Package of model [message #999927 is a reply to message #999921] |
Sun, 13 January 2013 07:56  |
Eclipse User |
|
|
|
Hi
You 'can' cast to EObject but you get a run-time failure without the
implicit root option. Perhaps therew should be a validation warning.
The library functions are all in the documentation! Help->Contents->OCL
Documentation->OCL Standard Library.
If you are using a Kepler milestone release, please raise a Bugzilla
about oclContainer() completion.
EObject stopped being the modeled ancestor of all EObjects in EMF at
Helios M4. Nothing to do with OCL. It was a side effect of the
introduction of eInvoke support for which it was considered that
imposing a full set of EObject EOperation literals on every class of
every model was undesirable. Actually modeling-wise this was a bug fix,
since EObject should never have been visible when not present in the
user's model.
Regards
Ed Willink
On 13/01/2013 12:38, Ralph Gerbig wrote:
> Hi Ed,
>
> thanks for your reply. I solved the problem by doing
> self.oclAsType(ecore::EObject).eClass().ePackage.
>
> About interactive console:
>
> The "Static instance for the implicit-root class option" entry is null
> and not EObject in my case but I can still do the cast. Is this
> intended or shall I open a bug on this?
>
> About XText Console:
>
> The code completition does not show functions like oclContainer. Where
> can I find an overvier of all these functions. Is there a meta-model
> where I can see these functions?
>
> Quote:
>> You can only cast to EObject if EObject is declared in your metamodel
>> as a supertype.
>
>
> I always thought EObject would be the implicit super type of all EMF
> Objects but this seems to not apply to OCL. What could I do to get all
> EMF operations available without introducing things like EObject into
> my meta model? Will all eXXX() functions become a oclXXX counterpart
> in future?
>
> Thanks,
>
> Ralph
|
|
|
Powered by
FUDForum. Page generated in 0.04509 seconds