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