Skip to content

Commit f6b50bb

Browse files
committed
Use contributes jsonValidation instead
1 parent 544ff89 commit f6b50bb

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

extensions/ql-vscode/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
"editor.wordBasedSuggestions": false
8585
}
8686
},
87+
"jsonValidation": [
88+
{
89+
"fileMatch": "workspace-databases.json",
90+
"url": "./workspace-databases-schema.json"
91+
}
92+
],
8793
"languages": [
8894
{
8995
"id": "ql",

extensions/ql-vscode/src/databases/db-config-store.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class DbConfigStore extends DisposableObject {
1010
private config: DbConfig;
1111
private configWatcher: chokidar.FSWatcher | undefined;
1212

13-
public constructor(workspaceStoragePath: string, private readonly extensionPath: string) {
13+
public constructor(workspaceStoragePath: string) {
1414
super();
1515

1616
this.configPath = path.join(workspaceStoragePath, 'workspace-databases.json');
@@ -35,12 +35,7 @@ export class DbConfigStore extends DisposableObject {
3535

3636
private async loadConfig(): Promise<void> {
3737
if (!await fs.pathExists(this.configPath)) {
38-
const schemaPath = path.resolve(this.extensionPath, 'workspace-databases-schema.json');
39-
const json = {
40-
'$schema': `file://${schemaPath}`,
41-
...this.createEmptyConfig()
42-
};
43-
await fs.writeJSON(this.configPath, json, { spaces: 2 });
38+
await fs.writeJSON(this.configPath, this.createEmptyConfig(), { spaces: 2 });
4439
}
4540

4641
await this.readConfig();

extensions/ql-vscode/src/databases/db-module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export class DbModule extends DisposableObject {
2222
void logger.log('Initializing database module');
2323

2424
const storagePath = extensionContext.storageUri?.fsPath || extensionContext.globalStorageUri.fsPath;
25-
const extensionPath = extensionContext.extensionPath;
26-
const dbConfigStore = new DbConfigStore(storagePath, extensionPath);
25+
const dbConfigStore = new DbConfigStore(storagePath);
2726
await dbConfigStore.initialize();
2827

2928
const dbManager = new DbManager(dbConfigStore);

extensions/ql-vscode/test/pure-tests/databases/db-config-store.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { expect } from 'chai';
66
describe('db config store', async () => {
77
const tempWorkspaceStoragePath = path.join(__dirname, 'test-workspace');
88
const testDataStoragePath = path.join(__dirname, 'data');
9-
const extensionPath = path.join(__dirname, 'data');
109

1110
beforeEach(async () => {
1211
await fs.ensureDir(tempWorkspaceStoragePath);
@@ -19,7 +18,7 @@ describe('db config store', async () => {
1918
it('should create a new config if one does not exist', async () => {
2019
const configPath = path.join(tempWorkspaceStoragePath, 'workspace-databases.json');
2120

22-
const configStore = new DbConfigStore(tempWorkspaceStoragePath, extensionPath);
21+
const configStore = new DbConfigStore(tempWorkspaceStoragePath);
2322
await configStore.initialize();
2423

2524
expect(await fs.pathExists(configPath)).to.be.true;
@@ -30,7 +29,7 @@ describe('db config store', async () => {
3029
});
3130

3231
it('should load an existing config', async () => {
33-
const configStore = new DbConfigStore(testDataStoragePath, extensionPath);
32+
const configStore = new DbConfigStore(testDataStoragePath);
3433
await configStore.initialize();
3534

3635
const config = configStore.getConfig();
@@ -45,7 +44,7 @@ describe('db config store', async () => {
4544
});
4645

4746
it('should not allow modification of the config', async () => {
48-
const configStore = new DbConfigStore(testDataStoragePath, extensionPath);
47+
const configStore = new DbConfigStore(testDataStoragePath);
4948
await configStore.initialize();
5049

5150
const config = configStore.getConfig();

0 commit comments

Comments
 (0)