mirror of
https://github.com/github/semantic.git
synced 2024-12-24 07:25:44 +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:
parent
e29651ce07
commit
1f1b0a9b3f
@ -34,6 +34,7 @@ import Term
|
|||||||
import TreeSitter
|
import TreeSitter
|
||||||
import Text.Parser.TreeSitter.Language
|
import Text.Parser.TreeSitter.Language
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import Category
|
||||||
import Data.Aeson (pairs)
|
import Data.Aeson (pairs)
|
||||||
import Data.Aeson.Encoding (encodingToLazyByteString)
|
import Data.Aeson.Encoding (encodingToLazyByteString)
|
||||||
|
|
||||||
@ -97,6 +98,7 @@ breakDownLeavesByWord source = cata replaceIn
|
|||||||
where
|
where
|
||||||
replaceIn (info :< syntax) = cofree $ info :< syntax'
|
replaceIn (info :< syntax) = cofree $ info :< syntax'
|
||||||
where syntax' = case (ranges, syntax) of
|
where syntax' = case (ranges, syntax) of
|
||||||
|
(_:_:_, Leaf _) | category info == Category.Comment -> syntax
|
||||||
(_:_:_, Leaf _) | category info /= Regex -> Indexed (makeLeaf info <$> ranges)
|
(_:_:_, Leaf _) | category info /= Regex -> Indexed (makeLeaf info <$> ranges)
|
||||||
_ -> syntax
|
_ -> syntax
|
||||||
ranges = rangesAndWordsInSource (characterRange info)
|
ranges = rangesAndWordsInSource (characterRange info)
|
||||||
|
Loading…
Reference in New Issue
Block a user