From edab2a8436e4f197d52d10c4234191738ece4938 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:01:32 -0400 Subject: [PATCH 01/49] Rename the Go module. --- languages/go/go.cabal | 2 +- languages/go/src/{Text/Parser => }/TreeSitter/Go.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename languages/go/src/{Text/Parser => }/TreeSitter/Go.hs (65%) diff --git a/languages/go/go.cabal b/languages/go/go.cabal index 7ccba0bc1..ab5c06604 100644 --- a/languages/go/go.cabal +++ b/languages/go/go.cabal @@ -13,7 +13,7 @@ cabal-version: >=1.10 library hs-source-dirs: src - exposed-modules: Text.Parser.TreeSitter.Go + exposed-modules: TreeSitter.Go build-depends: base >= 4.7 && < 5 , haskell-tree-sitter default-language: Haskell2010 diff --git a/languages/go/src/Text/Parser/TreeSitter/Go.hs b/languages/go/src/TreeSitter/Go.hs similarity index 65% rename from languages/go/src/Text/Parser/TreeSitter/Go.hs rename to languages/go/src/TreeSitter/Go.hs index 0976819d7..91d5e6028 100644 --- a/languages/go/src/Text/Parser/TreeSitter/Go.hs +++ b/languages/go/src/TreeSitter/Go.hs @@ -1,6 +1,6 @@ -module Text.Parser.TreeSitter.Go where +module TreeSitter.Go where -import Text.Parser.TreeSitter +import TreeSitter import Foreign.Ptr foreign import ccall unsafe "vendor/tree-sitter-go/src/parser.c tree_sitter_go" tree_sitter_go :: Ptr Language From 56d3c94b45210df7fa4fdd808e8eb9dae61d9ad8 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:01:38 -0400 Subject: [PATCH 02/49] Rename the JSON module. --- languages/json/json.cabal | 2 +- languages/json/src/{Text/Parser => }/TreeSitter/JSON.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename languages/json/src/{Text/Parser => }/TreeSitter/JSON.hs (66%) diff --git a/languages/json/json.cabal b/languages/json/json.cabal index 0b8e025c3..b19b2cdc0 100644 --- a/languages/json/json.cabal +++ b/languages/json/json.cabal @@ -13,7 +13,7 @@ cabal-version: >=1.10 library hs-source-dirs: src - exposed-modules: Text.Parser.TreeSitter.JSON + exposed-modules: TreeSitter.JSON build-depends: base >= 4.7 && < 5 , haskell-tree-sitter default-language: Haskell2010 diff --git a/languages/json/src/Text/Parser/TreeSitter/JSON.hs b/languages/json/src/TreeSitter/JSON.hs similarity index 66% rename from languages/json/src/Text/Parser/TreeSitter/JSON.hs rename to languages/json/src/TreeSitter/JSON.hs index 92dec946e..e20a770aa 100644 --- a/languages/json/src/Text/Parser/TreeSitter/JSON.hs +++ b/languages/json/src/TreeSitter/JSON.hs @@ -1,6 +1,6 @@ -module Text.Parser.TreeSitter.JSON where +module TreeSitter.JSON where import Foreign.Ptr -import Text.Parser.TreeSitter +import TreeSitter foreign import ccall unsafe "vendor/tree-sitter-json/src/parser.c tree_sitter_json" tree_sitter_json :: Ptr Language From 8eec429ac872408d33ffd92db76c6cf802a6b783 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:01:44 -0400 Subject: [PATCH 03/49] Rename the Python module. --- languages/python/python.cabal | 2 +- languages/python/src/{Text/Parser => }/TreeSitter/Python.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename languages/python/src/{Text/Parser => }/TreeSitter/Python.hs (72%) diff --git a/languages/python/python.cabal b/languages/python/python.cabal index 6a6dc08b1..7fc46cfd5 100644 --- a/languages/python/python.cabal +++ b/languages/python/python.cabal @@ -13,7 +13,7 @@ cabal-version: >=1.10 library hs-source-dirs: src - exposed-modules: Text.Parser.TreeSitter.Python + exposed-modules: TreeSitter.Python build-depends: base >= 4.7 && < 5 , haskell-tree-sitter default-language: Haskell2010 diff --git a/languages/python/src/Text/Parser/TreeSitter/Python.hs b/languages/python/src/TreeSitter/Python.hs similarity index 72% rename from languages/python/src/Text/Parser/TreeSitter/Python.hs rename to languages/python/src/TreeSitter/Python.hs index c5d52140b..3d4f26e67 100644 --- a/languages/python/src/Text/Parser/TreeSitter/Python.hs +++ b/languages/python/src/TreeSitter/Python.hs @@ -1,8 +1,8 @@ -module Text.Parser.TreeSitter.Python +module TreeSitter.Python ( tree_sitter_python ) where import Foreign.Ptr -import Text.Parser.TreeSitter +import TreeSitter foreign import ccall unsafe "vendor/tree-sitter-python/src/parser.c tree_sitter_python" tree_sitter_python :: Ptr Language From ee842366f30cd6305b9ec896b650693d92a7e35b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:01:49 -0400 Subject: [PATCH 04/49] Rename the Ruby module. --- languages/ruby/ruby.cabal | 2 +- languages/ruby/src/{Text/Parser => }/TreeSitter/Ruby.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename languages/ruby/src/{Text/Parser => }/TreeSitter/Ruby.hs (71%) diff --git a/languages/ruby/ruby.cabal b/languages/ruby/ruby.cabal index dc0524572..f0fa77eee 100644 --- a/languages/ruby/ruby.cabal +++ b/languages/ruby/ruby.cabal @@ -13,7 +13,7 @@ cabal-version: >=1.10 library hs-source-dirs: src - exposed-modules: Text.Parser.TreeSitter.Ruby + exposed-modules: TreeSitter.Ruby build-depends: base >= 4.7 && < 5 , haskell-tree-sitter default-language: Haskell2010 diff --git a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs b/languages/ruby/src/TreeSitter/Ruby.hs similarity index 71% rename from languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs rename to languages/ruby/src/TreeSitter/Ruby.hs index 05938f8de..604d2d346 100644 --- a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs +++ b/languages/ruby/src/TreeSitter/Ruby.hs @@ -1,8 +1,8 @@ -module Text.Parser.TreeSitter.Ruby +module TreeSitter.Ruby ( tree_sitter_ruby ) where import Foreign.Ptr -import Text.Parser.TreeSitter +import TreeSitter foreign import ccall unsafe "vendor/tree-sitter-ruby/src/parser.c tree_sitter_ruby" tree_sitter_ruby :: Ptr Language From 637a468a2697088340acaaa0412c75f96bbe966e Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:01:56 -0400 Subject: [PATCH 05/49] Rename the TypeScript module. --- .../typescript/src/{Text/Parser => }/TreeSitter/TypeScript.hs | 4 ++-- languages/typescript/typescript.cabal | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename languages/typescript/src/{Text/Parser => }/TreeSitter/TypeScript.hs (66%) diff --git a/languages/typescript/src/Text/Parser/TreeSitter/TypeScript.hs b/languages/typescript/src/TreeSitter/TypeScript.hs similarity index 66% rename from languages/typescript/src/Text/Parser/TreeSitter/TypeScript.hs rename to languages/typescript/src/TreeSitter/TypeScript.hs index f6fe5f97b..d4d8de45f 100644 --- a/languages/typescript/src/Text/Parser/TreeSitter/TypeScript.hs +++ b/languages/typescript/src/TreeSitter/TypeScript.hs @@ -1,6 +1,6 @@ -module Text.Parser.TreeSitter.TypeScript where +module TreeSitter.TypeScript where import Foreign.Ptr -import Text.Parser.TreeSitter +import TreeSitter foreign import ccall unsafe "vendor/tree-sitter-typescript/src/parser.c tree_sitter_typescript" tree_sitter_typescript :: Ptr Language diff --git a/languages/typescript/typescript.cabal b/languages/typescript/typescript.cabal index c28eff377..70445338a 100644 --- a/languages/typescript/typescript.cabal +++ b/languages/typescript/typescript.cabal @@ -13,7 +13,7 @@ cabal-version: >=1.10 library hs-source-dirs: src - exposed-modules: Text.Parser.TreeSitter.TypeScript + exposed-modules: TreeSitter.TypeScript build-depends: base >= 4.7 && < 5 , haskell-tree-sitter default-language: Haskell2010 From d6ea1b752f3a977ad919cf15adc2db2c1a837128 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:02:13 -0400 Subject: [PATCH 06/49] Bump haskell-tree-sitter for simpler module hierarchy. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 5a67480dc..6d198141f 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 5a67480dcfdac091d0febc221d121bedc47b6a24 +Subproject commit 6d198141f8bb834057defcc26aec9cc98ac9b86f From f8ab5f2ae3c1241c959130b4ef4ed286f6baef6b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:02:30 -0400 Subject: [PATCH 07/49] Update the imports. --- src/Data/Syntax/Assignment.hs | 2 +- src/Language/Go/Syntax.hs | 4 ++-- src/Language/JSON/Grammar.hs | 4 ++-- src/Language/Markdown.hs | 2 +- src/Language/Python/Grammar.hs | 4 ++-- src/Language/Ruby/Grammar.hs | 4 ++-- src/Language/TypeScript/Syntax.hs | 4 ++-- src/Parser.hs | 14 +++++++------- src/TreeSitter.hs | 10 +++++----- test/Data/Syntax/Assignment/Spec.hs | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Data/Syntax/Assignment.hs b/src/Data/Syntax/Assignment.hs index a00afb468..a700eb8ba 100644 --- a/src/Data/Syntax/Assignment.hs +++ b/src/Data/Syntax/Assignment.hs @@ -115,7 +115,7 @@ import GHC.Stack import qualified Info import Prelude hiding (head, until) import Text.Parser.Combinators as Parsers -import Text.Parser.TreeSitter.Language +import TreeSitter.Language -- | Assignment from an AST with some set of 'symbol's onto some other value. -- diff --git a/src/Language/Go/Syntax.hs b/src/Language/Go/Syntax.hs index 6a966aa49..663701139 100644 --- a/src/Language/Go/Syntax.hs +++ b/src/Language/Go/Syntax.hs @@ -2,8 +2,8 @@ module Language.Go.Syntax where import Language.Haskell.TH -import Text.Parser.TreeSitter.Go -import Text.Parser.TreeSitter.Language +import TreeSitter.Go +import TreeSitter.Language -- | Statically-known rules corresponding to symbols in the grammar. mkSymbolDatatype (mkName "Grammar") tree_sitter_go diff --git a/src/Language/JSON/Grammar.hs b/src/Language/JSON/Grammar.hs index ca4f9ea41..adfc262b3 100644 --- a/src/Language/JSON/Grammar.hs +++ b/src/Language/JSON/Grammar.hs @@ -2,8 +2,8 @@ module Language.JSON.Grammar where import Language.Haskell.TH -import Text.Parser.TreeSitter.Language -import Text.Parser.TreeSitter.JSON +import TreeSitter.Language +import TreeSitter.JSON -- | Statically-known rules corresponding to symbols in the grammar. -- v2 - bump this to regenerate diff --git a/src/Language/Markdown.hs b/src/Language/Markdown.hs index 7c757097e..ea637a068 100644 --- a/src/Language/Markdown.hs +++ b/src/Language/Markdown.hs @@ -11,7 +11,7 @@ import Data.Ix import Data.Source import qualified Data.Syntax.Assignment as A (AST, Node(..)) import Info -import Text.Parser.TreeSitter.Language (Symbol(..), SymbolType(..)) +import TreeSitter.Language (Symbol(..), SymbolType(..)) data Grammar = Document diff --git a/src/Language/Python/Grammar.hs b/src/Language/Python/Grammar.hs index 58a879429..b7c4045bc 100644 --- a/src/Language/Python/Grammar.hs +++ b/src/Language/Python/Grammar.hs @@ -2,8 +2,8 @@ module Language.Python.Grammar where import Language.Haskell.TH -import Text.Parser.TreeSitter.Language -import Text.Parser.TreeSitter.Python +import TreeSitter.Language +import TreeSitter.Python -- | Statically-known rules corresponding to symbols in the grammar. -- v3 - bump this to regenerate diff --git a/src/Language/Ruby/Grammar.hs b/src/Language/Ruby/Grammar.hs index b0604a85c..5ebd39157 100644 --- a/src/Language/Ruby/Grammar.hs +++ b/src/Language/Ruby/Grammar.hs @@ -2,8 +2,8 @@ module Language.Ruby.Grammar where import Language.Haskell.TH -import Text.Parser.TreeSitter.Language -import Text.Parser.TreeSitter.Ruby +import TreeSitter.Language +import TreeSitter.Ruby -- v2 - Bump to get file to change to force template haskell to regenerate. -- | Statically-known rules corresponding to symbols in the grammar. diff --git a/src/Language/TypeScript/Syntax.hs b/src/Language/TypeScript/Syntax.hs index 4c8f60191..1ecbb6c0e 100644 --- a/src/Language/TypeScript/Syntax.hs +++ b/src/Language/TypeScript/Syntax.hs @@ -2,8 +2,8 @@ module Language.TypeScript.Syntax where import Language.Haskell.TH -import Text.Parser.TreeSitter.Language -import Text.Parser.TreeSitter.TypeScript +import TreeSitter.Language +import TreeSitter.TypeScript -- | Statically-known rules corresponding to symbols in the grammar. mkSymbolDatatype (mkName "Grammar") tree_sitter_typescript diff --git a/src/Parser.hs b/src/Parser.hs index ad5d716c5..33f8d1181 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -30,13 +30,13 @@ import qualified Language.Python.Syntax as Python import qualified Language.Ruby.Syntax as Ruby import Syntax hiding (Go) import Term -import qualified Text.Parser.TreeSitter as TS -import Text.Parser.TreeSitter.Language (Symbol) -import Text.Parser.TreeSitter.Go -import Text.Parser.TreeSitter.Python -import Text.Parser.TreeSitter.Ruby -import Text.Parser.TreeSitter.TypeScript -import Text.Parser.TreeSitter.JSON +import qualified TreeSitter as TS +import TreeSitter.Language (Symbol) +import TreeSitter.Go +import TreeSitter.Python +import TreeSitter.Ruby +import TreeSitter.TypeScript +import TreeSitter.JSON -- | A parser from 'Source' onto some term type. data Parser term where diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 79471f923..895c44dda 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -27,11 +27,11 @@ import Foreign.C.String (peekCString) import Foreign.Marshal.Array (allocaArray) import qualified Syntax as S import Term -import Text.Parser.TreeSitter hiding (Language(..)) -import qualified Text.Parser.TreeSitter as TS -import qualified Text.Parser.TreeSitter.Go as TS -import qualified Text.Parser.TreeSitter.Ruby as TS -import qualified Text.Parser.TreeSitter.TypeScript as TS +import TreeSitter hiding (Language(..)) +import qualified TreeSitter as TS +import qualified TreeSitter.Go as TS +import qualified TreeSitter.Ruby as TS +import qualified TreeSitter.TypeScript as TS import Info -- | Returns a TreeSitter parser for the given language and TreeSitter grammar. diff --git a/test/Data/Syntax/Assignment/Spec.hs b/test/Data/Syntax/Assignment/Spec.hs index d9f3a6e68..516cbb4e8 100644 --- a/test/Data/Syntax/Assignment/Spec.hs +++ b/test/Data/Syntax/Assignment/Spec.hs @@ -14,7 +14,7 @@ import Data.Syntax.Assignment import GHC.Stack (getCallStack) import Prelude hiding (words) import Test.Hspec -import Text.Parser.TreeSitter.Language (Symbol(..), SymbolType(..)) +import TreeSitter.Language (Symbol(..), SymbolType(..)) spec :: Spec spec = do From 2588f04015f5be154c8482e16ce3e7c18a337848 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:03:27 -0400 Subject: [PATCH 08/49] Rename the go package. --- languages/go/go.cabal | 2 +- semantic-diff.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/go/go.cabal b/languages/go/go.cabal index ab5c06604..fd931f08d 100644 --- a/languages/go/go.cabal +++ b/languages/go/go.cabal @@ -1,4 +1,4 @@ -name: go +name: tree-sitter-go version: 0.1.0 synopsis: tree-sitter go language bindings description: Please see README.md diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 662281437..480fcd77d 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -116,7 +116,7 @@ library , time , unix , haskell-tree-sitter - , go + , tree-sitter-go , ruby , typescript , python From 7f6fed1e4ebf8d322cba0c8fa263f5623eb4ea31 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:03:55 -0400 Subject: [PATCH 09/49] Rename the json package. --- languages/json/json.cabal | 2 +- semantic-diff.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/json/json.cabal b/languages/json/json.cabal index b19b2cdc0..ec52b0481 100644 --- a/languages/json/json.cabal +++ b/languages/json/json.cabal @@ -1,4 +1,4 @@ -name: json +name: tree-sitter-json version: 0.1.0 synopsis: tree-sitter json language bindings description: Please see README.md diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 480fcd77d..7340ed7c7 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -117,10 +117,10 @@ library , unix , haskell-tree-sitter , tree-sitter-go + , tree-sitter-json , ruby , typescript , python - , json default-language: Haskell2010 default-extensions: DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric, FlexibleContexts, FlexibleInstances, OverloadedStrings, RecordWildCards, StrictData ghc-options: -Wall -fno-warn-name-shadowing -O -j From 10c653bd95fbcaf27ed3083b8d838b63a6251e36 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:06:08 -0400 Subject: [PATCH 10/49] Rename the python package. --- languages/python/python.cabal | 2 +- semantic-diff.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/python/python.cabal b/languages/python/python.cabal index 7fc46cfd5..32edfc2c3 100644 --- a/languages/python/python.cabal +++ b/languages/python/python.cabal @@ -1,4 +1,4 @@ -name: python +name: tree-sitter-python version: 0.1.0 synopsis: tree-sitter python language bindings homepage: https://github.com/github/semantic-diff#readme diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 7340ed7c7..00d01db70 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -118,9 +118,9 @@ library , haskell-tree-sitter , tree-sitter-go , tree-sitter-json + , tree-sitter-python , ruby , typescript - , python default-language: Haskell2010 default-extensions: DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric, FlexibleContexts, FlexibleInstances, OverloadedStrings, RecordWildCards, StrictData ghc-options: -Wall -fno-warn-name-shadowing -O -j From c5b6c0a054b35f95691011dbb58b4198f0886cf7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:06:37 -0400 Subject: [PATCH 11/49] Rename the ruby package. --- languages/ruby/ruby.cabal | 2 +- semantic-diff.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/ruby/ruby.cabal b/languages/ruby/ruby.cabal index f0fa77eee..be7b03a3c 100644 --- a/languages/ruby/ruby.cabal +++ b/languages/ruby/ruby.cabal @@ -1,4 +1,4 @@ -name: ruby +name: tree-sitter-ruby version: 0.1.0 synopsis: tree-sitter ruby language bindings description: Please see README.md diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 00d01db70..fd1b14dde 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -119,7 +119,7 @@ library , tree-sitter-go , tree-sitter-json , tree-sitter-python - , ruby + , tree-sitter-ruby , typescript default-language: Haskell2010 default-extensions: DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric, FlexibleContexts, FlexibleInstances, OverloadedStrings, RecordWildCards, StrictData From 6ddfcc3b9899b35b1da9420022c799b9b9b8a001 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:07:03 -0400 Subject: [PATCH 12/49] Rename the typescript package. --- languages/typescript/typescript.cabal | 2 +- semantic-diff.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/typescript/typescript.cabal b/languages/typescript/typescript.cabal index 70445338a..4180f7978 100644 --- a/languages/typescript/typescript.cabal +++ b/languages/typescript/typescript.cabal @@ -1,4 +1,4 @@ -name: typescript +name: tree-sitter-typescript version: 0.1.0 synopsis: tree-sitter typescript language bindings description: Please see README.md diff --git a/semantic-diff.cabal b/semantic-diff.cabal index fd1b14dde..de13ce784 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -120,7 +120,7 @@ library , tree-sitter-json , tree-sitter-python , tree-sitter-ruby - , typescript + , tree-sitter-typescript default-language: Haskell2010 default-extensions: DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric, FlexibleContexts, FlexibleInstances, OverloadedStrings, RecordWildCards, StrictData ghc-options: -Wall -fno-warn-name-shadowing -O -j From c576e0034f595875c6e932f5e64900f4ed6b6ab4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:10:26 -0400 Subject: [PATCH 13/49] Import the Language module in the language packages. --- languages/go/src/TreeSitter/Go.hs | 2 +- languages/json/src/TreeSitter/JSON.hs | 2 +- languages/python/src/TreeSitter/Python.hs | 2 +- languages/ruby/src/TreeSitter/Ruby.hs | 2 +- languages/typescript/src/TreeSitter/TypeScript.hs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/languages/go/src/TreeSitter/Go.hs b/languages/go/src/TreeSitter/Go.hs index 91d5e6028..7e6dc6327 100644 --- a/languages/go/src/TreeSitter/Go.hs +++ b/languages/go/src/TreeSitter/Go.hs @@ -1,6 +1,6 @@ module TreeSitter.Go where -import TreeSitter import Foreign.Ptr +import TreeSitter.Language foreign import ccall unsafe "vendor/tree-sitter-go/src/parser.c tree_sitter_go" tree_sitter_go :: Ptr Language diff --git a/languages/json/src/TreeSitter/JSON.hs b/languages/json/src/TreeSitter/JSON.hs index e20a770aa..339d26ea5 100644 --- a/languages/json/src/TreeSitter/JSON.hs +++ b/languages/json/src/TreeSitter/JSON.hs @@ -1,6 +1,6 @@ module TreeSitter.JSON where import Foreign.Ptr -import TreeSitter +import TreeSitter.Language foreign import ccall unsafe "vendor/tree-sitter-json/src/parser.c tree_sitter_json" tree_sitter_json :: Ptr Language diff --git a/languages/python/src/TreeSitter/Python.hs b/languages/python/src/TreeSitter/Python.hs index 3d4f26e67..fee722144 100644 --- a/languages/python/src/TreeSitter/Python.hs +++ b/languages/python/src/TreeSitter/Python.hs @@ -3,6 +3,6 @@ module TreeSitter.Python ) where import Foreign.Ptr -import TreeSitter +import TreeSitter.Language foreign import ccall unsafe "vendor/tree-sitter-python/src/parser.c tree_sitter_python" tree_sitter_python :: Ptr Language diff --git a/languages/ruby/src/TreeSitter/Ruby.hs b/languages/ruby/src/TreeSitter/Ruby.hs index 604d2d346..634457b7e 100644 --- a/languages/ruby/src/TreeSitter/Ruby.hs +++ b/languages/ruby/src/TreeSitter/Ruby.hs @@ -3,6 +3,6 @@ module TreeSitter.Ruby ) where import Foreign.Ptr -import TreeSitter +import TreeSitter.Language foreign import ccall unsafe "vendor/tree-sitter-ruby/src/parser.c tree_sitter_ruby" tree_sitter_ruby :: Ptr Language diff --git a/languages/typescript/src/TreeSitter/TypeScript.hs b/languages/typescript/src/TreeSitter/TypeScript.hs index d4d8de45f..ae39aa562 100644 --- a/languages/typescript/src/TreeSitter/TypeScript.hs +++ b/languages/typescript/src/TreeSitter/TypeScript.hs @@ -1,6 +1,6 @@ module TreeSitter.TypeScript where import Foreign.Ptr -import TreeSitter +import TreeSitter.Language foreign import ccall unsafe "vendor/tree-sitter-typescript/src/parser.c tree_sitter_typescript" tree_sitter_typescript :: Ptr Language From 661178bf9382d20c31de547890bb2953d8ec2819 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:11:59 -0400 Subject: [PATCH 14/49] Export the language symbol consistently. --- languages/go/src/TreeSitter/Go.hs | 4 +++- languages/json/src/TreeSitter/JSON.hs | 4 +++- languages/typescript/src/TreeSitter/TypeScript.hs | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/languages/go/src/TreeSitter/Go.hs b/languages/go/src/TreeSitter/Go.hs index 7e6dc6327..49fbce21e 100644 --- a/languages/go/src/TreeSitter/Go.hs +++ b/languages/go/src/TreeSitter/Go.hs @@ -1,4 +1,6 @@ -module TreeSitter.Go where +module TreeSitter.Go +( tree_sitter_go +) where import Foreign.Ptr import TreeSitter.Language diff --git a/languages/json/src/TreeSitter/JSON.hs b/languages/json/src/TreeSitter/JSON.hs index 339d26ea5..528dc93da 100644 --- a/languages/json/src/TreeSitter/JSON.hs +++ b/languages/json/src/TreeSitter/JSON.hs @@ -1,4 +1,6 @@ -module TreeSitter.JSON where +module TreeSitter.JSON +( tree_sitter_json +) where import Foreign.Ptr import TreeSitter.Language diff --git a/languages/typescript/src/TreeSitter/TypeScript.hs b/languages/typescript/src/TreeSitter/TypeScript.hs index ae39aa562..b8dc5f6b9 100644 --- a/languages/typescript/src/TreeSitter/TypeScript.hs +++ b/languages/typescript/src/TreeSitter/TypeScript.hs @@ -1,4 +1,6 @@ -module TreeSitter.TypeScript where +module TreeSitter.TypeScript +( tree_sitter_typescript +) where import Foreign.Ptr import TreeSitter.Language From 7ba37de6cdc9a63c6b55819c217637a746fd9c2c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:14:21 -0400 Subject: [PATCH 15/49] Move all of the language submodules into vendor/. --- .gitmodules | 10 +++++----- {languages/go/vendor => vendor}/tree-sitter-go | 0 {languages/json/vendor => vendor}/tree-sitter-json | 0 {languages/python/vendor => vendor}/tree-sitter-python | 0 {languages/ruby/vendor => vendor}/tree-sitter-ruby | 0 .../vendor => vendor}/tree-sitter-typescript | 0 6 files changed, 5 insertions(+), 5 deletions(-) rename {languages/go/vendor => vendor}/tree-sitter-go (100%) rename {languages/json/vendor => vendor}/tree-sitter-json (100%) rename {languages/python/vendor => vendor}/tree-sitter-python (100%) rename {languages/ruby/vendor => vendor}/tree-sitter-ruby (100%) rename {languages/typescript/vendor => vendor}/tree-sitter-typescript (100%) diff --git a/.gitmodules b/.gitmodules index 0088a413f..70ea3bf7c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,13 +14,13 @@ path = vendor/effects url = https://github.com/joshvera/effects.git [submodule "languages/ruby/vendor/tree-sitter-ruby"] - path = languages/ruby/vendor/tree-sitter-ruby + path = vendor/tree-sitter-ruby url = https://github.com/tree-sitter/tree-sitter-ruby.git [submodule "languages/c/vendor/tree-sitter-c"] path = languages/c/vendor/tree-sitter-c url = https://github.com/tree-sitter/tree-sitter-c.git [submodule "languages/go/vendor/tree-sitter-go"] - path = languages/go/vendor/tree-sitter-go + path = vendor/tree-sitter-go url = https://github.com/tree-sitter/tree-sitter-go.git [submodule "languages/javascript/vendor/tree-sitter-javascript"] path = languages/javascript/vendor/tree-sitter-javascript @@ -29,13 +29,13 @@ path = vendor/haskell-tree-sitter url = https://github.com/tree-sitter/haskell-tree-sitter.git [submodule "languages/typescript/vendor/tree-sitter-typescript"] - path = languages/typescript/vendor/tree-sitter-typescript + path = vendor/tree-sitter-typescript url = https://github.com/tree-sitter/tree-sitter-typescript/ [submodule "languages/python/vendor/tree-sitter-python"] - path = languages/python/vendor/tree-sitter-python + path = vendor/tree-sitter-python url = https://github.com/tree-sitter/tree-sitter-python.git [submodule "languages/json/vendor/tree-sitter-json"] - path = languages/json/vendor/tree-sitter-json + path = vendor/tree-sitter-json url = https://github.com/tree-sitter/tree-sitter-json [submodule "vendor/freer-cofreer"] path = vendor/freer-cofreer diff --git a/languages/go/vendor/tree-sitter-go b/vendor/tree-sitter-go similarity index 100% rename from languages/go/vendor/tree-sitter-go rename to vendor/tree-sitter-go diff --git a/languages/json/vendor/tree-sitter-json b/vendor/tree-sitter-json similarity index 100% rename from languages/json/vendor/tree-sitter-json rename to vendor/tree-sitter-json diff --git a/languages/python/vendor/tree-sitter-python b/vendor/tree-sitter-python similarity index 100% rename from languages/python/vendor/tree-sitter-python rename to vendor/tree-sitter-python diff --git a/languages/ruby/vendor/tree-sitter-ruby b/vendor/tree-sitter-ruby similarity index 100% rename from languages/ruby/vendor/tree-sitter-ruby rename to vendor/tree-sitter-ruby diff --git a/languages/typescript/vendor/tree-sitter-typescript b/vendor/tree-sitter-typescript similarity index 100% rename from languages/typescript/vendor/tree-sitter-typescript rename to vendor/tree-sitter-typescript From ace55d00ba32066d3e7d4a58a00c72f1c0764861 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:35:07 -0400 Subject: [PATCH 16/49] Get the tree-sitter-go package from the submodule. --- languages/go/Setup.hs | 2 -- languages/go/go.cabal | 25 ------------------------- languages/go/src/TreeSitter/Go.hs | 8 -------- vendor/tree-sitter-go | 2 +- 4 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 languages/go/Setup.hs delete mode 100644 languages/go/go.cabal delete mode 100644 languages/go/src/TreeSitter/Go.hs diff --git a/languages/go/Setup.hs b/languages/go/Setup.hs deleted file mode 100644 index 9a994af67..000000000 --- a/languages/go/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/languages/go/go.cabal b/languages/go/go.cabal deleted file mode 100644 index fd931f08d..000000000 --- a/languages/go/go.cabal +++ /dev/null @@ -1,25 +0,0 @@ -name: tree-sitter-go -version: 0.1.0 -synopsis: tree-sitter go language bindings -description: Please see README.md -homepage: https://github.com/github/semantic-diff#readme -author: semantic-code -maintainer: tclem@github.com -copyright: 2017 GitHub -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: TreeSitter.Go - build-depends: base >= 4.7 && < 5 - , haskell-tree-sitter - default-language: Haskell2010 - default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards - c-sources: vendor/tree-sitter-go/src/parser.c - -source-repository head - type: git - location: https://github.com/github/semantic-diff diff --git a/languages/go/src/TreeSitter/Go.hs b/languages/go/src/TreeSitter/Go.hs deleted file mode 100644 index 49fbce21e..000000000 --- a/languages/go/src/TreeSitter/Go.hs +++ /dev/null @@ -1,8 +0,0 @@ -module TreeSitter.Go -( tree_sitter_go -) where - -import Foreign.Ptr -import TreeSitter.Language - -foreign import ccall unsafe "vendor/tree-sitter-go/src/parser.c tree_sitter_go" tree_sitter_go :: Ptr Language diff --git a/vendor/tree-sitter-go b/vendor/tree-sitter-go index 025ece6dd..6d4724062 160000 --- a/vendor/tree-sitter-go +++ b/vendor/tree-sitter-go @@ -1 +1 @@ -Subproject commit 025ece6ddcdf3e3cbc6c865e2d2c010217fbf90f +Subproject commit 6d4724062c35cc715192f136bd8dd1f914f641f1 From e08f86300fc2f3044a1ff80ab38d34ca0ee3ce44 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:35:14 -0400 Subject: [PATCH 17/49] Get the tree-sitter-json package from the submodule. --- languages/json/Setup.hs | 2 -- languages/json/json.cabal | 27 --------------------------- languages/json/src/TreeSitter/JSON.hs | 8 -------- vendor/tree-sitter-json | 2 +- 4 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 languages/json/Setup.hs delete mode 100644 languages/json/json.cabal delete mode 100644 languages/json/src/TreeSitter/JSON.hs diff --git a/languages/json/Setup.hs b/languages/json/Setup.hs deleted file mode 100644 index 9a994af67..000000000 --- a/languages/json/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/languages/json/json.cabal b/languages/json/json.cabal deleted file mode 100644 index ec52b0481..000000000 --- a/languages/json/json.cabal +++ /dev/null @@ -1,27 +0,0 @@ -name: tree-sitter-json -version: 0.1.0 -synopsis: tree-sitter json language bindings -description: Please see README.md -homepage: https://github.com/github/semantic-diff#readme -author: semantic-code -maintainer: vera@github.com -copyright: 2017 GitHub -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: TreeSitter.JSON - build-depends: base >= 4.7 && < 5 - , haskell-tree-sitter - default-language: Haskell2010 - default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards - c-sources: vendor/tree-sitter-json/src/parser.c - cc-options: -std=c99 -Os - - -source-repository head - type: git - location: https://github.com/github/semantic-diff diff --git a/languages/json/src/TreeSitter/JSON.hs b/languages/json/src/TreeSitter/JSON.hs deleted file mode 100644 index 528dc93da..000000000 --- a/languages/json/src/TreeSitter/JSON.hs +++ /dev/null @@ -1,8 +0,0 @@ -module TreeSitter.JSON -( tree_sitter_json -) where - -import Foreign.Ptr -import TreeSitter.Language - -foreign import ccall unsafe "vendor/tree-sitter-json/src/parser.c tree_sitter_json" tree_sitter_json :: Ptr Language diff --git a/vendor/tree-sitter-json b/vendor/tree-sitter-json index 81b519e6a..b490b283b 160000 --- a/vendor/tree-sitter-json +++ b/vendor/tree-sitter-json @@ -1 +1 @@ -Subproject commit 81b519e6ad7aa87c61851f1f6925b59fcc34d347 +Subproject commit b490b283bb511d80d72b1cb7a4573d730fa3888d From b6075642d7188b04a9e4ce98cc4ff4c12282c8bf Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:35:21 -0400 Subject: [PATCH 18/49] Get the tree-sitter-python package from the submodule. --- languages/python/Setup.hs | 2 -- languages/python/python.cabal | 27 ----------------------- languages/python/src/TreeSitter/Python.hs | 8 ------- vendor/tree-sitter-python | 2 +- 4 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 languages/python/Setup.hs delete mode 100644 languages/python/python.cabal delete mode 100644 languages/python/src/TreeSitter/Python.hs diff --git a/languages/python/Setup.hs b/languages/python/Setup.hs deleted file mode 100644 index 9a994af67..000000000 --- a/languages/python/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/languages/python/python.cabal b/languages/python/python.cabal deleted file mode 100644 index 32edfc2c3..000000000 --- a/languages/python/python.cabal +++ /dev/null @@ -1,27 +0,0 @@ -name: tree-sitter-python -version: 0.1.0 -synopsis: tree-sitter python language bindings -homepage: https://github.com/github/semantic-diff#readme -description: Please see README.md -author: semantic-code -maintainer: tclem@github.com -copyright: 2017 GitHub -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: TreeSitter.Python - build-depends: base >= 4.7 && < 5 - , haskell-tree-sitter - default-language: Haskell2010 - default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards - c-sources: vendor/tree-sitter-python/src/parser.c - , vendor/tree-sitter-python/src/scanner.cc - extra-libraries: stdc++ - -source-repository head - type: git - location: https://github.com/github/semantic-diff diff --git a/languages/python/src/TreeSitter/Python.hs b/languages/python/src/TreeSitter/Python.hs deleted file mode 100644 index fee722144..000000000 --- a/languages/python/src/TreeSitter/Python.hs +++ /dev/null @@ -1,8 +0,0 @@ -module TreeSitter.Python -( tree_sitter_python -) where - -import Foreign.Ptr -import TreeSitter.Language - -foreign import ccall unsafe "vendor/tree-sitter-python/src/parser.c tree_sitter_python" tree_sitter_python :: Ptr Language diff --git a/vendor/tree-sitter-python b/vendor/tree-sitter-python index 24220e066..8cc1f377c 160000 --- a/vendor/tree-sitter-python +++ b/vendor/tree-sitter-python @@ -1 +1 @@ -Subproject commit 24220e066fd65ccfa5dba65c0095705d559e97cb +Subproject commit 8cc1f377ca633b4ae076888e3712dcb465031aad From b9e75cb59f000e430c7c45bbca22c4f88da7c556 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:35:29 -0400 Subject: [PATCH 19/49] Get the tree-sitter-ruby package from the submodule. --- languages/ruby/Setup.hs | 2 -- languages/ruby/ruby.cabal | 27 --------------------------- languages/ruby/src/TreeSitter/Ruby.hs | 8 -------- vendor/tree-sitter-ruby | 2 +- 4 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 languages/ruby/Setup.hs delete mode 100644 languages/ruby/ruby.cabal delete mode 100644 languages/ruby/src/TreeSitter/Ruby.hs diff --git a/languages/ruby/Setup.hs b/languages/ruby/Setup.hs deleted file mode 100644 index 9a994af67..000000000 --- a/languages/ruby/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/languages/ruby/ruby.cabal b/languages/ruby/ruby.cabal deleted file mode 100644 index be7b03a3c..000000000 --- a/languages/ruby/ruby.cabal +++ /dev/null @@ -1,27 +0,0 @@ -name: tree-sitter-ruby -version: 0.1.0 -synopsis: tree-sitter ruby language bindings -description: Please see README.md -homepage: https://github.com/github/semantic-diff#readme -author: semantic-code -maintainer: tclem@github.com -copyright: 2017 GitHub -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: TreeSitter.Ruby - build-depends: base >= 4.7 && < 5 - , haskell-tree-sitter - default-language: Haskell2010 - default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards - c-sources: vendor/tree-sitter-ruby/src/parser.c - , vendor/tree-sitter-ruby/src/scanner.cc - extra-libraries: stdc++ - -source-repository head - type: git - location: https://github.com/github/semantic-diff diff --git a/languages/ruby/src/TreeSitter/Ruby.hs b/languages/ruby/src/TreeSitter/Ruby.hs deleted file mode 100644 index 634457b7e..000000000 --- a/languages/ruby/src/TreeSitter/Ruby.hs +++ /dev/null @@ -1,8 +0,0 @@ -module TreeSitter.Ruby -( tree_sitter_ruby -) where - -import Foreign.Ptr -import TreeSitter.Language - -foreign import ccall unsafe "vendor/tree-sitter-ruby/src/parser.c tree_sitter_ruby" tree_sitter_ruby :: Ptr Language diff --git a/vendor/tree-sitter-ruby b/vendor/tree-sitter-ruby index 0fca7f41c..88d26c713 160000 --- a/vendor/tree-sitter-ruby +++ b/vendor/tree-sitter-ruby @@ -1 +1 @@ -Subproject commit 0fca7f41c7fdb44ca7fdecb9a94434e429b4843f +Subproject commit 88d26c713c2ba64d20bd3b071fe2c7088f4b3ed8 From e74da6846dab30b9adf5d64623c285c932959279 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:35:37 -0400 Subject: [PATCH 20/49] Get the tree-sitter-typescript package from the submodule. --- languages/typescript/Setup.hs | 2 -- .../typescript/src/TreeSitter/TypeScript.hs | 8 ------ languages/typescript/typescript.cabal | 28 ------------------- vendor/tree-sitter-typescript | 2 +- 4 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 languages/typescript/Setup.hs delete mode 100644 languages/typescript/src/TreeSitter/TypeScript.hs delete mode 100644 languages/typescript/typescript.cabal diff --git a/languages/typescript/Setup.hs b/languages/typescript/Setup.hs deleted file mode 100644 index 9a994af67..000000000 --- a/languages/typescript/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/languages/typescript/src/TreeSitter/TypeScript.hs b/languages/typescript/src/TreeSitter/TypeScript.hs deleted file mode 100644 index b8dc5f6b9..000000000 --- a/languages/typescript/src/TreeSitter/TypeScript.hs +++ /dev/null @@ -1,8 +0,0 @@ -module TreeSitter.TypeScript -( tree_sitter_typescript -) where - -import Foreign.Ptr -import TreeSitter.Language - -foreign import ccall unsafe "vendor/tree-sitter-typescript/src/parser.c tree_sitter_typescript" tree_sitter_typescript :: Ptr Language diff --git a/languages/typescript/typescript.cabal b/languages/typescript/typescript.cabal deleted file mode 100644 index 4180f7978..000000000 --- a/languages/typescript/typescript.cabal +++ /dev/null @@ -1,28 +0,0 @@ -name: tree-sitter-typescript -version: 0.1.0 -synopsis: tree-sitter typescript language bindings -description: Please see README.md -homepage: https://github.com/github/semantic-diff#readme -author: semantic-code -maintainer: vera@github.com -copyright: 2017 GitHub -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: TreeSitter.TypeScript - build-depends: base >= 4.7 && < 5 - , haskell-tree-sitter - default-language: Haskell2010 - default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards - c-sources: vendor/tree-sitter-typescript/src/parser.c - , vendor/tree-sitter-typescript/src/scanner.c - cc-options: -std=c99 -Os - - -source-repository head - type: git - location: https://github.com/github/semantic-diff diff --git a/vendor/tree-sitter-typescript b/vendor/tree-sitter-typescript index 6d44526e0..d06bbebaf 160000 --- a/vendor/tree-sitter-typescript +++ b/vendor/tree-sitter-typescript @@ -1 +1 @@ -Subproject commit 6d44526e059ebf456c9059ee1717126d69e41018 +Subproject commit d06bbebafef3e92c33f36bd0930ee2ba5bcf74a9 From 21ccc174e3c21969b5358b877392da063e5cb7ad Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:36:18 -0400 Subject: [PATCH 21/49] :fire: looking for packages in the languages dir. --- cabal.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index 24accf28e..77a952354 100644 --- a/cabal.project +++ b/cabal.project @@ -1,4 +1,4 @@ -packages: ./ languages/*/ tools/*/ +packages: ./ tools/*/ optional-packages: vendor/*/ jobs: $ncpus From 9dacfa1926ea1c3c0370c9b239a1caa9bc554ef6 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:38:39 -0400 Subject: [PATCH 22/49] Bump the submodules for corrected paths to the C sources. --- vendor/tree-sitter-go | 2 +- vendor/tree-sitter-json | 2 +- vendor/tree-sitter-python | 2 +- vendor/tree-sitter-ruby | 2 +- vendor/tree-sitter-typescript | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/tree-sitter-go b/vendor/tree-sitter-go index 6d4724062..3dfe8857c 160000 --- a/vendor/tree-sitter-go +++ b/vendor/tree-sitter-go @@ -1 +1 @@ -Subproject commit 6d4724062c35cc715192f136bd8dd1f914f641f1 +Subproject commit 3dfe8857ce7a1a69b067361aa3847d84f2204fa2 diff --git a/vendor/tree-sitter-json b/vendor/tree-sitter-json index b490b283b..47dbca5b0 160000 --- a/vendor/tree-sitter-json +++ b/vendor/tree-sitter-json @@ -1 +1 @@ -Subproject commit b490b283bb511d80d72b1cb7a4573d730fa3888d +Subproject commit 47dbca5b05dbb1821e2e559e2a60db651ca998ce diff --git a/vendor/tree-sitter-python b/vendor/tree-sitter-python index 8cc1f377c..28358b60e 160000 --- a/vendor/tree-sitter-python +++ b/vendor/tree-sitter-python @@ -1 +1 @@ -Subproject commit 8cc1f377ca633b4ae076888e3712dcb465031aad +Subproject commit 28358b60e5d7081ba24a7bb9e707dc45b4f27c26 diff --git a/vendor/tree-sitter-ruby b/vendor/tree-sitter-ruby index 88d26c713..63fcb7a6d 160000 --- a/vendor/tree-sitter-ruby +++ b/vendor/tree-sitter-ruby @@ -1 +1 @@ -Subproject commit 88d26c713c2ba64d20bd3b071fe2c7088f4b3ed8 +Subproject commit 63fcb7a6d8b9caa85ec3123d9e1eeda634e8b7f1 diff --git a/vendor/tree-sitter-typescript b/vendor/tree-sitter-typescript index d06bbebaf..82ed0d317 160000 --- a/vendor/tree-sitter-typescript +++ b/vendor/tree-sitter-typescript @@ -1 +1 @@ -Subproject commit d06bbebafef3e92c33f36bd0930ee2ba5bcf74a9 +Subproject commit 82ed0d317caf4c3905d706017aa647b4e87b1162 From 0c773722f9639acf9ca8c1e9de2909be76260a95 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:43:53 -0400 Subject: [PATCH 23/49] Correct the TreeSitter imports &c. --- src/TreeSitter.hs | 53 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 895c44dda..5a470caa0 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -27,8 +27,9 @@ import Foreign.C.String (peekCString) import Foreign.Marshal.Array (allocaArray) import qualified Syntax as S import Term -import TreeSitter hiding (Language(..)) -import qualified TreeSitter as TS +import qualified TreeSitter.Document as TS +import qualified TreeSitter.Node as TS +import qualified TreeSitter.Language as TS import qualified TreeSitter.Go as TS import qualified TreeSitter.Ruby as TS import qualified TreeSitter.TypeScript as TS @@ -36,33 +37,33 @@ import Info -- | Returns a TreeSitter parser for the given language and TreeSitter grammar. treeSitterParser :: Ptr TS.Language -> Blob -> IO (SyntaxTerm DefaultFields) -treeSitterParser language blob = bracket ts_document_new ts_document_free $ \ document -> do - ts_document_set_language document language +treeSitterParser language blob = bracket TS.ts_document_new TS.ts_document_free $ \ document -> do + TS.ts_document_set_language document language unsafeUseAsCStringLen (sourceBytes (blobSource blob)) $ \ (sourceBytes, len) -> do - ts_document_set_input_string_with_length document sourceBytes len - ts_document_parse_halt_on_error document + TS.ts_document_set_input_string_with_length document sourceBytes len + TS.ts_document_parse_halt_on_error document term <- documentToTerm language document blob pure term -- | Parse 'Source' with the given 'TS.Language' and return its AST. parseToAST :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Blob -> IO (A.AST grammar) -parseToAST language Blob{..} = bracket ts_document_new ts_document_free $ \ document -> do - ts_document_set_language document language +parseToAST language Blob{..} = bracket TS.ts_document_new TS.ts_document_free $ \ document -> do + TS.ts_document_set_language document language root <- unsafeUseAsCStringLen (sourceBytes blobSource) $ \ (source, len) -> do - ts_document_set_input_string_with_length document source len - ts_document_parse_halt_on_error document + TS.ts_document_set_input_string_with_length document source len + TS.ts_document_parse_halt_on_error document alloca (\ rootPtr -> do - ts_document_root_node_p document rootPtr + TS.ts_document_root_node_p document rootPtr peek rootPtr) anaM toAST root toAST :: forall grammar . (Bounded grammar, Enum grammar) => Node -> IO (Base (A.AST grammar) Node) -toAST node@Node{..} = do +toAST node@TS.Node{..} = do let count = fromIntegral nodeChildCount children <- allocaArray count $ \ childNodesPtr -> do - _ <- with nodeTSNode (\ nodePtr -> ts_node_copy_child_nodes nullPtr nodePtr childNodesPtr (fromIntegral count)) + _ <- with nodeTSNode (\ nodePtr -> TS.ts_node_copy_child_nodes nullPtr nodePtr childNodesPtr (fromIntegral count)) peekArray count childNodesPtr pure $! A.Node (toEnum (min (fromIntegral nodeSymbol) (fromEnum (maxBound :: grammar)))) (nodeRange node) (nodeSpan node) :< children @@ -74,37 +75,37 @@ anaM g = a where a = pure . embed <=< traverse a <=< g documentToTerm :: Ptr TS.Language -> Ptr Document -> Blob -> IO (SyntaxTerm DefaultFields) documentToTerm language document Blob{..} = do root <- alloca (\ rootPtr -> do - ts_document_root_node_p document rootPtr + TS.ts_document_root_node_p document rootPtr peek rootPtr) toTerm root where toTerm :: Node -> IO (SyntaxTerm DefaultFields) - toTerm node = do - name <- peekCString (nodeType node) + toTerm node@TS.Node{..} = do + name <- peekCString nodeType - children <- getChildren (fromIntegral (nodeNamedChildCount node)) copyNamed - let allChildren = getChildren (fromIntegral (nodeChildCount node)) copyAll + children <- getChildren (fromIntegral nodeNamedChildCount) copyNamed + let allChildren = getChildren (fromIntegral nodeChildCount) copyAll let source = slice (nodeRange node) blobSource assignTerm language source (range :. categoryForLanguageProductionName language (pack name) :. nodeSpan node :. Nil) children allChildren where getChildren count copy = do nodes <- allocaArray count $ \ childNodesPtr -> do - _ <- with (nodeTSNode node) (\ nodePtr -> copy nodePtr childNodesPtr (fromIntegral count)) + _ <- with nodeTSNode (\ nodePtr -> copy nodePtr childNodesPtr (fromIntegral count)) peekArray count childNodesPtr children <- traverse toTerm nodes return $! filter isNonEmpty children range = nodeRange node - copyNamed = ts_node_copy_named_child_nodes document - copyAll = ts_node_copy_child_nodes document + copyNamed = TS.ts_node_copy_named_child_nodes document + copyAll = TS.ts_node_copy_child_nodes document isNonEmpty :: HasField fields Category => SyntaxTerm fields -> Bool isNonEmpty = (/= Empty) . category . extract -nodeRange :: Node -> Range -nodeRange Node{..} = Range (fromIntegral nodeStartByte) (fromIntegral nodeEndByte) +nodeRange :: TS.Node -> Range +nodeRange TS.Node{..} = Range (fromIntegral nodeStartByte) (fromIntegral nodeEndByte) -nodeSpan :: Node -> Span -nodeSpan Node{..} = nodeStartPoint `seq` nodeEndPoint `seq` Span (pointPos nodeStartPoint) (pointPos nodeEndPoint) - where pointPos TSPoint{..} = pointRow `seq` pointColumn `seq` Pos (1 + fromIntegral pointRow) (1 + fromIntegral pointColumn) +nodeSpan :: TS.Node -> Span +nodeSpan TS.Node{..} = nodeStartPoint `seq` nodeEndPoint `seq` Span (pointPos nodeStartPoint) (pointPos nodeEndPoint) + where pointPos TS.TSPoint{..} = pointRow `seq` pointColumn `seq` Pos (1 + fromIntegral pointRow) (1 + fromIntegral pointColumn) assignTerm :: Ptr TS.Language -> Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields) assignTerm language source annotation children allChildren = From d6a467f50bf4a0ea6259eacc32b765557558c17d Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:52:17 -0400 Subject: [PATCH 24/49] Bump the submodules. --- vendor/tree-sitter-go | 2 +- vendor/tree-sitter-json | 2 +- vendor/tree-sitter-python | 2 +- vendor/tree-sitter-ruby | 2 +- vendor/tree-sitter-typescript | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/tree-sitter-go b/vendor/tree-sitter-go index 3dfe8857c..d61655aaa 160000 --- a/vendor/tree-sitter-go +++ b/vendor/tree-sitter-go @@ -1 +1 @@ -Subproject commit 3dfe8857ce7a1a69b067361aa3847d84f2204fa2 +Subproject commit d61655aaac02b01b52ff1bdb2d90be3d1a466bb0 diff --git a/vendor/tree-sitter-json b/vendor/tree-sitter-json index 47dbca5b0..fe5a6b816 160000 --- a/vendor/tree-sitter-json +++ b/vendor/tree-sitter-json @@ -1 +1 @@ -Subproject commit 47dbca5b05dbb1821e2e559e2a60db651ca998ce +Subproject commit fe5a6b81631ddb5a380b7f1f7b1f35b09d9cc3cc diff --git a/vendor/tree-sitter-python b/vendor/tree-sitter-python index 28358b60e..db3803ebc 160000 --- a/vendor/tree-sitter-python +++ b/vendor/tree-sitter-python @@ -1 +1 @@ -Subproject commit 28358b60e5d7081ba24a7bb9e707dc45b4f27c26 +Subproject commit db3803ebcc7b8065f509b33bf5147cabe876d570 diff --git a/vendor/tree-sitter-ruby b/vendor/tree-sitter-ruby index 63fcb7a6d..e8cd528b2 160000 --- a/vendor/tree-sitter-ruby +++ b/vendor/tree-sitter-ruby @@ -1 +1 @@ -Subproject commit 63fcb7a6d8b9caa85ec3123d9e1eeda634e8b7f1 +Subproject commit e8cd528b205d46a32dcd66f576cf353b8afe8d26 diff --git a/vendor/tree-sitter-typescript b/vendor/tree-sitter-typescript index 82ed0d317..a45a662de 160000 --- a/vendor/tree-sitter-typescript +++ b/vendor/tree-sitter-typescript @@ -1 +1 @@ -Subproject commit 82ed0d317caf4c3905d706017aa647b4e87b1162 +Subproject commit a45a662deb7d4b3668e49940bda7b4b81f2df6ab From 61052b334047c8b5a42b7832ca3ec8402c89dc39 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 08:52:25 -0400 Subject: [PATCH 25/49] Correct some references again. --- src/Parser.hs | 5 ++--- src/TreeSitter.hs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index 33f8d1181..60ad3fa93 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -30,8 +30,7 @@ import qualified Language.Python.Syntax as Python import qualified Language.Ruby.Syntax as Ruby import Syntax hiding (Go) import Term -import qualified TreeSitter as TS -import TreeSitter.Language (Symbol) +import qualified TreeSitter.Language as TS (Language, Symbol) import TreeSitter.Go import TreeSitter.Python import TreeSitter.Ruby @@ -43,7 +42,7 @@ data Parser term where -- | A parser producing 'AST' using a 'TS.Language'. ASTParser :: (Bounded grammar, Enum grammar) => Ptr TS.Language -> Parser (AST grammar) -- | A parser producing an à la carte term given an 'AST'-producing parser and an 'Assignment' onto 'Term's in some syntax type. - AssignmentParser :: (Bounded grammar, Ix grammar, Show grammar, Symbol grammar, Syntax.Error :< fs, Apply1 Foldable fs, Apply1 Functor fs, Eq ast, Recursive ast, Foldable (Base ast)) + AssignmentParser :: (Bounded grammar, Ix grammar, Show grammar, TS.Symbol grammar, Syntax.Error :< fs, Apply1 Foldable fs, Apply1 Functor fs, Eq ast, Recursive ast, Foldable (Base ast)) => Parser ast -- ^ A parser producing AST. -> (forall x. Base ast x -> Node grammar) -- ^ A function extracting the symbol and location. -> Assignment ast grammar (Term (Union fs) (Record Location)) -- ^ An assignment from AST onto 'Term's. diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 5a470caa0..c9b325a3a 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -59,7 +59,7 @@ parseToAST language Blob{..} = bracket TS.ts_document_new TS.ts_document_free $ anaM toAST root -toAST :: forall grammar . (Bounded grammar, Enum grammar) => Node -> IO (Base (A.AST grammar) Node) +toAST :: forall grammar . (Bounded grammar, Enum grammar) => TS.Node -> IO (Base (A.AST grammar) TS.Node) toAST node@TS.Node{..} = do let count = fromIntegral nodeChildCount children <- allocaArray count $ \ childNodesPtr -> do @@ -72,13 +72,13 @@ anaM g = a where a = pure . embed <=< traverse a <=< g -- | Return a parser for a tree sitter language & document. -documentToTerm :: Ptr TS.Language -> Ptr Document -> Blob -> IO (SyntaxTerm DefaultFields) +documentToTerm :: Ptr TS.Language -> Ptr TS.Document -> Blob -> IO (SyntaxTerm DefaultFields) documentToTerm language document Blob{..} = do root <- alloca (\ rootPtr -> do TS.ts_document_root_node_p document rootPtr peek rootPtr) toTerm root - where toTerm :: Node -> IO (SyntaxTerm DefaultFields) + where toTerm :: TS.Node -> IO (SyntaxTerm DefaultFields) toTerm node@TS.Node{..} = do name <- peekCString nodeType From 817000ff52e636082b55a9eaf64e458f016d4eae Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:04:46 -0400 Subject: [PATCH 26/49] Expand parenthesized expressions in place. --- src/Language/TypeScript.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index c24c84a19..6489cb52a 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -78,6 +78,7 @@ termAssignment _ category children = _ -> Nothing -- No body found. (Ty, children) -> Just $ S.Ty children (Interface, children) -> toInterface children + (Other "parenthesized_expression", [child]) -> Just (unwrap child) _ -> Nothing categoryForTypeScriptName :: Text -> Category From 3d6bc1f03b47c97efecb4be7454301efb66862ad Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:05:16 -0400 Subject: [PATCH 27/49] Map subscript_expression to SubscriptAccess. --- src/Language/TypeScript.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 6489cb52a..9678b36d0 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -132,6 +132,7 @@ categoryForTypeScriptName category = case category of "member_access" -> MemberAccess "op" -> Operator "subscript_access" -> SubscriptAccess + "subscript_expression" -> SubscriptAccess "regex" -> Regex "template_string" -> TemplateString "switch_statement" -> Switch From 362c3c7e4cd4b9e6f1093d3906ec414e693eea89 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:11:13 -0400 Subject: [PATCH 28/49] =?UTF-8?q?Don=E2=80=99t=20unwrap=20parenthesized=20?= =?UTF-8?q?expressions=20that=20way.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Language/TypeScript.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 9678b36d0..1ed6a9ffd 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -78,7 +78,6 @@ termAssignment _ category children = _ -> Nothing -- No body found. (Ty, children) -> Just $ S.Ty children (Interface, children) -> toInterface children - (Other "parenthesized_expression", [child]) -> Just (unwrap child) _ -> Nothing categoryForTypeScriptName :: Text -> Category From d61967e238ccfff64aa83fff8bab81c9dd0d4ce8 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:14:58 -0400 Subject: [PATCH 29/49] =?UTF-8?q?Don=E2=80=99t=20export=20defaultTermAssig?= =?UTF-8?q?nment.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TreeSitter.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index c9b325a3a..8c7939ce8 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -2,7 +2,6 @@ module TreeSitter ( treeSitterParser , parseToAST -, defaultTermAssignment ) where import Category From f9600f91d2810aa46c5105325b9d5a05d043733b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:18:08 -0400 Subject: [PATCH 30/49] Construct complete Terms in defaultTermAssignment. --- src/TreeSitter.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 8c7939ce8..2039e4852 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -108,9 +108,9 @@ nodeSpan TS.Node{..} = nodeStartPoint `seq` nodeEndPoint `seq` Span (pointPos no assignTerm :: Ptr TS.Language -> Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields) assignTerm language source annotation children allChildren = - cofree . (annotation :<) <$> case assignTermByLanguage source (category annotation) children of - Just a -> pure a - _ -> defaultTermAssignment source (category annotation) children allChildren + case assignTermByLanguage source (category annotation) children of + Just a -> pure (cofree (annotation :< a)) + _ -> defaultTermAssignment source annotation children allChildren where assignTermByLanguage :: Source -> Category -> [ SyntaxTerm DefaultFields ] -> Maybe (S.Syntax (SyntaxTerm DefaultFields)) assignTermByLanguage = case languageForTSLanguage language of Just Language.Go -> Go.termAssignment @@ -118,10 +118,10 @@ assignTerm language source annotation children allChildren = Just TypeScript -> TS.termAssignment _ -> \ _ _ _ -> Nothing -defaultTermAssignment :: Source -> Category -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (S.Syntax (SyntaxTerm DefaultFields)) -defaultTermAssignment source category children allChildren - | category `elem` operatorCategories = S.Operator <$> allChildren - | otherwise = pure $! case (category, children) of +defaultTermAssignment :: Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields) +defaultTermAssignment source annotation children allChildren + | category annotation `elem` operatorCategories = cofree . (annotation :<) . S.Operator <$> allChildren + | otherwise = pure . cofree . (annotation :<) $ case (category annotation, children) of (ParseError, children) -> S.ParseError children (Comment, _) -> S.Comment (toText source) From b08ea229d684b7b3a0c7c937b439ab5fbe436140 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:20:12 -0400 Subject: [PATCH 31/49] Drop parenthesized expression nodes. --- src/TreeSitter.hs | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 2039e4852..804031630 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -121,30 +121,32 @@ assignTerm language source annotation children allChildren = defaultTermAssignment :: Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields) defaultTermAssignment source annotation children allChildren | category annotation `elem` operatorCategories = cofree . (annotation :<) . S.Operator <$> allChildren - | otherwise = pure . cofree . (annotation :<) $ case (category annotation, children) of - (ParseError, children) -> S.ParseError children + | otherwise = pure $! case (category annotation, children) of + (ParseError, children) -> toTerm $ S.ParseError children - (Comment, _) -> S.Comment (toText source) + (Comment, _) -> toTerm $ S.Comment (toText source) - (Pair, [key, value]) -> S.Pair key value + (Pair, [key, value]) -> toTerm $ S.Pair key value -- Control flow statements - (If, condition : body) -> S.If condition body - (Switch, _) -> uncurry S.Switch (break ((== Case) . Info.category . extract) children) - (Case, expr : body) -> S.Case expr body - (While, expr : rest) -> S.While expr rest + (If, condition : body) -> toTerm $ S.If condition body + (Switch, _) -> toTerm $ uncurry S.Switch (break ((== Case) . Info.category . extract) children) + (Case, expr : body) -> toTerm $ S.Case expr body + (While, expr : rest) -> toTerm $ S.While expr rest -- Statements - (Return, _) -> S.Return children - (Yield, _) -> S.Yield children - (Throw, [expr]) -> S.Throw expr - (Break, [label]) -> S.Break (Just label) - (Break, []) -> S.Break Nothing - (Continue, [label]) -> S.Continue (Just label) - (Continue, []) -> S.Continue Nothing + (Return, _) -> toTerm $ S.Return children + (Yield, _) -> toTerm $ S.Yield children + (Throw, [expr]) -> toTerm $ S.Throw expr + (Break, [label]) -> toTerm $ S.Break (Just label) + (Break, []) -> toTerm $ S.Break Nothing + (Continue, [label]) -> toTerm $ S.Continue (Just label) + (Continue, []) -> toTerm $ S.Continue Nothing - (_, []) -> S.Leaf (toText source) - (_, children) -> S.Indexed children + (ParenthesizedExpression, [child]) -> child + + (_, []) -> toTerm $ S.Leaf (toText source) + (_, children) -> toTerm $ S.Indexed children where operatorCategories = [ Operator , Binary @@ -156,6 +158,7 @@ defaultTermAssignment source annotation children allChildren , RelationalOperator , BitwiseOperator ] + toTerm = cofree . (annotation :<) categoryForLanguageProductionName :: Ptr TS.Language -> Text -> Category From 96230f04b6454b977363a07dc0f807a901a623e1 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:25:19 -0400 Subject: [PATCH 32/49] Flatten switch_body nodes out. --- src/TreeSitter.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 804031630..8aa14813c 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -6,10 +6,12 @@ module TreeSitter import Category import Control.Comonad (extract) +import Control.Comonad.Cofree (unwrap) import Control.Exception import Control.Monad ((<=<)) import Data.Blob import Data.ByteString.Unsafe (unsafeUseAsCStringLen) +import Data.Foldable (toList) import Data.Functor.Foldable hiding (Nil) import Data.Range import Data.Record @@ -130,7 +132,7 @@ defaultTermAssignment source annotation children allChildren -- Control flow statements (If, condition : body) -> toTerm $ S.If condition body - (Switch, _) -> toTerm $ uncurry S.Switch (break ((== Case) . Info.category . extract) children) + (Switch, _) -> let (subject, body) = break ((== Other "switch_body") . Info.category . extract) children in toTerm $ S.Switch subject (body >>= toList . unwrap) (Case, expr : body) -> toTerm $ S.Case expr body (While, expr : rest) -> toTerm $ S.While expr rest From 57fe826d9f53347db14e62202323330b5538c8fd Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:26:14 -0400 Subject: [PATCH 33/49] Map a bunch of category names. --- src/Language/TypeScript.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 1ed6a9ffd..14667b864 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -95,6 +95,7 @@ categoryForTypeScriptName category = case category of "arrow_function" -> Function "generator_function" -> Function "math_op" -> MathOperator -- math operator, e.g. +, -, *, /. + "update_expression" -> MathOperator -- math operator, e.g. ++, -- "bool_op" -> BooleanOperator -- boolean operator, e.g. ||, &&. "comma_op" -> CommaOperator -- comma operator, e.g. expr1, expr2. "delete_op" -> Operator -- delete operator, e.g. delete x[2]. @@ -109,12 +110,15 @@ categoryForTypeScriptName category = case category of "new_expression" -> Constructor "class" -> Class "catch" -> Catch + "catch_clause" -> Catch "finally" -> Finally + "finally_clause" -> Finally "if_statement" -> If "trailing_if_statement" -> If "empty_statement" -> Empty "program" -> Program "function_call" -> FunctionCall + "call_expression" -> FunctionCall "pair" -> Pair "string" -> StringLiteral "integer" -> IntegerLiteral @@ -128,7 +132,9 @@ categoryForTypeScriptName category = case category of "arguments" -> Args "statement_block" -> ExpressionStatements "assignment" -> Assignment + "assignment_expression" -> Assignment "member_access" -> MemberAccess + "member_expression" -> MemberAccess "op" -> Operator "subscript_access" -> SubscriptAccess "subscript_expression" -> SubscriptAccess @@ -136,10 +142,13 @@ categoryForTypeScriptName category = case category of "template_string" -> TemplateString "switch_statement" -> Switch "math_assignment" -> MathAssignment + "augmented_assignment_expression" -> MathAssignment "case" -> Case + "switch_case" -> Case "true" -> Boolean "false" -> Boolean "ternary" -> Ternary + "ternary_expression" -> Ternary "while_statement" -> While "trailing_while_statement" -> While "do_statement" -> DoWhile @@ -165,4 +174,7 @@ categoryForTypeScriptName category = case category of "module" -> Module "internal_module" -> Namespace "interface_declaration" -> Interface + "unary_expression" -> Operator + "binary_expression" -> Operator + "parenthesized_expression" -> ParenthesizedExpression name -> Other name From a8e32d6739003d219ea3c1dadd5d91011e0dab4f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:29:01 -0400 Subject: [PATCH 34/49] Factor pure into toTerm. --- src/TreeSitter.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 8aa14813c..d8b585920 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -123,7 +123,7 @@ assignTerm language source annotation children allChildren = defaultTermAssignment :: Source -> Record DefaultFields -> [ SyntaxTerm DefaultFields ] -> IO [ SyntaxTerm DefaultFields ] -> IO (SyntaxTerm DefaultFields) defaultTermAssignment source annotation children allChildren | category annotation `elem` operatorCategories = cofree . (annotation :<) . S.Operator <$> allChildren - | otherwise = pure $! case (category annotation, children) of + | otherwise = case (category annotation, children) of (ParseError, children) -> toTerm $ S.ParseError children (Comment, _) -> toTerm $ S.Comment (toText source) @@ -145,7 +145,7 @@ defaultTermAssignment source annotation children allChildren (Continue, [label]) -> toTerm $ S.Continue (Just label) (Continue, []) -> toTerm $ S.Continue Nothing - (ParenthesizedExpression, [child]) -> child + (ParenthesizedExpression, [child]) -> pure child (_, []) -> toTerm $ S.Leaf (toText source) (_, children) -> toTerm $ S.Indexed children @@ -160,7 +160,7 @@ defaultTermAssignment source annotation children allChildren , RelationalOperator , BitwiseOperator ] - toTerm = cofree . (annotation :<) + toTerm = pure . cofree . (annotation :<) categoryForLanguageProductionName :: Ptr TS.Language -> Text -> Category From 2e0c870a82a3ac2e402f6491a80f9fb99ab7d307 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:40:18 -0400 Subject: [PATCH 35/49] Handle some operators in defaultTermAssignment. --- src/Language/TypeScript.hs | 2 -- src/TreeSitter.hs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 14667b864..7a574b96c 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -174,7 +174,5 @@ categoryForTypeScriptName category = case category of "module" -> Module "internal_module" -> Namespace "interface_declaration" -> Interface - "unary_expression" -> Operator - "binary_expression" -> Operator "parenthesized_expression" -> ParenthesizedExpression name -> Other name diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index d8b585920..650972b72 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -147,6 +147,22 @@ defaultTermAssignment source annotation children allChildren (ParenthesizedExpression, [child]) -> pure child + (Other "unary_expression", _) -> do + cs <- allChildren + let c = case category . extract <$> cs of + [Other "-", _] -> MathOperator + _ -> Operator + pure (cofree ((setCategory annotation c) :< S.Operator cs)) + + (Other "binary_expression", _) -> do + cs <- allChildren + let c = case category . extract <$> cs of + [_, Other s, _] + | s `elem` ["<=", "<", ">=", ">"] -> RelationalOperator + | s `elem` ["*", "+", "-", "/", "%"] -> MathOperator + _ -> Operator + pure (cofree ((setCategory annotation c) :< S.Operator cs)) + (_, []) -> toTerm $ S.Leaf (toText source) (_, children) -> toTerm $ S.Indexed children where operatorCategories = From 04ce0c89c63e9349ce52a83afce463adb2fa8c43 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:46:08 -0400 Subject: [PATCH 36/49] Match BooleanOperators. --- src/TreeSitter.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 650972b72..be24ad183 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -160,6 +160,7 @@ defaultTermAssignment source annotation children allChildren [_, Other s, _] | s `elem` ["<=", "<", ">=", ">"] -> RelationalOperator | s `elem` ["*", "+", "-", "/", "%"] -> MathOperator + | s `elem` ["&&", "||"] -> BooleanOperator _ -> Operator pure (cofree ((setCategory annotation c) :< S.Operator cs)) From 1f26be577a4f48def4e3bcfed9dcbbb757c24f05 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:53:08 -0400 Subject: [PATCH 37/49] Assign a bunch more operators. --- src/TreeSitter.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index be24ad183..04e4ab417 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -150,7 +150,12 @@ defaultTermAssignment source annotation children allChildren (Other "unary_expression", _) -> do cs <- allChildren let c = case category . extract <$> cs of - [Other "-", _] -> MathOperator + [Other s, _] + | s `elem` ["-", "+", "++", "--"] -> MathOperator + | s == "~" -> BitwiseOperator + | s == "!" -> BooleanOperator + [_, Other t] + | t `elem` ["--", "++"] -> MathOperator _ -> Operator pure (cofree ((setCategory annotation c) :< S.Operator cs)) @@ -158,9 +163,10 @@ defaultTermAssignment source annotation children allChildren cs <- allChildren let c = case category . extract <$> cs of [_, Other s, _] - | s `elem` ["<=", "<", ">=", ">"] -> RelationalOperator + | s `elem` ["<=", "<", ">=", ">", "==", "===", "!=", "!=="] -> RelationalOperator | s `elem` ["*", "+", "-", "/", "%"] -> MathOperator | s `elem` ["&&", "||"] -> BooleanOperator + | s `elem` [">>", ">>=", ">>>", ">>>=", "<<", "<<=", "&", "^", "|"] -> BitwiseOperator _ -> Operator pure (cofree ((setCategory annotation c) :< S.Operator cs)) From 0e2c4180381fa01e92ed12bd0d52b57ff1db2ca3 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 09:57:03 -0400 Subject: [PATCH 38/49] Ensure we treat /dev/null as empty. --- src/Files.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Files.hs b/src/Files.hs index 1b557a9a1..8445593f8 100644 --- a/src/Files.hs +++ b/src/Files.hs @@ -29,6 +29,7 @@ import Text.Read -- | Read a utf8-encoded file to a 'Blob'. readFile :: forall m. MonadIO m => FilePath -> Maybe Language -> m Blob.Blob +readFile path@"/dev/null" _ = pure (Blob.emptyBlob path) readFile path language = do raw <- liftIO $ (Just <$> B.readFile path) `catch` (const (pure Nothing) :: IOException -> IO (Maybe B.ByteString)) pure $ fromMaybe (Blob.emptyBlob path) (Blob.sourceBlob path language . fromBytes <$> raw) From 048b7874d17ea6f7464ca2163a5e80ed8ba60ad1 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 10:05:25 -0400 Subject: [PATCH 39/49] Correct the Go fixtures. --- test/fixtures/go/constructors.diff+A.txt | 7 +++---- test/fixtures/go/constructors.diff+B.txt | 7 +++---- test/fixtures/go/constructors.diff-A.txt | 7 +++---- test/fixtures/go/constructors.diff-B.txt | 7 +++---- test/fixtures/go/constructors.diffA-B.txt | 7 +++---- test/fixtures/go/constructors.diffB-A.txt | 7 +++---- test/fixtures/go/constructors.parseA.txt | 7 +++---- test/fixtures/go/constructors.parseB.txt | 7 +++---- .../go/type-conversion-expressions.diff+A.txt | 7 +++---- .../go/type-conversion-expressions.diff+B.txt | 7 +++---- .../go/type-conversion-expressions.diff-A.txt | 7 +++---- .../go/type-conversion-expressions.diff-B.txt | 7 +++---- .../go/type-conversion-expressions.diffA-B.txt | 11 +++++------ .../go/type-conversion-expressions.diffB-A.txt | 11 +++++------ .../go/type-conversion-expressions.parseA.txt | 7 +++---- .../go/type-conversion-expressions.parseB.txt | 7 +++---- 16 files changed, 52 insertions(+), 68 deletions(-) diff --git a/test/fixtures/go/constructors.diff+A.txt b/test/fixtures/go/constructors.diff+A.txt index 37dfd5c8b..4e0e54ee4 100644 --- a/test/fixtures/go/constructors.diff+A.txt +++ b/test/fixtures/go/constructors.diff+A.txt @@ -12,10 +12,9 @@ (Identifier) (ChannelTy (Identifier)) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.diff+B.txt b/test/fixtures/go/constructors.diff+B.txt index 37dfd5c8b..4e0e54ee4 100644 --- a/test/fixtures/go/constructors.diff+B.txt +++ b/test/fixtures/go/constructors.diff+B.txt @@ -12,10 +12,9 @@ (Identifier) (ChannelTy (Identifier)) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.diff-A.txt b/test/fixtures/go/constructors.diff-A.txt index f88d0b5fb..5e3f4cf31 100644 --- a/test/fixtures/go/constructors.diff-A.txt +++ b/test/fixtures/go/constructors.diff-A.txt @@ -12,10 +12,9 @@ (Identifier) (ChannelTy (Identifier)) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.diff-B.txt b/test/fixtures/go/constructors.diff-B.txt index f88d0b5fb..5e3f4cf31 100644 --- a/test/fixtures/go/constructors.diff-B.txt +++ b/test/fixtures/go/constructors.diff-B.txt @@ -12,10 +12,9 @@ (Identifier) (ChannelTy (Identifier)) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.diffA-B.txt b/test/fixtures/go/constructors.diffA-B.txt index b8b84248b..a805732f2 100644 --- a/test/fixtures/go/constructors.diffA-B.txt +++ b/test/fixtures/go/constructors.diffA-B.txt @@ -14,10 +14,9 @@ (ChannelTy { (Identifier) ->(Identifier) }) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.diffB-A.txt b/test/fixtures/go/constructors.diffB-A.txt index b8b84248b..a805732f2 100644 --- a/test/fixtures/go/constructors.diffB-A.txt +++ b/test/fixtures/go/constructors.diffB-A.txt @@ -14,10 +14,9 @@ (ChannelTy { (Identifier) ->(Identifier) }) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.parseA.txt b/test/fixtures/go/constructors.parseA.txt index 6f716b764..7d7c8d716 100644 --- a/test/fixtures/go/constructors.parseA.txt +++ b/test/fixtures/go/constructors.parseA.txt @@ -12,10 +12,9 @@ (Identifier) (ChannelTy (Identifier)) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/constructors.parseB.txt b/test/fixtures/go/constructors.parseB.txt index 6f716b764..7d7c8d716 100644 --- a/test/fixtures/go/constructors.parseB.txt +++ b/test/fixtures/go/constructors.parseB.txt @@ -12,10 +12,9 @@ (Identifier) (ChannelTy (Identifier)) - (ParenthesizedExpression - (RelationalOperator - (Identifier) - (Identifier)))) + (RelationalOperator + (Identifier) + (Identifier))) (FunctionCall (Identifier) (ChannelTy diff --git a/test/fixtures/go/type-conversion-expressions.diff+A.txt b/test/fixtures/go/type-conversion-expressions.diff+A.txt index 7277b212b..2c4a21793 100644 --- a/test/fixtures/go/type-conversion-expressions.diff+A.txt +++ b/test/fixtures/go/type-conversion-expressions.diff+A.txt @@ -23,8 +23,7 @@ (Identifier)) (Identifier)) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - (Identifier) - (Identifier))) + (SubscriptAccess + (Identifier) + (Identifier)) (Identifier))))+} diff --git a/test/fixtures/go/type-conversion-expressions.diff+B.txt b/test/fixtures/go/type-conversion-expressions.diff+B.txt index 7277b212b..2c4a21793 100644 --- a/test/fixtures/go/type-conversion-expressions.diff+B.txt +++ b/test/fixtures/go/type-conversion-expressions.diff+B.txt @@ -23,8 +23,7 @@ (Identifier)) (Identifier)) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - (Identifier) - (Identifier))) + (SubscriptAccess + (Identifier) + (Identifier)) (Identifier))))+} diff --git a/test/fixtures/go/type-conversion-expressions.diff-A.txt b/test/fixtures/go/type-conversion-expressions.diff-A.txt index ab98f4d74..bbea53595 100644 --- a/test/fixtures/go/type-conversion-expressions.diff-A.txt +++ b/test/fixtures/go/type-conversion-expressions.diff-A.txt @@ -23,8 +23,7 @@ (Identifier)) (Identifier)) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - (Identifier) - (Identifier))) + (SubscriptAccess + (Identifier) + (Identifier)) (Identifier))))-} diff --git a/test/fixtures/go/type-conversion-expressions.diff-B.txt b/test/fixtures/go/type-conversion-expressions.diff-B.txt index ab98f4d74..bbea53595 100644 --- a/test/fixtures/go/type-conversion-expressions.diff-B.txt +++ b/test/fixtures/go/type-conversion-expressions.diff-B.txt @@ -23,8 +23,7 @@ (Identifier)) (Identifier)) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - (Identifier) - (Identifier))) + (SubscriptAccess + (Identifier) + (Identifier)) (Identifier))))-} diff --git a/test/fixtures/go/type-conversion-expressions.diffA-B.txt b/test/fixtures/go/type-conversion-expressions.diffA-B.txt index 201e00e62..6af3d23d3 100644 --- a/test/fixtures/go/type-conversion-expressions.diffA-B.txt +++ b/test/fixtures/go/type-conversion-expressions.diffA-B.txt @@ -32,11 +32,10 @@ { (Identifier) ->(Identifier) }) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })) + (SubscriptAccess + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) }) { (Identifier) ->(Identifier) }))) diff --git a/test/fixtures/go/type-conversion-expressions.diffB-A.txt b/test/fixtures/go/type-conversion-expressions.diffB-A.txt index 201e00e62..6af3d23d3 100644 --- a/test/fixtures/go/type-conversion-expressions.diffB-A.txt +++ b/test/fixtures/go/type-conversion-expressions.diffB-A.txt @@ -32,11 +32,10 @@ { (Identifier) ->(Identifier) }) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })) + (SubscriptAccess + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) }) { (Identifier) ->(Identifier) }))) diff --git a/test/fixtures/go/type-conversion-expressions.parseA.txt b/test/fixtures/go/type-conversion-expressions.parseA.txt index 3feb0a558..0dea327f8 100644 --- a/test/fixtures/go/type-conversion-expressions.parseA.txt +++ b/test/fixtures/go/type-conversion-expressions.parseA.txt @@ -23,8 +23,7 @@ (Identifier)) (Identifier)) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - (Identifier) - (Identifier))) + (SubscriptAccess + (Identifier) + (Identifier)) (Identifier)))) diff --git a/test/fixtures/go/type-conversion-expressions.parseB.txt b/test/fixtures/go/type-conversion-expressions.parseB.txt index 3feb0a558..0dea327f8 100644 --- a/test/fixtures/go/type-conversion-expressions.parseB.txt +++ b/test/fixtures/go/type-conversion-expressions.parseB.txt @@ -23,8 +23,7 @@ (Identifier)) (Identifier)) (FunctionCall - (ParenthesizedExpression - (SubscriptAccess - (Identifier) - (Identifier))) + (SubscriptAccess + (Identifier) + (Identifier)) (Identifier)))) From ffa33bbe0fbe4268a0c68426c66df5b4e81b08e4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 10:11:34 -0400 Subject: [PATCH 40/49] Unwrap expression statements in for loops. --- src/Language/TypeScript.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 7a574b96c..37abf404b 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -69,7 +69,7 @@ termAssignment _ category children = | S.Indexed _ <- unwrap statements -> Just $ S.Export Nothing (toList (unwrap statements)) | otherwise -> Just $ S.Export (Just statements) [] - (For, _:_) -> Just $ S.For (init children) [last children] + (For, _:_) -> Just $ S.For (init children >>= unwrapExpressionStatements) [last children] (Function, children) -> case break ((== ExpressionStatements) . Info.category . extract) children of (inits, [body]) -> case inits of [id, callSignature] -> Just $ S.Function id (toList (unwrap callSignature)) (toList (unwrap body)) @@ -79,6 +79,9 @@ termAssignment _ category children = (Ty, children) -> Just $ S.Ty children (Interface, children) -> toInterface children _ -> Nothing + where unwrapExpressionStatements term + | Info.category (extract term) == ExpressionStatements = toList (unwrap term) + | otherwise = [term] categoryForTypeScriptName :: Text -> Category categoryForTypeScriptName category = case category of From 9effa7aea11ecccd527f180ba3a3d768ee816905 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 10:15:16 -0400 Subject: [PATCH 41/49] Flatten expression statements involving sequence expressions. --- src/Language/TypeScript.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 37abf404b..76b713a51 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -69,7 +69,7 @@ termAssignment _ category children = | S.Indexed _ <- unwrap statements -> Just $ S.Export Nothing (toList (unwrap statements)) | otherwise -> Just $ S.Export (Just statements) [] - (For, _:_) -> Just $ S.For (init children >>= unwrapExpressionStatements) [last children] + (For, _:_) -> Just $ S.For (init children >>= flattenExpressionStatements) [last children] (Function, children) -> case break ((== ExpressionStatements) . Info.category . extract) children of (inits, [body]) -> case inits of [id, callSignature] -> Just $ S.Function id (toList (unwrap callSignature)) (toList (unwrap body)) @@ -79,8 +79,8 @@ termAssignment _ category children = (Ty, children) -> Just $ S.Ty children (Interface, children) -> toInterface children _ -> Nothing - where unwrapExpressionStatements term - | Info.category (extract term) == ExpressionStatements = toList (unwrap term) + where flattenExpressionStatements term + | Info.category (extract term) `elem` [ExpressionStatements, Other "sequence_expression"] = toList (unwrap term) >>= flattenExpressionStatements | otherwise = [term] categoryForTypeScriptName :: Text -> Category From 01e5ddb1cb2f0e5883550f97084db32f8bcc71c7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Aug 2017 10:16:06 -0400 Subject: [PATCH 42/49] Map sequence_expression to CommaOperator. --- src/Language/TypeScript.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Language/TypeScript.hs b/src/Language/TypeScript.hs index 76b713a51..03cc8cb4a 100644 --- a/src/Language/TypeScript.hs +++ b/src/Language/TypeScript.hs @@ -80,7 +80,7 @@ termAssignment _ category children = (Interface, children) -> toInterface children _ -> Nothing where flattenExpressionStatements term - | Info.category (extract term) `elem` [ExpressionStatements, Other "sequence_expression"] = toList (unwrap term) >>= flattenExpressionStatements + | Info.category (extract term) `elem` [ExpressionStatements, CommaOperator] = toList (unwrap term) >>= flattenExpressionStatements | otherwise = [term] categoryForTypeScriptName :: Text -> Category @@ -101,6 +101,7 @@ categoryForTypeScriptName category = case category of "update_expression" -> MathOperator -- math operator, e.g. ++, -- "bool_op" -> BooleanOperator -- boolean operator, e.g. ||, &&. "comma_op" -> CommaOperator -- comma operator, e.g. expr1, expr2. + "sequence_expression" -> CommaOperator -- comma operator, e.g. expr1, expr2. "delete_op" -> Operator -- delete operator, e.g. delete x[2]. "type_op" -> Operator -- type operator, e.g. typeof Object. "void_op" -> Operator -- void operator, e.g. void 2. From 3104c547e8a132c07c9089d99bd16d23cacdbd7f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 20:00:56 -0400 Subject: [PATCH 43/49] Revert the language submodules to master. --- vendor/tree-sitter-go | 2 +- vendor/tree-sitter-json | 2 +- vendor/tree-sitter-python | 2 +- vendor/tree-sitter-ruby | 2 +- vendor/tree-sitter-typescript | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/tree-sitter-go b/vendor/tree-sitter-go index d61655aaa..025ece6dd 160000 --- a/vendor/tree-sitter-go +++ b/vendor/tree-sitter-go @@ -1 +1 @@ -Subproject commit d61655aaac02b01b52ff1bdb2d90be3d1a466bb0 +Subproject commit 025ece6ddcdf3e3cbc6c865e2d2c010217fbf90f diff --git a/vendor/tree-sitter-json b/vendor/tree-sitter-json index fe5a6b816..26e014795 160000 --- a/vendor/tree-sitter-json +++ b/vendor/tree-sitter-json @@ -1 +1 @@ -Subproject commit fe5a6b81631ddb5a380b7f1f7b1f35b09d9cc3cc +Subproject commit 26e014795f4bbbad2774f673017a457247daf0c6 diff --git a/vendor/tree-sitter-python b/vendor/tree-sitter-python index db3803ebc..24220e066 160000 --- a/vendor/tree-sitter-python +++ b/vendor/tree-sitter-python @@ -1 +1 @@ -Subproject commit db3803ebcc7b8065f509b33bf5147cabe876d570 +Subproject commit 24220e066fd65ccfa5dba65c0095705d559e97cb diff --git a/vendor/tree-sitter-ruby b/vendor/tree-sitter-ruby index e8cd528b2..0fca7f41c 160000 --- a/vendor/tree-sitter-ruby +++ b/vendor/tree-sitter-ruby @@ -1 +1 @@ -Subproject commit e8cd528b205d46a32dcd66f576cf353b8afe8d26 +Subproject commit 0fca7f41c7fdb44ca7fdecb9a94434e429b4843f diff --git a/vendor/tree-sitter-typescript b/vendor/tree-sitter-typescript index a45a662de..55d5b48c3 160000 --- a/vendor/tree-sitter-typescript +++ b/vendor/tree-sitter-typescript @@ -1 +1 @@ -Subproject commit a45a662deb7d4b3668e49940bda7b4b81f2df6ab +Subproject commit 55d5b48c3cf19dee5a4bfccb642700ef67ab6cce From 375646bb143ce326c997effb9df74851c593c6bf Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 20:12:40 -0400 Subject: [PATCH 44/49] Remove the parser submodules. --- .gitmodules | 15 --------------- vendor/tree-sitter-go | 1 - vendor/tree-sitter-json | 1 - vendor/tree-sitter-python | 1 - vendor/tree-sitter-ruby | 1 - vendor/tree-sitter-typescript | 1 - 6 files changed, 20 deletions(-) delete mode 160000 vendor/tree-sitter-go delete mode 160000 vendor/tree-sitter-json delete mode 160000 vendor/tree-sitter-python delete mode 160000 vendor/tree-sitter-ruby delete mode 160000 vendor/tree-sitter-typescript diff --git a/.gitmodules b/.gitmodules index 70ea3bf7c..a51ba2fb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,30 +13,15 @@ [submodule "vendor/effects"] path = vendor/effects url = https://github.com/joshvera/effects.git -[submodule "languages/ruby/vendor/tree-sitter-ruby"] - path = vendor/tree-sitter-ruby - url = https://github.com/tree-sitter/tree-sitter-ruby.git [submodule "languages/c/vendor/tree-sitter-c"] path = languages/c/vendor/tree-sitter-c url = https://github.com/tree-sitter/tree-sitter-c.git -[submodule "languages/go/vendor/tree-sitter-go"] - path = vendor/tree-sitter-go - url = https://github.com/tree-sitter/tree-sitter-go.git [submodule "languages/javascript/vendor/tree-sitter-javascript"] path = languages/javascript/vendor/tree-sitter-javascript url = https://github.com/tree-sitter/tree-sitter-javascript.git [submodule "vendor/haskell-tree-sitter"] path = vendor/haskell-tree-sitter url = https://github.com/tree-sitter/haskell-tree-sitter.git -[submodule "languages/typescript/vendor/tree-sitter-typescript"] - path = vendor/tree-sitter-typescript - url = https://github.com/tree-sitter/tree-sitter-typescript/ -[submodule "languages/python/vendor/tree-sitter-python"] - path = vendor/tree-sitter-python - url = https://github.com/tree-sitter/tree-sitter-python.git -[submodule "languages/json/vendor/tree-sitter-json"] - path = vendor/tree-sitter-json - url = https://github.com/tree-sitter/tree-sitter-json [submodule "vendor/freer-cofreer"] path = vendor/freer-cofreer url = https://github.com/robrix/freer-cofreer.git diff --git a/vendor/tree-sitter-go b/vendor/tree-sitter-go deleted file mode 160000 index 025ece6dd..000000000 --- a/vendor/tree-sitter-go +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 025ece6ddcdf3e3cbc6c865e2d2c010217fbf90f diff --git a/vendor/tree-sitter-json b/vendor/tree-sitter-json deleted file mode 160000 index 26e014795..000000000 --- a/vendor/tree-sitter-json +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 26e014795f4bbbad2774f673017a457247daf0c6 diff --git a/vendor/tree-sitter-python b/vendor/tree-sitter-python deleted file mode 160000 index 24220e066..000000000 --- a/vendor/tree-sitter-python +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 24220e066fd65ccfa5dba65c0095705d559e97cb diff --git a/vendor/tree-sitter-ruby b/vendor/tree-sitter-ruby deleted file mode 160000 index 0fca7f41c..000000000 --- a/vendor/tree-sitter-ruby +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0fca7f41c7fdb44ca7fdecb9a94434e429b4843f diff --git a/vendor/tree-sitter-typescript b/vendor/tree-sitter-typescript deleted file mode 160000 index 55d5b48c3..000000000 --- a/vendor/tree-sitter-typescript +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 55d5b48c3cf19dee5a4bfccb642700ef67ab6cce From eee15954e371f5267ea2e97c44521a2f6c77abd1 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 20:12:51 -0400 Subject: [PATCH 45/49] Bump haskell-tree-sitter to include the language packages. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 6d198141f..e772ff863 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 6d198141f8bb834057defcc26aec9cc98ac9b86f +Subproject commit e772ff8635fea8c25c358338566bdd3d753c142c From 260d5c52109e88aca53e2ec567205bc8929478a9 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 20:14:03 -0400 Subject: [PATCH 46/49] Add the language packages. --- cabal.project | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index 77a952354..c617c49c8 100644 --- a/cabal.project +++ b/cabal.project @@ -1,4 +1,3 @@ -packages: ./ tools/*/ -optional-packages: vendor/*/ +packages: ./ tools/*/ vendor/*/ vendor/haskell-tree-sitter/languages/*/ jobs: $ncpus From bea008329bf94619d5b0bb849dcc0f69da3d3257 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 20:16:47 -0400 Subject: [PATCH 47/49] Bump haskell-tree-sitter. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index e772ff863..d14c28f58 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit e772ff8635fea8c25c358338566bdd3d753c142c +Subproject commit d14c28f58d0bef3c6201a06958810c7773b2e131 From a8b98b98925e04746b558d73b432e19066eebbcb Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 14 Aug 2017 20:56:11 -0400 Subject: [PATCH 48/49] Bump the examples for for/in nodes. --- test/fixtures/ruby/for.diff+A.txt | 6 ++++-- test/fixtures/ruby/for.diff+B.txt | 9 +++++---- test/fixtures/ruby/for.diff-A.txt | 6 ++++-- test/fixtures/ruby/for.diff-B.txt | 9 +++++---- test/fixtures/ruby/for.diffA-B.txt | 14 ++++++++------ test/fixtures/ruby/for.diffB-A.txt | 14 ++++++++------ test/fixtures/ruby/for.parseA.txt | 6 ++++-- test/fixtures/ruby/for.parseB.txt | 9 +++++---- 8 files changed, 43 insertions(+), 30 deletions(-) diff --git a/test/fixtures/ruby/for.diff+A.txt b/test/fixtures/ruby/for.diff+A.txt index 4aad30e48..e68dcfcef 100644 --- a/test/fixtures/ruby/for.diff+A.txt +++ b/test/fixtures/ruby/for.diff+A.txt @@ -1,10 +1,12 @@ {+(Program (For (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier)) (For (Identifier) (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier)))+} diff --git a/test/fixtures/ruby/for.diff+B.txt b/test/fixtures/ruby/for.diff+B.txt index b2447923f..6092192e6 100644 --- a/test/fixtures/ruby/for.diff+B.txt +++ b/test/fixtures/ruby/for.diff+B.txt @@ -1,10 +1,11 @@ {+(Program (For (Identifier) - (ArrayLiteral - (IntegerLiteral) - (IntegerLiteral) - (IntegerLiteral)) + (Other "in" + (ArrayLiteral + (IntegerLiteral) + (IntegerLiteral) + (IntegerLiteral))) (MethodCall (Identifier) (Identifier))))+} diff --git a/test/fixtures/ruby/for.diff-A.txt b/test/fixtures/ruby/for.diff-A.txt index 52234513f..e59be77ee 100644 --- a/test/fixtures/ruby/for.diff-A.txt +++ b/test/fixtures/ruby/for.diff-A.txt @@ -1,10 +1,12 @@ {-(Program (For (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier)) (For (Identifier) (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier)))-} diff --git a/test/fixtures/ruby/for.diff-B.txt b/test/fixtures/ruby/for.diff-B.txt index 3a76a5b92..79d24c5b6 100644 --- a/test/fixtures/ruby/for.diff-B.txt +++ b/test/fixtures/ruby/for.diff-B.txt @@ -1,10 +1,11 @@ {-(Program (For (Identifier) - (ArrayLiteral - (IntegerLiteral) - (IntegerLiteral) - (IntegerLiteral)) + (Other "in" + (ArrayLiteral + (IntegerLiteral) + (IntegerLiteral) + (IntegerLiteral))) (MethodCall (Identifier) (Identifier))))-} diff --git a/test/fixtures/ruby/for.diffA-B.txt b/test/fixtures/ruby/for.diffA-B.txt index a8739ee49..5f3ec59f3 100644 --- a/test/fixtures/ruby/for.diffA-B.txt +++ b/test/fixtures/ruby/for.diffA-B.txt @@ -2,11 +2,12 @@ (For { (Identifier) ->(Identifier) } - { (Identifier) - ->(ArrayLiteral - (IntegerLiteral) - (IntegerLiteral) - (IntegerLiteral)) } + (Other "in" + {+(ArrayLiteral + (IntegerLiteral) + (IntegerLiteral) + (IntegerLiteral))+} + {-(Identifier)-}) { (Identifier) ->(MethodCall (Identifier) @@ -14,5 +15,6 @@ {-(For (Identifier) (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier))-}) diff --git a/test/fixtures/ruby/for.diffB-A.txt b/test/fixtures/ruby/for.diffB-A.txt index c4e0b00cf..e13e35321 100644 --- a/test/fixtures/ruby/for.diffB-A.txt +++ b/test/fixtures/ruby/for.diffB-A.txt @@ -2,11 +2,12 @@ (For { (Identifier) ->(Identifier) } - { (ArrayLiteral - (IntegerLiteral) - (IntegerLiteral) - (IntegerLiteral)) - ->(Identifier) } + (Other "in" + {+(Identifier)+} + {-(ArrayLiteral + (IntegerLiteral) + (IntegerLiteral) + (IntegerLiteral))-}) { (MethodCall (Identifier) (Identifier)) @@ -14,5 +15,6 @@ {+(For (Identifier) (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier))+}) diff --git a/test/fixtures/ruby/for.parseA.txt b/test/fixtures/ruby/for.parseA.txt index 1fd18400c..190298e8c 100644 --- a/test/fixtures/ruby/for.parseA.txt +++ b/test/fixtures/ruby/for.parseA.txt @@ -1,10 +1,12 @@ (Program (For (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier)) (For (Identifier) (Identifier) - (Identifier) + (Other "in" + (Identifier)) (Identifier))) diff --git a/test/fixtures/ruby/for.parseB.txt b/test/fixtures/ruby/for.parseB.txt index 166809b4c..0fcc816fd 100644 --- a/test/fixtures/ruby/for.parseB.txt +++ b/test/fixtures/ruby/for.parseB.txt @@ -1,10 +1,11 @@ (Program (For (Identifier) - (ArrayLiteral - (IntegerLiteral) - (IntegerLiteral) - (IntegerLiteral)) + (Other "in" + (ArrayLiteral + (IntegerLiteral) + (IntegerLiteral) + (IntegerLiteral))) (MethodCall (Identifier) (Identifier)))) From 5e8af37b455563a87608118df6bf8d1b88a027c5 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 15 Aug 2017 08:53:45 -0400 Subject: [PATCH 49/49] Bump haskell-tree-sitter to master. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index d14c28f58..45bbc5aff 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit d14c28f58d0bef3c6201a06958810c7773b2e131 +Subproject commit 45bbc5aff11ac5d4364b024d5b8693c297ee9ebb