Register type constructors from visited modules in Scope

This commit is contained in:
Jeroen Engels 2020-01-13 16:46:24 +01:00
parent 061a950679
commit 56e766ad62
3 changed files with 23 additions and 7 deletions

View File

@ -477,7 +477,9 @@ registerExposed declaration innerContext =
{ name = Node.value type_.name
, comment = ""
, args = []
, tags = []
, tags =
type_.constructors
|> List.map (\constructor -> ( Node.value (Node.value constructor).name, [] ))
}
:: innerContext.exposedUnions
}
@ -661,7 +663,12 @@ registerImportExposed import_ innerContext =
exposedValues : Dict String (List String)
exposedValues =
List.concat
[ List.map nameWithModuleName module_.unions
[ List.concatMap
(\union ->
nameWithModuleName union
:: List.map (\( name, _ ) -> ( name, moduleName )) union.tags
)
module_.unions
, List.map nameWithModuleName module_.values
, List.map nameWithModuleName module_.aliases
, List.map nameWithModuleName module_.binops

View File

@ -10,7 +10,13 @@ elmCore =
, modules =
[ { name = "Basics"
, comment = ""
, unions = []
, unions =
[ { name = "Bool"
, comment = ""
, args = []
, tags = [ ( "True", [] ), ( "False", [] ) ]
}
]
, aliases = []
, values =
[ { name = "always"

View File

@ -15,7 +15,6 @@ import Test exposing (Test, test)
all : Test
all =
Test.only <|
Test.describe "Scope"
[ realFunctionOrTypeTests
]
@ -42,6 +41,7 @@ a = localValue
exposedElement
nonExposedElement
elementFromExposesEverything
VariantA
Foo.bar
Foo.Bar
Baz.foo
@ -50,6 +50,7 @@ a = localValue
Http.get
get
always
True
Just
""", """module ExposesSomeThings exposing (SomeOtherTypeAlias, exposedElement)
type NonExposedCustomType = Variant
@ -75,6 +76,7 @@ elementFromExposesEverything = 1
<nothing>.exposedElement -> ExposesSomeThings.exposedElement
<nothing>.nonExposedElement -> <nothing>.nonExposedElement
<nothing>.elementFromExposesEverything -> ExposesEverything.elementFromExposesEverything
<nothing>.VariantA -> ExposesEverything.VariantA
Foo.bar -> Foo.bar
Foo.Bar -> Foo.Bar
Baz.foo -> Bar.foo
@ -83,6 +85,7 @@ Baz.foo -> Bar.foo
Http.get -> Http.get
<nothing>.get -> Http.get
<nothing>.always -> Basics.always
<nothing>.True -> Basics.True
<nothing>.Just -> Maybe.Just"""
, details = [ "details" ]
, under = "module"