Skip to content

Commit

Permalink
improve CtQueryImpl code and fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pvojtechovsky committed Jan 12, 2017
1 parent 954c371 commit 6e0279e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/spoon/reflect/visitor/chain/CtQueryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
import spoon.reflect.visitor.Filter;

/**
* The facade of {@link CtBaseQuery} which represents a query bound to the {@link CtElement},
* The facade of {@link CtQuery} which represents a query bound to the {@link CtElement},
* which is the constant input of this query.
* It is used by {@link CtElement} implementations of {@link CtQueryable}.
*
* @param <O> - the type of element which is produced by the last step of the query
*/
public class CtQueryImpl implements CtQuery {

Expand Down Expand Up @@ -224,7 +222,10 @@ private String getStepDescription(CurrentStep step, String message, Object... pa
/**
* The thread local implementation of CtConsumer,
* which knows index of actually processed step
* and handles response of current step and sends it to next step
* and handles response of current step and sends it to next step.
*
* This class plays a role of an orchestrator to move the step cursor forward,
* get the step, apply it and finally to call the output consumer.
*/
private class CurrentStep implements CtConsumer<Object> {
private final CtConsumer<?> outputConsumer;
Expand All @@ -242,9 +243,9 @@ public void accept(Object input) {
}
stepIdx++;
try {
if (stepIdx <= steps.size()) {
AbstractStep step = CtQueryImpl.this.getStep(stepIdx - 1);
if (step != null) {
//process next intermediate step
AbstractStep step = steps.get(stepIdx - 1);
log(this, "received", input);
try {
step.apply(input, this);
Expand Down Expand Up @@ -349,7 +350,7 @@ public void apply(Object input, CurrentStep outputConsumer) {
}

/**
* a step which calls Function. Implements contract of {@link CtBaseQuery#map(CtFunction)}
* a step which calls Function. Implements contract of {@link CtQuery#map(CtFunction)}
*/
private class FunctionWrapper extends AbstractStep {
private CtFunction<Object, Object> fnc;
Expand Down

0 comments on commit 6e0279e

Please sign in to comment.