Loading plugins/org.etsi.mts.tdl.helper/META-INF/MANIFEST.MF +2 −1 Original line number Diff line number Diff line Loading @@ -16,5 +16,6 @@ Require-Bundle: org.eclipse.xtext, org.etsi.mts.tdl.TDLan2, org.etsi.mts.tdl.TPLan2, org.etsi.mts.tdl.tx, org.etsi.mts.tdl.txi org.etsi.mts.tdl.txi, org.eclipse.emf.ecore Export-Package: org.etsi.mts.tdl.helper plugins/org.etsi.mts.tdl.helper/src/org/etsi/mts/tdl/helper/TDLHelper.java +51 −8 Original line number Diff line number Diff line Loading @@ -3,12 +3,17 @@ package org.etsi.mts.tdl.helper; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EValidator; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.ocl.common.OCLConstants; import org.eclipse.ocl.pivot.internal.delegate.OCLInvocationDelegateFactory; import org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegateFactory; Loading @@ -18,11 +23,8 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; import org.etsi.mts.tdl.TDLan2StandaloneSetup; import org.etsi.mts.tdl.TDLtxStandaloneSetup; import org.etsi.mts.tdl.TPLan2StandaloneSetup; import org.etsi.mts.tdl.impl.tdlPackageImpl; import org.etsi.mts.tdl.structuredobjectives.impl.StructuredObjectivesPackageImpl; import org.apache.log4j.Logger; import org.apache.log4j.Level; import com.google.inject.Injector; Loading @@ -49,7 +51,7 @@ public class TDLHelper { StructuredObjectivesPackageImpl.init(); EssentialOCLStandaloneSetup.doSetup(); initializeValidator(); resourceSet = getResourceSet(); resourceSet = getNewResourceSet(); } /** Loading @@ -58,11 +60,45 @@ public class TDLHelper { * @return A resource loaded from the file. */ public static Resource load(String filename) { //resourceSet = getResourceSet(); Resource resource = resourceSet.getResource(org.eclipse.emf.common.util.URI.createURI(filename), true); return resource; } /** * Link / resolve all loaded resources. */ public static void link() { EcoreUtil.resolveAll(resourceSet); } /** * Check all resources in the shared resourceSet. */ public static void check() { //TODO: check automatically? make optional in case of performance or redundancy concerns? // TDLHelper.link(); resourceSet.getResources().forEach(TDLHelper::check); } /** * Check resource in the shared resourceSet. Load if needed. * @param filename location of the resource to be checked. */ public static void check(String filename) { Resource r = TDLHelper.load(filename); check(r); } /** * Check resource. * @param r the resource to be checked. */ private static void check(Resource r) { r.getErrors().forEach(e -> System.out.println("Error: "+r.getURI().lastSegment()+": "+e.getLine()+": "+e.getMessage())); r.getWarnings().forEach(e -> System.out.println("Warning: "+r.getURI().lastSegment()+": "+e.getLine()+": "+e.getMessage())); } /** * Creates a new resource at the specified location. * @param filename Location of the resource to be loaded. Loading Loading @@ -92,10 +128,10 @@ public class TDLHelper { * Setup and return an XtextResourceSet with TDLan2 file support. * @return A new XtextResourceSet. */ public static XtextResourceSet getResourceSet() { public static XtextResourceSet getNewResourceSet() { new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("./"); injector = new TDLan2StandaloneSetup().createInjectorAndDoEMFRegistration(); injector = new TPLan2StandaloneSetup().createInjectorAndDoEMFRegistration(); // injector = new TPLan2StandaloneSetup().createInjectorAndDoEMFRegistration(); //TODO: can this be configurable? or does it preclude tdlan2 from being loaded? injector = new TDLtxStandaloneSetup().createInjectorAndDoEMFRegistration(); XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); Loading @@ -107,7 +143,7 @@ public class TDLHelper { * Reset the shared resourceSet. */ public static void resetResourceSet() { resourceSet = getResourceSet(); resourceSet = getNewResourceSet(); } /** Loading @@ -124,4 +160,11 @@ public class TDLHelper { new OCLValidationDelegateFactory(oclDelegateURI)); } /** * Get the shared resourceSet. */ public static XtextResourceSet getResourceSet() { return resourceSet; } } Loading
plugins/org.etsi.mts.tdl.helper/META-INF/MANIFEST.MF +2 −1 Original line number Diff line number Diff line Loading @@ -16,5 +16,6 @@ Require-Bundle: org.eclipse.xtext, org.etsi.mts.tdl.TDLan2, org.etsi.mts.tdl.TPLan2, org.etsi.mts.tdl.tx, org.etsi.mts.tdl.txi org.etsi.mts.tdl.txi, org.eclipse.emf.ecore Export-Package: org.etsi.mts.tdl.helper
plugins/org.etsi.mts.tdl.helper/src/org/etsi/mts/tdl/helper/TDLHelper.java +51 −8 Original line number Diff line number Diff line Loading @@ -3,12 +3,17 @@ package org.etsi.mts.tdl.helper; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EValidator; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.ocl.common.OCLConstants; import org.eclipse.ocl.pivot.internal.delegate.OCLInvocationDelegateFactory; import org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegateFactory; Loading @@ -18,11 +23,8 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.resource.XtextResourceSet; import org.etsi.mts.tdl.TDLan2StandaloneSetup; import org.etsi.mts.tdl.TDLtxStandaloneSetup; import org.etsi.mts.tdl.TPLan2StandaloneSetup; import org.etsi.mts.tdl.impl.tdlPackageImpl; import org.etsi.mts.tdl.structuredobjectives.impl.StructuredObjectivesPackageImpl; import org.apache.log4j.Logger; import org.apache.log4j.Level; import com.google.inject.Injector; Loading @@ -49,7 +51,7 @@ public class TDLHelper { StructuredObjectivesPackageImpl.init(); EssentialOCLStandaloneSetup.doSetup(); initializeValidator(); resourceSet = getResourceSet(); resourceSet = getNewResourceSet(); } /** Loading @@ -58,11 +60,45 @@ public class TDLHelper { * @return A resource loaded from the file. */ public static Resource load(String filename) { //resourceSet = getResourceSet(); Resource resource = resourceSet.getResource(org.eclipse.emf.common.util.URI.createURI(filename), true); return resource; } /** * Link / resolve all loaded resources. */ public static void link() { EcoreUtil.resolveAll(resourceSet); } /** * Check all resources in the shared resourceSet. */ public static void check() { //TODO: check automatically? make optional in case of performance or redundancy concerns? // TDLHelper.link(); resourceSet.getResources().forEach(TDLHelper::check); } /** * Check resource in the shared resourceSet. Load if needed. * @param filename location of the resource to be checked. */ public static void check(String filename) { Resource r = TDLHelper.load(filename); check(r); } /** * Check resource. * @param r the resource to be checked. */ private static void check(Resource r) { r.getErrors().forEach(e -> System.out.println("Error: "+r.getURI().lastSegment()+": "+e.getLine()+": "+e.getMessage())); r.getWarnings().forEach(e -> System.out.println("Warning: "+r.getURI().lastSegment()+": "+e.getLine()+": "+e.getMessage())); } /** * Creates a new resource at the specified location. * @param filename Location of the resource to be loaded. Loading Loading @@ -92,10 +128,10 @@ public class TDLHelper { * Setup and return an XtextResourceSet with TDLan2 file support. * @return A new XtextResourceSet. */ public static XtextResourceSet getResourceSet() { public static XtextResourceSet getNewResourceSet() { new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("./"); injector = new TDLan2StandaloneSetup().createInjectorAndDoEMFRegistration(); injector = new TPLan2StandaloneSetup().createInjectorAndDoEMFRegistration(); // injector = new TPLan2StandaloneSetup().createInjectorAndDoEMFRegistration(); //TODO: can this be configurable? or does it preclude tdlan2 from being loaded? injector = new TDLtxStandaloneSetup().createInjectorAndDoEMFRegistration(); XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); Loading @@ -107,7 +143,7 @@ public class TDLHelper { * Reset the shared resourceSet. */ public static void resetResourceSet() { resourceSet = getResourceSet(); resourceSet = getNewResourceSet(); } /** Loading @@ -124,4 +160,11 @@ public class TDLHelper { new OCLValidationDelegateFactory(oclDelegateURI)); } /** * Get the shared resourceSet. */ public static XtextResourceSet getResourceSet() { return resourceSet; } }