Skip to content

Commit 8e0c073

Browse files
author
晓康
committed
fix: improve dml completion
1 parent a1f822e commit 8e0c073

File tree

5 files changed

+75
-69
lines changed

5 files changed

+75
-69
lines changed

packages/monaco-plugin-ob/build/webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
module: false
1717
}
1818
},
19+
1920
target: 'webworker',
2021
module: {
2122
rules: [
@@ -30,7 +31,9 @@ module.exports = {
3031
],
3132
},
3233
devServer: {
34+
port: 9090,
3335
hot: true,
36+
3437
},
3538
mode: 'development',
3639
};

packages/monaco-plugin-ob/example/config/webpack.config.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,23 @@ module.exports = {
3939
new webpack.DefinePlugin({
4040
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
4141
}),
42-
new CopyPlugin({
43-
patterns: [
44-
{ from: process.cwd() + '/worker-dist/', to: 'ob-workers' },
45-
],
46-
}),
42+
// new CopyPlugin({
43+
// patterns: [
44+
// { from: process.cwd() + '/worker-dist/', to: 'ob-workers' },
45+
// ],
46+
// }),
4747
],
4848
devServer: {
49-
hot: true
49+
hot: true,
50+
proxy: [
51+
{
52+
context: ['/ob-workers'],
53+
target: 'http://localhost:9090',
54+
pathRewrite: {
55+
'^/ob-workers': ''
56+
}
57+
}
58+
]
5059
},
5160
mode: 'development',
5261
};

packages/monaco-plugin-ob/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@oceanbase-odc/monaco-plugin-ob",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {

