public Tuple2<Either<java.util.Set<ParseFailedException>, Term>, java.util.Set<VarInfo>> apply(TermCons tc) {
Set<VarInfo> collector = Sets.newHashSet();
for (int i = 0, j = 0; i < tc.production().items().size(); i++) {
if (tc.production().items().apply(i) instanceof NonTerminal) {
if (tc.production().klabel().isDefined()
&& (tc.production().klabel().get().name().equals("#SyntacticCast")
|| tc.production().klabel().get().name().startsWith("#SemanticCastTo")
|| tc.production().klabel().get().name().equals("#InnerCast"))) {
Term t = tc.get(0);
collector = new CollectVariables2(getSortOfCast(tc), VarType.USER).apply(t)._2();
} else if (tc.production().klabel().isDefined() && isFunctionRule(tc) && j == 0) {
Term t = tc.get(0);
collector = new CollectVariables2(getSortOfCast(tc), VarType.CONTEXT).apply(t)._2();
j++;
} else {
Term t = tc.get(j);
Set<VarInfo> vars = new CollectVariables2(((NonTerminal) tc.production().items().apply(i)).sort(), VarType.CONTEXT).apply(t)._2();
collector.addAll(vars);
j++;
}
}
}
Tuple2<Either<java.util.Set<ParseFailedException>, Term>, java.util.Set<VarInfo>> rez = super.apply(tc);
return new Tuple2<>(Right.apply(rez._1().right().get()), mergeWarnings(collector, rez._2()));
}