Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion common-react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ __metadata:
dependencies:
"@dbeaver/cli": "workspace:^"
"@dbeaver/tsconfig": "workspace:^"
async-mutex: "npm:^0.5.0"
rimraf: "npm:^6"
typescript: "npm:^5"
vitest: "npm:^3"
Expand Down Expand Up @@ -2234,6 +2235,15 @@ __metadata:
languageName: node
linkType: hard

"async-mutex@npm:^0.5.0":
version: 0.5.0
resolution: "async-mutex@npm:0.5.0"
dependencies:
tslib: "npm:^2.4.0"
checksum: 10c0/9096e6ad6b674c894d8ddd5aa4c512b09bb05931b8746ebd634952b05685608b2b0820ed5c406e6569919ff5fe237ab3c491e6f2887d6da6b6ba906db3ee9c32
languageName: node
linkType: hard

"axe-core@npm:^4.10.2":
version: 4.10.3
resolution: "axe-core@npm:4.10.3"
Expand Down Expand Up @@ -6935,7 +6945,7 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2, tslib@npm:^2.0.3, tslib@npm:^2.3.0":
"tslib@npm:^2, tslib@npm:^2.0.3, tslib@npm:^2.3.0, tslib@npm:^2.4.0":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
Expand Down
3 changes: 3 additions & 0 deletions common-typescript/@dbeaver/js-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
"rimraf": "^6",
"typescript": "^5",
"vitest": "^3"
},
"dependencies": {
"async-mutex": "^0.5.0"
}
}
1 change: 1 addition & 0 deletions common-typescript/@dbeaver/js-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './isDefined.js';
export * from './isNotNullDefined.js';
export * from './mutex.js';
1 change: 1 addition & 0 deletions common-typescript/@dbeaver/js-helpers/src/mutex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as mutex from 'async-mutex';
12 changes: 11 additions & 1 deletion common-typescript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ __metadata:
dependencies:
"@dbeaver/cli": "workspace:^"
"@dbeaver/tsconfig": "workspace:^"
async-mutex: "npm:^0.5.0"
rimraf: "npm:^6"
typescript: "npm:^5"
vitest: "npm:^3"
Expand Down Expand Up @@ -949,6 +950,15 @@ __metadata:
languageName: node
linkType: hard

"async-mutex@npm:^0.5.0":
version: 0.5.0
resolution: "async-mutex@npm:0.5.0"
dependencies:
tslib: "npm:^2.4.0"
checksum: 10c0/9096e6ad6b674c894d8ddd5aa4c512b09bb05931b8746ebd634952b05685608b2b0820ed5c406e6569919ff5fe237ab3c491e6f2887d6da6b6ba906db3ee9c32
languageName: node
linkType: hard

"balanced-match@npm:^1.0.0":
version: 1.0.2
resolution: "balanced-match@npm:1.0.2"
Expand Down Expand Up @@ -2749,7 +2759,7 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2, tslib@npm:^2.3.0":
"tslib@npm:^2, tslib@npm:^2.3.0, tslib@npm:^2.4.0":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
Expand Down
2 changes: 1 addition & 1 deletion webapp/.yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "9.25.1-sdk",
"version": "9.29.0-sdk",
"main": "./lib/api.js",
"type": "commonjs",
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"@types/react": "^19",
"@types/react-dom": "^19",
"concurrently": "^9",
"eslint": "^9.25.1",
"happy-dom": "^17",
"eslint": "^9.29.0",
"happy-dom": "^18",
"lefthook": "^1",
"mobx": "^6",
"mobx-react-lite": "^4",
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@cloudbeaver/eslint-plugin": "workspace:*",
"@eslint/js": "^9",
"@stylistic/eslint-plugin": "^3",
"@stylistic/eslint-plugin": "^4",
"@typescript-eslint/eslint-plugin": "^8",
"@typescript-eslint/parser": "^8",
"eslint": "^9",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand All @@ -20,16 +20,14 @@
onCursorChange: (anchor: number, head?: number) => void;
}

