diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-25 21:07:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-25 21:07:22 +0800 |
commit | 5242ea4f866f112e91ffa918db07626280decb71 (patch) | |
tree | 83f2d805120d0ac99b6d927dfd6d5b82ef32913c /script/provider | |
parent | 8da13a0f7daba5eabed3d801643bc260d9990193 (diff) | |
download | lua-language-server-5242ea4f866f112e91ffa918db07626280decb71.zip |
clean up code
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/diagnostic.lua | 5 | ||||
-rw-r--r-- | script/provider/provider.lua | 19 |
2 files changed, 6 insertions, 18 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 2184a6cd..cf9500f6 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -22,7 +22,6 @@ local function concat(t, sep) end local function buildSyntaxError(uri, err) - local lines = files.getLines(uri) local text = files.getText(uri) local message = lang.script('PARSER_'..err.type, err.info) @@ -63,9 +62,7 @@ local function buildSyntaxError(uri, err) end local function buildDiagnostic(uri, diag) - local lines = files.getLines(uri) - local text = files.getText(uri) - if not text or not lines then + if files.exists(uri) then return end diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 0b880ff7..6c8890ac 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -236,8 +236,6 @@ proto.on('textDocument/definition', function (params) if not files.exists(uri) then return nil end - local lines = files.getLines(uri) - local text = files.getText(uri) local offset = files.offsetOfWord(uri, params.position) local result = core(uri, offset) if not result then @@ -247,8 +245,7 @@ proto.on('textDocument/definition', function (params) for i, info in ipairs(result) do local targetUri = info.uri if targetUri then - local targetLines = files.getLines(targetUri) - if targetLines then + if files.exists(targetUri) then response[i] = define.locationLink(targetUri , files.range(targetUri, info.target.start, info.target.finish) , files.range(targetUri, info.target.start, info.target.finish) @@ -266,8 +263,6 @@ proto.on('textDocument/references', function (params) if not files.exists(uri) then return nil end - local lines = files.getLines(uri) - local text = files.getText(uri) local offset = files.offsetOfWord(uri, params.position) local result = core(uri, offset) if not result then @@ -516,7 +511,7 @@ end) proto.on('textDocument/documentSymbol', function (params) local core = require 'core.document-symbol' local uri = params.textDocument.uri - while not files.getLines(uri) do + while not files.exists(uri) do await.sleep(0.1) end @@ -560,9 +555,7 @@ proto.on('textDocument/codeAction', function (params) local uri = params.textDocument.uri local range = params.range local diagnostics = params.context.diagnostics - local text = files.getText(uri) - local lines = files.getLines(uri) - if not text or not lines then + if files.exists(uri) then return nil end @@ -649,7 +642,7 @@ proto.on('textDocument/semanticTokens/range', function (params) local core = require 'core.semantic-tokens' local uri = params.textDocument.uri log.debug('semanticTokens/range', uri) - while not files.getLines(uri) do + while not files.exists(uri) do await.sleep(0.1) end local start = files.offsetOfWord(uri, params.range.start) @@ -663,9 +656,7 @@ end) proto.on('textDocument/foldingRange', function (params) local core = require 'core.folding' local uri = params.textDocument.uri - local lines = files.getLines(uri) - local text = files.getText(uri) - if not lines or not text then + if not files.exists(uri) then return nil end local regions = core(uri) |