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

Commit ceb4791

Browse files
authored
Merge branch 'master' into gen-x
2 parents 02b9558 + 9199555 commit ceb4791

File tree

15 files changed

+118
-81
lines changed

15 files changed

+118
-81
lines changed

.ghci

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
:set -package pretty-show -package hscolour
33

44
-- See docs/💡ProTip!.md
5-
:undef pretty
6-
:def pretty \ _ -> return ":set -interactive-print Semantic.Util.Pretty.prettyShow"
7-
8-
-- See docs/💡ProTip!.md
9-
:undef no-pretty
10-
:def no-pretty \_ -> return ":set -interactive-print System.IO.print"
11-
12-
-- See docs/💡ProTip!.md
13-
:undef r
14-
:def r \_ -> return (unlines [":reload", ":pretty"])
5+
:def! pretty \ _ -> return ":set -interactive-print Semantic.Util.Pretty.prettyShow"
6+
:def! no-pretty \_ -> return ":set -interactive-print System.IO.print"
7+
:def! r \_ -> return (unlines [":reload", ":pretty"])
158

169
-- See docs/💡ProTip!.md for documentation & examples.
1710
:{
@@ -29,8 +22,7 @@ assignmentExample lang = case lang of
2922
_ -> mk "" ""
3023
where mk fileExtension parser = putStrLn ("example: fmap (() <$) . runTask . parse " ++ parser ++ "Parser =<< Semantic.Util.blob \"example." ++ fileExtension ++ "\"") >> return ("import Parsing.Parser\nimport Semantic.Task\nimport Semantic.Util")
3124
:}
32-
:undef assignment
33-
:def assignment assignmentExample
25+
:def! assignment assignmentExample
3426

3527
-- Enable breaking on errors for code written in the repl.
3628
:seti -fbreak-on-error

script/publish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
set -e
77
cd $(dirname "$0")/..
88

9-
VERSION="0.6.0"
9+
VERSION="0.7.0.0"
1010
BUILD_SHA=$(git rev-parse HEAD 2>/dev/null)
1111
DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic
1212

semantic.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 2.4
22

33
name: semantic
4-
version: 0.6.0.0
4+
version: 0.7.0.0
55
synopsis: Framework and executable for analyzing and diffing untrusted code.
66
description: Semantic is a library for parsing, analyzing, and comparing source code across many languages.
77
homepage: http://github.com/github/semantic#readme

src/Data/Abstract/Address/Monovariant.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Data.Abstract.Name
99
import qualified Data.Set as Set
1010
import Prologue
1111

12-
-- | 'Monovariant' models using one address for a particular name. It trackes the set of values that a particular address takes and uses it's name to lookup in the store and only allocation if new.
12+
-- | 'Monovariant' models using one address for a particular name. It tracks the set of values that a particular address takes and uses it's name to lookup in the store and only allocation if new.
1313
newtype Monovariant = Monovariant { unMonovariant :: Name }
1414
deriving (Eq, Ord)
1515

src/Data/Abstract/ScopeGraph.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ instance Ord AccessControl where
7676
(<=) Private _ = True
7777
(<=) _ Private = False
7878

79-
-- | Protected AccessControl is inbetween Private and Public in the order specification.
79+
-- | Protected AccessControl is in between Private and Public in the order specification.
8080
-- Protected AccessControl "on the left" has access to Protected or Public AccessControls "on the right".
8181
(<=) Protected Public = True
8282
(<=) Protected Protected = True

src/Data/Blob/IO.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ readBlobsFromDir path = liftIO . fmap catMaybes $
3939
findFilesInDir path supportedExts mempty >>= Async.mapConcurrently (readBlobFromFile . fileForPath)
4040

