From 0a4379bae81a05f5277b243cc360b90fd61f1471 Mon Sep 17 00:00:00 2001 From: Panagiotis Kourouklidis <22411884+pkourouklidis@users.noreply.github.com> Date: Fri, 17 Jan 2025 10:13:04 +0000 Subject: [PATCH] add type calculator for selectOne --- .../operations/declarative/SelectOneOperation.java | 2 ++ .../declarative/SelectOneTypeCalculator.java | 13 +++++++++++++ .../tests/scripts/selectOperation.eol | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneTypeCalculator.java diff --git a/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneOperation.java b/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneOperation.java index 27939874e9..037be26afa 100644 --- a/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneOperation.java +++ b/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneOperation.java @@ -15,7 +15,9 @@ import org.eclipse.epsilon.eol.dom.Parameter; import org.eclipse.epsilon.eol.exceptions.EolRuntimeException; import org.eclipse.epsilon.eol.execute.context.IEolContext; +import org.eclipse.epsilon.eol.execute.operations.TypeCalculator; +@TypeCalculator(klass = SelectOneTypeCalculator.class) public class SelectOneOperation extends SelectBasedOperation { @Override diff --git a/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneTypeCalculator.java b/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneTypeCalculator.java new file mode 100644 index 0000000000..abf92a5d50 --- /dev/null +++ b/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/declarative/SelectOneTypeCalculator.java @@ -0,0 +1,13 @@ +package org.eclipse.epsilon.eol.execute.operations.declarative; + +import org.eclipse.epsilon.eol.execute.operations.ITypeCalculator; +import org.eclipse.epsilon.eol.staticanalyser.types.EolType; + +public class SelectOneTypeCalculator implements ITypeCalculator { + + @Override + public EolType calculateType(EolType contextType, EolType iteratorType, EolType expressionType) { + return iteratorType; + } + +} diff --git a/tests/org.eclipse.epsilon.eol.staticanalyser.tests/src/org/eclipse/epsilon/eol/staticanalyser/tests/scripts/selectOperation.eol b/tests/org.eclipse.epsilon.eol.staticanalyser.tests/src/org/eclipse/epsilon/eol/staticanalyser/tests/scripts/selectOperation.eol index d45d02f053..3080b3747e 100644 --- a/tests/org.eclipse.epsilon.eol.staticanalyser.tests/src/org/eclipse/epsilon/eol/staticanalyser/tests/scripts/selectOperation.eol +++ b/tests/org.eclipse.epsilon.eol.staticanalyser.tests/src/org/eclipse/epsilon/eol/staticanalyser/tests/scripts/selectOperation.eol @@ -3,4 +3,6 @@ var os : OrderedSet = OrderedSet{0,1,'foo'}; /*Sequence*/seq.select(e:Integer|true); /*OrderedSet*/os.select(e:Integer|true); /*Sequence*/seq.select(e|true); -/*OrderedSet*/os.select(e|true); \ No newline at end of file +/*OrderedSet*/os.select(e|true); + +/*Integer*/Sequence{0,1,'foo'}.selectOne(e:Integer|e<5); \ No newline at end of file