diff options
author | 2021-06-27 01:43:59 +0200 | |
---|---|---|
committer | 2021-06-27 02:01:19 +0200 | |
commit | b88c842ba625753ea185e6166cd967e694160798 (patch) | |
tree | 51931f892dff12d253f7697179e137bdfe705155 /org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java | |
parent | Opposite reference scope (diff) | |
download | refinery-b88c842ba625753ea185e6166cd967e694160798.tar.gz refinery-b88c842ba625753ea185e6166cd967e694160798.tar.zst refinery-b88c842ba625753ea185e6166cd967e694160798.zip |
Add enum support
Diffstat (limited to 'org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java')
-rw-r--r-- | org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java index 3e7d515f..09f062f5 100644 --- a/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java +++ b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/ProblemUtil.java | |||
@@ -14,6 +14,7 @@ import org.eclipse.viatra.solver.language.model.problem.Node; | |||
14 | import org.eclipse.viatra.solver.language.model.problem.Problem; | 14 | import org.eclipse.viatra.solver.language.model.problem.Problem; |
15 | import org.eclipse.viatra.solver.language.model.problem.ProblemPackage; | 15 | import org.eclipse.viatra.solver.language.model.problem.ProblemPackage; |
16 | import org.eclipse.viatra.solver.language.model.problem.ReferenceDeclaration; | 16 | import org.eclipse.viatra.solver.language.model.problem.ReferenceDeclaration; |
17 | import org.eclipse.viatra.solver.language.model.problem.Relation; | ||
17 | import org.eclipse.viatra.solver.language.model.problem.Variable; | 18 | import org.eclipse.viatra.solver.language.model.problem.Variable; |
18 | import org.eclipse.viatra.solver.language.scoping.ProblemGlobalScopeProvider; | 19 | import org.eclipse.viatra.solver.language.scoping.ProblemGlobalScopeProvider; |
19 | 20 | ||
@@ -40,9 +41,15 @@ public final class ProblemUtil { | |||
40 | return variable.eContainingFeature() == ProblemPackage.Literals.ARGUMENT__SINGLETON_VARIABLE; | 41 | return variable.eContainingFeature() == ProblemPackage.Literals.ARGUMENT__SINGLETON_VARIABLE; |
41 | } | 42 | } |
42 | 43 | ||
44 | public static boolean isEnumLiteral(Node node) { | ||
45 | return node.eContainingFeature() == ProblemPackage.Literals.ENUM_DECLARATION__LITERALS; | ||
46 | } | ||
47 | |||
43 | public static boolean isEnumNode(Node node) { | 48 | public static boolean isEnumNode(Node node) { |
44 | String name = node.getName(); | 49 | String name = node.getName(); |
45 | return name != null && name.startsWith(ENUM_NODE_NAME_QUOTE) && name.endsWith(ENUM_NODE_NAME_QUOTE); | 50 | boolean isNameQuoted = name != null && name.startsWith(ENUM_NODE_NAME_QUOTE) |
51 | && name.endsWith(ENUM_NODE_NAME_QUOTE); | ||
52 | return isNameQuoted || isEnumLiteral(node); | ||
46 | } | 53 | } |
47 | 54 | ||
48 | public static boolean isNewNode(Node node) { | 55 | public static boolean isNewNode(Node node) { |
@@ -71,7 +78,11 @@ public final class ProblemUtil { | |||
71 | ClassDeclaration current = queue.removeFirst(); | 78 | ClassDeclaration current = queue.removeFirst(); |
72 | if (!found.contains(current)) { | 79 | if (!found.contains(current)) { |
73 | found.add(current); | 80 | found.add(current); |
74 | queue.addAll(current.getSuperTypes()); | 81 | for (Relation superType : current.getSuperTypes()) { |
82 | if (superType instanceof ClassDeclaration) { | ||
83 | queue.addLast((ClassDeclaration) superType); | ||
84 | } | ||
85 | } | ||
75 | } | 86 | } |
76 | } | 87 | } |
77 | return found; | 88 | return found; |