@@ -305,49 +305,50 @@ defmodule IEx.Helpers do
305
305
"""
306
306
defmacro t ( { :/ , _ , [ { { :. , _ , [ mod , fun ] } , _ , [ ] } , arity ] } ) do
307
307
quote do
308
- t ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
308
+ IEx.Helpers . __type__ ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
309
309
end
310
310
end
311
311
312
312
defmacro t ( { { :. , _ , [ mod , fun ] } , _ , [ ] } ) do
313
313
quote do
314
- t ( unquote ( mod ) , unquote ( fun ) )
314
+ IEx.Helpers . __type__ ( unquote ( mod ) , unquote ( fun ) )
315
315
end
316
316
end
317
317
318
318
defmacro t ( module ) do
319
319
quote do
320
- t ( unquote ( module ) , [ ] )
320
+ IEx.Helpers . __type__ ( unquote ( module ) )
321
321
end
322
322
end
323
323
324
324
@ doc false
325
- def t ( module , type ) when is_atom ( type ) do
326
- types = lc { _ , { t , _ , _args } } = typespec inlist Kernel.Typespec . beam_types ( module ) ,
327
- t == type do
328
- print_type ( typespec )
329
- typespec
330
- end
325
+ def __type__ ( module ) do
326
+ types = lc type inlist Kernel.Typespec . beam_types ( module ) , do: print_type ( type )
331
327
332
328
if types == [ ] do
333
- IO . puts IO.ANSI . escape ( "%{red}No types for #{ inspect module } . #{ type } have been found" )
329
+ IO . puts IO.ANSI . escape ( "%{red}No types for #{ inspect module } have been found" )
334
330
end
335
331
336
332
:ok
337
333
end
338
334
339
- def t ( module , [ ] ) do
340
- types = lc type inlist Kernel.Typespec . beam_types ( module ) , do: print_type ( type )
335
+ @ doc false
336
+ def __type__ ( module , type ) when is_atom ( type ) do
337
+ types = lc { _ , { t , _ , _args } } = typespec inlist Kernel.Typespec . beam_types ( module ) ,
338
+ t == type do
339
+ print_type ( typespec )
340
+ typespec
341
+ end
341
342
342
343
if types == [ ] do
343
- IO . puts IO.ANSI . escape ( "%{red}No types for #{ inspect module } have been found" )
344
+ IO . puts IO.ANSI . escape ( "%{red}No types for #{ inspect module } . #{ type } have been found" )
344
345
end
345
346
346
347
:ok
347
348
end
348
349
349
350
@ doc false
350
- def t ( module , type , arity ) do
351
+ def __type__ ( module , type , arity ) do
351
352
types = lc { _ , { t , _ , args } } = typespec inlist Kernel.Typespec . beam_types ( module ) ,
352
353
length ( args ) == arity and t == type , do: typespec
353
354
@@ -375,61 +376,62 @@ defmodule IEx.Helpers do
375
376
"""
376
377
defmacro s ( { :/ , _ , [ { { :. , _ , [ mod , fun ] } , _ , [ ] } , arity ] } ) do
377
378
quote do
378
- s ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
379
+ IEx.Helpers . __spec__ ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
379
380
end
380
381
end
381
382
382
383
defmacro s ( { { :. , _ , [ mod , fun ] } , _ , [ ] } ) do
383
384
quote do
384
- s ( unquote ( mod ) , unquote ( fun ) )
385
+ IEx.Helpers . __spec__ ( unquote ( mod ) , unquote ( fun ) )
385
386
end
386
387
end
387
388
388
389
defmacro s ( { fun , _ , args } ) when args == [ ] or is_atom ( args ) do
389
390
quote do
390
- s ( Kernel , unquote ( fun ) )
391
+ IEx.Helpers . __spec__ ( Kernel , unquote ( fun ) )
391
392
end
392
393
end
393
394
394
395
defmacro s ( { :/ , _ , [ { fun , _ , args } , arity ] } ) when args == [ ] or is_atom ( args ) do
395
396
quote do
396
- s ( Kernel , unquote ( fun ) , unquote ( arity ) )
397
+ IEx.Helpers . __spec__ ( Kernel , unquote ( fun ) , unquote ( arity ) )
397
398
end
398
399
end
399
400
400
401
defmacro s ( module ) do
401
402
quote do
402
- s ( unquote ( module ) , [ ] )
403
+ IEx.Helpers . __spec__ ( unquote ( module ) )
403
404
end
404
405
end
405
406
406
407
@ doc false
407
- def s ( module , function ) when is_atom ( function ) do
408
- specs = lc { _kind , { { f , _arity } , _spec } } = spec inlist beam_specs ( module ) ,
409
- f == function do
410
- print_spec ( spec )
411
- spec
412
- end
408
+ def __spec__ ( module ) do
409
+ specs = lc spec inlist beam_specs ( module ) , do: print_spec ( spec )
413
410
414
411
if specs == [ ] do
415
- IO . puts IO.ANSI . escape ( "%{red}No specs for #{ inspect module } . #{ function } have been found" )
412
+ IO . puts IO.ANSI . escape ( "%{red}No specs for #{ inspect module } have been found" )
416
413
end
417
414
418
415
:ok
419
416
end
420
417
421
- def s ( module , [ ] ) do
422
- specs = lc spec inlist beam_specs ( module ) , do: print_spec ( spec )
418
+ @ doc false
419
+ def __spec__ ( module , function ) when is_atom ( function ) do
420
+ specs = lc { _kind , { { f , _arity } , _spec } } = spec inlist beam_specs ( module ) ,
421
+ f == function do
422
+ print_spec ( spec )
423
+ spec
424
+ end
423
425
424
426
if specs == [ ] do
425
- IO . puts IO.ANSI . escape ( "%{red}No specs for #{ inspect module } have been found" )
427
+ IO . puts IO.ANSI . escape ( "%{red}No specs for #{ inspect module } . #{ function } have been found" )
426
428
end
427
429
428
430
:ok
429
431
end
430
432
431
433
@ doc false
432
- def s ( module , function , arity ) do
434
+ def __spec__ ( module , function , arity ) do
433
435
specs = lc { _kind , { { f , a } , _spec } } = spec inlist beam_specs ( module ) ,
434
436
f == function and a == arity do
435
437
print_spec ( spec )
0 commit comments