diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:08:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:08:02 +0800 |
commit | 4b085b8aea5f33ec114baa31d2b9d72341383c32 (patch) | |
tree | fe35a326408e762711a31d3e803464f0c1a8468d /script/vm | |
parent | 0c8c6bbf23082d0b858646846a47a3001f718ae2 (diff) | |
parent | 35ce57976db3b4c42193279dd55972ea013fecad (diff) | |
download | lua-language-server-4b085b8aea5f33ec114baa31d2b9d72341383c32.zip |
Merge branch 'newparser'
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/getDocs.lua | 80 | ||||
-rw-r--r-- | script/vm/getLinks.lua | 6 |
2 files changed, 38 insertions, 48 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua index c0205654..0c6b1695 100644 --- a/script/vm/getDocs.lua +++ b/script/vm/getDocs.lua @@ -177,7 +177,6 @@ function vm.isDeprecated(value, deep) end local function makeDiagRange(uri, doc, results) - local lines = files.getLines(uri) local names if doc.names then names = {} @@ -186,57 +185,51 @@ local function makeDiagRange(uri, doc, results) names[name] = true end end - local row = guide.positionOf(lines, doc.start) + local row = guide.rowColOf(doc.start) if doc.mode == 'disable-next-line' then - if lines[row+1] then - results[#results+1] = { - mode = 'disable', - names = names, - offset = lines[row+1].start, - source = doc, - } - results[#results+1] = { - mode = 'enable', - names = names, - offset = lines[row+1].finish, - source = doc, - } - end + results[#results+1] = { + mode = 'disable', + names = names, + row = row + 1, + source = doc, + } + results[#results+1] = { + mode = 'enable', + names = names, + row = row + 2, + source = doc, + } elseif doc.mode == 'disable-line' then results[#results+1] = { mode = 'disable', names = names, - offset = lines[row].start, + row = row, source = doc, } results[#results+1] = { mode = 'enable', names = names, - offset = lines[row].finish, + row = row + 1, source = doc, } elseif doc.mode == 'disable' then - if lines[row+1] then - results[#results+1] = { - mode = 'disable', - names = names, - offset = lines[row+1].start, - source = doc, - } - end + results[#results+1] = { + mode = 'disable', + names = names, + row = row + 1, + source = doc, + } elseif doc.mode == 'enable' then - if lines[row+1] then - results[#results+1] = { - mode = 'enable', - names = names, - offset = lines[row+1].start, - source = doc, - } - end + results[#results+1] = { + mode = 'enable', + names = names, + row = row + 1, + source = doc, + } end end -function vm.isDiagDisabledAt(uri, offset, name) +function vm.isDiagDisabledAt(uri, position, name) local status = files.getState(uri) if not status then return false @@ -253,29 +246,26 @@ function vm.isDiagDisabledAt(uri, offset, name) end end table.sort(cache.diagnosticRanges, function (a, b) - return a.offset < b.offset + return a.row < b.row end) end if #cache.diagnosticRanges == 0 then return false end - local stack = {} + local myRow = guide.rowColOf(position) + local count = 0 for _, range in ipairs(cache.diagnosticRanges) do - if range.offset <= offset then + if range.row <= myRow then if not range.names or range.names[name] then if range.mode == 'disable' then - stack[#stack+1] = range + count = count + 1 elseif range.mode == 'enable' then - stack[#stack] = nil + count = count - 1 end end else break end end - local current = stack[#stack] - if not current then - return false - end - return true + return count > 0 end diff --git a/script/vm/getLinks.lua b/script/vm/getLinks.lua index 161396f6..d2332504 100644 --- a/script/vm/getLinks.lua +++ b/script/vm/getLinks.lua @@ -6,12 +6,12 @@ local files = require 'files' local function getFileLinks(uri) local ws = require 'workspace' local links = {} - local ast = files.getState(uri) - if not ast then + local state = files.getState(uri) + if not state then return links end tracy.ZoneBeginN('getFileLinks') - guide.eachSpecialOf(ast.ast, 'require', function (source) + guide.eachSpecialOf(state.ast, 'require', function (source) local call = source.parent if not call or call.type ~= 'call' then return |