summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-23 16:02:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-23 16:02:08 +0800
commit466874e8a8e360634833a07508fb48131530b704 (patch)
treeb5ea2e570b2e2621658d44891b7949bc867fa247 /script
parent5c9b1b467af1636ea21a9bd3d398e220790eea54 (diff)
downloadlua-language-server-466874e8a8e360634833a07508fb48131530b704.zip
cleanup
Diffstat (limited to 'script')
-rw-r--r--script/brave/work.lua2
-rw-r--r--script/client.lua3
-rw-r--r--script/core/code-action.lua2
-rw-r--r--script/core/command/jsonToLua.lua15
-rw-r--r--script/core/command/removeSpace.lua11
-rw-r--r--script/core/command/solve.lua2
-rw-r--r--script/core/noder.lua2
-rw-r--r--script/provider/diagnostic.lua31
-rw-r--r--script/provider/provider.lua42
9 files changed, 57 insertions, 53 deletions
diff --git a/script/brave/work.lua b/script/brave/work.lua
index ee7b4acd..7af36fda 100644
--- a/script/brave/work.lua
+++ b/script/brave/work.lua
@@ -26,7 +26,7 @@ brave.on('timer', function (time)
end)
brave.on('compile', function (text)
- local state, err = parser.compile(text, 'lua', 'Lua 5.4')
+ local state, err = parser.compile(text, 'Lua', 'Lua 5.4')
if not state then
log.error(err)
return
diff --git a/script/client.lua b/script/client.lua
index c22b59ab..c539a0f7 100644
--- a/script/client.lua
+++ b/script/client.lua
@@ -4,6 +4,7 @@ local lang = require 'language'
local proto = require 'proto'
local define = require 'proto.define'
local config = require 'config'
+local converter = require 'proto.converter'
local m = {}
@@ -223,7 +224,7 @@ function m.editText(uri, edits)
local files = require 'files'
local textEdits = {}
for i, edit in ipairs(edits) do
- textEdits[i] = define.textEdit(files.range(uri, edit.start, edit.finish), edit.text)
+ textEdits[i] = define.textEdit(converter.packRange(uri, edit.start, edit.finish), edit.text)
end
proto.request('workspace/applyEdit', {
edit = {
diff --git a/script/core/code-action.lua b/script/core/code-action.lua
index 2bc6ae50..40aef8fc 100644
--- a/script/core/code-action.lua
+++ b/script/core/code-action.lua
@@ -166,7 +166,7 @@ local function findSyntax(uri, diag)
local ast = files.getState(uri)
for _, err in ipairs(ast.errs) do
if err.type:lower():gsub('_', '-') == diag.code then
- local range = files.range(uri, err.start, err.finish)
+ local range = converter.packRange(uri, err.start, err.finish)
if util.equal(range, diag.range) then
return err
end
diff --git a/script/core/command/jsonToLua.lua b/script/core/command/jsonToLua.lua
index c4f001ff..8a493b5e 100644
--- a/script/core/command/jsonToLua.lua
+++ b/script/core/command/jsonToLua.lua
@@ -1,9 +1,10 @@
-local files = require 'files'
-local json = require 'json'
-local util = require 'utility'
-local proto = require 'proto'
-local define = require 'proto.define'
-local lang = require 'language'
+local files = require 'files'
+local json = require 'json'
+local util = require 'utility'
+local proto = require 'proto'
+local define = require 'proto.define'
+local lang = require 'language'
+local converter = require 'proto.converter'
return function (data)
local text = files.getText(data.uri)
@@ -26,7 +27,7 @@ return function (data)
changes = {
[data.uri] = {
{
- range = files.range(data.uri, data.start, data.finish),
+ range = converter.packRange(data.uri, data.start, data.finish),
newText = luaStr,
}
}
diff --git a/script/core/command/removeSpace.lua b/script/core/command/removeSpace.lua
index 34c74ce0..3d7795a1 100644
--- a/script/core/command/removeSpace.lua
+++ b/script/core/command/removeSpace.lua
@@ -1,7 +1,8 @@
-local files = require 'files'
-local guide = require 'parser.guide'
-local proto = require 'proto'
-local lang = require 'language'
+local files = require 'files'
+local guide = require 'parser.guide'
+local proto = require 'proto'
+local lang = require 'language'
+local converter = require 'proto.converter'
local function isInString(ast, offset)
return guide.eachSourceContain(ast.ast, offset, function (source)
@@ -30,7 +31,7 @@ return function (data)
goto NEXT_LINE
end
textEdit[#textEdit+1] = {
- range = files.range(uri, start, finish),
+ range = converter.packRange(uri, start, finish),
newText = '',
}
goto NEXT_LINE
diff --git a/script/core/command/solve.lua b/script/core/command/solve.lua
index 790adbee..9428d065 100644
--- a/script/core/command/solve.lua
+++ b/script/core/command/solve.lua
@@ -85,7 +85,7 @@ return function (data)
changes = {
[uri] = {
{
- range = files.range(uri, result.start, result.finish),
+ range = converter.packRange(uri, result.start, result.finish),
newText = ('(%s)'):format(text:sub(result.start, result.finish)),
}
},
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 1107dcda..177a151c 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -1337,7 +1337,7 @@ function m.compileNode(noders, source)
local id = getID(source)
bindValue(noders, source, id)
- if specialMap[source.special] then
+ if id and specialMap[source.special] then
noders.skip[id] = true
end
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index db377ea0..ec579428 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -1,14 +1,15 @@
-local await = require 'await'
-local proto = require 'proto.proto'
-local define = require 'proto.define'
-local lang = require 'language'
-local files = require 'files'
-local config = require 'config'
-local core = require 'core.diagnostics'
-local util = require 'utility'
-local ws = require 'workspace'
-local progress = require "progress"
-local client = require 'client'
+local await = require 'await'
+local proto = require 'proto.proto'
+local define = require 'proto.define'
+local lang = require 'language'
+local files = require 'files'
+local config = require 'config'
+local core = require 'core.diagnostics'
+local util = require 'utility'
+local ws = require 'workspace'
+local progress = require "progress"
+local client = require 'client'
+local converter = require 'proto.converter'
local m = {}
m._start = false
@@ -48,14 +49,14 @@ local function buildSyntaxError(uri, err)
local relUri = rel.uri
relatedInformation[#relatedInformation+1] = {
message = rmessage,
- location = define.location(relUri, files.range(relUri, rel.start, rel.finish)),
+ location = define.location(relUri, converter.packRange(relUri, rel.start, rel.finish)),
}
end
end
return {
code = err.type:lower():gsub('_', '-'),
- range = files.range(uri, err.start, err.finish),
+ range = converter.packRange(uri, err.start, err.finish),
severity = define.DiagnosticSeverity.Error,
source = lang.script.DIAG_SYNTAX_CHECK,
message = message,
@@ -75,13 +76,13 @@ local function buildDiagnostic(uri, diag)
local rtext = files.getText(rel.uri)
relatedInformation[#relatedInformation+1] = {
message = rel.message or rtext:sub(rel.start, rel.finish),
- location = define.location(rel.uri, files.range(rel.uri, rel.start, rel.finish))
+ location = define.location(rel.uri, converter.packRange(rel.uri, rel.start, rel.finish))
}
end
end
return {
- range = files.range(uri, diag.start, diag.finish),
+ range = converter.packRange(uri, diag.start, diag.finish),
source = lang.script.DIAG_DIAGNOSTICS,
severity = diag.level,
message = diag.message,
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index d4bf0bee..af62372b 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -194,7 +194,7 @@ proto.on('textDocument/hover', function (params)
value = tostring(hover),
kind = 'markdown',
},
- range = files.range(uri, source.start, source.finish),
+ range = converter.packRange(uri, source.start, source.finish),
}
end)
@@ -218,13 +218,13 @@ proto.on('textDocument/definition', function (params)
if files.exists(targetUri) then
if client.getAbility 'textDocument.definition.linkSupport' then
response[i] = define.locationLink(targetUri
- , files.range(targetUri, info.target.start, info.target.finish)
- , files.range(targetUri, info.target.start, info.target.finish)
- , files.range(uri, info.source.start, info.source.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(uri, info.source.start, info.source.finish)
)
else
response[i] = define.location(targetUri
- , files.range(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
)
end
end
@@ -253,13 +253,13 @@ proto.on('textDocument/typeDefinition', function (params)
if files.exists(targetUri) then
if client.getAbility 'textDocument.typeDefinition.linkSupport' then
response[i] = define.locationLink(targetUri
- , files.range(targetUri, info.target.start, info.target.finish)
- , files.range(targetUri, info.target.start, info.target.finish)
- , files.range(uri, info.source.start, info.source.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(uri, info.source.start, info.source.finish)
)
else
response[i] = define.location(targetUri
- , files.range(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
)
end
end
@@ -285,7 +285,7 @@ proto.on('textDocument/references', function (params)
for i, info in ipairs(result) do
local targetUri = info.uri
response[i] = define.location(targetUri
- , files.range(targetUri, info.target.start, info.target.finish)
+ , converter.packRange(targetUri, info.target.start, info.target.finish)
)
end
return response
@@ -305,7 +305,7 @@ proto.on('textDocument/documentHighlight', function (params)
local response = {}
for _, info in ipairs(result) do
response[#response+1] = {
- range = files.range(uri, info.start, info.finish),
+ range = converter.packRange(uri, info.start, info.finish),
kind = info.kind,
}
end
@@ -333,7 +333,7 @@ proto.on('textDocument/rename', function (params)
if not workspaceEdit.changes[ruri] then
workspaceEdit.changes[ruri] = {}
end
- local textEdit = define.textEdit(files.range(ruri, info.start, info.finish), info.text)
+ local textEdit = define.textEdit(converter.packRange(ruri, info.start, info.finish), info.text)
workspaceEdit.changes[ruri][#workspaceEdit.changes[ruri]+1] = textEdit
end
return workspaceEdit
@@ -351,7 +351,7 @@ proto.on('textDocument/prepareRename', function (params)
return nil
end
return {
- range = files.range(uri, result.start, result.finish),
+ range = converter.packRange(uri, result.start, result.finish),
placeholder = result.text,
}
end)
@@ -418,7 +418,7 @@ proto.on('textDocument/completion', function (params)
commitCharacters = res.commitCharacters,
command = res.command,
textEdit = res.textEdit and {
- range = files.range(
+ range = converter.packRange(
uri,
res.textEdit.start,
res.textEdit.finish
@@ -429,7 +429,7 @@ proto.on('textDocument/completion', function (params)
local t = {}
for j, edit in ipairs(res.additionalTextEdits) do
t[j] = {
- range = files.range(
+ range = converter.packRange(
uri,
edit.start,
edit.finish
@@ -493,7 +493,7 @@ proto.on('completionItem/resolve', function (item)
local t = {}
for j, edit in ipairs(resolved.additionalTextEdits) do
t[j] = {
- range = files.range(
+ range = converter.packRange(
uri,
edit.start,
edit.finish
@@ -563,12 +563,12 @@ proto.on('textDocument/documentSymbol', function (params)
local function convert(symbol)
await.delay()
- symbol.range = files.range(
+ symbol.range = converter.packRange(
uri,
symbol.range[1],
symbol.range[2]
)
- symbol.selectionRange = files.range(
+ symbol.selectionRange = converter.packRange(
uri,
symbol.selectionRange[1],
symbol.selectionRange[2]
@@ -611,7 +611,7 @@ proto.on('textDocument/codeAction', function (params)
if res.edit then
for turi, changes in pairs(res.edit.changes) do
for _, change in ipairs(changes) do
- change.range = files.range(turi, change.start, change.finish)
+ change.range = converter.packRange(turi, change.start, change.finish)
change.start = nil
change.finish = nil
end
@@ -658,7 +658,7 @@ proto.on('workspace/symbol', function (params)
local function convert(symbol)
symbol.location = define.location(
symbol.uri,
- files.range(
+ converter.packRange(
symbol.uri,
symbol.range[1],
symbol.range[2]
@@ -790,7 +790,7 @@ proto.on('textDocument/onTypeFormatting', function (params)
local results = {}
for i, edit in ipairs(edits) do
results[i] = {
- range = files.range(uri, edit.start, edit.finish),
+ range = converter.packRange(uri, edit.start, edit.finish),
newText = edit.text:gsub('\t', tab),
}
end