Skip to content

Commit cfd86a1

Browse files
authored
Merge pull request #151 from scijava/scijava-ops-api/remove-infotree
OpEnvironment.infoTree() is no longer necessary with the Ops.infoTree() utility method
2 parents b68366a + d7c68af commit cfd86a1

File tree

3 files changed

+6
-49
lines changed

3 files changed

+6
-49
lines changed

scijava-ops-api/src/main/java/org/scijava/ops/api/OpEnvironment.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -161,41 +161,6 @@ default <T> T op( //
161161
<T> T op(final String opName, final Nil<T> specialType,
162162
final Nil<?>[] inTypes, final Nil<?> outType, Hints hints);
163163

164-
/**
165-
* Returns an {@link InfoTree} fitting the provided arguments. NB
166-
* implementations of this method likely depend on the {@link Hints} set by
167-
* {@link OpEnvironment#setDefaultHints(Hints)}, which provides no guarantee
168-
* of thread-safety. Users interested in parallel Op matching should consider
169-
* using {@link OpEnvironment#op(String, Nil, Nil[], Nil, Hints)} instead.
170-
*
171-
* @param opName the name of the Op
172-
* @param specialType the generic {@link Type} of the Op
173-
* @param inTypes the arguments (inputs) to the Op
174-
* @param outType the return of the Op (note that it may also be an argument)
175-
* @return an instance of an Op aligning with the search parameters
176-
*/
177-
default InfoTree infoTree( //
178-
final String opName, //
179-
final Nil<?> specialType, //
180-
final Nil<?>[] inTypes, //
181-
final Nil<?> outType //
182-
) {
183-
return infoTree(opName, specialType, inTypes, outType, getDefaultHints());
184-
}
185-
186-
/**
187-
* Returns an {@link InfoTree} fitting the provided arguments.
188-
*
189-
* @param opName the name of the Op
190-
* @param specialType the generic {@link Type} of the Op
191-
* @param inTypes the arguments (inputs) to the Op
192-
* @param outType the return of the Op (note that it may also be an argument)
193-
* @param hints the {@link Hints} that should guide this matching call
194-
* @return an instance of an Op aligning with the search parameters
195-
*/
196-
InfoTree infoTree(final String opName, final Nil<?> specialType,
197-
final Nil<?>[] inTypes, final Nil<?> outType, Hints hints);
198-
199164
default <T> T opFromInfoChain(InfoTree tree, Nil<T> specialType) {
200165
return opFromInfoChain(tree, specialType, getDefaultHints());
201166
}

scijava-ops-engine/src/main/java/org/scijava/ops/engine/impl/DefaultOpEnvironment.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,6 @@ public <T> T op( //
212212
return findOp(opName, specialType, inTypes, outType, hints).asOpType();
213213
}
214214

215-
@Override
216-
public InfoTree infoTree(String opName, Nil<?> specialType, Nil<?>[] inTypes,
217-
Nil<?> outType, Hints hints)
218-
{
219-
return findOp(opName, specialType, inTypes, outType, hints).infoTree();
220-
}
221-
222215
@Override
223216
public InfoTree treeFromInfo(OpInfo info, Nil<?> specialType, Hints hints) {
224217
return findOp(info, specialType, hints).infoTree();

scijava-ops-engine/src/main/java/org/scijava/ops/engine/matcher/adapt/AdaptationMatchingRoutine.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,9 @@
4242
import java.util.function.Function;
4343
import java.util.stream.Collectors;
4444

45-
import org.scijava.ops.api.Hints;
46-
import org.scijava.ops.api.InfoTree;
47-
import org.scijava.ops.api.OpMatchingException;
45+
import org.scijava.ops.api.*;
4846
import org.scijava.ops.engine.*;
4947
import org.scijava.ops.engine.OpCandidate.StatusCode;
50-
import org.scijava.ops.api.OpEnvironment;
51-
import org.scijava.ops.api.OpInfo;
52-
import org.scijava.ops.api.OpRequest;
5348
import org.scijava.ops.engine.matcher.MatchingRoutine;
5449
import org.scijava.ops.engine.matcher.OpMatcher;
5550
import org.scijava.ops.engine.matcher.impl.DefaultOpRequest;
@@ -140,8 +135,12 @@ public OpCandidate findMatch(MatchingConditions conditions, OpMatcher matcher,
140135
Nil<?>[] args = Arrays.stream(request.getArgs()).map(Nil::of)
141136
.toArray(Nil[]::new);
142137
Nil<?> outType = Nil.of(request.getOutType());
143-
return env.infoTree(request.getName(), type, args, outType,
138+
var op = env.op(request.getName(), type, args, outType,
144139
adaptationHints);
140+
// NB the dependency is interested in the INFOTREE of the match,
141+
// not the Op itself. We want to instantiate the dependencies
142+
// separately, so they can e.g. operate silently.
143+
return Ops.infoTree(op);
145144
}).collect(Collectors.toList());
146145
// And return the Adaptor, wrapped up into an OpCandidate
147146
Type adapterOpType = Types.substituteTypeVariables(adaptor.output()

0 commit comments

Comments
 (0)