File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -170,12 +170,17 @@ describe('GLua API Writer', () => {
170170 } ,
171171 {
172172 key : 'MATERIAL_FOG_LINEAR_BELOW_FOG_Z' ,
173- value : '2' ,
173+ value : '-2147483648' , // test large negative number
174+ } ,
175+ {
176+ // Should be skipped
177+ key : 'MATERIAL_FOG_NEW_FAKE' ,
178+ value : 'TODO' ,
174179 }
175180 ] ,
176181 } ) ;
177182
178- expect ( api ) . toEqual ( `---@alias MATERIAL_FOG 0|1|2 \n--- No fog\nMATERIAL_FOG_NONE = 0\n--- Linear fog\nMATERIAL_FOG_LINEAR = 1\nMATERIAL_FOG_LINEAR_BELOW_FOG_Z = 2 \n\n\n` ) ;
183+ expect ( api ) . toEqual ( `---@alias MATERIAL_FOG 0|1|-2147483648 \n--- No fog\nMATERIAL_FOG_NONE = 0\n--- Linear fog\nMATERIAL_FOG_LINEAR = 1\nMATERIAL_FOG_LINEAR_BELOW_FOG_Z = -2147483648 \n\n\n` ) ;
179184 } ) ;
180185
181186 it ( 'should create enums for table enumerations' , ( ) => {
Original file line number Diff line number Diff line change @@ -240,7 +240,9 @@ export class GluaApiWriter {
240240 } else {
241241 // Until LuaLS supports global enumerations (https://github.com/LuaLS/lua-language-server/issues/2721) we
242242 // will use @alias as a workaround
243- const validEnumerations = _enum . items . map ( item => item . value ) . join ( '|' ) ;
243+ const validEnumerations = _enum . items . map ( item => item . value )
244+ . filter ( value => ! isNaN ( Number ( value ) ) )
245+ . join ( '|' ) ;
244246 api += `---@alias ${ _enum . name } ${ validEnumerations } \n` ;
245247 }
246248
@@ -255,6 +257,12 @@ export class GluaApiWriter {
255257 return ;
256258 }
257259
260+ if ( isNaN ( Number ( item . value . trim ( ) ) ) ) {
261+ // Happens for TODO value in NAV_MESH_BLOCKED_LUA in https://wiki.facepunch.com/gmod/Enums/NAV_MESH
262+ console . warn ( `Enum ${ _enum . name } has a TODO value for key ${ key } . Skipping.` ) ;
263+ return ;
264+ }
265+
258266 if ( isContainedInTable ) {
259267 key = key . split ( '.' ) [ 1 ] ;
260268
You can’t perform that action at this time.
0 commit comments