From 9b7a246d397aff61bc29837c40a1317ff18c7887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 5 Nov 2019 11:27:05 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=87=8D=E5=AE=9A=E4=B9=89=E5=B1=80?= =?UTF-8?q?=E9=83=A8=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/diagnostics/redefined-local.lua | 2 +- server-beta/src/parser/ast.lua | 2 +- server-beta/src/parser/guide.lua | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server-beta/src/core/diagnostics/redefined-local.lua b/server-beta/src/core/diagnostics/redefined-local.lua index a1b0e77a..f6176794 100644 --- a/server-beta/src/core/diagnostics/redefined-local.lua +++ b/server-beta/src/core/diagnostics/redefined-local.lua @@ -13,7 +13,7 @@ return function (uri, callback) or name == '_ENV' then return end - local exist = guide.getLocal(source, name, source.start) + local exist = guide.getLocal(source, name, source.start-1) if exist then callback { start = source.start, diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index ae8f9a7a..39e7d871 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -862,7 +862,7 @@ local Defs = { return end - local loc = createLocal(name, start, actions) + local loc = createLocal(name, name.start, actions) loc.localfunction = true return loc diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index d8dd873e..02284b1e 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -316,12 +316,14 @@ function m.eachSourceType(ast, type, callback) if not cache then cache = {} ast.typeCache[type] = cache + local mark = {} + m.eachSource(ast, function (source) + if source.type == type and not mark[source] then + mark[source] = true + cache[#cache+1] = source + end + end) end - m.eachSource(ast, function (source) - if source.type == type then - cache[#cache+1] = source - end - end) for i = 1, #cache do callback(cache[i]) end -- cgit v1.2.3