Skip to content

Commit a9e6ddc

Browse files
committed
update supporting of hover and semantic-tokens
1 parent 116de62 commit a9e6ddc

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

script/core/hover/label.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ end
9898
---@async
9999
---@param level integer
100100
local function asGlobal(source, level)
101+
if source.declare and source[1] == '*' then
102+
return '(global) any', 0
103+
end
101104
return asValue(source, '(global)', level)
102105
end
103106

script/core/semantic-tokens.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ local Care = util.switch()
1818
end
1919

2020
local name = source[1]
21+
if source.declare and name == '*' then
22+
return
23+
end
2124
local isLib = options.libGlobals[name]
2225
if isLib == nil then
2326
isLib = false
@@ -38,6 +41,10 @@ local Care = util.switch()
3841
local type = isFunc and define.TokenTypes['function'] or define.TokenTypes.variable
3942
local modifier = isLib and define.TokenModifiers.defaultLibrary or define.TokenModifiers.global
4043

44+
if source.declare then
45+
modifier = modifier | define.TokenModifiers.declaration
46+
end
47+
4148
results[#results+1] = {
4249
start = source.start,
4350
finish = source.finish,

script/parser/compile.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3415,7 +3415,7 @@ local function parseGlobal()
34153415
if Tokens[Index + 1] == '*' then
34163416
local action = {
34173417
type = 'globalall',
3418-
start = globalPos,
3418+
start = getPosition(Tokens[Index], 'left'),
34193419
finish = getPosition(Tokens[Index], 'right'),
34203420
attrs = attrs,
34213421
[1] = '*',

test/hover/init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,3 +2512,12 @@ end
25122512
[[
25132513
function f(a: number, b: string, ...args: boolean)
25142514
]]
2515+
2516+
config.set(nil, 'Lua.runtime.version', 'Lua 5.5')
2517+
TEST [[
2518+
global <?*?>
2519+
]]
2520+
[[
2521+
(global) any
2522+
]]
2523+
config.set(nil, 'Lua.runtime.version', nil)

test/parser_test/syntax_check.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,4 +1022,7 @@ global <!X!>
10221022
]]
10231023
{
10241024
type = 'ENV_IS_GLOBAL',
1025+
info = {
1026+
name = 'X',
1027+
}
10251028
}

0 commit comments

Comments
 (0)