Class InlineSnippet

java.lang.Object
org.graalvm.polyglot.tck.InlineSnippet

public final class InlineSnippet extends Object
The unit of execution with an inline source. The InlineSnippet represents an execution of a script and an associated inline source code that is to be executed at script's locations.

It's recommended to provide two snippets at least, one with local variables and restricted location predicate and one with globally accessible code and no location predicate.

Since:
0.32
  • Method Details

    • getScript

      public Snippet getScript()
      Returns a script to be executed. The source code is executed inlined in this script.
      Since:
      0.32
    • getCode

      public CharSequence getCode()
      Returns an inline source code that is to be executed at specific locations, or at all statement and call locations if the predicate is null.
      Since:
      0.32
    • getLocationPredicate

      public Predicate<org.graalvm.polyglot.SourceSection> getLocationPredicate()
      Returns a testing predicate for locations at which source code is executed.
      Returns:
      the predicate that returns true for SourceSections where the source code is to be executed, or null if the source code should be executed at all instrumentable statement and call locations.
      Since:
      0.32
    • getResultVerifier

      public ResultVerifier getResultVerifier()
      Returns the ResultVerifier to verify the result of source code execution.
      Returns:
      either a custom or the default ResultVerifier.
      Since:
      0.32
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      0.32
    • newBuilder

      public static InlineSnippet.Builder newBuilder(Snippet script, CharSequence code)
      Creates a new InlineSnippet builder object.
      Parameters:
      script - the script to execute (use Snippet.newBuilder(String, Value, TypeDescriptor) to create one)
      code - the inline source code that is to be executed inside the script
      Returns:
      the new InlineSnippet.Builder
      Since:
      0.32