中文介绍可以看这里。
- syntax highlighting
- auto complete (Use 'Ctrl' key)
- show syntax error
- check sql line one by one
- sql context involve
- codemirror
- vue
- js
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
All feature's implement are base on Codemirror. There already have "spark-sql" mode in Codemirror sql mode.
You can run this project and access 'http://localhost:8080' to find the Spark-Sql editor.
Try to access 'http://localhost:8080/#/selfsql' to see what happened. The implement you can find in SelfsqlEditor.vue
and selfsql.js
.
Spark SQL uses module Spark-Catalyst to do SQL parse. And Spark-Catalyst use ANTLR4 to generate Gammer Parser in Java.
So if we want to use ANTLR4 for syntax check in webpage, we need generate code in JS. Refer to here. There also have a npm implement in github which named antlr4-tool.
The steps are as blow:
- Get the G4 file from Spark-Catalyst.
- Generate antlr4 related js by using antlr4-tool
- According to parsePlan#ParseDriver.scala, create JS function.
- Register lint to codemirror