Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "JSDT/JSDT-DOM-and-bindings"
Line 1: | Line 1: | ||
− | + | This page explains the ClosureCompiler AST, the JSDT core DOM AST and its Bindings to the Eclipse IDE | |
+ | = JSDT DOM/AST parsing and IDE bindings = | ||
− | + | This document explains the JSDT 2.0 architecture for javascript parsing, comprising: | |
− | JSDT changed | + | * Parsing with Closure Compiler and generation of its ParseTree |
+ | * Conversion of the CC ParseTree to jsdt.core.dom.AST . | ||
+ | * Binding of the jsdt.dom.AST model, to provide outline, content assist, indexing, etc. | ||
+ | |||
+ | == JSDT 1.0 to 2.0== | ||
+ | |||
+ | Starting from Eclipse Oxygen, JSDT 2.0 uses Closure Compiler for parsing. | ||
+ | After parsing, a converter transforms the CC's ParseTree into the jsdt.core.dom.AST. | ||
+ | Then, bindings are used to consume the DOM model to provide content assist, code completion, etc. | ||
+ | |||
+ | In the past, we changed parser/compiler toolchain twice: | ||
* '''JSDT 1.0''', until Mars.2: supports ES3 using [https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino Rhino] (Mozilla Foundation), a Java-based parser/compiler for JavaScript. | * '''JSDT 1.0''', until Mars.2: supports ES3 using [https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino Rhino] (Mozilla Foundation), a Java-based parser/compiler for JavaScript. | ||
Line 10: | Line 21: | ||
* '''JSDT 2.0''', from Neon.2 release: supports ES6 using [https://developers.google.com/closure/compiler/ ClosureCompiler] (Google), a java-based parsing infrastructure for JavaScript. | * '''JSDT 2.0''', from Neon.2 release: supports ES6 using [https://developers.google.com/closure/compiler/ ClosureCompiler] (Google), a java-based parsing infrastructure for JavaScript. | ||
− | |||
− | |||
− | |||
− | + | ||
Other JSDT Architectural information is reported in the parent page [https://wiki.eclipse.org/JSDT/Architecture JSDT/Architecture]. | Other JSDT Architectural information is reported in the parent page [https://wiki.eclipse.org/JSDT/Architecture JSDT/Architecture]. | ||
== ClosureCompiler AST == | == ClosureCompiler AST == | ||
+ | |||
+ | The | ||
+ | [https://github.com/google/closure-compiler google/closure-compiler] project, has a | ||
+ | [https://github.com/google/closure-compiler/wiki wiki] with | ||
+ | [https://github.com/google/closure-compiler/wiki/Tutorials tutorials], | ||
+ | [https://github.com/google/closure-compiler/wiki/FAQ FAQs] and | ||
+ | [https://github.com/google/closure-compiler/wiki/Design-Documents design documents], which explain | ||
+ | [https://github.com/google/closure-compiler/wiki/Using-the-Compiler's-Java-API how to use the Java API], and | ||
+ | [https://github.com/google/closure-compiler/wiki/Writing-Compiler-Pass how to write compiler passes]. | ||
+ | |||
+ | You | ||
+ | However, the docs are quite technical, and often you will have to loot at the source code, | ||
+ | |||
Closure Compiler documentation is mostly in its code. | Closure Compiler documentation is mostly in its code. | ||
Line 24: | Line 45: | ||
* Closure Compiler source on GitHub: https://github.com/google/closure-compiler | * Closure Compiler source on GitHub: https://github.com/google/closure-compiler | ||
− | * Docs from [https://github.com/google/closure-compiler/wiki CC wiki] ( i.e. [https://github.com/google/closure-compiler/wiki/Design-Documents CC Design Documents], [https://github.com/google/closure-compiler/wiki/Using-the-Compiler's-Java-API using CC Java API], [https://github.com/google/closure-compiler/wiki/Tutorials CC tutorials], [https://github.com/google/closure-compiler/wiki/Writing-Compiler-Pass writing compiler pass], etc... | + | * Docs from [https://github.com/google/closure-compiler/wiki CC wiki] ( i.e. |
+ | [https://github.com/google/closure-compiler/wiki/Design-Documents CC Design Documents], | ||
+ | [https://github.com/google/closure-compiler/wiki/Using-the-Compiler's-Java-API using CC Java API], | ||
+ | [https://github.com/google/closure-compiler/wiki/Tutorials CC tutorials], | ||
+ | [https://github.com/google/closure-compiler/wiki/Writing-Compiler-Pass writing compiler pass], etc... | ||
* Adding closure compiler for JSDT parsing: https://git.eclipse.org/r/#/c/92404/ | * Adding closure compiler for JSDT parsing: https://git.eclipse.org/r/#/c/92404/ | ||
Revision as of 08:12, 19 April 2017
This page explains the ClosureCompiler AST, the JSDT core DOM AST and its Bindings to the Eclipse IDE
Contents
JSDT DOM/AST parsing and IDE bindings
This document explains the JSDT 2.0 architecture for javascript parsing, comprising:
- Parsing with Closure Compiler and generation of its ParseTree
- Conversion of the CC ParseTree to jsdt.core.dom.AST .
- Binding of the jsdt.dom.AST model, to provide outline, content assist, indexing, etc.
JSDT 1.0 to 2.0
Starting from Eclipse Oxygen, JSDT 2.0 uses Closure Compiler for parsing. After parsing, a converter transforms the CC's ParseTree into the jsdt.core.dom.AST. Then, bindings are used to consume the DOM model to provide content assist, code completion, etc.
In the past, we changed parser/compiler toolchain twice:
- JSDT 1.0, until Mars.2: supports ES3 using Rhino (Mozilla Foundation), a Java-based parser/compiler for JavaScript.
- JSDT 2.0, initial release: supports ES6 using Esprima (jQuery Foundation). As Esprima is written in JavaScript, this version of JSDT 2.0 needs to hook Nashorn, the Java8’s JS interpreter.
- JSDT 2.0, from Neon.2 release: supports ES6 using ClosureCompiler (Google), a java-based parsing infrastructure for JavaScript.
Other JSDT Architectural information is reported in the parent page JSDT/Architecture.
ClosureCompiler AST
The google/closure-compiler project, has a wiki with tutorials, FAQs and design documents, which explain how to use the Java API, and how to write compiler passes.
You However, the docs are quite technical, and often you will have to loot at the source code,
Closure Compiler documentation is mostly in its code.
To understand how it works, we should look at the CC source, at few documentation pages, and at the work done when moving JSDT to ClosureCompiler.
- Closure Compiler source on GitHub: https://github.com/google/closure-compiler
- Docs from CC wiki ( i.e.
CC Design Documents, using CC Java API, CC tutorials, writing compiler pass, etc...
- Adding closure compiler for JSDT parsing: https://git.eclipse.org/r/#/c/92404/
DOM AST
The AST class The package org.eclipse.wst.jsdt.core.dom contains the class
This is the AST used in JSDT core. It contains all the information needed to create outline, for content assist etc..
Bindings
This part is about the bindings needed to show the model in the outline, to provide content assist, indexing etc.
Other Notes
See commit https://git.eclipse.org/r/#/c/57504/ (M.Istria) to see the new outline