All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jbase.util.JbaseNodeModelUtil Maven / Gradle / Ivy

There is a newer version: 0.12.2
Show newest version
/**
 * 
 */
package jbase.util;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;

/**
 * Retrieves the original program text, to check for the terminating semicolon.
 * 
 * @author Lorenzo Bettini
 *
 */
public class JbaseNodeModelUtil {

	public String getProgramText(EObject object) {
		return NodeModelUtils.getTokenText(findActualNode(object));
	}

	public int getElementOffsetInProgram(EObject object) {
		return findActualNode(object).getOffset();
	}

	public boolean hasSemicolon(EObject object) {
		return getProgramText(object).endsWith(";");
	}

	private ICompositeNode findActualNode(EObject object) {
		return NodeModelUtils.findActualNodeFor(object);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy