@@ -305,49 +305,50 @@ defmodule IEx.Helpers do
305305 """
306306 defmacro t ( { :/ , _ , [ { { :. , _ , [ mod , fun ] } , _ , [ ] } , arity ] } ) do
307307 quote do
308- t ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
308+ IEx.Helpers . __type__ ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
309309 end
310310 end
311311
312312 defmacro t ( { { :. , _ , [ mod , fun ] } , _ , [ ] } ) do
313313 quote do
314- t ( unquote ( mod ) , unquote ( fun ) )
314+ IEx.Helpers . __type__ ( unquote ( mod ) , unquote ( fun ) )
315315 end
316316 end
317317
318318 defmacro t ( module ) do
319319 quote do
320- t ( unquote ( module ) , [ ] )
320+ IEx.Helpers . __type__ ( unquote ( module ) )
321321 end
322322 end
323323
324324 @ 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 )
331327
332328 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" )
334330 end
335331
336332 :ok
337333 end
338334
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
341342
342343 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" )
344345 end
345346
346347 :ok
347348 end
348349
349350 @ doc false
350- def t ( module , type , arity ) do
351+ def __type__ ( module , type , arity ) do
351352 types = lc { _ , { t , _ , args } } = typespec inlist Kernel.Typespec . beam_types ( module ) ,
352353 length ( args ) == arity and t == type , do: typespec
353354
@@ -375,61 +376,62 @@ defmodule IEx.Helpers do
375376 """
376377 defmacro s ( { :/ , _ , [ { { :. , _ , [ mod , fun ] } , _ , [ ] } , arity ] } ) do
377378 quote do
378- s ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
379+ IEx.Helpers . __spec__ ( unquote ( mod ) , unquote ( fun ) , unquote ( arity ) )
379380 end
380381 end
381382
382383 defmacro s ( { { :. , _ , [ mod , fun ] } , _ , [ ] } ) do
383384 quote do
384- s ( unquote ( mod ) , unquote ( fun ) )
385+ IEx.Helpers . __spec__ ( unquote ( mod ) , unquote ( fun ) )
385386 end
386387 end
387388
388389 defmacro s ( { fun , _ , args } ) when args == [ ] or is_atom ( args ) do
389390 quote do
390- s ( Kernel , unquote ( fun ) )
391+ IEx.Helpers . __spec__ ( Kernel , unquote ( fun ) )
391392 end
392393 end
393394
394395 defmacro s ( { :/ , _ , [ { fun , _ , args } , arity ] } ) when args == [ ] or is_atom ( args ) do
395396 quote do
396- s ( Kernel , unquote ( fun ) , unquote ( arity ) )
397+ IEx.Helpers . __spec__ ( Kernel , unquote ( fun ) , unquote ( arity ) )
397398 end
398399 end
399400
400401 defmacro s ( module ) do
401402 quote do
402- s ( unquote ( module ) , [ ] )
403+ IEx.Helpers . __spec__ ( unquote ( module ) )
403404 end
404405 end
405406
406407 @ 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 )
413410
414411 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" )
416413 end
417414
418415 :ok
419416 end
420417
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
423425
424426 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" )
426428 end
427429
428430 :ok
429431 end
430432
431433 @ doc false
432- def s ( module , function , arity ) do
434+ def __spec__ ( module , function , arity ) do
433435 specs = lc { _kind , { { f , a } , _spec } } = spec inlist beam_specs ( module ) ,
434436 f == function and a == arity do
435437 print_spec ( spec )
0 commit comments