@@ -4,15 +4,15 @@ import {
4
4
CompletionItem ,
5
5
CompletionParams ,
6
6
} from 'vscode-languageserver/node'
7
- import { TextDocuments } from 'vscode-languageserver/lib/common/server '
7
+ import { LSPObject , TextDocuments } from 'vscode-languageserver'
8
8
import { CompletionTriggerKind } from 'vscode-languageserver-protocol/lib/common/protocol'
9
9
import { TextDocument } from 'vscode-languageserver-textdocument'
10
10
import { CodeAction , TextDocumentEdit , TextEdit , Position , CodeActionKind } from 'vscode-languageserver-types'
11
11
import cache from './cache'
12
12
import { complete } from './complete'
13
13
import createDiagnostics from './createDiagnostics'
14
14
import createConnection from './createConnection'
15
- import SettingStore from './SettingStore'
15
+ import SettingStore , { Connection as SettingConnection } from './SettingStore'
16
16
import { Schema } from './database_libs/AbstractClient'
17
17
import getDatabaseClient from './database_libs/getDatabaseClient'
18
18
import initializeLogging from './initializeLogging'
@@ -186,13 +186,19 @@ export function createServerWithConnection(connection: Connection, debug = false
186
186
if ( ! hasConfigurationCapability ) {
187
187
return
188
188
}
189
- const connections = change . settings ?. sqlLanguageServer ?. connections ?? [ ]
189
+ if ( ! Object . prototype . hasOwnProperty . call ( change . settings , 'sqlLanguageServer' ) ) {
190
+ logger . debug ( 'onDidChangeConfiguration' , "it doesn't have sqlLanguageServer property" )
191
+ return
192
+ }
193
+ const sqlLanguageServerSetting = ( ( change . settings as LSPObject ) . sqlLanguageServer ) as LSPObject
194
+
195
+ const connections = ( sqlLanguageServerSetting . connections ?? [ ] ) as SettingConnection [ ]
190
196
if ( connections . length > 0 ) {
191
197
SettingStore . getInstance ( ) . setSettingFromWorkspaceConfig ( connections )
192
198
}
193
199
194
200
// On configuration changes we retrieve the lint config
195
- const lint = change . settings ?. sqlLanguageServer ?. lint
201
+ const lint = ( ( sqlLanguageServerSetting ) . lint ) as RawConfig
196
202
lintConfig = lint
197
203
if ( lint ?. rules ) {
198
204
documents . all ( ) . forEach ( v => {
@@ -272,7 +278,7 @@ export function createServerWithConnection(connection: Connection, debug = false
272
278
) {
273
279
try {
274
280
SettingStore . getInstance ( ) . changeConnection (
275
- request . arguments && request . arguments [ 0 ] || ''
281
+ request . arguments && request . arguments [ 0 ] ?. toString ( ) || ''
276
282
)
277
283
} catch ( e ) {
278
284
const err = e as NodeJS . ErrnoException
@@ -291,7 +297,7 @@ export function createServerWithConnection(connection: Connection, debug = false
291
297
} )
292
298
return
293
299
}
294
- const document = documents . get ( uri )
300
+ const document = documents . get ( uri . toString ( ) )
295
301
const text = document ?. getText ( )
296
302
if ( ! text ) {
297
303
logger . debug ( 'Failed to get text' )
@@ -305,7 +311,7 @@ export function createServerWithConnection(connection: Connection, debug = false
305
311
logger . debug ( 'Fix all fixable problems' , text , result [ 0 ] . fixedText )
306
312
connection . workspace . applyEdit ( {
307
313
documentChanges : [
308
- TextDocumentEdit . create ( { uri, version : document ! . version } , [
314
+ TextDocumentEdit . create ( { uri : uri . toString ( ) , version : document ! . version } , [
309
315
TextEdit . replace ( {
310
316
start : Position . create ( 0 , 0 ) ,
311
317
end : Position . create ( Number . MAX_VALUE , Number . MAX_VALUE )
0 commit comments