mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Merge pull request #676 from github/fix-some-other-warnings
Fix some other warnings
This commit is contained in:
commit
e742a8c86d
@ -3,7 +3,6 @@ module Category where
|
||||
import Prologue
|
||||
import Data.Hashable
|
||||
import Test.QuickCheck hiding (Args)
|
||||
import Data.Text (unpack)
|
||||
import Data.Text.Arbitrary()
|
||||
|
||||
-- | A standardized category of AST node. Used to determine the semantics for
|
||||
@ -99,11 +98,6 @@ data Category
|
||||
|
||||
instance Hashable Category
|
||||
|
||||
instance CoArbitrary Text where
|
||||
coarbitrary = coarbitrary . unpack
|
||||
instance CoArbitrary Category where
|
||||
coarbitrary = genericCoarbitrary
|
||||
|
||||
instance Arbitrary Category where
|
||||
arbitrary = oneof [
|
||||
pure Program
|
||||
|
@ -63,18 +63,20 @@ toTermName source term = case unwrap term of
|
||||
S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}"
|
||||
S.Pair a b -> toTermName' a <> ": " <> toTermName' b
|
||||
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.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.Try expr _ _ -> toText $ Source.slice (characterRange $ extract expr) source
|
||||
S.Array _ -> toText $ Source.slice (characterRange $ extract term) source
|
||||
S.Try expr _ _ -> termNameFromSource expr
|
||||
S.Array _ -> termNameFromSource term
|
||||
S.Class identifier _ _ -> toTermName' identifier
|
||||
S.Method identifier _ _ -> toTermName' identifier
|
||||
Comment a -> toCategoryName a
|
||||
S.Commented _ _ -> termNameFromChildren term
|
||||
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)
|
||||
termNameFromRange range = toText $ Source.slice range source
|
||||
range = characterRange . extract
|
||||
|
@ -71,6 +71,7 @@ styleName category = "category-" <> case category of
|
||||
C.Finally -> "finally_statement"
|
||||
ArrayLiteral -> "array"
|
||||
C.Class -> "class_statement"
|
||||
C.Method -> "method"
|
||||
Other string -> string
|
||||
|
||||
-- | Pick the class name for a split patch.
|
||||
|
Loading…
Reference in New Issue
Block a user