1
1
mirror of https://github.com/github/semantic.git synced 2024-11-23 08:27:56 +03:00

Roll back temporary changes to semantic-source

These changes are subsumed by semantic-source version 0.1.0.0
This commit is contained in:
Rick Winfrey 2020-03-31 12:16:34 -07:00
parent de9665873f
commit 5dad3b07f0
3 changed files with 6 additions and 14 deletions

View File

@ -1,7 +1,7 @@
cabal-version: 2.4
name: semantic-source
version: 0.0.3.0
version: 0.1.0.0
synopsis: Types and functionality for working with source code
description: Types and functionality for working with source code (program text).
homepage: https://github.com/github/semantic/tree/master/semantic-source#readme

View File

@ -1,4 +1,5 @@
{-# LANGUAGE DeriveGeneric, GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-|
'Source' models source code, represented as a thin wrapper around a 'B.ByteString' with conveniences for splitting by line, slicing, etc.
@ -37,7 +38,7 @@ import Data.Aeson (FromJSON (..), withText)
import qualified Data.ByteString as B
import Data.Char (ord)
import Data.Maybe (fromMaybe)
import Data.Monoid (Last(..))
import Data.Monoid (Last (..))
import Data.Semilattice.Lower
import Data.String (IsString (..))
import qualified Data.Text as T
@ -45,7 +46,7 @@ import qualified Data.Text.Encoding as T
import Data.Text.Encoding.Error (lenientDecode)
import GHC.Generics (Generic)
import Source.Range
import Source.Span (Span(Span), Pos(..))
import Source.Span (Pos (..), Span (Span))
-- | The contents of a source file. This is represented as a UTF-8
@ -75,7 +76,7 @@ totalRange = Range 0 . B.length . bytes
-- | Return a 'Span' that covers the entire text.
totalSpan :: Source -> Span
totalSpan source = Span lowerBound (Pos (Prelude.length ranges) (succ (end lastRange - start lastRange))) where
totalSpan source = Span (Pos 1 1) (Pos (Prelude.length ranges) (succ (end lastRange - start lastRange))) where
ranges = lineRanges source
lastRange = fromMaybe lowerBound (getLast (foldMap (Last . Just) ranges))

View File

@ -18,7 +18,6 @@ import Control.DeepSeq (NFData)
import Data.Aeson ((.:), (.=))
import qualified Data.Aeson as A
import Data.Hashable (Hashable)
import Data.Semilattice.Lower (Lower (..))
import GHC.Generics (Generic)
import GHC.Stack (SrcLoc (..))
@ -46,10 +45,6 @@ instance A.FromJSON Span where
<$> o .: "start"
<*> o .: "end"
instance Lower Span where
lowerBound = Span lowerBound lowerBound
-- | Construct a Span with a given value for both its start and end positions.
point :: Pos -> Span
point p = Span p p
@ -83,10 +78,6 @@ instance A.FromJSON Pos where
[ line, col ] <- A.parseJSON arr
pure $ Pos line col
instance Lower Pos where
lowerBound = Pos 1 1
line_, column_ :: Lens' Pos Int
line_ = lens line (\p l -> p { line = l })
column_ = lens column (\p l -> p { column = l })