mirror of
https://github.com/github/semantic.git
synced 2024-12-18 20:31:55 +03:00
Merge branch 'master' into ghc8
# Conflicts: # tools/semantic-git-diff/test/corpus/diff-summaries/javascript/chained-ca llbacks.json
This commit is contained in:
commit
2a62dd7bfc
@ -24,22 +24,21 @@ import Source
|
|||||||
|
|
||||||
data Identifiable a = Identifiable a | Unidentifiable a
|
data Identifiable a = Identifiable a | Unidentifiable a
|
||||||
|
|
||||||
isIdentifiable :: SyntaxTerm leaf fields -> Bool
|
|
||||||
isIdentifiable term =
|
|
||||||
case unwrap term of
|
|
||||||
S.FunctionCall _ _ -> True
|
|
||||||
S.Function{} -> True
|
|
||||||
S.Assignment{} -> True
|
|
||||||
S.MathAssignment{} -> True
|
|
||||||
S.VarAssignment{} -> True
|
|
||||||
S.SubscriptAccess{} -> True
|
|
||||||
S.Class _ _ _ -> True
|
|
||||||
S.Method _ _ _ -> True
|
|
||||||
S.Leaf _ -> True
|
|
||||||
_ -> False
|
|
||||||
|
|
||||||
identifiable :: SyntaxTerm leaf fields -> Identifiable (SyntaxTerm leaf fields)
|
identifiable :: SyntaxTerm leaf fields -> Identifiable (SyntaxTerm leaf fields)
|
||||||
identifiable term = if isIdentifiable term then Identifiable term else Unidentifiable term
|
identifiable term = isIdentifiable (unwrap term) $ term
|
||||||
|
where isIdentifiable = \case
|
||||||
|
S.FunctionCall{} -> Identifiable
|
||||||
|
S.MethodCall{} -> Identifiable
|
||||||
|
S.Function{} -> Identifiable
|
||||||
|
S.Assignment{} -> Identifiable
|
||||||
|
S.MathAssignment{} -> Identifiable
|
||||||
|
S.VarAssignment{} -> Identifiable
|
||||||
|
S.SubscriptAccess{} -> Identifiable
|
||||||
|
S.Class{} -> Identifiable
|
||||||
|
S.Method{} -> Identifiable
|
||||||
|
S.Leaf{} -> Identifiable
|
||||||
|
S.DoWhile{} -> Identifiable
|
||||||
|
_ -> Unidentifiable
|
||||||
|
|
||||||
data DiffInfo = LeafInfo { categoryName :: Text, termName :: Text }
|
data DiffInfo = LeafInfo { categoryName :: Text, termName :: Text }
|
||||||
| BranchInfo { branches :: [ DiffInfo ], categoryName :: Text, branchType :: Branch }
|
| BranchInfo { branches :: [ DiffInfo ], categoryName :: Text, branchType :: Branch }
|
||||||
@ -141,8 +140,8 @@ toTermName source term = case unwrap term of
|
|||||||
S.Ternary expr _ -> toTermName' expr
|
S.Ternary expr _ -> toTermName' expr
|
||||||
S.MathAssignment id _ -> toTermName' id
|
S.MathAssignment id _ -> toTermName' id
|
||||||
S.Operator _ -> termNameFromSource term
|
S.Operator _ -> termNameFromSource term
|
||||||
S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}"
|
S.Object kvs -> "{ " <> intercalate ", " (toTermName' <$> kvs) <> " }"
|
||||||
S.Pair a b -> toTermName' a <> ": " <> toTermName' b
|
S.Pair a _ -> toTermName' a <> ": …"
|
||||||
S.Return expr -> maybe "empty" toTermName' expr
|
S.Return expr -> maybe "empty" toTermName' expr
|
||||||
S.Error _ _ -> termNameFromSource term
|
S.Error _ _ -> termNameFromSource term
|
||||||
S.If expr _ _ -> termNameFromSource expr
|
S.If expr _ _ -> termNameFromSource expr
|
||||||
@ -165,7 +164,7 @@ toTermName source term = case unwrap term of
|
|||||||
toArgName :: SyntaxTerm leaf fields -> Text
|
toArgName :: SyntaxTerm leaf fields -> Text
|
||||||
toArgName arg = case identifiable arg of
|
toArgName arg = case identifiable arg of
|
||||||
Identifiable arg -> toTermName' arg
|
Identifiable arg -> toTermName' arg
|
||||||
Unidentifiable _ -> "..."
|
Unidentifiable _ -> "…"
|
||||||
|
|
||||||
maybeParentContext :: Maybe (Category, Text) -> Doc
|
maybeParentContext :: Maybe (Category, Text) -> Doc
|
||||||
maybeParentContext = maybe "" (\annotation ->
|
maybeParentContext = maybe "" (\annotation ->
|
||||||
|
Loading…
Reference in New Issue
Block a user