mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Merge branch 'master' into precompute-p,q-grams
This commit is contained in:
commit
59ef5efd1e
@ -3,7 +3,6 @@ module Category where
|
|||||||
import Prologue
|
import Prologue
|
||||||
import Data.Hashable
|
import Data.Hashable
|
||||||
import Test.QuickCheck hiding (Args)
|
import Test.QuickCheck hiding (Args)
|
||||||
import Data.Text (unpack)
|
|
||||||
import Data.Text.Arbitrary()
|
import Data.Text.Arbitrary()
|
||||||
|
|
||||||
-- | A standardized category of AST node. Used to determine the semantics for
|
-- | A standardized category of AST node. Used to determine the semantics for
|
||||||
@ -99,11 +98,6 @@ data Category
|
|||||||
|
|
||||||
instance Hashable Category
|
instance Hashable Category
|
||||||
|
|
||||||
instance CoArbitrary Text where
|
|
||||||
coarbitrary = coarbitrary . unpack
|
|
||||||
instance CoArbitrary Category where
|
|
||||||
coarbitrary = genericCoarbitrary
|
|
||||||
|
|
||||||
instance Arbitrary Category where
|
instance Arbitrary Category where
|
||||||
arbitrary = oneof [
|
arbitrary = oneof [
|
||||||
pure Program
|
pure Program
|
||||||
|
@ -63,18 +63,20 @@ toTermName source term = case unwrap term of
|
|||||||
S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}"
|
S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}"
|
||||||
S.Pair a b -> toTermName' a <> ": " <> toTermName' b
|
S.Pair a b -> toTermName' a <> ": " <> toTermName' b
|
||||||
S.Return expr -> maybe "empty" toTermName' expr
|
S.Return expr -> maybe "empty" toTermName' expr
|
||||||
S.For exprs _ -> termNameFromChildren term exprs
|
S.Error span _ -> displayStartEndPos span
|
||||||
|
S.For _ _ -> termNameFromChildren term
|
||||||
S.While expr _ -> toTermName' expr
|
S.While expr _ -> toTermName' expr
|
||||||
S.DoWhile _ expr -> toTermName' expr
|
S.DoWhile _ expr -> toTermName' expr
|
||||||
S.Throw expr -> toText $ Source.slice (characterRange $ extract expr) source
|
S.Throw expr -> termNameFromSource expr
|
||||||
S.Constructor expr -> toTermName' expr
|
S.Constructor expr -> toTermName' expr
|
||||||
S.Try expr _ _ -> toText $ Source.slice (characterRange $ extract expr) source
|
S.Try expr _ _ -> termNameFromSource expr
|
||||||
S.Array _ -> toText $ Source.slice (characterRange $ extract term) source
|
S.Array _ -> termNameFromSource term
|
||||||
S.Class identifier _ _ -> toTermName' identifier
|
S.Class identifier _ _ -> toTermName' identifier
|
||||||
S.Method identifier _ _ -> toTermName' identifier
|
S.Method identifier _ _ -> toTermName' identifier
|
||||||
Comment a -> toCategoryName a
|
Comment a -> toCategoryName a
|
||||||
|
S.Commented _ _ -> termNameFromChildren term
|
||||||
where toTermName' = toTermName source
|
where toTermName' = toTermName source
|
||||||
termNameFromChildren term cs = termNameFromRange (unionRangesFrom (range term) (range <$> cs))
|
termNameFromChildren term = termNameFromRange (unionRangesFrom (range term) (range <$> toList (unwrap term)))
|
||||||
termNameFromSource term = termNameFromRange (range term)
|
termNameFromSource term = termNameFromRange (range term)
|
||||||
termNameFromRange range = toText $ Source.slice range source
|
termNameFromRange range = toText $ Source.slice range source
|
||||||
range = characterRange . extract
|
range = characterRange . extract
|
||||||
|
@ -71,6 +71,7 @@ styleName category = "category-" <> case category of
|
|||||||
C.Finally -> "finally_statement"
|
C.Finally -> "finally_statement"
|
||||||
ArrayLiteral -> "array"
|
ArrayLiteral -> "array"
|
||||||
C.Class -> "class_statement"
|
C.Class -> "class_statement"
|
||||||
|
C.Method -> "method"
|
||||||
Other string -> string
|
Other string -> string
|
||||||
|
|
||||||
-- | Pick the class name for a split patch.
|
-- | Pick the class name for a split patch.
|
||||||
|
Loading…
Reference in New Issue
Block a user