export function useSQLCodeEditorPanel(data: ISQLEditorData, editor: IEditor) {

Check warning on line 23 in webapp/packages/plugin-sql-editor-new/src/SQLEditor/SQLCodeEditorPanel/useSQLCodeEditorPanel.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Missing return type on function
const state: State = useObservableRef(
() => ({
highlightActiveQuery() {
this.editor.clearActiveQueryHighlight();

const segment = this.data.activeSegment;

if (segment) {
this.editor.highlightActiveQuery(segment.begin, segment.end);
if (this.data.cursorSegment) {
this.editor.highlightActiveQuery(this.data.cursorSegment.begin, this.data.cursorSegment.end);
}
},
onQueryChange(query: string) {
Expand All @@ -43,7 +41,7 @@
{ editor, data },
);

const updateHighlight = useCallback(

Check warning on line 44 in webapp/packages/plugin-sql-editor-new/src/SQLEditor/SQLCodeEditorPanel/useSQLCodeEditorPanel.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
throttle(() => state.highlightActiveQuery(), 1000),
[state],
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@ export interface ISQLEditorData {
activeSegmentMode: ISQLEditorMode;
readonly parser: SQLParser;
readonly dialect: SqlDialectInfo | undefined;
readonly activeSegment: ISQLScriptSegment | undefined;
readonly cursorSegment: ISQLScriptSegment | undefined;
readonly readonly: boolean;
readonly editing: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import type { ISyncContextLoader } from '@cloudbeaver/core-executor';

import type { ISQLScriptSegment } from '../SQLParser.js';
import type { ISQLEditorData } from './ISQLEditorData.js';

export interface ISQLEditorMode {
activeSegment: ISQLScriptSegment | undefined;
activeSegmentMode: boolean;
}

export const SQLEditorModeContext: ISyncContextLoader<ISQLEditorMode, ISQLEditorData> = function SQLEditorModeContext(context, data) {

Check warning on line 16 in webapp/packages/plugin-sql-editor/src/SqlEditor/SQLEditorModeContext.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

'data' is defined but never used

Check warning on line 16 in webapp/packages/plugin-sql-editor/src/SqlEditor/SQLEditorModeContext.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

'context' is defined but never used
const from = Math.min(data.cursor.anchor, data.cursor.head);
const to = Math.max(data.cursor.anchor, data.cursor.head);

return {
activeSegment: data.parser.getSegment(from, to),
activeSegmentMode: false,
};
};
45 changes: 25 additions & 20 deletions webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2025 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -84,14 +84,9 @@
},

activeSegmentMode: {
activeSegment: undefined,
activeSegmentMode: false,
},

get activeSegment(): ISQLScriptSegment | undefined {
return this.activeSegmentMode.activeSegment;
},

get cursorSegment(): ISQLScriptSegment | undefined {
return this.parser.getSegment(this.cursor.anchor, -1);
},
Expand Down Expand Up @@ -251,7 +246,7 @@

await this.executeQueryAction(
query,
async () => {

Check failure on line 249 in webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Async arrow function has no 'await' expression
if (this.dataSource?.databaseModels.length) {
this.sqlQueryService.initDatabaseDataModels(this.state);
}
Expand Down Expand Up @@ -297,7 +292,7 @@
} catch {}
},

async switchEditing(): Promise<void> {

Check failure on line 295 in webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Async method 'switchEditing' has no 'await' expression
this.dataSource?.setEditing(!this.dataSource.isEditing());
},

Expand Down Expand Up @@ -428,31 +423,41 @@
return this.parser.getScriptSegment();
}

return this.activeSegment;
return this.cursorSegment;
},

async getResolvedSegment(): Promise<ISQLScriptSegment | undefined> {
const projectId = this.dataSource?.executionContext?.projectId;
const connectionId = this.dataSource?.executionContext?.connectionId;

await data.updateParserScripts();
while (true) {
const currentScript = this.parser.actualScript;
// TODO: we updating parser scripts
// script may be changed this will lead to temporary wrong segments offsets

if (!projectId || !connectionId || this.cursor.anchor !== this.cursor.head) {
return this.getSubQuery();
}
await data.updateParserScripts();

if (this.activeSegmentMode.activeSegmentMode) {
return this.activeSegment;
}
if (currentScript !== this.parser.actualScript) {
continue;
}
if (!projectId || !connectionId || this.cursor.anchor !== this.cursor.head) {
return this.getSubQuery();
}

const result = await this.sqlEditorService.parseSQLQuery(projectId, connectionId, this.value, this.cursor.anchor);
const result = await this.sqlEditorService.parseSQLQuery(projectId, connectionId, currentScript, this.cursor.anchor);

if (result.end === 0 && result.start === 0) {
return;
}
if (currentScript !== this.parser.actualScript) {
continue;
}

const segment = this.parser.getSegment(result.start, result.end);
return segment;
if (result.end === 0 && result.start === 0) {
return;
}

// TODO: here we use parser that may be outdated and segment will return wrong value
const segment = this.parser.getSegment(result.start, result.end);
return segment;
}
},

getSubQuery(): ISQLScriptSegment | undefined {
Expand Down Expand Up @@ -553,7 +558,7 @@
return subscription;
}, [data]);

useEffect(() => () => data.destruct(), []);

Check warning on line 561 in webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

React Hook useEffect has a missing dependency: 'data'. Either include it or remove the dependency array

return data;
}
2 changes: 1 addition & 1 deletion webapp/packages/tests-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/node": "^22",
"@types/react": "^19",
"fake-indexeddb": "^6",
"happy-dom": "^17",
"happy-dom": "^18",
"typescript": "^5",
"vitest": "^3"
}
Expand Down
Loading
Loading