Support record update functions for module name lookup table

This commit is contained in:
Jeroen Engels 2020-08-25 15:28:56 +02:00
parent 7455bca8a8
commit 7c0d7e6fad
2 changed files with 27 additions and 0 deletions

View File

@ -4986,6 +4986,15 @@ scope_expressionEnterVisitor node context =
context.lookupTable
}
Expression.RecordUpdateExpression (Node range name) _ ->
{ context
| lookupTable =
ModuleNameLookupTableInternal.add
range
(moduleNameForValue context name [])
context.lookupTable
}
Expression.LambdaExpression { args } ->
{ context
| lookupTable =

View File

@ -46,6 +46,7 @@ a = localValue
Foo.Bar
Baz.foo
baz
{ baz | a = 1 }
button
Http.get
get
@ -92,6 +93,7 @@ Foo.bar -> Foo.bar
Foo.Bar -> Foo.Bar
Baz.foo -> Bar.foo
<nothing>.baz -> Bar.baz
<nothing>.baz -> Bar.baz
<nothing>.button -> Html.button
Http.get -> Http.get
<nothing>.get -> Http.get
@ -167,6 +169,22 @@ expressionVisitor node context =
in
( [], { context | texts = context.texts ++ [ nameInCode ++ " -> " ++ realName ] } )
Expression.RecordUpdateExpression (Node range name) _ ->
let
realName : String
realName =
case ModuleNameLookupTable.moduleNameAt context.lookupTable range of
Just [] ->
"<nothing>." ++ name
Just moduleName_ ->
String.join "." moduleName_ ++ "." ++ name
Nothing ->
"!!! UNKNOWN !!!"
in
( [], { context | texts = context.texts ++ [ "<nothing>." ++ name ++ " -> " ++ realName ] } )
_ ->
( [], context )