8000 Merge branch 'master' into semantic-python · github/semantic@9ea288a · 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.

Commit 9ea288a

Browse files
authored
Merge branch 'master' into semantic-python
2 parents cf8b344 + 9d1c024 commit 9ea288a

File tree

51 files changed

+530
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+530
-481
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
test/fixtures linguist-vendored
33
test/repos linguist-vendored
44
vendor linguist-vendored
5+
*.protobuf.bin binary

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
99

10+
We're happy to accept code and documentation contributions, as well as issues suggesting new features, asking questions about how things work, or generally about what we're trying to accomplish! However, we are not opening up the code review process to the public. PRs should _only_ be reviewed by one of the project maintainers. Therefore, we ask that you refrain from leaving approvals or change requests on in-progress pull requests, as spurious reviews make it difficult to discern which patches are truly ready for integration.
11+
1012
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE.md).
1113

1214
Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
@@ -28,6 +30,8 @@ Here are a few things you can do that will increase the likelihood of your pull
2830
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
2931
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
3032

33+
Unless you are a member of the Semantic team or a code owner, we ask that you refrain from leaving approvals or change requests on in-progress pull requests, as spurious reviews make it difficult to discern which patches are truly ready for integration.
34+
3135
Please be aware that contributions to Semantic may multiple cycles of code review—we are grateful for all community involvement, but because Semantic powers real systems, we must maintain a high standard of code quality. For reasons of compatibility with production uses of Semantic within GitHub, we may also reject or require modifications to changes that would affect these systems. We may also reject patches that don't fit with our vision of the project; should this be the case, we will be clear about our rationale.
3236

3337
## Resources

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,20 @@ Available options:
9696

9797
## Development
9898

99+
`semantic` requires at least GHC 8.6.4 and Cabal 2.4. We strongly recommend using [`ghcup`][ghcup] to sandbox GHC versions, as GHC packages installed through your OS's package manager may not install statically-linked versions of the GHC boot libraries.
100+
99101
We use `cabal's` [Nix-style local builds][nix] for development. To get started quickly:
100102

101103
```bash
102104
git clone git@github.com:github/semantic.git
103105
cd semantic
104-
git submodule sync --recursive && git submodule update --init --recursive --force
105-
cabal new-update
106+
script/bootstrap
106107
cabal new-build
107108
cabal new-test
108109
cabal new-run semantic -- --help
109110
```
110111

