summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/config/template.lua1
-rw-r--r--script/core/diagnostics/invisible.lua14
-rw-r--r--script/core/hover/description.lua5
-rw-r--r--script/parser/luadoc.lua14
-rw-r--r--script/vm/visible.lua5
5 files changed, 34 insertions, 5 deletions
diff --git a/script/config/template.lua b/script/config/template.lua
index dfdfab56..ea79c2d3 100644
--- a/script/config/template.lua
+++ b/script/config/template.lua
@@ -392,6 +392,7 @@ local template = {
['Lua.type.weakNilCheck'] = Type.Boolean >> false,
['Lua.doc.privateName'] = Type.Array(Type.String),
['Lua.doc.protectedName'] = Type.Array(Type.String),
+ ['Lua.doc.packageName'] = Type.Array(Type.String),
-- VSCode
['files.associations'] = Type.Hash(Type.String, Type.String),
diff --git a/script/core/diagnostics/invisible.lua b/script/core/diagnostics/invisible.lua
index 0bd369a4..7172c4a5 100644
--- a/script/core/diagnostics/invisible.lua
+++ b/script/core/diagnostics/invisible.lua
@@ -37,7 +37,7 @@ return function (uri, callback)
class = vm.getParentClass(def):getName(),
}),
}
- else
+ elseif vm.getVisibleType(def) == 'protected' then
callback {
start = child.start,
finish = child.finish,
@@ -47,6 +47,18 @@ return function (uri, callback)
class = vm.getParentClass(def):getName(),
}),
}
+ elseif vm.getVisibleType(def) == 'package' then
+ callback {
+ start = child.start,
+ finish = child.finish,
+ uri = uri,
+ message = lang.script('DIAG_INVISIBLE_PACKAGE', {
+ field = key,
+ uri = guide.getUri(def),
+ }),
+ }
+ else
+ error('Unknown visible type: ' .. vm.getVisibleType(def))
end
break
end
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 74720bdf..f8b0694d 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -142,7 +142,10 @@ local function lookUpDocComments(source)
for _, doc in ipairs(docGroup) do
if doc.type == 'doc.comment' then
lines[#lines+1] = normalizeComment(doc.comment.text, uri)
- elseif doc.type == 'doc.type' then
+ elseif doc.type == 'doc.type'
+ or doc.type == 'doc.public'
+ or doc.type == 'doc.protected'
+ or doc.type == 'doc.private' then
if doc.comment then
lines[#lines+1] = normalizeComment(doc.comment.text, uri)
end
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 8a671dbc..0e560b0d 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -992,7 +992,8 @@ local docSwitch = util.switch()
if value == 'public'
or value == 'protected'
or value == 'private'
- or value == 'public' then
+ or value == 'public'
+ or value == 'package' then
result.visible = value
result.start = getStart()
return true
@@ -1470,6 +1471,14 @@ local docSwitch = util.switch()
finish = getFinish(),
}
end)
+ : case 'package'
+ : call(function ()
+ return {
+ type = 'doc.package',
+ start = getFinish(),
+ finish = getFinish(),
+ }
+ end)
local function convertTokens(doc)
local tp, text = nextToken()
@@ -1688,7 +1697,8 @@ local function bindDoc(source, binded)
or doc.type == 'doc.source'
or doc.type == 'doc.private'
or doc.type == 'doc.protected'
- or doc.type == 'doc.public' then
+ or doc.type == 'doc.public'
+ or doc.type == 'doc.package' then
if source.type == 'function'
or isParam then
goto CONTINUE
diff --git a/script/vm/visible.lua b/script/vm/visible.lua
index 1b0726ee..9d667744 100644
--- a/script/vm/visible.lua
+++ b/script/vm/visible.lua
@@ -4,7 +4,7 @@ local guide = require 'parser.guide'
local config = require 'config'
local glob = require 'glob'
----@alias parser.visibleType 'public' | 'protected' | 'private'
+---@alias parser.visibleType 'public' | 'protected' | 'private' | 'package'
---@class parser.object
---@field public _visibleType? parser.visibleType
@@ -128,6 +128,9 @@ function vm.isVisible(parent, field)
if visible == 'public' then
return true
end
+ if visible == 'package' then
+ return guide.getUri(parent) == guide.getUri(field)
+ end
local class = vm.getParentClass(field)
if not class then
return true