packages/monaco-plugin-ob/src/obmysql/worker/parser.ts

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Token as Antlr4Token, InputStream, CommonTokenStream, } from 'antlr4';
1+
import { Token as Antlr4Token, InputStream, CommonTokenStream, } from 'antlr4';
22
// @ts-ignore
33
import { SQLType, SQLDocument } from '@oceanbase-odc/ob-parser-js';
44
import { PLLexer as MySQLLexer } from "@oceanbase-odc/ob-parser-js/esm/parser/obmysql/PLLexer"
@@ -180,7 +180,7 @@ export default {
180180
completions = tokens.map(token => convertMap[token] || token);
181181
}
182182
}
183-
function getSchemaAndTableNameFromText (text: string) {
183+
function getSchemaAndTableNameFromText(text: string) {
184184
if (!text) {
185185
return {
186186
schema: '',
@@ -201,15 +201,14 @@ export default {
201201
}
202202
if (result.insertStmt) {
203203
addKeywords();
204-
if (!result.insertStmt.table) {
205-
completions.push({
206-
type: 'allSchemas'
207-
})
208-
completions.push({
209-
type: 'allTables',
210-
disableSys: true
211-
})
212-
} else {
204+
completions.push({
205+
type: 'allSchemas'
206+
})
207+
completions.push({
208+
type: 'allTables',
209+
disableSys: true
210+
})
211+
if (result.insertStmt.table) {
213212
completions.push({
214213
type: 'tableColumns',
215214
autoNext: false,
@@ -220,15 +219,14 @@ export default {
220219
return completions;
221220
} else if (result.updateStmt) {
222221
addKeywords();
223-
if (!result.updateStmt.table) {
224-
completions.push({
225-
type: 'allSchemas'
226-
})
227-
completions.push({
228-
type: 'allTables',
229-
disableSys: true
230-
})
231-
} else {
222+
completions.push({
223+
type: 'allSchemas'
224+
})
225+
completions.push({
226+
type: 'allTables',
227+
disableSys: true
228+
})
229+
if (result.updateStmt.table) {
232230
completions.push({
233231
type: 'tableColumns',
234232
autoNext: false,
@@ -239,15 +237,14 @@ export default {
239237
return completions;
240238
} else if (result.deleteStmt) {
241239
addKeywords();
242-
if (!result.deleteStmt.table) {
243-
completions.push({
244-
type: 'allSchemas'
245-
})
246-
completions.push({
247-
type: 'allTables',
248-
disableSys: true
249-
})
250-
} else {
240+
completions.push({
241+
type: 'allSchemas'
242+
})
243+
completions.push({
244+
type: 'allTables',
245+
disableSys: true
246+
})
247+
if (result.deleteStmt.table) {
251248
completions.push({
252249
type: 'tableColumns',
253250
autoNext: false,
@@ -303,7 +300,7 @@ export default {
303300
}
304301

305302
const queryContext = tableContext?.getContext(offset - 1);
306-
switch(queryContext) {
303+
switch (queryContext) {
307304
case QueryCursorContext.FromList: {
308305
completions = [
309306
{
@@ -347,7 +344,7 @@ export default {
347344
objectName: triggerWord
348345
});
349346
return completions;
350-
347+
351348
}
352349
}
353350
}
@@ -410,7 +407,7 @@ export default {
410407
}
411408

412409
return sqlCompletion(statement, offset - statement.start)
413-
410+
414411
},
415412

416413
getOffsetType(text: string, delimiter: string, offset: number): {
@@ -427,8 +424,8 @@ export default {
427424
return null;
428425
}
429426
offset = offset - statement.start;
430-
const result = statement.parse(offset, () => {});
431-
if (!result){
427+
const result = statement.parse(offset, () => { });
428+
if (!result) {
432429
return null;
433430
}
434431
const queryMap = createFromASTTree(result.result);

packages/monaco-plugin-ob/src/oboracle/worker/parser.ts

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export default {
193193
completions = tokens.map(token => convertMap[token] || token);
194194
}
195195
}
196-
function getSchemaAndTableNameFromText (text: string) {
196+
function getSchemaAndTableNameFromText(text: string) {
197197
if (!text) {
198198
return {
199199
schema: '',
@@ -214,15 +214,14 @@ export default {
214214
}
215215
if (result.insertStmt) {
216216
addKeywords();
217-
if (!result.insertStmt.table) {
218-
completions.push({
219-
type: 'allSchemas'
220-
})
221-
completions.push({
222-
type: 'allTables',
223-
disableSys: true
224-
})
225-
} else {
217+
completions.push({
218+
type: 'allSchemas'
219+
})
220+
completions.push({
221+
type: 'allTables',
222+
disableSys: true
223+
})
224+
if (result.insertStmt.table) {
226225
completions.push({
227226
type: 'tableColumns',
228227
autoNext: false,
@@ -233,15 +232,14 @@ export default {
233232
return completions;
234233
} else if (result.updateStmt) {
235234
addKeywords();
236-
if (!result.updateStmt.table) {
237-
completions.push({
238-
type: 'allSchemas'
239-
})
240-
completions.push({
241-
type: 'allTables',
242-
disableSys: true
243-
})
244-
} else {
235+
completions.push({
236+
type: 'allSchemas'
237+
})
238+
completions.push({
239+
type: 'allTables',
240+
disableSys: true
241+
})
242+
if (result.updateStmt.table) {
245243
completions.push({
246244
type: 'tableColumns',
247245
autoNext: false,
@@ -252,15 +250,14 @@ export default {
252250
return completions;
253251
} else if (result.deleteStmt) {
254252
addKeywords();
255-
if (!result.deleteStmt.table) {
256-
completions.push({
257-
type: 'allSchemas'
258-
})
259-
completions.push({
260-
type: 'allTables',
261-
disableSys: true
262-
})
263-
} else {
253+
completions.push({
254+
type: 'allSchemas'
255+
})
256+
completions.push({
257+
type: 'allTables',
258+
disableSys: true
259+
})
260+
if (result.deleteStmt.table) {
264261
completions.push({
265262
type: 'tableColumns',
266263
autoNext: false,

0 commit comments

Comments
 (0)