111-
`semantic` requires at least GHC 8.6.4 and Cabal 2.4. We recommend using [`ghcup`][ghcup] to sandbox GHC versions. `stack` as a build tool is not officially supported; there is an unofficial [`stack.yaml`](https://gist.github.com/jkachmar/f200caee83280f1f25e9cfa2dd2b16bb) available, though we cannot make guarantees as to its stability.
112+
`stack` as a build tool is not officially supported; there is an unofficial [`stack.yaml`](https://gist.github.com/jkachmar/f200caee83280f1f25e9cfa2dd2b16bb) available, though we cannot make guarantees as to its stability.
112113

113114
[nix]: https://www.haskell.org/cabal/users-guide/nix-local-build-overview.html
114115
[stackage]: https://stackage.org

script/bootstrap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
git submodule sync --recursive && git submodule update --init --recursive --force
4+
cabal new-update

semantic.cabal

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ common dependencies
5959
, fused-effects-exceptions ^>= 0.1.1.0
6060
, hashable ^>= 1.2.7.0
6161
, tree-sitter ^>= 0.1.0.0
62-
, machines ^>= 0.6.4
6362
, mtl ^>= 2.2.2
6463
, network ^>= 2.8.0.0
6564
, process ^>= 1.6.3.0
6665
, recursion-schemes ^>= 5.1
6766
, scientific ^>= 0.3.6.2
6867
, safe-exceptions ^>= 0.1.7.0
6968
, semilattices ^>= 0.0.0.3
69+
, shelly >= 1.5 && <2
70+
, streaming ^>= 0.2.2.0
7071
, text ^>= 1.2.3.1
7172
, these >= 0.7 && <1
7273
, unix ^>= 2.7.2.2
@@ -273,6 +274,7 @@ library
273274
-- Serialization
274275
, Serializing.Format
275276
, Serializing.SExpression
277+
, Serializing.SExpression.Precise
276278
, Tags.Taggable
277279
, Tags.Tagging
278280
-- Custom Prelude
@@ -309,8 +311,6 @@ library
309311
, profunctors ^>= 5.3
310312
, reducers ^>= 3.12.3
311313
, semigroupoids ^>= 5.3.2
312-
, servant ^>= 0.15
313-
, shelly >= 1.5 && <2
314314
, split ^>= 0.2.3.3
315315
, stm-chans ^>= 3.0.0.4
316316
, template-haskell ^>= 2.14
@@ -396,6 +396,7 @@ test-suite test
10000
396396
, tasty-golden ^>= 2.3.2
397397
, tasty-hedgehog ^>= 1.0.0.1
398398
, tasty-hspec ^>= 1.1.5.1
399+
, tasty-hunit ^>= 0.10.0.2
399400
, HUnit ^>= 1.6.0.0
400401
, leancheck >= 0.8 && <1
401402
, temporary ^>= 1.3

src/Data/Blob.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Data.Blob
55
, Blob(..)
66
, Blobs(..)
77
, blobLanguage
8+
, NoLanguageForBlob (..)
89
, blobPath
910
, makeBlob
1011
, decodeBlobs

src/Data/Handle.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE GADTs #-}
1+
{-# LANGUAGE DeriveAnyClass, GADTs #-}
22

33
module Data.Handle
44
( Handle (..)
@@ -11,14 +11,15 @@ module Data.Handle
1111
, readBlobPairsFromHandle
1212
, readFromHandle
1313
, openFileForReading
14+
, InvalidJSONException (..)
1415
) where
1516

1617
import Prologue
1718

19+
import Control.Exception (throw)
1820
import Data.Aeson
1921
import qualified Data.ByteString.Lazy as BL
2022
import qualified Data.ByteString.Lazy.Char8 as BLC
21-
import System.Exit
2223
import qualified System.IO as IO
2324

2425
import Data.Blob
@@ -58,9 +59,14 @@ readPathsFromHandle (ReadHandle h) = liftIO $ fmap BLC.unpack . BLC.lines <$> BL
5859
readBlobPairsFromHandle :: MonadIO m => Handle 'IO.ReadMode -> m [BlobPair]
5960
readBlobPairsFromHandle = fmap blobs <$> readFromHandle
6061

62+
newtype InvalidJSONException = InvalidJSONException String
63+
deriving (Eq, Show, Exception)
64+
65+
-- | Read JSON-encoded data from a 'Handle'. Throws
66+
-- 'InvalidJSONException' on parse failure.
6167
readFromHandle :: (FromJSON a, MonadIO m) => Handle 'IO.ReadMode -> m a
6268
readFromHandle (ReadHandle h) = do
6369
input <- liftIO $ BL.hGetContents h
6470
case eitherDecode input of
65-
Left e -> liftIO (die (e <> ". Invalid input on " <> show h <> ", expecting JSON"))
71+
Left e -> throw (InvalidJSONException e)
6672
Right d -> pure d

src/Data/Language.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ languageForType mediaType = case mediaType of
108108
".rb" -> Ruby
109109
".go" -> Go
110110
".js" -> JavaScript
111+
".mjs" -> JavaScript
111112
".ts" -> TypeScript
112113
".tsx" -> TSX
113114
".jsx" -> JSX
@@ -120,7 +121,7 @@ extensionsForLanguage :: Language -> [String]
120121
extensionsForLanguage language = case language of
121122
Go -> [".go"]
122123
Haskell -> [".hs"]
123-
JavaScript -> [".js"]
124+
JavaScript -> [".js", ".mjs"]
124125
PHP -> [".php"]
125126
Python -> [".py"]
126127
Ruby -> [".rb"]
@@ -134,10 +135,10 @@ languageForFilePath :: FilePath -> Language
134135
languageForFilePath = languageForType . takeExtension
135136

136137
supportedExts :: [String]
137-
supportedExts = [".go", ".py", ".rb", ".js", ".ts"]
138+
supportedExts = [".go", ".py", ".rb", ".js", ".mjs", ".ts", ".php", ".phpt"]
138139

139140
codeNavLanguages :: [Language]
140-
codeNavLanguages = [Go, Ruby, Python, JavaScript, TypeScript]
141+
codeNavLanguages = [Go, Ruby, Python, JavaScript, PHP, TypeScript]
141142

142143
pathIsMinified :: FilePath -> Bool
143144
pathIsMinified = isExtensionOf ".min.js"

src/Data/Reprinting/Fragment.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ module Data.Reprinting.Fragment
77
, defer
88
) where
99

10-
import Data.Machine
1110
import Data.Text (Text)
11+
import Streaming
12+
import Streaming.Prelude (yield)
1213

1314
import Data.Reprinting.Scope
1415
import Data.Reprinting.Token
@@ -25,13 +26,13 @@ data Fragment
2526
deriving (Eq, Show)
2627

2728
-- | Copy along some original, un-refactored 'Text'.
28-
copy :: Text -> Plan k Fragment ()
29+
copy :: Monad m => Text -> Stream (Of Fragment) m ()
2930
copy = yield . Verbatim
3031

3132
-- | Insert some new 'Text'.
32-
insert :: Element -> [Scope] -> Text -> Plan k Fragment ()
33+
insert :: Monad m => Element -> [Scope] -> Text -> Stream (Of Fragment) m ()
3334
insert el c = yield . New el c
3435

3536
-- | Defer processing an element to a later stage.
36-
defer :: Element -> [Scope] -> Plan k Fragment ()
37+
defer :: Monad m => Element -> [Scope] -> Stream (Of Fragment) m ()
3738
defer el = yield . Defer el

src/Data/Reprinting/Splice.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ module Data.Reprinting.Splice
1818

1919
import Prologue hiding (Element)
2020

21-
import Data.Machine
21+
import Streaming
22+
import Streaming.Prelude (yield)
2223

2324
import Data.Reprinting.Fragment
2425

@@ -29,29 +30,29 @@ data Splice
2930
deriving (Eq, Show)
3031

3132
-- | Emit some 'Text' as a 'Splice'.
32-
emit :: Text -> Plan k Splice ()
33+
emit :: Monad m => Text -> Stream (Of Splice) m ()
3334
emit = yield . Emit
3435

3536
-- | Emit the provided 'Text' if the given predicate is true.
36-
emitIf :: Bool -> Text -> Plan k Splice ()
37+
emitIf :: Monad m => Bool -> Text -> Stream (Of Splice) m ()
3738
emitIf p = when p . emit
3839

3940
-- | Construct a layout 'Splice'.
40-
layout :: Whitespace -> Plan k Splice ()
41+
layout :: Monad m => Whitespace -> Stream (Of Splice) m ()
4142
layout = yield . Layout
4243

4344
-- | @indent w n@ emits @w@ 'Spaces' @n@ times.
44-
indent :: Int -> Int -> Plan k Splice ()
45+
indent :: Monad m => Int -> Int -> Stream (Of Splice) m ()
4546
indent width times
4647
| times > 0 = replicateM_ times (layout (Indent width Spaces))
4748
| otherwise = pure ()
4849

4950
-- | Construct multiple layouts.
50-
layouts :: [Whitespace] -> Plan k Splice ()
51+
layouts :: Monad m => [Whitespace] -> Stream (Of Splice) m ()
5152
layouts = traverse_ (yield . Layout)
5253

5354
-- | Single space.
54-
space :: Plan k Splice ()
55+
space :: Monad m => Stream (Of Splice) m ()
5556
space = yield (Layout Space)
5657

5758
-- | Indentation, spacing, and other whitespace.

0 commit comments

Comments
 (0)
0