Skip to content

mergestat/treequery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card BuildStatus

treequery

treequery is a CLI for executing Tree-sitter queries on source code files. It uses enry to detect a language and apply the right Tree-sitter parser. The default output includes a list of line number locations where there's a query match, followed by a snippet of the matching code. It will eventually be integrated into askgit.

Getting Started

Install with homebrew:

brew tap askgitdev/treequery
brew install treequery

Or by running make in the root of this repo, which will produce a tq binary.

> tq testdata/TriestBase.java "(method_declaration name: (identifier) @method_name)"
./treequery/testdata/TriestBase.java:20
handleEdge
./treequery/testdata/TriestBase.java:48
swapIn
./treequery/testdata/TriestBase.java:53
addEdge
./treequery/testdata/TriestBase.java:88
removeEdge
./treequery/testdata/TriestBase.java:119
getEstimate

The above example shows a way to select all method names in the testdata/TriestBase.java file. To exclude file names and line locations, use the -q (quiet) flag:

handleEdge
swapIn
addEdge
removeEdge
getEstimate

Supported Languages

  • bash
  • c
  • cpp
  • csharp
  • css
  • elm
  • golang
  • html
  • java
  • javascript
  • lua
  • ocaml
  • php
  • python
  • ruby
  • rust
  • scala
  • svelte
  • toml
  • typescript
  • yaml

About

Run Tree-sitter queries on source code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •