1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Tighten up toTermName.

This commit is contained in:
Rob Rix 2017-05-08 11:16:23 -04:00
parent 76002f08c0
commit 9df2a73e38

View File

@ -165,12 +165,9 @@ toTermName parentOffset parentSource term = case unwrap term of
_ -> toMethodNameWithReceiver receiver identifier _ -> toMethodNameWithReceiver receiver identifier
_ -> toText source _ -> toText source
where where
source = Source.slice (offsetRange (range term) (negate parentOffset)) parentSource source = Source.slice (offsetRange (byteRange (extract term)) (negate parentOffset)) parentSource
toMethodNameWithReceiver receiver name = toTermName' receiver <> "." <> toTermName' name toMethodNameWithReceiver receiver name = toTermName' receiver <> "." <> toTermName' name
offset = start (range term) toTermName' = toTermName (start (byteRange (extract term))) source
toTermName' :: SyntaxTerm leaf fields -> Text
toTermName' = toTermName offset source
range = byteRange . extract
-- The user-facing category name -- The user-facing category name
toCategoryName :: Category -> Text toCategoryName :: Category -> Text