diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/folding.lua | 10 | ||||
-rw-r--r-- | script/core/semantic-tokens.lua | 8 | ||||
-rw-r--r-- | script/provider/provider.lua | 29 |
3 files changed, 28 insertions, 19 deletions
diff --git a/script/core/folding.lua b/script/core/folding.lua index 51d1be6b..bd3ba5f3 100644 --- a/script/core/folding.lua +++ b/script/core/folding.lua @@ -146,22 +146,22 @@ local Care = { } return function (uri) - local ast = files.getState(uri) - local text = files.getText(uri) - if not ast or not text then + local state = files.getState(uri) + local text = files.getText(uri) + if not state or not text then return nil end local regions = {} local status = {} - guide.eachSource(ast.ast, function (source) + guide.eachSource(state.ast, function (source) local tp = source.type if Care[tp] then await.delay() Care[tp](source, text, regions) end end) - for _, source in ipairs(ast.comms) do + for _, source in ipairs(state.comms) do local tp = source.type if Care[tp] then await.delay() diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index 405f2735..38b75227 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -214,14 +214,14 @@ local function buildTokens(uri, results) end return function (uri, start, finish) - local ast = files.getState(uri) + local state = files.getState(uri) local text = files.getText(uri) - if not ast then + if not state then return nil end local results = {} - guide.eachSourceBetween(ast.ast, start, finish, function (source) + guide.eachSourceBetween(state.ast, start, finish, function (source) local method = Care[source.type] if not method then return @@ -230,7 +230,7 @@ return function (uri, start, finish) await.delay() end) - for _, comm in ipairs(ast.comms) do + for _, comm in ipairs(state.comms) do if comm.type == 'comment.cshort' then results[#results+1] = { start = comm.start, diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 39683b2b..2b6a1f7c 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -166,8 +166,11 @@ proto.on('textDocument/didChange', function (params) end) proto.on('textDocument/hover', function (params) + local doc = params.textDocument + local uri = doc.uri await.close 'hover' await.setID 'hover' + await.setID('update:' .. uri) if not workspace.isReady() then local count, max = workspace.getLoadProcess() return { @@ -179,8 +182,6 @@ proto.on('textDocument/hover', function (params) end local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_HOVER, 0.5) local core = require 'core.hover' - local doc = params.textDocument - local uri = doc.uri if not files.exists(uri) then return nil end @@ -357,8 +358,10 @@ proto.on('textDocument/prepareRename', function (params) end) proto.on('textDocument/completion', function (params) + local uri = params.textDocument.uri await.close 'completion' await.setID 'completion' + await.setID('update:' .. uri) if not workspace.isReady() then local count, max = workspace.getLoadProcess() return { @@ -378,7 +381,6 @@ proto.on('textDocument/completion', function (params) local core = require 'core.completion' --log.debug('textDocument/completion') --log.debug('completion:', params.context and params.context.triggerKind, params.context and params.context.triggerCharacter) - local uri = params.textDocument.uri if not files.exists(uri) then return nil end @@ -475,10 +477,11 @@ proto.on('completionItem/resolve', function (item) if not item.data then return item end - await.close 'completion.resolve' - await.setID 'completion.resolve' local id = item.data.id local uri = item.data.uri + await.close 'completion.resolve' + await.setID 'completion.resolve' + await.setID('update:' .. uri) --await.setPriority(1000) local resolved = core.resolve(id) if not resolved then @@ -518,6 +521,7 @@ proto.on('textDocument/signatureHelp', function (params) end await.close('signatureHelp') await.setID('signatureHelp') + await.setID('update:' .. uri) local pos = converter.unpackPosition(uri, params.position) local core = require 'core.signature' local results = core(uri, pos) @@ -649,6 +653,7 @@ proto.on('workspace/symbol', function (params) await.close('workspace/symbol') await.setID('workspace/symbol') + await.setID('files.version') local symbols = core(params.query) if not symbols or #symbols == 0 then @@ -676,12 +681,13 @@ end) proto.on('textDocument/semanticTokens/full', function (params) - workspace.awaitReady() + local uri = params.textDocument.uri await.close('textDocument/semanticTokens/full') await.setID('textDocument/semanticTokens/full') + await.setID('update:' .. uri) + workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5) local core = require 'core.semantic-tokens' - local uri = params.textDocument.uri local text = files.getText(uri) if not text then return nil @@ -693,12 +699,13 @@ proto.on('textDocument/semanticTokens/full', function (params) end) proto.on('textDocument/semanticTokens/range', function (params) + local uri = params.textDocument.uri + await.close('textDocument/semanticTokens/range') + await.setID('textDocument/semanticTokens/range') + await.setID('update:' .. uri) workspace.awaitReady() - --await.close('textDocument/semanticTokens/range') - --await.setID('textDocument/semanticTokens/range') local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) local core = require 'core.semantic-tokens' - local uri = params.textDocument.uri local cache = files.getOpenedCache(uri) local start, finish if cache and not cache['firstSemantic'] then @@ -722,6 +729,7 @@ proto.on('textDocument/foldingRange', function (params) end await.close('textDocument/foldingRange') await.setID('textDocument/foldingRange') + await.setID('update:' .. uri) local regions = core(uri) if not regions then return nil @@ -826,6 +834,7 @@ do return end await.setID(awaitID) + await.setID('update:' .. uri) workspace.awaitReady() local visibles = files.getVisibles(uri) if not visibles then |