diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/core/hover/hover.lua | 11 | ||||
-rw-r--r-- | server/src/parser/ast.lua | 40 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 4 | ||||
-rw-r--r-- | server/src/vm/local.lua | 3 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 7 |
5 files changed, 48 insertions, 17 deletions
diff --git a/server/src/core/hover/hover.lua b/server/src/core/hover/hover.lua index d8694766..48f91796 100644 --- a/server/src/core/hover/hover.lua +++ b/server/src/core/hover/hover.lua @@ -172,6 +172,17 @@ local function getValueHover(source, name, value, lib) local tp if source:bindLocal() then tp = 'local' + local loc = source:bindLocal() + if loc.tags then + local mark = {} + for _, tag in ipairs(loc.tags) do + local tagName = tag[1] + if not mark[tagName] then + mark[tagName] = true + tp = ('%s <%s>'):format(tp, tagName) + end + end + end elseif source:get 'global' then tp = 'global' elseif source:get 'simple' then diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index fac276b8..130f497c 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -836,21 +836,39 @@ local Defs = { keys, values, } end, - Local = function (tag, keys, values) - if tag and State.Version ~= 'Lua 5.4' then - pushError { - type = 'UNSUPPORT_SYMBOL', - start = tag.start, - finish = tag.finish, - version = 'Lua 5.4', - info = { - version = State.Version, + LocalTag = function (...) + if not ... or ... == '' then + return nil + end + local tags = {...} + for _, tag in ipairs(tags) do + if State.Version ~= 'Lua 5.4' then + pushError { + type = 'UNSUPPORT_SYMBOL', + start = tag.start, + finish = tag.finish, + version = 'Lua 5.4', + info = { + version = State.Version, + } } - } + elseif tag[1] ~= 'const' and tag[1] ~= 'toclose' then + pushError { + type = 'UNKNOWN_TAG', + start = tag.start, + finish = tag.finish, + info = { + tag = tag[1], + } + } + end end + return tags + end, + Local = function (tags, keys, values) return { type = 'local', - keys, values, tag + keys, values, tags } end, DoBody = function (...) diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index c0025a9c..7f8284a0 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -482,8 +482,8 @@ RepeatBody <- REPEAT BreakEnd NeedUntil DirtyExp -LocalTag <- Sp '<' MustName LocalTagEnd - / %nil +LocalTag <- (Sp '<' MustName LocalTagEnd)* + -> LocalTag LocalTagEnd <- '>' / {} -> MissGT Local <- (LOCAL LocalTag NameList (ASSIGN ExpList)?) -> Local diff --git a/server/src/vm/local.lua b/server/src/vm/local.lua index 5b936625..e7355dc2 100644 --- a/server/src/vm/local.lua +++ b/server/src/vm/local.lua @@ -153,7 +153,7 @@ function mt:setEmmy(emmy) end end -local function create(name, source, value) +local function create(name, source, value, tags) if not value then error('Local must has a value') end @@ -168,6 +168,7 @@ local function create(name, source, value) name = name, source = id, value = value, + tags = tags, _info = {}, }, mt) Watch[self] = true diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 3aee3c6f..98b79fe9 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -853,6 +853,7 @@ function mt:doLocal(action) self:instantSource(action) local vars = action[1] local exps = action[2] + local tags = action[3] local values if exps then local value = self:getExp(exps) @@ -875,7 +876,7 @@ function mt:doLocal(action) if values then value = values[i] end - self:createLocal(key[1], key, value, emmy) + self:createLocal(key[1], key, value, tags, emmy) end) end @@ -1186,7 +1187,7 @@ function mt:bindLabel(source, label, action) end end -function mt:createLocal(key, source, value, emmy) +function mt:createLocal(key, source, value, tags, emmy) local loc = self:bindLocal(source) if not value then value = self:createValue('nil', source) @@ -1198,7 +1199,7 @@ function mt:createLocal(key, source, value, emmy) return loc end - loc = localMgr.create(key, source, value) + loc = localMgr.create(key, source, value, tags) loc:setEmmy(emmy) self:saveLocal(key, loc) self:bindLocal(source, loc, 'local') |