Commit 4ee6f867 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added initial serialisation to string in TDLHelper

parent acf98e47
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -19,8 +19,11 @@ import org.eclipse.ocl.pivot.internal.delegate.OCLInvocationDelegateFactory;
import org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegateFactory;
import org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegateFactory;
import org.eclipse.ocl.xtext.essentialocl.EssentialOCLStandaloneSetup;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.SaveOptions;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.serializer.impl.Serializer;
import org.etsi.mts.tdl.TDLan2StandaloneSetup;
import org.etsi.mts.tdl.TDLtxStandaloneSetup;
import org.etsi.mts.tdl.TDLtxiStandaloneSetup;
@@ -126,6 +129,22 @@ public class TDLHelper {
	}


	/**
	 * Get textual representation of resource contents.  
	 * @param resource A resource to be represented.
	 * @throws Exception 
	 */
	public static String getText(Resource resource) throws Exception {
//		if (resource instanceof XtextResource) {
//			return NodeModelUtils.getNode(resource.getContents().get(0)).getText();
//		} else {
			//TODO: this needs to be more robust for the desired format
			Serializer serializer = injector.getInstance(Serializer.class);  
			return serializer.serialize(resource.getContents().get(0));
//		}
	}

	
	/**
	 * Setup and return an XtextResourceSet with TDLan2 file support.
	 * @return A new XtextResourceSet.