From 68d932594e0a44dfd8d275a738a48dadadd8be78 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 12 Sep 2016 21:06:53 -0700 Subject: [PATCH] Add in NumberLiteral category --- src/Category.hs | 3 +++ src/DiffSummary.hs | 1 + src/Diffing.hs | 2 +- src/Language/JavaScript.hs | 1 + src/Renderer/Split.hs | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Category.hs b/src/Category.hs index af30e5ba0..18dba236a 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -104,6 +104,8 @@ data Category | RelationalOperator -- | An empty statement. (e.g. ; in JavaScript) | Empty + -- | A number literal. + | NumberLiteral deriving (Eq, Generic, Ord, Show) -- Instances @@ -127,6 +129,7 @@ instance Arbitrary Category where , pure Args , pure StringLiteral , pure IntegerLiteral + , pure NumberLiteral , pure Regex , pure Return , pure SymbolLiteral diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 0dbae5c48..cab638736 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -246,6 +246,7 @@ instance HasCategory Category where C.Operator -> "operator" Identifier -> "identifier" IntegerLiteral -> "integer" + NumberLiteral -> "number" Other s -> s C.Pair -> "pair" Params -> "params" diff --git a/src/Diffing.hs b/src/Diffing.hs index fa0f1eef3..761791b38 100644 --- a/src/Diffing.hs +++ b/src/Diffing.hs @@ -106,7 +106,7 @@ breakDownLeavesByWord source = cata replaceIn -- Some Category constructors should retain their original structure, and not be sliced -- into words. This Set represents those Category constructors for which we want to -- preserve the original Syntax. - preserveSyntax = Set.fromList [Regex, Category.Comment, Category.TemplateString] + preserveSyntax = Set.fromList [Regex, Category.Comment, Category.TemplateString, Category.NumberLiteral] -- | Transcode a file to a unicode source. transcode :: B1.ByteString -> IO (Source Char) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index 5be276759..73fef7d3f 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -108,6 +108,7 @@ categoryForJavaScriptProductionName name = case name of "pair" -> Pair "string" -> StringLiteral "integer" -> IntegerLiteral + "number" -> NumberLiteral "symbol" -> SymbolLiteral "array" -> ArrayLiteral "function" -> Function diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 40388b5d0..b609d58f4 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -42,6 +42,7 @@ styleName category = "category-" <> case category of StringLiteral -> "string" SymbolLiteral -> "symbol" IntegerLiteral -> "integer" + NumberLiteral -> "number" C.Comment -> "comment" C.FunctionCall -> "function_call" C.Function -> "function"