mirror of
https://github.com/github/semantic.git
synced 2025-01-02 20:41:38 +03:00
Add Modifier categories.
These are used when a normal syntactic category is attached as a modifier instead of as a statement, e.g.: ```ruby if foo then bar end ``` vs. ```ruby bar if foo ```
This commit is contained in:
parent
33040ea22e
commit
408ad2ecc5
@ -222,6 +222,8 @@ data Category
|
||||
| FieldDeclarations
|
||||
-- | A Go rune literal.
|
||||
| RuneLiteral
|
||||
-- | A modifier version of another Category, e.g. Ruby’s trailing @if@, @while@, etc. terms, whose subterms are swapped relative to regular @if@, @while@, etc. terms.
|
||||
| Modifier Category
|
||||
deriving (Eq, Generic, Ord, Show)
|
||||
|
||||
-- Instances
|
||||
@ -347,3 +349,4 @@ instance Listable Category where
|
||||
\/ cons0 FieldDeclarations
|
||||
\/ cons0 RuneLiteral
|
||||
\/ cons1 (Other . unListableText)
|
||||
\/ cons1 Modifier
|
||||
|
@ -477,6 +477,7 @@ instance HasCategory Category where
|
||||
C.QualifiedIdentifier -> "qualified identifier"
|
||||
C.FieldDeclarations -> "field declarations"
|
||||
C.RuneLiteral -> "rune literal"
|
||||
C.Modifier c -> toCategoryName c <> " modifier"
|
||||
|
||||
instance HasField fields Category => HasCategory (SyntaxTerm leaf fields) where
|
||||
toCategoryName = toCategoryName . category . extract
|
||||
|
@ -145,6 +145,7 @@ styleName category = "category-" <> case category of
|
||||
C.IndexExpression -> "index_expression"
|
||||
C.FieldDeclarations -> "field_declarations"
|
||||
C.RuneLiteral -> "rune_literal"
|
||||
C.Modifier c -> styleName c <> "_modifier"
|
||||
|
||||
-- | Pick the class name for a split patch.
|
||||
splitPatchToClassName :: SplitPatch a -> AttributeValue
|
||||
|
Loading…
Reference in New Issue
Block a user