File tree Expand file tree Collapse file tree 6 files changed +37
-9
lines changed
Expand file tree Collapse file tree 6 files changed +37
-9
lines changed Original file line number Diff line number Diff line change 33## 3.7.0
44* ` NEW ` support ` ---@type ` and ` --[[@as]] ` for return statement
55* ` NEW ` commandline parameter ` --force-accept-workspace ` : allowing the use of the root directory or home directory as the workspace
6+ * ` NEW ` diagnostic: ` inject-field `
67* ` FIX ` wrong hover and signature for method with varargs and overloads
78* ` FIX ` [ #2155 ]
89* ` FIX ` [ #2224 ]
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ DIAG_GLOBAL_ELEMENT =
170170' Element is global.'
171171DIAG_MISSING_FIELDS =
172172' Missing fields: {}'
173+ DIAG_INJECT_FIELD =
174+ ' Fields cannot be injected into the reference of `{class}` for `{field}`. To do so, use `---@class` for `{node}`.'
173175
174176MWS_NOT_SUPPORT =
175177' {} does not support multi workspace for now, I may need to restart to support the new workspace ...'
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ DIAG_GLOBAL_ELEMENT = -- TODO: need translate!
170170' Element is global.'
171171DIAG_MISSING_FIELDS = -- TODO: need translate!
172172' Missing fields: {}'
173+ DIAG_INJECT_FIELD = -- TODO: need translate!
174+ ' Fields cannot be injected into the reference of `{class}` for `{field}`. To do so, use `---@class` for `{node}`.'
173175
174176MWS_NOT_SUPPORT =
175177' {} não é suportado múltiplos espaços de trabalho por enquanto, posso precisar reiniciar para estabelecer um novo espaço de trabalho ...'
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ DIAG_GLOBAL_ELEMENT =
170170' 全局变量。'
171171DIAG_MISSING_FIELDS =
172172' 缺少字段: {}'
173+ DIAG_INJECT_FIELD =
174+ ' 不能在 `{class}` 的引用中注入字段 `{field}` 。如要这么做,请对 `{node}` 使用 `---@class` 。'
173175
174176MWS_NOT_SUPPORT =
175177' {} 目前还不支持多工作目录,我可能需要重启才能支持新的工作目录...'
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ DIAG_GLOBAL_ELEMENT = -- TODO: need translate!
170170' Element is global.'
171171DIAG_MISSING_FIELDS = -- TODO: need translate!
172172' Missing fields: {}'
173+ DIAG_INJECT_FIELD = -- TODO: need translate!
174+ ' Fields cannot be injected into the reference of `{class}` for `{field}`. To do so, use `---@class` for `{node}`.'
173175
174176MWS_NOT_SUPPORT =
175177' {} 目前還不支援多工作目錄,我可能需要重新啟動才能支援新的工作目錄...'
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ local vm = require 'vm'
33local lang = require ' language'
44local guide = require ' parser.guide'
55local await = require ' await'
6+ local hname = require ' core.hover.name'
67
78local skipCheckClass = {
89 [' unknown' ] = true ,
@@ -22,19 +23,37 @@ return function (uri, callback)
2223 await .delay ()
2324
2425 local node = src .node
25- if node then
26- local ok
27- for view in vm . getInfer ( node ): eachView ( uri ) do
28- if skipCheckClass [ view ] then
29- return
30- end
31- ok = true
26+ if not node then
27+ return
28+ end
29+ local ok
30+ for view in vm . getInfer ( node ): eachView ( uri ) do
31+ if skipCheckClass [ view ] then
32+ return
3233 end
33- if not ok then
34+ ok = true
35+ end
36+ if not ok then
37+ return
38+ end
39+
40+ local class = vm .getDefinedClass (uri , node )
41+ if class then
42+ return
43+ end
44+
45+ for _ , def in ipairs (vm .getDefs (src )) do
46+ local dnode = def .node
47+ if dnode and vm .getDefinedClass (uri , dnode ) then
3448 return
3549 end
3650 end
37- local message = lang .script (' DIAG_INJECT_FIELD' , guide .getKeyName (src ))
51+
52+ local message = lang .script (' DIAG_INJECT_FIELD' , {
53+ class = vm .getInfer (node ):view (uri ),
54+ field = guide .getKeyName (src ),
55+ node = hname (node ),
56+ })
3857 if src .type == ' setfield' and src .field then
3958 callback {
4059 start = src .field .start ,
You can’t perform that action at this time.
0 commit comments