package org.etsi.mts.tdl.constraints.evl;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.epsilon.eol.tools.AbstractTool;
import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;

//DONE: extract to plugin? -> not for now
public class XtextBridge extends AbstractTool {
	public String getTextFor(EObject o) {
		String text = "";
		if (o.eResource() instanceof XtextResource) {
			ICompositeNode node = NodeModelUtils.findActualNodeFor(o);
			text = "Line "+node.getStartLine()+"-"+node.getEndLine()+ ": "+node.getText().trim();
		} else {
			//TODO: handle non-xtext resources
		}
		return text;
	}	
}
