8000 Factor source code-related facilities into a new package by robrix · Pull Request #269 · github/semantic · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Factor source code-related facilities into a new package #269

Merged
merged 49 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
974e2ca
Define a semantic-source package.
robrix Sep 20, 2019
a66f459
Merge branch 'master' into semantic-source
robrix Sep 20, 2019
5802d46
Move the ToJSONFields instance for Range into Data.JSON.Fields.
robrix Sep 20, 2019
10e4bbb
Move the ToJSONFields instance for Span into Data.JSON.Fields.
robrix Sep 20, 2019
57ab2f6
Link the doctests against the lib.
robrix Sep 20, 2019
2c99f09
Link the doctests against QuickCheck.
robrix Sep 20, 2019
a126e39
Use the right dir for the doctests.
robrix Sep 20, 2019
4e40108
Copy Range in.
robrix Sep 20, 2019
325e1f1
Derive a Hashable instance for Range.
robrix Sep 20, 2019
ddef713
Copy Span in.
robrix Sep 20, 2019
81f43c9
Move the ToJSONFields instance for Location into Data.JSON.Fields.
robrix Sep 20, 2019
2748529
Copy Location in as Loc.
robrix Sep 20, 2019
cc82051
Depend on semantic-source.
robrix Sep 20, 2019
1d5e150
Switch everything over to using Source.Range.
robrix Sep 20, 2019
17c61c1
Switch everything over to using Source.Span.
robrix Sep 20, 2019
0f8e69c
Switch everything over to using Source.Loc.
robrix Sep 20, 2019
f6e4864
Move the span/range stuff into CMark.
robrix Sep 20, 2019
b20dcf4
Copy Source in.
robrix Sep 20, 2019
8aae312
Rename the Source symbols and recommend importing it qualified.
robrix Sep 20, 2019
ca6a785
Flip lineRangesWithin.
robrix Sep 20, 2019
d929a8c
Make Data.Source reexport Source.Source.
Sep 20, 2019
948deb4
Fixup remaining test cases.
Sep 20, 2019
7b599a6
Use Source.Source instead of Data.Source.
Sep 20, 2019
a422061
Delete Data.Source.
Sep 20, 2019
f17a2e8
Remove Data.Source from the .cabal file.
Sep 20, 2019
f0567fd
De-suffix dropSource and takeSource.
Sep 20, 2019
86682d8
De-suffix sourceBytes.
Sep 20, 2019
74693f4
Bring in the Source tests.
robrix Sep 20, 2019
2ce8b51
:fire: Data.Source.Spec.
robrix Sep 20, 2019
c86186a
:fire: a redundant import.
robrix Sep 20, 2019
a00a78e
Merge branch 'master' into semantic-source
robrix Sep 20, 2019
bb20471
Define lenses for the starts/ends of Range.
robrix Sep 20, 2019
64ef37e
Rename the line/column lenses to line_/column_.
robrix Sep 20, 2019
1e6ebd2
Rename posLine/posColumn to line/column.
robrix Sep 20, 2019
57c385d
Rename the HasSpan start/end lenses to start_/end_.
robrix Sep 20, 2019
d59a44b
Rename the HasSpan span lens to span_.
robrix Sep 20, 2019
7d1567e
:fire: a bunch of redundant hidden imports.
robrix Sep 20, 2019
0312300
Rename the spanStart/spanEnd fields to start/end.
robrix Sep 20, 2019
e08a495
Define a point fiunction for Range.
robrix Sep 20, 2019
935acb4
:memo: point.
robrix Sep 20, 2019
6356443
Define a point constructor for Span.
robrix Sep 20, 2019
e28e81b
:memo: point.
robrix Sep 20, 2019
9551742
Use point to define emptyTerm.
robrix Sep 20, 2019
52bc7e6
Rename locByteRange/locSpan to byteRange/span.
robrix Sep 20, 2019
4bc5491
Extract lens to the top level.
robrix Sep 20, 2019
909fa63
Define a byteRange_ lens for Loc.
robrix Sep 20, 2019
8df1345
Run semantic-source’s tests in CI.
robrix Sep 20, 2019
918bfb4
Apparently this should not exist.
robrix Sep 20, 2019
77ff50b
Run the doctests from the right place.
robrix Sep 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switch everything over to using Source.Range.
  • Loading branch information
