| <%@ jet package="org.eclipse.emf.refactor.smells" class="HenshinFinderClass" |
| imports="org.eclipse.emf.refactor.smells.henshin.core.HenshinModelSmellInfo"%> |
| <%HenshinModelSmellInfo info = (HenshinModelSmellInfo) argument; %> |
| package <%=info.getPackage()%>; |
| |
| import java.io.IOException; |
| import java.net.URL; |
| import java.util.Collections; |
| import java.util.LinkedList; |
| |
| import org.eclipse.core.runtime.FileLocator; |
| import org.eclipse.core.runtime.Path; |
| import org.eclipse.emf.ecore.EObject; |
| |
| import org.eclipse.emf.refactor.smells.henshin.managers.HenshinRuntimeManager; |
| import org.eclipse.emf.refactor.smells.interfaces.IModelSmellFinderClass; |
| |
| public final class <%=info.getClassName()%> implements IModelSmellFinderClass { |
| |
| private final String transformationPath = "transformations/"; |
| private final String henshinFileName = "<%=info.getHenshinFileName()%>"; |
| |
| @Override |
| public LinkedList<LinkedList<EObject>> findSmell(EObject root) { |
| String fullPath = getFullPath(transformationPath + henshinFileName); |
| return HenshinRuntimeManager.run(root, fullPath); |
| } |
| |
| private String getFullPath(String transformationPath){ |
| URL url = FileLocator.find(<%=info.getProjectName().toLowerCase()%>.Activator.getDefault().getBundle(), new Path(transformationPath), Collections.EMPTY_MAP); |
| URL fileUrl = null; |
| try { |
| fileUrl = FileLocator.toFileURL(url); |
| } |
| catch (IOException e) { |
| e.printStackTrace(); |
| } |
| return fileUrl.getPath(); |
| } |
| |
| } |