jdk.nashorn.api.tree (Java SE 13 & JDK 13 )
Description: declaration: module: jdk.scripting.nashorn, package: jdk.nashorn.api.tree
Keywords: jdk.nashorn.api.tree package

Module jdk.scripting.nashorn

# Package jdk.nashorn.api.tree

Nashorn parser API provides interfaces to represent ECMAScript source code as abstract syntax trees (AST) and Parser to parse ECMAScript source scripts.

Using parser API user can write Java code to access parse tree representation of ECMAScript source. Script source may be a file, a URL or a String. Unless stated otherwise null argument in methods of this package result in NullPointerException being thrown.

     import jdk.nashorn.api.tree.*;
     import java.io.File;

     // Simple example that prints warning on 'with' statements
     public class Main {
         public static void main(String[] args) throws Exception {
             // Create a new parser instance
             Parser parser = Parser.create();
             File sourceFile = new File(args[0]);

             // Parse given source File using parse method.
             // Pass a diagnostic listener to print error messages.
             CompilationUnitTree cut = parser.parse(sourceFile,
                 (d) -> { System.out.println(d); });

             if (cut != null) {
                 // call Tree.accept method passing a SimpleTreeVisitor
                 cut.accept(new SimpleTreeVisitor<Void, Void>() {
                     // visit method for 'with' statement
                     public Void visitWith(WithTree wt, Void v) {
                         // print warning on 'with' statement
                         System.out.println("Warning: using 'with' statement!");
                         return null;
                     }
                 }, null);
             }
         }
     }

Since:
  9

- Interface Summary
  Interface | Description
  --- | ---
  ArrayAccessTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ArrayLiteralTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  AssignmentTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  BinaryTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  BlockTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  BreakTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  CaseTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  CatchTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ClassDeclarationTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ClassExpressionTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  CompilationUnitTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  CompoundAssignmentTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ConditionalExpressionTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ConditionalLoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ContinueTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  DebuggerTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  Diagnostic | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  DiagnosticListener | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  DoWhileLoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  EmptyStatementTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ErroneousTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ExportEntryTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ExpressionStatementTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ExpressionTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ForInLoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ForLoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ForOfLoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  FunctionCallTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  FunctionDeclarationTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  FunctionExpressionTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  GotoTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  IdentifierTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  IfTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ImportEntryTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  InstanceOfTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  LabeledStatementTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  LineMap | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  LiteralTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  LoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  MemberSelectTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ModuleTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  NewTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ObjectLiteralTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ParenthesizedTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  Parser | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  PropertyTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  RegExpLiteralTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ReturnTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  SpreadTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  StatementTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  SwitchTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  TemplateLiteralTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  ThrowTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  Tree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  TreeVisitor<R,​P> | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  TryTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  UnaryTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  VariableTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  WhileLoopTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  WithTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  YieldTree | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.

- Class Summary
  Class | Description
  --- | ---
  SimpleTreeVisitorES5_1<R,​P> | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  SimpleTreeVisitorES6<R,​P> | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.

- Enum Summary
  Enum | Description
  --- | ---
  Diagnostic.Kind | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.
  Tree.Kind | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.

- Exception Summary
  Exception | Description
  --- | ---
  UnknownTreeException | Deprecated, for removal: This API element is subject to removal in a future version. Nashorn JavaScript script engine and APIs, and the jjs tool are deprecated with the intent to remove them in a future release.