robrix committed Sep 20, 2019
commit 1d5e15010f6cddd60399642f921c148e492a2bec
2 changes: 0 additions & 2 deletions semantic.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ library
, Data.Patch
, Data.Project
, Data.Quieterm
, Data.Range
, Data.Reprinting.Errors
, Data.Reprinting.Fragment
, Data.Reprinting.Operator
Expand Down Expand Up @@ -360,7 +359,6 @@ test-suite test
, Data.Graph.Spec
, Data.Mergeable
, Data.Language.Spec
, Data.Range.Spec
, Data.Scientific.Spec
, Data.Semigroup.App.Spec
, Data.Source.Spec
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis/TOCSummary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import Data.Error (Error (..), Colourize (..), showExpectation)
import Data.Flag
import Data.Language as Language
import Data.Location
import Data.Range
import Data.Source as Source
import qualified Data.Syntax as Syntax
import qualified Data.Syntax.Declaration as Declaration
import Data.Term
import qualified Data.Text as T
import Source.Range
import qualified Language.Markdown.Syntax as Markdown

-- | A declaration’s identifier and type.
Expand Down
2 changes: 1 addition & 1 deletion src/Assigning/Assignment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ import qualified Assigning.Assignment.Table as Table
import Control.Monad.Except (MonadError (..))
import Data.AST
import Data.Error
import Data.Range
import qualified Data.Location as L
import qualified Data.Source as Source (Source, slice, sourceBytes)
import Data.Span hiding (HasSpan(..))
import Data.Term
import Data.Text (Text)
import Data.Text.Encoding (decodeUtf8')
import Source.Range
import Text.Parser.Combinators as Parsers hiding (choice)
import TreeSitter.Language

Expand Down
1 change: 0 additions & 1 deletion src/Assigning/Assignment/Deterministic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Data.AST
import Data.Error
import qualified Data.IntMap as IntMap
import qualified Data.IntSet as IntSet
import Data.Range
import Data.Location
import Data.Source as Source
import Data.Span hiding (HasSpan (..))
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Location.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module Data.Location
import Prologue

import Control.Lens.Lens
import Data.Range
import Data.Span
import Source.Range

data Location
= Location
Expand Down
36 changes: 0 additions & 36 deletions src/Data/Range.hs

This file was deleted.

6 changes: 3 additions & 3 deletions src/Data/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import Data.Array
import qualified Data.ByteString as B
import Data.Char (ord)
import Data.List (span)
import Data.Range
import Data.Span hiding (HasSpan (..))
import Data.String (IsString (..))
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Source.Range


-- | The contents of a source file. This is represented as a UTF-8
Expand Down Expand Up @@ -68,7 +68,7 @@ totalRange = Range 0 . B.length . sourceBytes
totalSpan :: Source -> Span
totalSpan source = Span (Pos 1 1) (Pos (length ranges) (succ (end lastRange - start lastRange)))
where ranges = sourceLineRanges source
lastRange = fromMaybe emptyRange (getLast (foldMap (Last . Just) ranges))
lastRange = fromMaybe lowerBound (getLast (foldMap (Last . Just) ranges))


-- En/decoding
Expand Down Expand Up @@ -157,5 +157,5 @@ rangeToSpan source (Range rangeStart rangeEnd) = Span startPos endPos
firstLine = length before
(before, rest) = span ((< rangeStart) . end) (sourceLineRanges source)
(lineRanges, _) = span ((<= rangeEnd) . start) rest
firstRange = fromMaybe emptyRange (getFirst (foldMap (First . Just) lineRanges))
firstRange = fromMaybe lowerBound (getFirst (foldMap (First . Just) lineRanges))
lastRange = fromMaybe firstRange (getLast (foldMap (Last . Just) lineRanges))
1 change: 0 additions & 1 deletion src/Data/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Data.Syntax where
import Data.Abstract.Evaluatable hiding (Empty, Error)
import Data.Aeson as Aeson (ToJSON(..), object)
import Data.JSON.Fields
import Data.Range
import Data.Location
import qualified Data.Set as Set
import Data.Sum
Expand Down
1 change: 0 additions & 1 deletion src/Parsing/CMark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module Parsing.CMark
import CMarkGFM
import qualified Data.AST as A
import Data.Ix
import Data.Range
import Data.Location
import Data.Span
import Data.Source
Expand Down
2 changes: 1 addition & 1 deletion src/Reprinting/Tokenize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import qualified Streaming.Prelude as Streaming

import Data.History
import Data.List (intersperse)
import Data.Range
import Data.Reprinting.Scope (Scope)
import qualified Data.Reprinting.Scope as Scope
import Data.Reprinting.Token as Token
import Data.Reprinting.Operator as Operator
import Data.Source
import Data.Term
import Source.Range

-- | The 'Tokenizer' monad represents a context in which 'Control'
-- tokens and 'Element' tokens can be sent to some downstream
Expand Down
2 changes: 1 addition & 1 deletion src/Tags/Taggable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import Data.Abstract.Name
import Data.Blob
import Data.Language
import Data.Location
import Data.Range
import Data.Term
import Data.Text hiding (empty)
import Source.Range

import Streaming hiding (Sum)
import Streaming.Prelude (yield)
Expand Down
2 changes: 1 addition & 1 deletion test/Assigning/Assignment/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import Assigning.Assignment
import Data.AST
import Data.Bifunctor (first)
import Data.Ix
import Data.Range
import Data.Semigroup ((<>))
import Data.Source
import Data.Span
import Data.Term
import Data.Text as T (Text, length, words)
import Data.Text.Encoding (encodeUtf8)
import GHC.Stack (getCallStack)
import Source.Range
import Prelude hiding (words)
import Test.Hspec
import TreeSitter.Language (Symbol (..), SymbolType (..))
Expand Down
2 changes: 1 addition & 1 deletion test/Data/Functor/Listable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Data.Functor.Both
import qualified Data.Language as Language
import Data.List.NonEmpty
import Data.Patch
import Data.Range
import Data.Location
import Data.Semigroup.App
import Data.Span
Expand All @@ -47,6 +46,7 @@ import Data.Text as T (Text, pack)
import Data.These
import Data.Sum
import Diffing.Algorithm.RWS
import Source.Range
import Test.LeanCheck

type Tier a = [a]
Expand Down
11 changes: 0 additions & 11 deletions test/Data/Range/Spec.hs

This file was deleted.

2 changes: 1 addition & 1 deletion test/Data/Source/Spec.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Data.Source.Spec (spec, testTree) where

import Data.Range
import Data.Source
import Data.Span
import qualified Data.Text as Text
import Source.Range

import Test.Hspec

Expand Down
2 changes: 0 additions & 2 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import qualified Data.Abstract.Path.Spec
import qualified Data.Functor.Classes.Generic.Spec
import qualified Data.Graph.Spec
import qualified Data.Language.Spec
import qualified Data.Range.Spec
import qualified Data.Scientific.Spec
import qualified Data.Semigroup.App.Spec
import qualified Data.Source.Spec
Expand Down Expand Up @@ -81,7 +80,6 @@ legacySpecs = parallel $ do
describe "Data.Abstract.Path" Data.Abstract.Path.Spec.spec
describe "Data.Abstract.Name" Data.Abstract.Name.Spec.spec
describe "Data.Functor.Classes.Generic" Data.Functor.Classes.Generic.Spec.spec
describe "Data.Range" Data.Range.Spec.spec
describe "Data.Semigroup.App" Data.Semigroup.App.Spec.spec
describe "Data.Source" Data.Source.Spec.spec
describe "Data.Term" Data.Term.Spec.spec
Expand Down
2 changes: 1 addition & 1 deletion test/SpecHelpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import Data.Foldable (toList)
import Data.Functor.Listable as X
import Data.Language as X
import Data.List.NonEmpty as X (NonEmpty(..))
import Data.Range as X
import Data.Semilattice.Lower as X
import Data.Source as X
import Data.Span as X hiding (HasSpan(..))
Expand All @@ -55,6 +54,7 @@ import Parsing.Parser as X
import Semantic.Task as X
import Semantic.Util as X
import Semantic.Graph (runHeap, runScopeGraph)
import Source.Range as X
import System.FilePath as X
import Debug.Trace as X (traceShowM, traceM)

Expand Down
0