Skip to content

Commit

Permalink
Improve: Trigger grammar check when save edit. release v1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
camilesing committed Jul 18, 2023
1 parent bf09cd7 commit f4a1bd5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### v1.7.2
- Improve: Trigger grammar check when save edit.
### v1.7.1
- Feature: Grammar check be optional features from experiment.

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Flink-SQL-Checker

This extension provides Flink SQL support for VSCode. Support Flink SQL error grammer check, syntax highlighting, complete keywords, rename and code format, including user-defined functions.
This extension provides Flink SQL support for VSCode. support Flink SQL error grammar check, syntax highlighting, complete keywords, rename and code format, including user-defined functions.


## 1.Features

### 1.1 Grammar Check
open your `setting.json`, add `"flink-sql-grammar-check.enable": true` or
open your `setting.json`, add `"flink-sql-grammar-check.enable": true` or setting like
![](images/open-setting.jpg)

example:
- ![](images/expect-semicolon.jpg)
then the plugin will check grammar when you save edit (suggest you turn off automatic saving).

- ![](images/select-not-expect-comma.jpg)
example:

- ![](images/unexpect-input.jpg)
- ![](images/select-not-expect-comma.jpg)
- ![](images/expect-semicolon.jpg)

### 1.2 Rename
![](images/rename.gif)
Expand Down
2 changes: 1 addition & 1 deletion out/extension.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/extension.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flink-sql",
"version": "1.7.1",
"version": "1.7.2",
"displayName": "Flink SQL Checker",
"description": "Support Flink SQL grammar check, syntax highlighting, complete keywords, rename and code format, including user-defined functions",
"publisher": "CamileSing",
Expand Down
8 changes: 4 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ function updateFeatureStatus() {
// 创建诊断集合,用于报告语法错误和警告
const diagnosticCollection = vscode.languages.createDiagnosticCollection(selector);

// 监听文件更改事件
vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => {
// 保存时触发
vscode.workspace.onDidSaveTextDocument((event: vscode.TextDocument) => {
// 检查文件是否为Flink SQL文件
if (event.document.languageId !== selector) {
if (event.languageId !== selector) {
return;
}
// 清除之前的诊断信息
diagnosticCollection.clear();

// 使用生成的词法分析器和解析器进行语法检查
const inputStream = new ANTLRInputStream(event.document.getText());
const inputStream = new ANTLRInputStream(event.getText());
const lexer = new FlinkSQLLexer(inputStream);
const tokenStream = new CommonTokenStream(lexer);
const parser = new FlinkSQLParser(tokenStream);
Expand Down

0 comments on commit f4a1bd5

Please sign in to comment.