1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Specifically handle Comment nodes instead of breaking them down by words (the default behavior for Leaf syntaxes that are not Regex)

This commit is contained in:
Rick Winfrey 2016-08-16 13:10:26 -05:00
parent e29651ce07
commit 1f1b0a9b3f

View File

@ -34,6 +34,7 @@ import Term
import TreeSitter
import Text.Parser.TreeSitter.Language
import qualified Data.Text as T
import Category
import Data.Aeson (pairs)
import Data.Aeson.Encoding (encodingToLazyByteString)
@ -97,6 +98,7 @@ breakDownLeavesByWord source = cata replaceIn
where
replaceIn (info :< syntax) = cofree $ info :< syntax'
where syntax' = case (ranges, syntax) of
(_:_:_, Leaf _) | category info == Category.Comment -> syntax
(_:_:_, Leaf _) | category info /= Regex -> Indexed (makeLeaf info <$> ranges)
_ -> syntax
ranges = rangesAndWordsInSource (characterRange info)