bazel syntax: eliminate Debugger interface
It has only one implementation, Environment, which is a public class in the same package.
RELNOTES: N/A
PiperOrigin-RevId: 268680079
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
index e8f9be4..6871eac 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
@@ -47,6 +47,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
+import java.util.function.Predicate;
import javax.annotation.Nullable;
/**
@@ -115,7 +116,7 @@
// Once the API is small and sound, we can start to represent all
// the lexical frames within a single function using just an array,
// indexed by a small integer computed during the validation pass.
-public final class Environment implements Freezable, Debuggable {
+public final class Environment implements Freezable {
/**
* A mapping of bindings, either mutable or immutable according to an associated {@link
@@ -1232,7 +1233,7 @@
}
}
- @Override
+ /** Evaluates a Skylark statement in the adapter's environment. (Debugger API) */
public Object evaluate(String contents) throws EvalException, InterruptedException {
ParserInputSource input =
ParserInputSource.create(contents, PathFragment.create("<debug eval>"));
@@ -1260,7 +1261,13 @@
}
}
- @Override
+ /**
+ * Returns the stack frames corresponding of the context's current (paused) state. (Debugger API)
+ *
+ * <p>For all stack frames except the innermost, location information is retrieved from the
+ * current context. The innermost frame's location must be supplied as {@code currentLocation} by
+ * the caller.
+ */
public ImmutableList<DebugFrame> listFrames(Location currentLocation) {
ImmutableList.Builder<DebugFrame> frameListBuilder = ImmutableList.builder();
@@ -1293,7 +1300,16 @@
return frameListBuilder.build();
}
- @Override
+ /**
+ * Given a requested stepping behavior, returns a predicate over the context that tells the
+ * debugger when to pause. (Debugger API)
+ *
+ * <p>The predicate will return true if we are at the next statement where execution should pause,
+ * and it will return false if we are not yet at that statement. No guarantee is made about the
+ * predicate's return value after we have reached the desired statement.
+ *
+ * <p>A null return value indicates that no further pausing should occur.
+ */
@Nullable
public ReadyToPause stepControl(Stepping stepping) {
final Continuation pausedContinuation = continuation;
@@ -1313,6 +1329,34 @@
throw new IllegalArgumentException("Unsupported stepping type: " + stepping);
}
+ /** See stepControl (Debugger API) */
+ public interface ReadyToPause extends Predicate<Environment> {}
+
+ /**
+ * Describes the stepping behavior that should occur when execution of a thread is continued.
+ * (Debugger API)
+ */
+ public enum Stepping {
+ /** Continue execution without stepping. */
+ NONE,
+ /**
+ * If the thread is paused on a statement that contains a function call, step into that
+ * function. Otherwise, this is the same as OVER.
+ */
+ INTO,
+ /**
+ * Step over the current statement and any functions that it may call, stopping at the next
+ * statement in the same frame. If no more statements are available in the current frame, same
+ * as OUT.
+ */
+ OVER,
+ /**
+ * Continue execution until the current frame has been exited and then pause. If we are
+ * currently in the outer-most frame, same as NONE.
+ */
+ OUT,
+ }
+
/** Returns true if {@code env} is in a parent frame of {@code pausedContinuation}. */
private static boolean isOutside(Environment env, @Nullable Continuation pausedContinuation) {
return pausedContinuation != null && env.continuation == pausedContinuation.continuation;