Skip to content

Commit

Permalink
add type calculator for selectOne
Browse files Browse the repository at this point in the history
  • Loading branch information
pkourouklidis committed Jan 17, 2025
1 parent 16d6a02 commit 0a4379b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ var os : OrderedSet<Any> = OrderedSet{0,1,'foo'};
/*Sequence<Integer>*/seq.select(e:Integer|true);
/*OrderedSet<Integer>*/os.select(e:Integer|true);
/*Sequence<Any>*/seq.select(e|true);
/*OrderedSet<Any>*/os.select(e|true);
/*OrderedSet<Any>*/os.select(e|true);

/*Integer*/Sequence{0,1,'foo'}.selectOne(e:Integer|e<5);

0 comments on commit 0a4379b

Please sign in to comment.