Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions src/main/java/graphql/language/AstTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import graphql.util.TraverserVisitor;
import graphql.util.TraverserVisitorStub;
import graphql.util.TreeParallelTransformer;
import graphql.util.TreeTransformer;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.util.Map;
import java.util.concurrent.ForkJoinPool;

import static graphql.Assert.assertNotNull;
import static graphql.language.AstNodeAdapter.AST_NODE_ADAPTER;

/**
* Allows for an easy way to "manipulate" the immutable Ast by changing specific nodes and getting back a new Ast
* containing the changed nodes while everything else is the same.
* Visitors are invoked sequentially on the calling thread.
*/
@PublicApi
@NullMarked
Expand Down Expand Up @@ -58,26 +56,6 @@ public class AstTransformer {
return treeTransformer.transform(root, traverserVisitor, rootVars);
}

public Node transformParallel(Node root, NodeVisitor nodeVisitor) {
return transformParallel(root, nodeVisitor, ForkJoinPool.commonPool());
}

public Node transformParallel(Node root, NodeVisitor nodeVisitor, ForkJoinPool forkJoinPool) {
assertNotNull(root);
assertNotNull(nodeVisitor);

TraverserVisitor<Node> traverserVisitor = new TraverserVisitorStub<Node>() {
@Override
public TraversalControl enter(TraverserContext<Node> context) {
return assertNotNull(context.thisNode(), "thisNode should not be null").accept(context, nodeVisitor);
}

};

TreeParallelTransformer<Node> treeParallelTransformer = TreeParallelTransformer.parallelTransformer(AST_NODE_ADAPTER, forkJoinPool);
return treeParallelTransformer.transform(root, traverserVisitor);
}

private TraverserVisitor<Node> getNodeTraverserVisitor(NodeVisitor nodeVisitor) {
return new TraverserVisitor<Node>() {
@Override
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/graphql/schema/SchemaTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import graphql.introspection.Introspection;
import graphql.schema.idl.ScalarInfo;
import graphql.util.Breadcrumb;
import graphql.util.NodeAdapter;
import graphql.util.NodeLocation;
import graphql.util.NodeZipper;
import graphql.util.TraversalControl;
Expand Down Expand Up @@ -281,7 +280,6 @@ public TraversalControl enter(TraverserContext<GraphQLSchemaElement> context) {
}
NodeZipper<GraphQLSchemaElement> nodeZipper = new NodeZipper<>(currentSchemaElement, context.getBreadcrumbs(), SCHEMA_ELEMENT_ADAPTER);
context.setVar(NodeZipper.class, nodeZipper);
context.setVar(NodeAdapter.class, SCHEMA_ELEMENT_ADAPTER);

int zippersBefore = zippers.size();
TraversalControl result = currentSchemaElement.accept(context, visitor);
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/graphql/util/DefaultTraverserContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class DefaultTraverserContext<T> implements TraverserContext<T> {
private Object curAccValue;
private final NodeLocation location;
private final boolean isRootContext;
private boolean parallel;
private Map<String, List<TraverserContext<T>>> children;
private Phase phase;
private final List<Breadcrumb<T>> breadcrumbs;
Expand All @@ -42,16 +41,14 @@ public DefaultTraverserContext(T curNode,
Map<Class<?>, Object> vars,
Object sharedContextData,
NodeLocation location,
boolean isRootContext,
boolean parallel) {
boolean isRootContext) {
this.curNode = curNode;
this.parent = parent;
this.visited = visited;
this.vars = vars;
this.sharedContextData = sharedContextData;
this.location = location;
this.isRootContext = isRootContext;
this.parallel = parallel;

if (parent == null || parent.isRootContext()) {
this.breadcrumbs = ImmutableKit.emptyList();
Expand All @@ -65,11 +62,11 @@ public DefaultTraverserContext(T curNode,
}

public static <T> DefaultTraverserContext<T> dummy() {
return new DefaultTraverserContext<>(null, null, null, null, null, null, true, false);
return new DefaultTraverserContext<>(null, null, null, null, null, null, true);
}

public static <T> DefaultTraverserContext<T> simple(T node) {
return new DefaultTraverserContext<>(node, null, null, null, null, null, true, false);
return new DefaultTraverserContext<>(node, null, null, null, null, null, true);
}

@Override
Expand Down Expand Up @@ -245,9 +242,4 @@ void setPhase(Phase phase) {
public Phase getPhase() {
return phase;
}

@Override
public boolean isParallel() {
return parallel;
}
}
5 changes: 0 additions & 5 deletions src/main/java/graphql/util/TraverserContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,4 @@ enum Phase {
*/
Phase getPhase();

/**
* @return true if the traversing happens in parallel (multi threaded) or not.
*/
boolean isParallel();

}
2 changes: 1 addition & 1 deletion src/main/java/graphql/util/TraverserState.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ private DefaultTraverserContext<T> newContextImpl(T curNode,
NodeLocation nodeLocation,
boolean isRootContext) {
assertNotNull(vars);
return new DefaultTraverserContext<>(curNode, parent, visited, vars, sharedContextData, nodeLocation, isRootContext, false);
return new DefaultTraverserContext<>(curNode, parent, visited, vars, sharedContextData, nodeLocation, isRootContext);
}
}
252 changes: 0 additions & 252 deletions src/main/java/graphql/util/TreeParallelTransformer.java

This file was deleted.

Loading
Loading