@@ -230,24 +230,23 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
230230 }
231231 }
232232
233- override fun hover (params : HoverParams ? ): CompletableFuture <Hover ?> {
233+ override fun hover (params : HoverParams ): CompletableFuture <Hover ?> {
234+ val file = workspace.findFile(params.textDocument.uri)
234235 return computeAsync {
235236 var hover: Hover ? = null
236- if (params != null ) {
237- val file = workspace.findFile(params.textDocument.uri)
238- if (file is ILuaFile ) {
239- file.lock {
240- val pos = file.getPosition(params.position.line, params.position.character)
241- val element = TargetElementUtil .findTarget(file.psi, pos)
242- if (element != null ) {
243- val ref = element.reference?.resolve() ? : element
244- val doc = documentProvider.generateDoc(ref, false )
245- if (doc != null )
246- hover = Hover (listOf (Either .forLeft(doc)))
247- }
237+ if (file is ILuaFile ) {
238+ file.lock {
239+ val pos = file.getPosition(params.position.line, params.position.character)
240+ val element = TargetElementUtil .findTarget(file.psi, pos)
241+ if (element != null ) {
242+ val ref = element.reference?.resolve() ? : element
243+ val doc = documentProvider.generateDoc(ref, false )
244+ if (doc != null )
245+ hover = Hover (listOf (Either .forLeft(doc)))
248246 }
249247 }
250248 }
249+
251250 hover
252251 }
253252 }
@@ -324,10 +323,10 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
324323 }
325324
326325 override fun codeLens (params : CodeLensParams ): CompletableFuture <MutableList <out CodeLens >> {
326+ val file = workspace.findFile(params.textDocument.uri)
327327 return computeAsync { cc ->
328328 val list = mutableListOf<CodeLens >()
329329 if (VSCodeSettings .showCodeLens) {
330- val file = workspace.findFile(params.textDocument.uri)
331330 if (file is ILuaFile ) {
332331 file.lock {
333332 file.psi?.acceptChildren(object : LuaVisitor () {
@@ -426,10 +425,10 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
426425 }
427426
428427 override fun completion (params : CompletionParams ): CompletableFuture <Either <MutableList <CompletionItem >, CompletionList>> {
428+ val file = workspace.findFile(params.textDocument.uri)
429429 return computeAsync { checker ->
430430 val list = CompletionList ()
431431 list.items = mutableListOf ()
432- val file = workspace.findFile(params.textDocument.uri)
433432 if (file is ILuaFile ) {
434433 file.lock {
435434 val psi = file.psi
@@ -461,9 +460,9 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
461460// }
462461
463462 override fun documentSymbol (params : DocumentSymbolParams ): CompletableFuture <List <Either <SymbolInformation , DocumentSymbol >>> {
463+ val file = workspace.findFile(params.textDocument.uri)
464464 return computeAsync {
465465 val list = mutableListOf<Either <SymbolInformation , DocumentSymbol >>()
466- val file = workspace.findFile(params.textDocument.uri)
467466 if (file is ILuaFile ) {
468467 file.lock {
469468 val psi = file.psi
@@ -1056,8 +1055,8 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
10561055// }
10571056
10581057 override fun inlayHint (params : InlayHintParams ): CompletableFuture <MutableList <InlayHint >> {
1058+ val file = workspace.findFile(params.textDocument.uri)
10591059 return computeAsync {
1060- val file = workspace.findFile(params.textDocument.uri)
10611060 var list: MutableList <InlayHint > = mutableListOf ()
10621061 if (file is LuaFile ) {
10631062 file.lock {
@@ -1071,8 +1070,8 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
10711070 }
10721071
10731072 override fun diagnostic (params : DocumentDiagnosticParams ): CompletableFuture <DocumentDiagnosticReport > {
1073+ val file = workspace.findFile(params.textDocument.uri)
10741074 return computeAsync { checker ->
1075- val file = workspace.findFile(params.textDocument.uri)
10761075 if (file is ILuaFile ) {
10771076 val report = workspace.diagnoseFile(file, params.previousResultId, checker)
10781077 report
0 commit comments