summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-07-15 14:20:03 +0800
committerGitHub <noreply@github.com>2024-07-15 14:20:03 +0800
commitdf30d05b5e4cd127cf44c9009664894edf907b8d (patch)
tree0d7db3bfdc2c6ff5ecf6279fb5db4317de1e238b /script
parent74a38036bc64940520502fc8f6a28f710ce42dbb (diff)
parent491ad2f40b2e2b6285dfe88558e3d8dd0c8395bd (diff)
downloadlua-language-server-df30d05b5e4cd127cf44c9009664894edf907b8d.zip
Merge branch 'master' into master
Diffstat (limited to 'script')
-rw-r--r--script/config/template.lua5
-rw-r--r--script/core/diagnostics/inject-field.lua3
-rw-r--r--script/core/hint.lua2
-rw-r--r--script/provider/provider.lua4
-rw-r--r--script/vm/visible.lua32
5 files changed, 35 insertions, 11 deletions
diff --git a/script/config/template.lua b/script/config/template.lua
index e74a9f9c..7b044d7a 100644
--- a/script/config/template.lua
+++ b/script/config/template.lua
@@ -402,7 +402,10 @@ local template = {
['Lua.doc.privateName'] = Type.Array(Type.String),
['Lua.doc.protectedName'] = Type.Array(Type.String),
['Lua.doc.packageName'] = Type.Array(Type.String),
-
+ ['Lua.doc.regengine'] = Type.String >> 'glob' << {
+ 'glob',
+ 'lua',
+ },
-- VSCode
["Lua.addonManager.enable"] = Type.Boolean >> true,
['files.associations'] = Type.Hash(Type.String, Type.String),
diff --git a/script/core/diagnostics/inject-field.lua b/script/core/diagnostics/inject-field.lua
index 2866eef8..e1ef02a3 100644
--- a/script/core/diagnostics/inject-field.lua
+++ b/script/core/diagnostics/inject-field.lua
@@ -68,6 +68,9 @@ return function (uri, callback)
if def.type == 'doc.field' then
return
end
+ if def.type == 'tablefield' and not isExact then
+ return
+ end
end
local howToFix = ''
diff --git a/script/core/hint.lua b/script/core/hint.lua
index 67ac8516..9d098aa9 100644
--- a/script/core/hint.lua
+++ b/script/core/hint.lua
@@ -59,7 +59,7 @@ local function typeHint(uri, results, start, finish)
end
mark[src] = true
results[#results+1] = {
- text = ':' .. view,
+ text = ': ' .. view,
offset = src.finish,
kind = define.InlayHintKind.Type,
where = 'right',
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 15e78b9a..2e2fb5eb 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -1426,8 +1426,8 @@ m.register 'textDocument/inlayHint' {
},
position = converter.packPosition(state, res.offset),
kind = res.kind,
- paddingLeft = res.kind == 1,
- paddingRight = res.kind == 2,
+ paddingLeft = false,
+ paddingRight = res.kind == define.InlayHintKind.Parameter,
}
end
return hintResults
diff --git a/script/vm/visible.lua b/script/vm/visible.lua
index 0f486d6b..518307a0 100644
--- a/script/vm/visible.lua
+++ b/script/vm/visible.lua
@@ -7,6 +7,19 @@ local glob = require 'glob'
---@class parser.object
---@field package _visibleType? parser.visibleType
+local function globMatch(patterns, fieldName)
+ return glob.glob(patterns)(fieldName)
+end
+
+local function luaMatch(patterns, fieldName)
+ for i = 1, #patterns do
+ if string.find(fieldName, patterns[i]) then
+ return true
+ end
+ end
+ return false
+end
+
local function getVisibleType(source)
if guide.isLiteral(source) then
return 'public'
@@ -42,21 +55,22 @@ local function getVisibleType(source)
if type(fieldName) == 'string' then
local uri = guide.getUri(source)
-
+ local regengine = config.get(uri, 'Lua.doc.regengine')
+ local match = regengine == "glob" and globMatch or luaMatch
local privateNames = config.get(uri, 'Lua.doc.privateName')
- if #privateNames > 0 and glob.glob(privateNames)(fieldName) then
+ if #privateNames > 0 and match(privateNames, fieldName) then
source._visibleType = 'private'
return 'private'
end
-
+
local protectedNames = config.get(uri, 'Lua.doc.protectedName')
- if #protectedNames > 0 and glob.glob(protectedNames)(fieldName) then
+ if #protectedNames > 0 and match(protectedNames, fieldName) then
source._visibleType = 'protected'
return 'protected'
end
-
+
local packageNames = config.get(uri, 'Lua.doc.packageName')
- if #packageNames > 0 and glob.glob(packageNames)(fieldName) then
+ if #packageNames > 0 and match(packageNames, fieldName) then
source._visibleType = 'package'
return 'package'
end
@@ -96,10 +110,14 @@ function vm.getParentClass(source)
if source.type == 'setfield'
or source.type == 'setindex'
or source.type == 'setmethod'
- or source.type == 'tablefield'
or source.type == 'tableindex' then
return vm.getDefinedClass(guide.getUri(source), source.node)
end
+
+ if source.type == 'tablefield' then
+ return vm.getDefinedClass(guide.getUri(source), source.node) or
+ vm.getDefinedClass(guide.getUri(source), source.parent.parent)
+ end
return nil
end