@@ -22,80 +22,63 @@ return function (uri, callback)
2222 if def .bindSource and guide .isInRange (def .bindSource , src .start ) then
2323 return
2424 end
25- if not sortedDefs [def .class [1 ]] then
26- sortedDefs [def .class [1 ]] = {}
25+ local className = def .class [1 ]
26+ if not sortedDefs [className ] then
27+ sortedDefs [className ] = {}
2728 end
28- local samedefs = sortedDefs [def . class [ 1 ] ]
29+ local samedefs = sortedDefs [className ]
2930 samedefs [# samedefs + 1 ] = def
3031 end
3132 if def .type == ' doc.type.array'
3233 or def .type == ' doc.type.table' then
3334 return
3435 end
3536 end
36-
37- local Allwarnings = {}
37+
38+ local warnings = {}
3839 for _ , samedefs in pairs (sortedDefs ) do
39- local warnings = {}
40+ local missedKeys = {}
41+ local className
4042 for _ , def in ipairs (samedefs ) do
41- if def . type == ' doc .class' then
42- if not def .fields then
43- goto continue
44- end
43+ className = def .class [ 1 ]
44+ if not def .fields or # def . fields == 0 then
45+ goto continue
46+ end
4547
46- local requiresKeys = {}
47- for _ , field in ipairs (def .fields ) do
48- if not field .optional
49- and not vm .compileNode (field ):isNullable () then
50- local key = vm .getKeyName (field )
51- if key and not requiresKeys [key ] then
52- requiresKeys [key ] = true
53- requiresKeys [# requiresKeys + 1 ] = key
54- end
55- end
48+ local myKeys = {}
49+ for _ , field in ipairs (src ) do
50+ local key = vm .getKeyName (field )
51+ if key then
52+ myKeys [key ] = true
5653 end
54+ end
5755
58- if # requiresKeys == 0 then
59- goto continue
60- end
61- local myKeys = {}
62- for _ , field in ipairs (src ) do
56+ for _ , field in ipairs (def .fields ) do
57+ if not field .optional
58+ and not vm .compileNode (field ):isNullable () then
6359 local key = vm .getKeyName (field )
64- if key then
65- myKeys [key ] = true
66- end
67- end
68-
69- local missedKeys = {}
70- for _ , key in ipairs (requiresKeys ) do
71- if not myKeys [key ] then
60+ if key and not myKeys [key ] then
7261 missedKeys [# missedKeys + 1 ] = (' `%s`' ):format (key )
7362 end
7463 end
75-
76- if # missedKeys == 0 then
77- goto continue
78- end
79-
80- warnings [# warnings + 1 ] = lang .script (' DIAG_MISSING_FIELDS' , def .class [1 ], table.concat (missedKeys , ' , ' ))
81- end
64+ end
8265 :: continue::
8366 end
84- if # warnings == 0 then
67+
68+ if # missedKeys == 0 then
8569 return
8670 else
87- for i = 1 , # warnings do
88- Allwarnings [# Allwarnings + 1 ] = warnings [i ]
89- end
71+ warnings [# warnings + 1 ] = lang .script (' DIAG_MISSING_FIELDS' , className , table.concat (missedKeys , ' , ' ))
9072 end
9173 end
92- if # Allwarnings == 0 then
74+
75+ if # warnings == 0 then
9376 return
9477 end
9578 callback {
9679 start = src .start ,
9780 finish = src .finish ,
98- message = table.concat (Allwarnings , ' \n ' )
81+ message = table.concat (warnings , ' \n ' )
9982 }
10083 end )
10184end
0 commit comments