summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-07-15 14:16:26 +0800
committerGitHub <noreply@github.com>2024-07-15 14:16:26 +0800
commit8dd27106bb3c07f0a63a18dba76ef4a66ea8bf74 (patch)
treef152c27a73a9623fe64601557fbcb2b8bb63b8c0 /script/vm
parente558d6e3ed61feffa65314a9464feda742e12b1c (diff)
parent3d88f3313263f316834b2e9e0de47485a4a8d3f3 (diff)
downloadlua-language-server-8dd27106bb3c07f0a63a18dba76ef4a66ea8bf74.zip
Merge branch 'master' into fixes-a-specific-case-for-getVisibleType
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/visible.lua26
1 files changed, 20 insertions, 6 deletions
diff --git a/script/vm/visible.lua b/script/vm/visible.lua
index fddb7faf..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