mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Omit a function call's arguments if it's arguments match the underlying anonymous function's arguments
This commit is contained in:
parent
30c9fd8f5f
commit
af938b87f4
@ -163,8 +163,16 @@ toTermName source term = case unwrap term of
|
|||||||
S.Indexed children -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children
|
S.Indexed children -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children
|
||||||
Leaf leaf -> toCategoryName leaf
|
Leaf leaf -> toCategoryName leaf
|
||||||
S.Assignment identifier _ -> toTermName' identifier
|
S.Assignment identifier _ -> toTermName' identifier
|
||||||
S.Function identifier _ _ -> toTermName' identifier
|
S.Function identifier _ _ ->
|
||||||
S.FunctionCall i args -> toTermName' i <> "(" <> intercalate ", " (toArgName <$> args) <> ")"
|
toTermName' identifier
|
||||||
|
S.FunctionCall i args -> case unwrap i of
|
||||||
|
S.AnonymousFunction params _ ->
|
||||||
|
-- Omit a function call's arguments if it's arguments match the underlying
|
||||||
|
-- anonymous function's arguments.
|
||||||
|
if (category . extract <$> args) == (category . extract <$> params)
|
||||||
|
then toTermName' i
|
||||||
|
else "(" <> toTermName' i <> ")" <> paramsToArgNames args
|
||||||
|
_ -> toTermName' i <> paramsToArgNames args
|
||||||
S.MemberAccess base property -> case (unwrap base, unwrap property) of
|
S.MemberAccess base property -> case (unwrap base, unwrap property) of
|
||||||
(S.FunctionCall{}, S.FunctionCall{}) -> toTermName' base <> "()." <> toTermName' property <> "()"
|
(S.FunctionCall{}, S.FunctionCall{}) -> toTermName' base <> "()." <> toTermName' property <> "()"
|
||||||
(S.FunctionCall{}, _) -> toTermName' base <> "()." <> toTermName' property
|
(S.FunctionCall{}, _) -> toTermName' base <> "()." <> toTermName' property
|
||||||
|
Loading…
Reference in New Issue
Block a user