From fc7e9312d00e60171ed77c477ed91231d3dbfff9 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 12 Dec 2021 17:48:47 +0100 Subject: build: move modules into subproject directory --- .../language/model/GenerateProblemModel.mwe2 | 20 --- .../refinery/language/model/ProblemEMFSetup.java | 34 ---- .../tools/refinery/language/model/ProblemUtil.java | 121 ------------- .../src/main/resources/model/builtin.problem_xmi | 67 -------- .../src/main/resources/model/problem.ecore | 191 --------------------- .../src/main/resources/model/problem.genmodel | 165 ------------------ 6 files changed, 598 deletions(-) delete mode 100644 language-model/src/main/java/tools/refinery/language/model/GenerateProblemModel.mwe2 delete mode 100644 language-model/src/main/java/tools/refinery/language/model/ProblemEMFSetup.java delete mode 100644 language-model/src/main/java/tools/refinery/language/model/ProblemUtil.java delete mode 100644 language-model/src/main/resources/model/builtin.problem_xmi delete mode 100644 language-model/src/main/resources/model/problem.ecore delete mode 100644 language-model/src/main/resources/model/problem.genmodel (limited to 'language-model/src/main') diff --git a/language-model/src/main/java/tools/refinery/language/model/GenerateProblemModel.mwe2 b/language-model/src/main/java/tools/refinery/language/model/GenerateProblemModel.mwe2 deleted file mode 100644 index 15198d69..00000000 --- a/language-model/src/main/java/tools/refinery/language/model/GenerateProblemModel.mwe2 +++ /dev/null @@ -1,20 +0,0 @@ -module tools.refinery.language.model.GenerateProblemModel - -Workflow { - bean = org.eclipse.emf.mwe.utils.StandaloneSetup { - projectMapping = { - projectName = "tools.refinery.refinery-language-model" - path = "." - } - } - - component = org.eclipse.emf.mwe.utils.DirectoryCleaner { - directory = "src/main/emf-gen" - } - - component = org.eclipse.emf.mwe2.ecore.EcoreGenerator { - generateCustomClasses = false - genModel = "platform:/resource/tools.refinery.refinery-language-model/src/main/resources/model/problem.genmodel" - srcPath = "platform:/resource/tools.refinery.refinery-language-model/src/main/emf-gen" - } -} diff --git a/language-model/src/main/java/tools/refinery/language/model/ProblemEMFSetup.java b/language-model/src/main/java/tools/refinery/language/model/ProblemEMFSetup.java deleted file mode 100644 index 9383098b..00000000 --- a/language-model/src/main/java/tools/refinery/language/model/ProblemEMFSetup.java +++ /dev/null @@ -1,34 +0,0 @@ -package tools.refinery.language.model; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.resource.Resource; - -import tools.refinery.language.model.problem.ProblemPackage; -import tools.refinery.language.model.problem.impl.ProblemFactoryImpl; - -public class ProblemEMFSetup { - public static final String XMI_RESOURCE_EXTENSION = "problem_xmi"; - - private ProblemEMFSetup() { - throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); - } - - // Here we can't rely on java.util.HashMap#putIfAbsent, because - // org.eclipse.emf.ecore.impl.EPackageRegistryImpl#containsKey is overridden - // without also overriding putIfAbsent. We must make sure to call the - // overridden containsKey implementation. - @SuppressWarnings("squid:S3824") - public static void doEMFRegistration() { - if (!EPackage.Registry.INSTANCE.containsKey(ProblemPackage.eNS_URI)) { - EPackage.Registry.INSTANCE.put(ProblemPackage.eNS_URI, ProblemPackage.eINSTANCE); - } - - // This Resource.Factory is not actually used once - // tools.refinery.language.ProblemStandaloneSetup.createInjectorAndDoEMFRegistration() - // is called, because if will be replaced by - // tools.refinery.language.resource.ProblemXmiResourceFactory, which implements - // org.eclipse.xtext.resource.IResourceFactory as required by Xtext. - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().putIfAbsent(XMI_RESOURCE_EXTENSION, - new ProblemFactoryImpl()); - } -} diff --git a/language-model/src/main/java/tools/refinery/language/model/ProblemUtil.java b/language-model/src/main/java/tools/refinery/language/model/ProblemUtil.java deleted file mode 100644 index d8958381..00000000 --- a/language-model/src/main/java/tools/refinery/language/model/ProblemUtil.java +++ /dev/null @@ -1,121 +0,0 @@ -package tools.refinery.language.model; - -import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Deque; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; - -import tools.refinery.language.model.problem.ClassDeclaration; -import tools.refinery.language.model.problem.ImplicitVariable; -import tools.refinery.language.model.problem.Node; -import tools.refinery.language.model.problem.Problem; -import tools.refinery.language.model.problem.ProblemPackage; -import tools.refinery.language.model.problem.ReferenceDeclaration; -import tools.refinery.language.model.problem.Relation; -import tools.refinery.language.model.problem.Variable; - -public final class ProblemUtil { - public static final String BUILTIN_LIBRARY_NAME = "builtin"; - - public static final URI BUILTIN_LIBRARY_URI = getLibraryUri(BUILTIN_LIBRARY_NAME); - - public static final String NODE_CLASS_NAME = "node"; - - private ProblemUtil() { - throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); - } - - public static boolean isSingletonVariable(Variable variable) { - return variable.eContainingFeature() == ProblemPackage.Literals.VARIABLE_OR_NODE_ARGUMENT__SINGLETON_VARIABLE; - } - - public static boolean isImplicitVariable(Variable variable) { - return variable instanceof ImplicitVariable; - } - - public static boolean isImplicitNode(Node node) { - return node.eContainingFeature() == ProblemPackage.Literals.PROBLEM__NODES; - } - - public static boolean isImplicit(EObject eObject) { - if (eObject instanceof Node node) { - return isImplicitNode(node); - } else if (eObject instanceof Variable variable) { - return isImplicitVariable(variable); - } else { - return false; - } - } - - public static boolean isIndividualNode(Node node) { - var containingFeature = node.eContainingFeature(); - return containingFeature == ProblemPackage.Literals.INDIVIDUAL_DECLARATION__NODES - || containingFeature == ProblemPackage.Literals.ENUM_DECLARATION__LITERALS; - } - - public static boolean isNewNode(Node node) { - return node.eContainingFeature() == ProblemPackage.Literals.CLASS_DECLARATION__NEW_NODE; - } - - public static Optional getBuiltInLibrary(EObject context) { - return Optional.ofNullable(context.eResource()).map(Resource::getResourceSet) - .map(resourceSet -> resourceSet.getResource(BUILTIN_LIBRARY_URI, true)).map(Resource::getContents) - .filter(contents -> !contents.isEmpty()).map(contents -> contents.get(0)) - .filter(Problem.class::isInstance).map(Problem.class::cast); - } - - public static boolean isBuiltIn(EObject eObject) { - if (eObject != null) { - var eResource = eObject.eResource(); - if (eResource != null) { - return BUILTIN_LIBRARY_URI.equals(eResource.getURI()); - } - } - return false; - } - - public static Optional getNodeClassDeclaration(EObject context) { - return getBuiltInLibrary(context).flatMap(problem -> problem.getStatements().stream() - .filter(ClassDeclaration.class::isInstance).map(ClassDeclaration.class::cast) - .filter(declaration -> NODE_CLASS_NAME.equals(declaration.getName())).findFirst()); - } - - public static Collection getSuperclassesAndSelf(ClassDeclaration classDeclaration) { - Set found = new HashSet<>(); - getNodeClassDeclaration(classDeclaration).ifPresent(found::add); - Deque queue = new ArrayDeque<>(); - queue.addLast(classDeclaration); - while (!queue.isEmpty()) { - ClassDeclaration current = queue.removeFirst(); - if (!found.contains(current)) { - found.add(current); - for (Relation superType : current.getSuperTypes()) { - if (superType instanceof ClassDeclaration superDeclaration) { - queue.addLast(superDeclaration); - } - } - } - } - return found; - } - - public static Collection getAllReferenceDeclarations(ClassDeclaration classDeclaration) { - Set referenceDeclarations = new HashSet<>(); - for (ClassDeclaration superclass : getSuperclassesAndSelf(classDeclaration)) { - referenceDeclarations.addAll(superclass.getReferenceDeclarations()); - } - return referenceDeclarations; - } - - private static URI getLibraryUri(String libraryName) { - return URI.createURI(ProblemUtil.class.getClassLoader() - .getResource("model/" + libraryName + "." + ProblemEMFSetup.XMI_RESOURCE_EXTENSION) - .toString()); - } -} diff --git a/language-model/src/main/resources/model/builtin.problem_xmi b/language-model/src/main/resources/model/builtin.problem_xmi deleted file mode 100644 index 9255ab66..00000000 --- a/language-model/src/main/resources/model/builtin.problem_xmi +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/language-model/src/main/resources/model/problem.ecore b/language-model/src/main/resources/model/problem.ecore deleted file mode 100644 index 582f67c8..00000000 --- a/language-model/src/main/resources/model/problem.ecore +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/language-model/src/main/resources/model/problem.genmodel b/language-model/src/main/resources/model/problem.genmodel deleted file mode 100644 index 9ba2274b..00000000 --- a/language-model/src/main/resources/model/problem.genmodel +++ /dev/null @@ -1,165 +0,0 @@ - - - problem.ecore - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-70-g09d2