parsed CompleteOCL file doesn't resolve cross reference [message #928078] |
Sun, 30 September 2012 09:10 |
Fy Za Messages: 245 Registered: March 2010 |
Senior Member |
|
|
I define my file test.ocl using
completeocl sources (org.eclipse.ocl.examples.xtext.completeocl -> Run As Eclipse Application)
import 'MyEcore.ecore'
package test
context TestClass
...
....
I try after to parse this file using Xtext.
package fr.enseeiht.completeocl.parser;
import java.io.IOException;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.ocl.examples.xtext.completeocl.CompleteOCLStandaloneSetup;
public class Parser {
public static void main(String[] args) throws IOException {
CompleteOCLStandaloneSetup.doSetup();
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(URI.createURI(args[0]));
resource.load(null);
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("completeocl", new XMIResourceFactoryImpl());
EcoreUtil.resolveAll(resource);
Resource resourceAsXmi = resourceSet.createResource(URI.createURI(args[0].substring(0, args[0].length()-4)+".completeOCLCST"));
resourceAsXmi.getContents().addAll(resource.getContents());
resourceAsXmi.save(null);
System.out.println(args[0].substring(0, args[0].length()-5));
}
}
I get this error
Exception in thread "main" org.eclipse.ocl.examples.pivot.utilities.IllegalLibraryException: No OCL Standard Library content available
at org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary.getRequiredLibraryType(PivotStandardLibrary.java:277)
at org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary.resolveRequiredSimpleType(PivotStandardLibrary.java:376)
at org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary.getOclInvalidType(PivotStandardLibrary.java:206)
at org.eclipse.ocl.examples.xtext.base.baseCST.impl.PathElementCSImpl.getElement(PathElementCSImpl.java:354)
at org.eclipse.ocl.examples.xtext.base.baseCST.impl.PathNameCSImpl.getElement(PathNameCSImpl.java:390)
at org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.impl.ClassifierContextDeclCSImpl.getClassifier(ClassifierContextDeclCSImpl.java:201)
at org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.impl.ClassifierContextDeclCSImpl.eIsSet(ClassifierContextDeclCSImpl.java:168)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:401)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:559)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveCrossReferences(EcoreUtil.java:302)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:296)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:281)
at fr.enseeiht.completeocl.parser.Parser.main(Parser.java:33)
and if I comment this line
//EcoreUtil.resolveAll(resource);
My OCL file is parsed but without resolve cross references:
For example,
the
is parsed as
<element xsi:type="pivot:Annotation" href="/location path ...../test.ocl#xtextLink_::0.10.0.6.1.0::2::/1"/>
Can you please help me to resolve this problem
Best regards,
Thanks
[Updated on: Sun, 30 September 2012 09:10] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03609 seconds