Skip to content

Commit a737ce9

Browse files
committed
rename attribute skip_diagnostic to lsp_perf_optim
1 parent 7c249c2 commit a737ce9

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

CHANGELOG.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,47 @@
33
*All notable changes to the EmmyLua Analyzer Rust project will be documented in this file.*
44

55
---
6-
## [0.15.0] - Unreleased
6+
## [0.17.0] - Unreleased
77

88
### 🔧 Changed
99
- **Refactor IndexAliasName**: 删除原先的索引别名实现(`-- [IndexAliasName]`), 现在使用`---@[index_alias("name")]`
10+
- **Refactor ClassDefaultCall**: 删除配置项`runtime.class_default_call`, 转为使用`---@[constructor("<constructor_method_name>")]`
1011

1112
### ✨ Added
12-
- **Attribute**: 实现了新的特性`---@attribute`,用于定义附加元数据,内置三个特性
13+
- **Attribute**: 实现了新的特性`---@attribute`,用于定义附加元数据,内置多个特性
1314
```lua
1415
--- Deprecated. Receives an optional message parameter.
1516
---@attribute deprecated(message: string?)
1617

17-
--- Skip partial diagnostics, typically used to optimize diagnostic performance.
18+
--- Language Server Performance Optimization Items.
1819
---
1920
--- Receives a parameter, the options are:
20-
--- - `table_field` - Skip diagnostic for `table` fields
21-
---@attribute skip_diagnostic(code: string)
21+
--- - `check_table_field` - Skip the assign check for table fields. It is recommended to use this option for all large configuration tables.
22+
---@attribute lsp_perf_optim(code: "check_table_field"|string)
2223

2324
--- Index field alias, will be displayed in `hint` and `completion`.
2425
---
2526
--- Receives a string parameter for the alias name.
2627
---@attribute index_alias(name: string)
28+
29+
--- This attribute must be applied to function parameters, and the function parameter's type must be a string template generic,
30+
--- used to specify the default constructor of a class.
31+
---
32+
--- Parameters:
33+
--- - `name` - The name of the method as a constructor.
34+
--- - `root_class` - Used to mark the root class, will implicitly inherit this class, such as `System.Object` in c#. Defaults to empty.
35+
--- - `strip_self` - Whether the `self` parameter can be omitted when calling the constructor, defaults to `true`
36+
--- - `return_self` - Whether the constructor is forced to return `self`, defaults to `true`
37+
---@attribute constructor(name: string, root_class: string?, strip_self: boolean?, return_self: boolean?)
38+
39+
--- Associates `getter` and `setter` methods with a field. Currently provides only definition navigation functionality,
40+
--- and the target methods must reside within the same class.
41+
---
42+
--- Parameters:
43+
--- - convention: Naming convention, defaults to `camelCase`. Implicitly adds `get` and `set` prefixes. eg: `_age` -> `getAge`, `setAge`.
44+
--- - getter: Getter method name. Takes precedence over `convention`.
45+
--- - setter: Setter method name. Takes precedence over `convention`.
46+
---@attribute field_accessor(convention: "camelCase"|"PascalCase"|"snake_case"|nil, getter: string?, setter: string?)
2747
```
2848

2949
使用语法为 `---@[attribute_name_1(arg...), attribute_name_2(arg...), ...]`, 可以同时使用多个特性, 示例:

crates/emmylua_code_analysis/resources/std/builtin.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@
144144
--- Deprecated. Receives an optional message parameter.
145145
---@attribute deprecated(message: string?)
146146

147-
--- Skip partial diagnostics, typically used to optimize diagnostic performance.
147+
--- Language Server Performance Optimization Items.
148148
---
149149
--- Receives a parameter, the options are:
150-
--- - `table_field` - Skip diagnostic for `table` fields. Usually attached to configuration tables that do not require actual diagnostic fields.
151-
---@attribute skip_diagnostic(code: string)
150+
--- - `check_table_field` - Skip the assign check for table fields. It is recommended to use this option for all large configuration tables.
151+
---@attribute lsp_perf_optim(code: "check_table_field"|string)
152152

153153
--- Index field alias, will be displayed in `hint` and `completion`.
154154
---

crates/emmylua_code_analysis/src/compilation/test/attribute_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod test {
3535
ws.check_code_for(
3636
DiagnosticCode::AssignTypeMismatch,
3737
r#"
38-
---@[skip_diagnostic("table_field")]
38+
---@[lsp_perf_optim("check_table_field")]
3939
local config = {}
4040
"#,
4141
);

crates/emmylua_code_analysis/src/diagnostic/checker/assign_type_mismatch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ pub fn check_table_expr(
219219
.get_property_index()
220220
.get_property(&semantic_decl)
221221
{
222-
if let Some(skip_diagnostic) =
223-
property.find_attribute_use(LuaTypeDeclId::new("skip_diagnostic"))
222+
if let Some(lsp_perf_optim) =
223+
property.find_attribute_use(LuaTypeDeclId::new("lsp_perf_optim"))
224224
{
225225
if let Some(LuaType::DocStringConst(code)) =
226-
skip_diagnostic.get_param_by_name("code")
226+
lsp_perf_optim.get_param_by_name("code")
227227
{
228-
if code.as_ref() == "table_field" {
228+
if code.as_ref() == "check_table_field" {
229229
return Some(false);
230230
}
231231
};

0 commit comments

Comments
 (0)