mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-23 09:42:49 +03:00
Speed up collection modules names from patterns
This commit is contained in:
parent
313e8e26da
commit
2c6ddeacb8
@ -6305,10 +6305,7 @@ scope_declarationEnterVisitor node context =
|
|||||||
|
|
||||||
moduleNamesFromArguments : List ( Range, ModuleName )
|
moduleNamesFromArguments : List ( Range, ModuleName )
|
||||||
moduleNamesFromArguments =
|
moduleNamesFromArguments =
|
||||||
function.declaration
|
collectModuleNamesFromPattern newContext (Node.value function.declaration).arguments []
|
||||||
|> Node.value
|
|
||||||
|> .arguments
|
|
||||||
|> ListExtra.orderIndependentConcatMap (collectModuleNamesFromPattern newContext)
|
|
||||||
|
|
||||||
newModuleNames : List ( Range, ModuleName )
|
newModuleNames : List ( Range, ModuleName )
|
||||||
newModuleNames =
|
newModuleNames =
|
||||||
@ -6442,39 +6439,34 @@ collectNamesFromPattern variableType patternsToVisit acc =
|
|||||||
acc
|
acc
|
||||||
|
|
||||||
|
|
||||||
collectModuleNamesFromPattern : ScopeModuleContext -> Node Pattern -> List ( Range, ModuleName )
|
collectModuleNamesFromPattern : ScopeModuleContext -> List (Node Pattern) -> List ( Range, ModuleName ) -> List ( Range, ModuleName )
|
||||||
collectModuleNamesFromPattern context pattern =
|
collectModuleNamesFromPattern context patternsToVisit acc =
|
||||||
collectModuleNamesFromPatternHelp context [ pattern ] []
|
|
||||||
|
|
||||||
|
|
||||||
collectModuleNamesFromPatternHelp : ScopeModuleContext -> List (Node Pattern) -> List ( Range, ModuleName ) -> List ( Range, ModuleName )
|
|
||||||
collectModuleNamesFromPatternHelp context patternsToVisit acc =
|
|
||||||
case patternsToVisit of
|
case patternsToVisit of
|
||||||
pattern :: restOfPatternsToVisit ->
|
pattern :: restOfPatternsToVisit ->
|
||||||
case Node.value pattern of
|
case Node.value pattern of
|
||||||
Pattern.NamedPattern { moduleName, name } subPatterns ->
|
Pattern.NamedPattern { moduleName, name } subPatterns ->
|
||||||
collectModuleNamesFromPatternHelp
|
collectModuleNamesFromPattern
|
||||||
context
|
context
|
||||||
(ListExtra.orderIndependentAppend subPatterns restOfPatternsToVisit)
|
(ListExtra.orderIndependentAppend subPatterns restOfPatternsToVisit)
|
||||||
(( Node.range pattern, moduleNameForValue context name moduleName ) :: acc)
|
(( Node.range pattern, moduleNameForValue context name moduleName ) :: acc)
|
||||||
|
|
||||||
Pattern.UnConsPattern left right ->
|
Pattern.UnConsPattern left right ->
|
||||||
collectModuleNamesFromPatternHelp context (left :: right :: restOfPatternsToVisit) acc
|
collectModuleNamesFromPattern context (left :: right :: restOfPatternsToVisit) acc
|
||||||
|
|
||||||
Pattern.TuplePattern subPatterns ->
|
Pattern.TuplePattern subPatterns ->
|
||||||
collectModuleNamesFromPatternHelp context (ListExtra.orderIndependentAppend subPatterns restOfPatternsToVisit) acc
|
collectModuleNamesFromPattern context (ListExtra.orderIndependentAppend subPatterns restOfPatternsToVisit) acc
|
||||||
|
|
||||||
Pattern.ParenthesizedPattern subPattern ->
|
Pattern.ParenthesizedPattern subPattern ->
|
||||||
collectModuleNamesFromPatternHelp context (subPattern :: restOfPatternsToVisit) acc
|
collectModuleNamesFromPattern context (subPattern :: restOfPatternsToVisit) acc
|
||||||
|
|
||||||
Pattern.AsPattern subPattern _ ->
|
Pattern.AsPattern subPattern _ ->
|
||||||
collectModuleNamesFromPatternHelp context (subPattern :: restOfPatternsToVisit) acc
|
collectModuleNamesFromPattern context (subPattern :: restOfPatternsToVisit) acc
|
||||||
|
|
||||||
Pattern.ListPattern subPatterns ->
|
Pattern.ListPattern subPatterns ->
|
||||||
collectModuleNamesFromPatternHelp context (ListExtra.orderIndependentAppend subPatterns restOfPatternsToVisit) acc
|
collectModuleNamesFromPattern context (ListExtra.orderIndependentAppend subPatterns restOfPatternsToVisit) acc
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
collectModuleNamesFromPatternHelp context restOfPatternsToVisit acc
|
collectModuleNamesFromPattern context restOfPatternsToVisit acc
|
||||||
|
|
||||||
[] ->
|
[] ->
|
||||||
acc
|
acc
|
||||||
@ -6546,32 +6538,32 @@ scope_expressionEnterVisitor node context =
|
|||||||
|
|
||||||
moduleNames : List ( Range, ModuleName )
|
moduleNames : List ( Range, ModuleName )
|
||||||
moduleNames =
|
moduleNames =
|
||||||
declarations
|
List.foldl
|
||||||
|> ListExtra.fastConcatMap
|
(\declaration acc ->
|
||||||
(\declaration ->
|
case Node.value declaration of
|
||||||
case Node.value declaration of
|
Expression.LetFunction function ->
|
||||||
Expression.LetFunction function ->
|
let
|
||||||
let
|
declarationModuleNames : List ( Range, ModuleName )
|
||||||
declarationModuleNames : List ( Range, ModuleName )
|
declarationModuleNames =
|
||||||
declarationModuleNames =
|
collectModuleNamesFromPattern newContext
|
||||||
function.declaration
|
(Node.value function.declaration).arguments
|
||||||
|> Node.value
|
acc
|
||||||
|> .arguments
|
in
|
||||||
|> ListExtra.fastConcatMap (collectModuleNamesFromPattern newContext)
|
case function.signature of
|
||||||
in
|
Just signature ->
|
||||||
case function.signature of
|
collectModuleNamesFromTypeAnnotationHelp
|
||||||
Just signature ->
|
context
|
||||||
collectModuleNamesFromTypeAnnotationHelp
|
[ (Node.value signature).typeAnnotation ]
|
||||||
context
|
|
||||||
[ (Node.value signature).typeAnnotation ]
|
|
||||||
declarationModuleNames
|
|
||||||
|
|
||||||
Nothing ->
|
|
||||||
declarationModuleNames
|
declarationModuleNames
|
||||||
|
|
||||||
Expression.LetDestructuring pattern _ ->
|
Nothing ->
|
||||||
collectModuleNamesFromPattern newContext pattern
|
declarationModuleNames
|
||||||
)
|
|
||||||
|
Expression.LetDestructuring pattern _ ->
|
||||||
|
collectModuleNamesFromPattern newContext [ pattern ] acc
|
||||||
|
)
|
||||||
|
[]
|
||||||
|
declarations
|
||||||
in
|
in
|
||||||
{ newContext | lookupTable = ModuleNameLookupTableInternal.addMultiple moduleNames newContext.lookupTable }
|
{ newContext | lookupTable = ModuleNameLookupTableInternal.addMultiple moduleNames newContext.lookupTable }
|
||||||
|
|
||||||
@ -6589,8 +6581,11 @@ scope_expressionEnterVisitor node context =
|
|||||||
|
|
||||||
moduleNames : List ( Range, ModuleName )
|
moduleNames : List ( Range, ModuleName )
|
||||||
moduleNames =
|
moduleNames =
|
||||||
ListExtra.fastConcatMap
|
List.foldl
|
||||||
(\( pattern, _ ) -> collectModuleNamesFromPattern context pattern)
|
(\( pattern, _ ) acc ->
|
||||||
|
collectModuleNamesFromPattern context [ pattern ] acc
|
||||||
|
)
|
||||||
|
[]
|
||||||
caseBlock.cases
|
caseBlock.cases
|
||||||
in
|
in
|
||||||
{ context
|
{ context
|
||||||
@ -6620,7 +6615,7 @@ scope_expressionEnterVisitor node context =
|
|||||||
{ context
|
{ context
|
||||||
| lookupTable =
|
| lookupTable =
|
||||||
ModuleNameLookupTableInternal.addMultiple
|
ModuleNameLookupTableInternal.addMultiple
|
||||||
(ListExtra.fastConcatMap (collectModuleNamesFromPattern context) args)
|
(collectModuleNamesFromPattern context args [])
|
||||||
context.lookupTable
|
context.lookupTable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user