File tree 1 file changed +7
-5
lines changed
crates/pg_treesitter_queries/src/queries
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change
1
+ use std:: sync:: LazyLock ;
2
+
1
3
use crate :: { Query , QueryResult } ;
2
4
3
5
use super :: QueryTryFrom ;
4
6
5
- static QUERY : & ' static str = r#"
7
+ static TS_QUERY : LazyLock < tree_sitter:: Query > = LazyLock :: new ( || {
8
+ static QUERY_STR : & ' static str = r#"
6
9
(relation
7
10
(object_reference
8
11
.
@@ -12,6 +15,8 @@ static QUERY: &'static str = r#"
12
15
)+
13
16
)
14
17
"# ;
18
+ tree_sitter:: Query :: new ( tree_sitter_sql:: language ( ) , & QUERY_STR ) . expect ( "Invalid TS Query" )
19
+ } ) ;
15
20
16
21
#[ derive( Debug ) ]
17
22
pub struct RelationMatch < ' a > {
@@ -57,12 +62,9 @@ impl<'a> QueryTryFrom<'a> for RelationMatch<'a> {
57
62
58
63
impl < ' a > Query < ' a > for RelationMatch < ' a > {
59
64
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
-
63
65
let mut cursor = tree_sitter:: QueryCursor :: new ( ) ;
64
66
65
- let matches = cursor. matches ( & query , root_node, stmt. as_bytes ( ) ) ;
67
+ let matches = cursor. matches ( & TS_QUERY , root_node, stmt. as_bytes ( ) ) ;
66
68
67
69
let mut to_return = vec ! [ ] ;
68
70
You can’t perform that action at this time.
0 commit comments