ModuleNameLookupTableTest: Refactor declaration visitor

This commit is contained in:
Jeroen Engels 2020-09-23 10:27:10 +02:00
parent ccfcc99468
commit efebce84d1

View File

@ -69,6 +69,10 @@ a = localValue
b = case () of
VariantA -> ()
(ExposesEverything.VariantA as foo) -> foo
someFunction Something.B.Bar =
let SomeThing.B.Bar = ()
in ()
""", """module ExposesSomeThings exposing (SomeOtherTypeAlias, exposedElement)
type NonExposedCustomType = Variant
type alias SomeOtherTypeAlias = {}
@ -303,12 +307,17 @@ declarationVisitor node context =
( [], { context | texts = context.texts ++ typeAnnotationNames context typeAnnotation } )
Declaration.FunctionDeclaration function ->
case function.signature |> Maybe.map (Node.value >> .typeAnnotation) of
Nothing ->
( [], context )
let
typeAnnotationTexts : List String
typeAnnotationTexts =
case function.signature |> Maybe.map (Node.value >> .typeAnnotation) of
Nothing ->
[]
Just typeAnnotation ->
( [], { context | texts = context.texts ++ typeAnnotationNames context typeAnnotation } )
Just typeAnnotation ->
typeAnnotationNames context typeAnnotation
in
( [], { context | texts = context.texts ++ typeAnnotationTexts } )
_ ->
( [], context )