From cd5fe18219eeb13897737f19f35d9024f832ba62 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Tue, 30 Jun 2020 11:17:47 -0400 Subject: [PATCH] Pin to the tree-sitter-ql used in the latest Hackage package. --- WORKSPACE | 16 +++++--- semantic-codeql/src/Language/CodeQL/Tags.hs | 45 +++++++++++++++++---- semantic/test/Semantic/CLI/Spec.hs | 10 ++--- 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 850068100..07dc9386d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -199,12 +199,6 @@ tree_sitter_node_types_archive( version = "0.16.2", ) -tree_sitter_node_types_archive( - name = "tree-sitter-ql", - sha256 = "b43dca6676dd95eb817bf5e8933183591f48169f6466382463f199ba6132b5c5", - version = "1.1.0", -) - # Download lingo (which has its own Bazel build instructions). git_repository( @@ -226,3 +220,13 @@ exports_files(["src/node-types.json"]) remote = "https://github.com/tree-sitter/tree-sitter-ruby.git", shallow_since = "1576688803 -0800", ) + +new_git_repository( + name = "tree-sitter-ql", + build_file_content = """ +exports_files(["src/node-types.json"]) +""", + commit = "c0d674abed8836bb5a4770f547343ef100f88c24", + remote = "https://github.com/tree-sitter/tree-sitter-ql.git", + shallow_since = "1585868745 -0700", +) diff --git a/semantic-codeql/src/Language/CodeQL/Tags.hs b/semantic-codeql/src/Language/CodeQL/Tags.hs index 779cd94b5..490ed49a2 100644 --- a/semantic-codeql/src/Language/CodeQL/Tags.hs +++ b/semantic-codeql/src/Language/CodeQL/Tags.hs @@ -117,6 +117,14 @@ instance ToTags CodeQL.DatatypeBranch where } = yieldTag text P.CLASS P.DEFINITION ann byteRange >> gtags t tags _ = pure () +instance ToTags CodeQL.ClasslessPredicateCall where + tags + CodeQL.ClasslessPredicateCall + { extraChildren + } = for_ extraChildren $ \x -> case x of + EPrj t@CodeQL.AritylessPredicateExpr {} -> tags t + _ -> pure () + instance ToTags CodeQL.QualifiedRhs where tags t@CodeQL.QualifiedRhs @@ -142,54 +150,74 @@ instance ToTags CodeQL.Aggregate instance ToTags CodeQL.AnnotArg instance ToTags CodeQL.Annotation instance ToTags CodeQL.AnnotName +instance ToTags CodeQL.Any +instance ToTags CodeQL.As +instance ToTags CodeQL.Asc instance ToTags CodeQL.AsExpr instance ToTags CodeQL.AsExprs +instance ToTags CodeQL.Avg instance ToTags CodeQL.Body instance ToTags CodeQL.Bool -instance ToTags CodeQL.CallBody -instance ToTags CodeQL.CallOrUnqualAggExpr +instance ToTags CodeQL.Boolean instance ToTags CodeQL.Charpred instance ToTags CodeQL.ClassMember instance ToTags CodeQL.ClassName instance ToTags CodeQL.Closure instance ToTags CodeQL.Compop instance ToTags CodeQL.CompTerm +instance ToTags CodeQL.Concat instance ToTags CodeQL.Conjunction +instance ToTags CodeQL.Count +instance ToTags CodeQL.Class instance ToTags CodeQL.DatatypeBranches +instance ToTags CodeQL.Date instance ToTags CodeQL.Dbtype +instance ToTags CodeQL.Desc instance ToTags CodeQL.Direction instance ToTags CodeQL.Disjunction instance ToTags CodeQL.Empty instance ToTags CodeQL.Eq +instance ToTags CodeQL.Exists instance ToTags CodeQL.ExprAggregateBody +instance ToTags CodeQL.Extends instance ToTags CodeQL.False instance ToTags CodeQL.Field instance ToTags CodeQL.Float +instance ToTags CodeQL.Forall +instance ToTags CodeQL.Forex instance ToTags CodeQL.FullAggregateBody instance ToTags CodeQL.Ge instance ToTags CodeQL.Gt instance ToTags CodeQL.HigherOrderTerm instance ToTags CodeQL.IfTerm instance ToTags CodeQL.Implication -instance ToTags CodeQL.ImportDirective +instance ToTags CodeQL.Import instance ToTags CodeQL.ImportModuleExpr +instance ToTags CodeQL.Imprt +instance ToTags CodeQL.In instance ToTags CodeQL.InExpr instance ToTags CodeQL.InstanceOf +instance ToTags CodeQL.Instanceof instance ToTags CodeQL.Integer instance ToTags CodeQL.Le instance ToTags CodeQL.Literal instance ToTags CodeQL.LiteralId instance ToTags CodeQL.Lt +instance ToTags CodeQL.Max instance ToTags CodeQL.Mod instance ToTags CodeQL.ModuleAliasBody instance ToTags CodeQL.ModuleExpr instance ToTags CodeQL.ModuleMember instance ToTags CodeQL.ModuleName +instance ToTags CodeQL.Min instance ToTags CodeQL.Minus instance ToTags CodeQL.MulExpr instance ToTags CodeQL.Mulop instance ToTags CodeQL.Ne instance ToTags CodeQL.Negation +instance ToTags CodeQL.Newtype +instance ToTags CodeQL.None +instance ToTags CodeQL.Not instance ToTags CodeQL.OrderBy instance ToTags CodeQL.OrderBys instance ToTags CodeQL.ParExpr @@ -199,7 +227,6 @@ instance ToTags CodeQL.PredicateAliasBody instance ToTags CodeQL.PredicateExpr instance ToTags CodeQL.PredicateName instance ToTags CodeQL.PrefixCast -instance ToTags CodeQL.PrimitiveType instance ToTags CodeQL.Ql instance ToTags CodeQL.Qldoc instance ToTags CodeQL.QualifiedExpr @@ -207,25 +234,29 @@ instance ToTags CodeQL.QualModuleExpr instance ToTags CodeQL.Quantified instance ToTags CodeQL.Quantifier instance ToTags CodeQL.Range +instance ToTags CodeQL.Rank instance ToTags CodeQL.Result +instance ToTags CodeQL.ReturnType instance ToTags CodeQL.Select -instance ToTags CodeQL.SetLiteral instance ToTags CodeQL.SimpleId instance ToTags CodeQL.Slash instance ToTags CodeQL.SpecialCall instance ToTags CodeQL.SpecialId instance ToTags CodeQL.Star +instance ToTags CodeQL.Strictconcat +instance ToTags CodeQL.Strictcount +instance ToTags CodeQL.Strictsum instance ToTags CodeQL.String +instance ToTags CodeQL.Sum instance ToTags CodeQL.Super instance ToTags CodeQL.SuperRef instance ToTags CodeQL.This instance ToTags CodeQL.True instance ToTags CodeQL.TypeAliasBody -instance ToTags CodeQL.TypeUnionBody +instance ToTags CodeQL.TypeLiteral instance ToTags CodeQL.UnaryExpr instance ToTags CodeQL.Underscore instance ToTags CodeQL.Unop -instance ToTags CodeQL.UnqualAggBody instance ToTags CodeQL.VarDecl instance ToTags CodeQL.Variable instance ToTags CodeQL.VarName diff --git a/semantic/test/Semantic/CLI/Spec.hs b/semantic/test/Semantic/CLI/Spec.hs index e45cbe488..57f390334 100644 --- a/semantic/test/Semantic/CLI/Spec.hs +++ b/semantic/test/Semantic/CLI/Spec.hs @@ -45,7 +45,7 @@ renderDiff ref new = unsafePerformIO $ do {-# NOINLINE renderDiff #-} -testForParseFixture :: (String, [Blob] -> ParseC TaskC Builder, [File Language], Path.RelFile) -> TestTree +testForParseFixture :: (String, [Blob] -> ParseC TaskC Builder, [File Language], Path.AbsRelFile) -> TestTree testForParseFixture (format, runParse, files, expected) = goldenVsStringDiff ("parse fixture renders to " <> format) @@ -53,11 +53,11 @@ testForParseFixture (format, runParse, files, expected) = (Path.toString expected) (fmap toLazyByteString . runTaskOrDie $ readBlobs (FilesFromPaths files) >>= runParse) -parseFixtures :: [(String, [Blob] -> ParseC TaskC Builder, [File Language], Path.RelFile)] +parseFixtures :: [(String, [Blob] -> ParseC TaskC Builder, [File Language], Path.AbsRelFile)] parseFixtures = - [ ("s-expression", run . parseTermBuilder TermSExpression, path, Path.relFile "semantic/test/fixtures/ruby/corpus/and-or.parseA.txt") - , ("symbols", run . parseSymbolsBuilder Serializing.Format.JSON, path'', Path.relFile "semantic/test/fixtures/cli/parse-tree.symbols.json") - , ("protobuf symbols", run . parseSymbolsBuilder Serializing.Format.Proto, path'', Path.relFile "semantic/test/fixtures/cli/parse-tree.symbols.protobuf.bin") + [ ("s-expression", run . parseTermBuilder TermSExpression, path, Path.absRel "semantic/test/fixtures/ruby/corpus/and-or.parseA.txt") + , ("symbols", run . parseSymbolsBuilder Serializing.Format.JSON, path'', Path.absRel "semantic/test/fixtures/cli/parse-tree.symbols.json") + , ("protobuf symbols", run . parseSymbolsBuilder Serializing.Format.Proto, path'', Path.absRel "semantic/test/fixtures/cli/parse-tree.symbols.protobuf.bin") ] where path = [File (Path.absRel "semantic/test/fixtures/ruby/corpus/and-or.A.rb") lowerBound Ruby] path'' = [File (Path.absRel "semantic/test/fixtures/ruby/corpus/method-declaration.A.rb") lowerBound Ruby]