Skip to content

Commit 9c6e57d

Browse files
authored
Locale and completion additions for 3.6.0 annotations (#1683)
* add: new annotations to completion * add: en-us descriptions for access modifiers * add: en-us descriptions for other locales * add: update @field description for `pt-br` and `zh-cn`
1 parent 329d268 commit 9c6e57d

File tree

5 files changed

+302
-4
lines changed

5 files changed

+302
-4
lines changed

locale/en-us/script.lua

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,11 @@ function getTags(item) end
790790
LUADOC_DESC_FIELD =
791791
[=[
792792
Declare a field in a class/table. This allows you to provide more in-depth
793-
documentation for a table.
793+
documentation for a table. As of `v3.6.0`, you can mark a field as `private`,
794+
`protected`, `public`, or `package`.
794795
795796
## Syntax
796-
`---@field <name> <type> [description]`
797+
`---@field [scope] <name> <type> [description]`
797798
798799
## Usage
799800
```
@@ -1126,3 +1127,76 @@ local function setColor(color) end
11261127
setColor(colors.green)
11271128
```
11281129
]=]
1130+
LUADOC_DESC_PACKAGE =
1131+
[=[
1132+
Mark a function as private to the file it is defined in. A packaged function
1133+
cannot be accessed from another file.
1134+
1135+
## Syntax
1136+
`@package`
1137+
1138+
## Usage
1139+
```
1140+
---@class Animal
1141+
---@field private eyes integer
1142+
local Animal = {}
1143+
1144+
---@package
1145+
---This cannot be accessed in another file
1146+
function Animal:eyesCount()
1147+
return self.eyes
1148+
end
1149+
```
1150+
]=]
1151+
LUADOC_DESC_PRIVATE =
1152+
[=[
1153+
Mark a function as private to a @class. Private functions can be accessed only
1154+
from within their class and are not accessable from child classes.
1155+
1156+
## Syntax
1157+
`@private`
1158+
1159+
## Usage
1160+
```
1161+
---@class Animal
1162+
---@field private eyes integer
1163+
local Animal = {}
1164+
1165+
---@private
1166+
function Animal:eyesCount()
1167+
return self.eyes
1168+
end
1169+
1170+
---@class Dog:Animal
1171+
local myDog = {}
1172+
1173+
---NOT PERMITTED!
1174+
myDog:eyesCount();
1175+
```
1176+
]=]
1177+
LUADOC_DESC_PROTECTED =
1178+
[=[
1179+
Mark a function as protected within a @class. Protected functions can be
1180+
accessed only from within their class or from child classes.
1181+
1182+
## Syntax
1183+
`@protected`
1184+
1185+
## Usage
1186+
```
1187+
---@class Animal
1188+
---@field private eyes integer
1189+
local Animal = {}
1190+
1191+
---@protected
1192+
function Animal:eyesCount()
1193+
return self.eyes
1194+
end
1195+
1196+
---@class Dog:Animal
1197+
local myDog = {}
1198+
1199+
---Permitted because function is protected, not private.
1200+
myDog:eyesCount();
1201+
```
1202+
]=]

locale/pt-br/script.lua

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ function getTags(item) end
790790
LUADOC_DESC_FIELD = -- TODO: need translate!
791791
[=[
792792
Declare a field in a class/table. This allows you to provide more in-depth
793-
documentation for a table.
793+
documentation for a table. As of `v3.6.0`, you can mark a field as `private`,
794+
`protected`, `public`, or `package`.
794795
795796
## Syntax
796797
`---@field <name> <type> [description]`
@@ -1126,3 +1127,76 @@ local function setColor(color) end
11261127
setColor(colors.green)
11271128
```
11281129
]=]
1130+
LUADOC_DESC_PACKAGE = -- TODO: need translate!
1131+
[=[
1132+
Mark a function as private to the file it is defined in. A packaged function
1133+
cannot be accessed from another file.
1134+
1135+
## Syntax
1136+
`@package`
1137+
1138+
## Usage
1139+
```
1140+
---@class Animal
1141+
---@field private eyes integer
1142+
local Animal = {}
1143+
1144+
---@package
1145+
---This cannot be accessed in another file
1146+
function Animal:eyesCount()
1147+
return self.eyes
1148+
end
1149+
```
1150+
]=]
1151+
LUADOC_DESC_PRIVATE = -- TODO: need translate!
1152+
[=[
1153+
Mark a function as private to a @class. Private functions can be accessed only
1154+
from within their class and are not accessable from child classes.
1155+
1156+
## Syntax
1157+
`@private`
1158+
1159+
## Usage
1160+
```
1161+
---@class Animal
1162+
---@field private eyes integer
1163+
local Animal = {}
1164+
1165+
---@private
1166+
function Animal:eyesCount()
1167+
return self.eyes
1168+
end
1169+
1170+
---@class Dog:Animal
1171+
local myDog = {}
1172+
1173+
---NOT PERMITTED!
1174+
myDog:eyesCount();
1175+
```
1176+
]=]
1177+
LUADOC_DESC_PROTECTED = -- TODO: need translate!
1178+
[=[
1179+
Mark a function as protected within a @class. Protected functions can be
1180+
accessed only from within their class or from child classes.
1181+
1182+
## Syntax
1183+
`@protected`
1184+
1185+
## Usage
1186+
```
1187+
---@class Animal
1188+
---@field private eyes integer
1189+
local Animal = {}
1190+
1191+
---@protected
1192+
function Animal:eyesCount()
1193+
return self.eyes
1194+
end
1195+
1196+
---@class Dog:Animal
1197+
local myDog = {}
1198+
1199+
---Permitted because function is protected, not private.
1200+
myDog:eyesCount();
1201+
```
1202+
]=]

locale/zh-cn/script.lua

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ function getTags(item) end
790790
LUADOC_DESC_FIELD = -- TODO: need translate!
791791
[=[
792792
Declare a field in a class/table. This allows you to provide more in-depth
793-
documentation for a table.
793+
documentation for a table. As of `v3.6.0`, you can mark a field as `private`,
794+
`protected`, `public`, or `package`.
794795
795796
## Syntax
796797
`---@field <name> <type> [description]`
@@ -1126,3 +1127,76 @@ local function setColor(color) end
11261127
setColor(colors.green)
11271128
```
11281129
]=]
1130+
LUADOC_DESC_PACKAGE = -- TODO: need translate!
1131+
[=[
1132+
Mark a function as private to the file it is defined in. A packaged function
1133+
cannot be accessed from another file.
1134+
1135+
## Syntax
1136+
`@package`
1137+
1138+
## Usage
1139+
```
1140+
---@class Animal
1141+
---@field private eyes integer
1142+
local Animal = {}
1143+
1144+
---@package
1145+
---This cannot be accessed in another file
1146+
function Animal:eyesCount()
1147+
return self.eyes
1148+
end
1149+
```
1150+
]=]
1151+
LUADOC_DESC_PRIVATE = -- TODO: need translate!
1152+
[=[
1153+
Mark a function as private to a @class. Private functions can be accessed only
1154+
from within their class and are not accessable from child classes.
1155+
1156+
## Syntax
1157+
`@private`
1158+
1159+
## Usage
1160+
```
1161+
---@class Animal
1162+
---@field private eyes integer
1163+
local Animal = {}
1164+
1165+
---@private
1166+
function Animal:eyesCount()
1167+
return self.eyes
1168+
end
1169+
1170+
---@class Dog:Animal
1171+
local myDog = {}
1172+
1173+
---NOT PERMITTED!
1174+
myDog:eyesCount();
1175+
```
1176+
]=]
1177+
LUADOC_DESC_PROTECTED = -- TODO: need translate!
1178+
[=[
1179+
Mark a function as protected within a @class. Protected functions can be
1180+
accessed only from within their class or from child classes.
1181+
1182+
## Syntax
1183+
`@protected`
1184+
1185+
## Usage
1186+
```
1187+
---@class Animal
1188+
---@field private eyes integer
1189+
local Animal = {}
1190+
1191+
---@protected
1192+
function Animal:eyesCount()
1193+
return self.eyes
1194+
end
1195+
1196+
---@class Dog:Animal
1197+
local myDog = {}
1198+
1199+
---Permitted because function is protected, not private.
1200+
myDog:eyesCount();
1201+
```
1202+
]=]

locale/zh-tw/script.lua

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,3 +1121,76 @@ local function setColor(color) end
11211121
setColor(colors.green)
11221122
```
11231123
]=]
1124+
LUADOC_DESC_PACKAGE = -- TODO: need translate!
1125+
[=[
1126+
Mark a function as private to the file it is defined in. A packaged function
1127+
cannot be accessed from another file.
1128+
1129+
## Syntax
1130+
`@package`
1131+
1132+
## Usage
1133+
```
1134+
---@class Animal
1135+
---@field private eyes integer
1136+
local Animal = {}
1137+
1138+
---@package
1139+
---This cannot be accessed in another file
1140+
function Animal:eyesCount()
1141+
return self.eyes
1142+
end
1143+
```
1144+
]=]
1145+
LUADOC_DESC_PRIVATE = -- TODO: need translate!
1146+
[=[
1147+
Mark a function as private to a @class. Private functions can be accessed only
1148+
from within their class and are not accessable from child classes.
1149+
1150+
## Syntax
1151+
`@private`
1152+
1153+
## Usage
1154+
```
1155+
---@class Animal
1156+
---@field private eyes integer
1157+
local Animal = {}
1158+
1159+
---@private
1160+
function Animal:eyesCount()
1161+
return self.eyes
1162+
end
1163+
1164+
---@class Dog:Animal
1165+
local myDog = {}
1166+
1167+
---NOT PERMITTED!
1168+
myDog:eyesCount();
1169+
```
1170+
]=]
1171+
LUADOC_DESC_PROTECTED = -- TODO: need translate!
1172+
[=[
1173+
Mark a function as protected within a @class. Protected functions can be
1174+
accessed only from within their class or from child classes.
1175+
1176+
## Syntax
1177+
`@protected`
1178+
1179+
## Usage
1180+
```
1181+
---@class Animal
1182+
---@field private eyes integer
1183+
local Animal = {}
1184+
1185+
---@protected
1186+
function Animal:eyesCount()
1187+
return self.eyes
1188+
end
1189+
1190+
---@class Dog:Animal
1191+
local myDog = {}
1192+
1193+
---Permitted because function is protected, not private.
1194+
myDog:eyesCount();
1195+
```
1196+
]=]

script/core/completion/completion.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,9 @@ local function tryluaDocCate(word, results)
16831683
'operator',
16841684
'source',
16851685
'enum',
1686+
'package',
1687+
'private',
1688+
'protected'
16861689
} do
16871690
if matchKey(word, docType) then
16881691
results[#results+1] = {

0 commit comments

Comments
 (0)