diff options
author | NeOzay <colpaert.benoit@gmail.com> | 2024-07-13 14:51:15 +0200 |
---|---|---|
committer | NeOzay <colpaert.benoit@gmail.com> | 2024-07-13 14:51:15 +0200 |
commit | e1c06d0697a89dd4cc4af0987c5f642142b93ebb (patch) | |
tree | 41da7d051921d3089bbb945e35dcc6e046f042ce /script/vm/visible.lua | |
parent | b09b057857bd65a3caa324443ffce0850933f32c (diff) | |
download | lua-language-server-e1c06d0697a89dd4cc4af0987c5f642142b93ebb.zip |
moves the match function outside of getVisibleType function
Diffstat (limited to 'script/vm/visible.lua')
-rw-r--r-- | script/vm/visible.lua | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/script/vm/visible.lua b/script/vm/visible.lua index 11b6c8d6..a085be08 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' @@ -43,32 +56,21 @@ local function getVisibleType(source) if type(fieldName) == 'string' then local uri = guide.getUri(source) local regengine = config.get(uri, 'Lua.doc.regengine') - local function match(patterns) - if regengine == "glob" then - return glob.glob(patterns)(fieldName) - else - for i = 1, #patterns do - if string.find(fieldName, patterns[i]) then - return true - end - end - end - end - + local match = regengine == "glob" and globMatch or luaMatch local privateNames = config.get(uri, 'Lua.doc.privateName') - if #privateNames > 0 and match(privateNames) 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 match(protectedNames) 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 match(packageNames) then + if #packageNames > 0 and match(packageNames, fieldName) then source._visibleType = 'package' return 'package' end |