From bd73cd0e1d1b9bcad69bd42aa1ac30769f0d4c50 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 27 Sep 2019 14:02:49 -0400 Subject: [PATCH] Bump to the latest tree-sitter* packages. --- semantic-python/semantic-python.cabal | 5 +++-- semantic-python/src/Language/Python/Core.hs | 12 ++++++------ semantic-tags/semantic-tags.cabal | 4 ++-- semantic.cabal | 20 ++++++++++---------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/semantic-python/semantic-python.cabal b/semantic-python/semantic-python.cabal index 83d9bf52c..a5cf77a90 100644 --- a/semantic-python/semantic-python.cabal +++ b/semantic-python/semantic-python.cabal @@ -23,9 +23,10 @@ common haskell build-depends: base ^>=4.12 , fused-effects ^>= 0.5 , semantic-core ^>= 0.0 + , semantic-source ^>= 0.0 , text ^>= 1.2.3 - , tree-sitter == 0.3.0.0 - , tree-sitter-python == 0.4.0.0 + , tree-sitter ^>= 0.4 + , tree-sitter-python ^>= 0.5 ghc-options: -Weverything diff --git a/semantic-python/src/Language/Python/Core.hs b/semantic-python/src/Language/Python/Core.hs index b259be847..3f7185993 100644 --- a/semantic-python/src/Language/Python/Core.hs +++ b/semantic-python/src/Language/Python/Core.hs @@ -25,9 +25,9 @@ import Data.String (IsString) import Data.Text (Text) import GHC.Generics import GHC.Records +import Source.Span (Span) +import qualified Source.Span as Source import qualified TreeSitter.Python.AST as Py -import TreeSitter.Span (Span) -import qualified TreeSitter.Span as TreeSitter newtype SourcePath = SourcePath { rawPath :: Text } deriving stock (Eq, Show) @@ -90,7 +90,7 @@ locate :: ( HasField "ann" syntax Span ) => syntax -> t a -> m (t a) locate syn item = do fp <- asks @SourcePath rawPath - let locFromTSSpan (TreeSitter.Span (TreeSitter.Pos a b) (TreeSitter.Pos c d)) + let locFromTSSpan (Source.Span (Source.Pos a b) (Source.Pos c d)) = Data.Loc.Loc fp (Data.Loc.Span (Data.Loc.Pos a b) (Data.Loc.Pos c d)) pure (Core.annAt (locFromTSSpan (getField @"ann" syn)) item) @@ -103,7 +103,7 @@ newtype CompileSum py = CompileSum py instance (Generic py, GCompileSum (Rep py)) => Compile (CompileSum py) where compileCC (CompileSum a) cc = gcompileCCSum (from a) cc -deriving via CompileSum (Either l r) instance (Compile l, Compile r) => Compile (Either l r) +deriving via CompileSum ((l :+: r) Span) instance (Compile (l Span), Compile (r Span)) => Compile ((l :+: r) Span) instance Compile (Py.AssertStatement Span) instance Compile (Py.Attribute Span) @@ -198,8 +198,8 @@ instance Compile (Py.Identifier Span) where instance Compile (Py.IfStatement Span) where compileCC it@Py.IfStatement{ condition, consequence, alternative} cc = locate it =<< (if' <$> compile condition <*> compileCC consequence cc <*> foldr clause cc alternative) - where clause (Right Py.ElseClause{ body }) _ = compileCC body cc - clause (Left Py.ElifClause{ condition, consequence }) rest = + where clause (R1 Py.ElseClause{ body }) _ = compileCC body cc + clause (L1 Py.ElifClause{ condition, consequence }) rest = if' <$> compile condition <*> compileCC consequence cc <*> rest diff --git a/semantic-tags/semantic-tags.cabal b/semantic-tags/semantic-tags.cabal index 17a225b2d..3731d929f 100644 --- a/semantic-tags/semantic-tags.cabal +++ b/semantic-tags/semantic-tags.cabal @@ -32,8 +32,8 @@ library , fused-effects ^>= 0.5 , semantic-source ^>= 0.0 , text ^>= 1.2.3.1 - , tree-sitter == 0.3.0.0 - , tree-sitter-python == 0.4.0.0 + , tree-sitter ^>= 0.4 + , tree-sitter-python ^>= 0.5 hs-source-dirs: src default-language: Haskell2010 ghc-options: diff --git a/semantic.cabal b/semantic.cabal index 3d155d339..97f1e46e0 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -56,7 +56,7 @@ common dependencies , fused-effects ^>= 0.5.0.0 , fused-effects-exceptions ^>= 0.2.0.0 , hashable ^>= 1.2.7.0 - , tree-sitter == 0.3.0.0 + , tree-sitter ^>= 0.4 , mtl ^>= 2.2.2 , network ^>= 2.8.0.0 , pathtype ^>= 0.8.1 @@ -310,15 +310,15 @@ library , unliftio-core ^>= 0.1.2.0 , unordered-containers ^>= 0.2.9.0 , vector ^>= 0.12.0.2 - , tree-sitter-go == 0.2.0.0 - , tree-sitter-haskell == 0.2.0.0 - , tree-sitter-json == 0.2.0.0 - , tree-sitter-php == 0.2.0.0 - , tree-sitter-python == 0.4.0.0 - , tree-sitter-ruby == 0.2.0.0 - , tree-sitter-typescript == 0.2.1.0 - , tree-sitter-tsx == 0.2.1.0 - , tree-sitter-java == 0.2.0.0 + , tree-sitter-go ^>= 0.2 + , tree-sitter-haskell ^>= 0.2 + , tree-sitter-json ^>= 0.2 + , tree-sitter-php ^>= 0.2 + , tree-sitter-python ^>= 0.5 + , tree-sitter-ruby ^>= 0.2 + , tree-sitter-typescript ^>= 0.2.1 + , tree-sitter-tsx ^>= 0.2.1 + , tree-sitter-java ^>= 0.2 if flag(release) cpp-options: -DCOMPUTE_GIT_SHA