File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
crates/pg_treesitter_queries/src/queries Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 1+ use std:: sync:: LazyLock ;
2+
13use crate :: { Query , QueryResult } ;
24
35use super :: QueryTryFrom ;
46
5- static QUERY : & ' static str = r#"
7+ static TS_QUERY : LazyLock < tree_sitter:: Query > = LazyLock :: new ( || {
8+ static QUERY_STR : & ' static str = r#"
69 (relation
710 (object_reference
811 .
@@ -12,6 +15,8 @@ static QUERY: &'static str = r#"
1215 )+
1316 )
1417"# ;
18+ tree_sitter:: Query :: new ( tree_sitter_sql:: language ( ) , & QUERY_STR ) . expect ( "Invalid TS Query" )
19+ } ) ;
1520
1621#[ derive( Debug ) ]
1722pub struct RelationMatch < ' a > {
@@ -57,12 +62,9 @@ impl<'a> QueryTryFrom<'a> for RelationMatch<'a> {
5762
5863impl < ' a > Query < ' a > for RelationMatch < ' a > {
5964 fn execute ( root_node : tree_sitter:: Node < ' a > , stmt : & ' a str ) -> Vec < crate :: QueryResult < ' a > > {
60- let query =
61- tree_sitter:: Query :: new ( tree_sitter_sql:: language ( ) , & QUERY ) . expect ( "Invalid Query." ) ;
62-
6365 let mut cursor = tree_sitter:: QueryCursor :: new ( ) ;
6466
65- let matches = cursor. matches ( & query , root_node, stmt. as_bytes ( ) ) ;
67+ let matches = cursor. matches ( & TS_QUERY , root_node, stmt. as_bytes ( ) ) ;
6668
6769 let mut to_return = vec ! [ ] ;
6870
You can’t perform that action at this time.
0 commit comments