4141
-- | Read all blobs from the Git repo with Language.supportedExts
42-
readBlobsFromGitRepo :: MonadIO m => FilePath -> Git.OID -> [FilePath] -> m [Blob]
43-
readBlobsFromGitRepo path oid excludePaths = liftIO . fmap catMaybes $
42+
readBlobsFromGitRepo :: MonadIO m => FilePath -> Git.OID -> [FilePath] -> [FilePath] -> m [Blob]
43+
readBlobsFromGitRepo path oid excludePaths includePaths = liftIO . fmap catMaybes $
4444
Git.lsTree path oid >>= Async.mapConcurrently (blobFromTreeEntry path)
4545
where
4646
-- Only read tree entries that are normal mode, non-minified blobs in a language we can parse.
@@ -50,6 +50,7 @@ readBlobsFromGitRepo path oid excludePaths = liftIO . fmap catMaybes $
5050
, lang `elem` codeNavLanguages
5151
, not (pathIsMinified path)
5252
, path `notElem` excludePaths
53+
, null includePaths || path `elem` includePaths
5354
= Just . sourceBlob' path lang oid . fromText <$> Git.catFile gitDir oid
5455
blobFromTreeEntry _ _ = pure Nothing
5556

src/Language/Go/Assignment.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,6 @@ manyTermsTill step end = manyTill (step <|> comment) end
661661
manyTerm :: Assignment Term -> Assignment [Term]
662662
manyTerm = many . term
663663

664-
-- | Match a term and contextualize any comments preceeding or proceeding the term.
664+
-- | Match a term and contextualize any comments preceding or proceeding the term.
665665
term :: Assignment Term -> Assignment Term
666666
term term' = contextualize comment term' <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm)

src/Rendering/Graph.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ diffStyle name = (defaultStyle (fromString . show . diffVertexId))
5151
{ graphName = fromString (quote name)
5252
, vertexAttributes = vertexAttributes }
5353
where quote a = "\"" <> a <> "\""
54-
vertexAttributes (DiffTreeVertex _ (Just (Deleted DeletedTerm{..}))) = [ "label" := fromString (T.unpack term), "color" := "red" ]
55-
vertexAttributes (DiffTreeVertex _ (Just (Inserted InsertedTerm{..}))) = [ "label" := fromString (T.unpack term), "color" := "green" ]
56-
vertexAttributes (DiffTreeVertex _ (Just (Replaced ReplacedTerm{..}))) = [ "label" := "Replacement", "color" := "orange", "style" := "dashed" ]
57-
vertexAttributes (DiffTreeVertex _ (Just (Merged MergedTerm{..}))) = [ "label" := fromString (T.unpack term) ]
54+
vertexAttributes (DiffTreeVertex _ (Just (Deleted (Just DeletedTerm{..})))) = [ "label" := fromString (T.unpack term), "color" := "red" ]
55+
vertexAttributes (DiffTreeVertex _ (Just (Inserted (Just InsertedTerm{..})))) = [ "label" := fromString (T.unpack term), "color" := "green" ]
56+
vertexAttributes (DiffTreeVertex _ (Just (Replaced (Just ReplacedTerm{..})))) = [ "label" := "Replacement", "color" := "orange", "style" := "dashed" ]
57+
vertexAttributes (DiffTreeVertex _ (Just (Merged (Just MergedTerm{..})))) = [ "label" := fromString (T.unpack term) ]
5858
vertexAttributes _ = []
5959

6060
class ToTreeGraph vertex t | t -> vertex where
@@ -82,16 +82,16 @@ instance (ConstructorName syntax, Foldable syntax) =>
8282
instance (ConstructorName syntax, Foldable syntax) =>
8383
ToTreeGraph DiffTreeVertex (DiffF syntax Location Location) where
8484
toTreeGraph d = case d of
85-
Merge t@(In (a1, a2) syntax) -> diffAlgebra t (Merged (MergedTerm (T.pack (constructorName syntax)) (ann a1) (ann a2)))
86-
Patch (Delete t1@(In a1 syntax)) -> diffAlgebra t1 (Deleted (DeletedTerm (T.pack (constructorName syntax)) (ann a1)))
87-
Patch (Insert t2@(In a2 syntax)) -> diffAlgebra t2 (Inserted (InsertedTerm (T.pack (constructorName syntax)) (ann a2)))
85+
Merge t@(In (a1, a2) syntax) -> diffAlgebra t (Merged (Just (MergedTerm (T.pack (constructorName syntax)) (ann a1) (ann a2))))
86+
Patch (Delete t1@(In a1 syntax)) -> diffAlgebra t1 (Deleted (Just (DeletedTerm (T.pack (constructorName syntax)) (ann a1))))
87+
Patch (Insert t2@(In a2 syntax)) -> diffAlgebra t2 (Inserted (Just (InsertedTerm (T.pack (constructorName syntax)) (ann a2))))
8888
Patch (Replace t1@(In a1 syntax1) t2@(In a2 syntax2)) -> do
8989
i <- fresh
9090
parent <- ask
9191
let (beforeName, beforeSpan) = (T.pack (constructorName syntax1), ann a1)
9292
let (afterName, afterSpan) = (T.pack (constructorName syntax2), ann a2)
93-
let replace = vertex (DiffTreeVertex (fromIntegral i) (Just (Replaced (ReplacedTerm beforeName beforeSpan afterName afterSpan))))
94-
graph <- local (const replace) (overlay <$> diffAlgebra t1 (Deleted (DeletedTerm beforeName beforeSpan))) <*> diffAlgebra t2 (Inserted (InsertedTerm afterName afterSpan))
93+
let replace = vertex (DiffTreeVertex (fromIntegral i) (Just (Replaced (Just (ReplacedTerm beforeName beforeSpan afterName afterSpan)))))
94+
graph <- local (const replace) (overlay <$> diffAlgebra t1 (Deleted (Just (DeletedTerm beforeName beforeSpan))) <*> diffAlgebra t2 (Inserted (Just (InsertedTerm afterName afterSpan))))
9595
pure (parent `connect` replace `overlay` graph)
9696
where
9797
ann a = converting #? locationSpan a

src/Rendering/TOC.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ newtype DedupeKey = DedupeKey (T.Text, T.Text) deriving (Eq, Ord)
9696
-- different behaviors:
9797
-- 1. Identical entries are in the list.
9898
-- Action: take the first one, drop all subsequent.
99-
-- 2. Two similar entries (defined by a case insensitive comparision of their
99+
-- 2. Two similar entries (defined by a case insensitive comparison of their
100100
-- identifiers) are in the list.
101101
-- Action: Combine them into a single Replaced entry.
102102
dedupe :: [Entry Declaration] -> [Entry Declaration]

src/Semantic/CLI.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ parseCommand = command "parse" (info parseArgumentsParser (progDesc "Generate pa
114114
<$> option str (long "gitDir" <> help "A .git directory to read from")
115115
<*> option shaReader (long "sha" <> help "The commit SHA1 to read from")
116116
<*> ( ExcludePaths <$> many (option str (long "exclude" <> short 'x' <> help "Paths to exclude"))
117-
<|> ExcludeFromHandle <$> flag' stdin (long "exclude-stdin" <> help "Exclude paths given to stdin"))
117+
<|> ExcludeFromHandle <$> flag' stdin (long "exclude-stdin" <> help "Exclude paths given to stdin")
118+
<|> IncludePaths <$> many (option str (long "only" <> help "Only include the specified paths"))
119+
<|> IncludePathsFromHandle <$> flag' stdin (long "only-stdin" <> help "Include only the paths given to stdin"))
118120
<|> FilesFromPaths <$> some (argument filePathReader (metavar "FILES..."))
119121
<|> pure (FilesFromHandle stdin)
120122
pure $ Task.readBlobs filesOrStdin >>= renderer
@@ -131,7 +133,9 @@ tsParseCommand = command "ts-parse" (info tsParseArgumentsParser (progDesc "Gene
131133
<$> option str (long "gitDir" <> help "A .git directory to read from")
132134
<*> option shaReader (long "sha" <> help "The commit SHA1 to read from")
133135
<*> ( ExcludePaths <$> many (option str (long "exclude" <> short 'x' <> help "Paths to exclude"))
134-
<|> ExcludeFromHandle <$> flag' stdin (long "exclude-stdin" <> help "Exclude paths given to stdin"))
136+
<|> ExcludeFromHandle <$> flag' stdin (long "exclude-stdin" <> help "Exclude paths given to stdin")
137+
<|> IncludePaths <$> many (option str (long "only" <> help "Only include the specified paths"))
138+
<|> IncludePathsFromHandle <$> flag' stdin (long "only-stdin" <> help "Include only the paths given to stdin"))
135139
<|> FilesFromPaths <$> some (argument filePathReader (metavar "FILES..."))
136140
<|> pure (FilesFromHandle stdin)
137141
pure $ Task.readBlobs filesOrStdin >>= AST.runASTParse format

0 commit comments

Comments
 (0)