@@ -137,11 +137,11 @@ pub enum CaptureQuantifier {
137137impl From < ffi:: TSQuantifier > for CaptureQuantifier {
138138 fn from ( value : ffi:: TSQuantifier ) -> Self {
139139 match value {
140- ffi:: TSQuantifier_TSQuantifierZero => CaptureQuantifier :: Zero ,
141- ffi:: TSQuantifier_TSQuantifierZeroOrOne => CaptureQuantifier :: ZeroOrOne ,
142- ffi:: TSQuantifier_TSQuantifierZeroOrMore => CaptureQuantifier :: ZeroOrMore ,
143- ffi:: TSQuantifier_TSQuantifierOne => CaptureQuantifier :: One ,
144- ffi:: TSQuantifier_TSQuantifierOneOrMore => CaptureQuantifier :: OneOrMore ,
140+ ffi:: TSQuantifierZero => CaptureQuantifier :: Zero ,
141+ ffi:: TSQuantifierZeroOrOne => CaptureQuantifier :: ZeroOrOne ,
142+ ffi:: TSQuantifierZeroOrMore => CaptureQuantifier :: ZeroOrMore ,
143+ ffi:: TSQuantifierOne => CaptureQuantifier :: One ,
144+ ffi:: TSQuantifierOneOrMore => CaptureQuantifier :: OneOrMore ,
145145 _ => panic ! ( "Unrecognized quantifier: {}" , value) ,
146146 }
147147 }
@@ -312,14 +312,12 @@ impl Language {
312312 /// Check if the node type for the given numerical id is named (as opposed
313313 /// to an anonymous node type).
314314 pub fn node_kind_is_named ( & self , id : u16 ) -> bool {
315- unsafe { ffi:: ts_language_symbol_type ( self . 0 , id) == ffi:: TSSymbolType_TSSymbolTypeRegular }
315+ unsafe { ffi:: ts_language_symbol_type ( self . 0 , id) == ffi:: TSSymbolTypeRegular }
316316 }
317317
318318 #[ doc( alias = "ts_language_symbol_type" ) ]
319319 pub fn node_kind_is_visible ( & self , id : u16 ) -> bool {
320- unsafe {
321- ffi:: ts_language_symbol_type ( self . 0 , id) <= ffi:: TSSymbolType_TSSymbolTypeAnonymous
322- }
320+ unsafe { ffi:: ts_language_symbol_type ( self . 0 , id) <= ffi:: TSSymbolTypeAnonymous }
323321 }
324322
325323 /// Get the number of distinct field names in this language.
@@ -445,7 +443,7 @@ impl Parser {
445443 ) {
446444 let callback = ( payload as * mut Logger ) . as_mut ( ) . unwrap ( ) ;
447445 if let Ok ( message) = CStr :: from_ptr ( c_message) . to_str ( ) {
448- let log_type = if c_log_type == ffi:: TSLogType_TSLogTypeParse {
446+ let log_type = if c_log_type == ffi:: TSLogTypeParse {
449447 LogType :: Parse
450448 } else {
451449 LogType :: Lex
@@ -571,7 +569,7 @@ impl Parser {
571569 let c_input = ffi:: TSInput {
572570 payload : & mut payload as * mut ( & mut F , Option < T > ) as * mut c_void ,
573571 read : Some ( read :: < T , F > ) ,
574- encoding : ffi:: TSInputEncoding_TSInputEncodingUTF8 ,
572+ encoding : ffi:: TSInputEncodingUTF8 ,
575573 } ;
576574
577575 let c_old_tree = old_tree. map_or ( ptr:: null_mut ( ) , |t| t. 0 . as_ptr ( ) ) ;
@@ -627,7 +625,7 @@ impl Parser {
627625 let c_input = ffi:: TSInput {
628626 payload : & mut payload as * mut ( & mut F , Option < T > ) as * mut c_void ,
629627 read : Some ( read :: < T , F > ) ,
630- encoding : ffi:: TSInputEncoding_TSInputEncodingUTF16 ,
628+ encoding : ffi:: TSInputEncodingUTF16 ,
631629 } ;
632630
633631 let c_old_tree = old_tree. map_or ( ptr:: null_mut ( ) , |t| t. 0 . as_ptr ( ) ) ;
@@ -1568,7 +1566,7 @@ impl Query {
15681566
15691567 // On failure, build an error based on the error code and offset.
15701568 if ptr. is_null ( ) {
1571- if error_type == ffi:: TSQueryError_TSQueryErrorLanguage {
1569+ if error_type == ffi:: TSQueryErrorLanguage {
15721570 return Err ( QueryError {
15731571 row : 0 ,
15741572 column : 0 ,
@@ -1600,18 +1598,16 @@ impl Query {
16001598 let message;
16011599 match error_type {
16021600 // Error types that report names
1603- ffi:: TSQueryError_TSQueryErrorNodeType
1604- | ffi:: TSQueryError_TSQueryErrorField
1605- | ffi:: TSQueryError_TSQueryErrorCapture => {
1601+ ffi:: TSQueryErrorNodeType | ffi:: TSQueryErrorField | ffi:: TSQueryErrorCapture => {
16061602 let suffix = source. split_at ( offset) . 1 ;
16071603 let end_offset = suffix
16081604 . find ( |c| !char:: is_alphanumeric ( c) && c != '_' && c != '-' )
16091605 . unwrap_or ( suffix. len ( ) ) ;
16101606 message = suffix. split_at ( end_offset) . 0 . to_string ( ) ;
16111607 kind = match error_type {
1612- ffi:: TSQueryError_TSQueryErrorNodeType => QueryErrorKind :: NodeType ,
1613- ffi:: TSQueryError_TSQueryErrorField => QueryErrorKind :: Field ,
1614- ffi:: TSQueryError_TSQueryErrorCapture => QueryErrorKind :: Capture ,
1608+ ffi:: TSQueryErrorNodeType => QueryErrorKind :: NodeType ,
1609+ ffi:: TSQueryErrorField => QueryErrorKind :: Field ,
1610+ ffi:: TSQueryErrorCapture => QueryErrorKind :: Capture ,
16151611 _ => unreachable ! ( ) ,
16161612 } ;
16171613 }
@@ -1624,7 +1620,7 @@ impl Query {
16241620 "Unexpected EOF" . to_string ( )
16251621 } ;
16261622 kind = match error_type {
1627- ffi:: TSQueryError_TSQueryErrorStructure => QueryErrorKind :: Structure ,
1623+ ffi:: TSQueryErrorStructure => QueryErrorKind :: Structure ,
16281624 _ => QueryErrorKind :: Syntax ,
16291625 } ;
16301626 }
@@ -1720,20 +1716,21 @@ impl Query {
17201716 . filter ( |( _, c) | * c == '\n' )
17211717 . count ( ) ;
17221718
1723- let type_done = ffi:: TSQueryPredicateStepType_TSQueryPredicateStepTypeDone ;
1724- let type_capture = ffi:: TSQueryPredicateStepType_TSQueryPredicateStepTypeCapture ;
1725- let type_string = ffi:: TSQueryPredicateStepType_TSQueryPredicateStepTypeString ;
1719+ use ffi:: TSQueryPredicateStepType as T ;
1720+ const TYPE_DONE : T = ffi:: TSQueryPredicateStepTypeDone ;
1721+ const TYPE_CAPTURE : T = ffi:: TSQueryPredicateStepTypeCapture ;
1722+ const TYPE_STRING : T = ffi:: TSQueryPredicateStepTypeString ;
17261723
17271724 let mut text_predicates = Vec :: new ( ) ;
17281725 let mut property_predicates = Vec :: new ( ) ;
17291726 let mut property_settings = Vec :: new ( ) ;
17301727 let mut general_predicates = Vec :: new ( ) ;
1731- for p in predicate_steps. split ( |s| s. type_ == type_done ) {
1728+ for p in predicate_steps. split ( |s| s. type_ == TYPE_DONE ) {
17321729 if p. is_empty ( ) {
17331730 continue ;
17341731 }
17351732
1736- if p[ 0 ] . type_ != type_string {
1733+ if p[ 0 ] . type_ != TYPE_STRING {
17371734 return Err ( predicate_error (
17381735 row,
17391736 format ! (
@@ -1756,7 +1753,7 @@ impl Query {
17561753 ) ,
17571754 ) ) ;
17581755 }
1759- if p[ 1 ] . type_ != type_capture {
1756+ if p[ 1 ] . type_ != TYPE_CAPTURE {
17601757 return Err ( predicate_error ( row, format ! (
17611758 "First argument to #eq? predicate must be a capture name. Got literal \" {}\" ." ,
17621759 string_values[ p[ 1 ] . value_id as usize ] ,
@@ -1769,7 +1766,7 @@ impl Query {
17691766 "any-eq?" | "any-not-eq?" => false ,
17701767 _ => unreachable ! ( ) ,
17711768 } ;
1772- text_predicates. push ( if p[ 2 ] . type_ == type_capture {
1769+ text_predicates. push ( if p[ 2 ] . type_ == TYPE_CAPTURE {
17731770 TextPredicateCapture :: EqCapture (
17741771 p[ 1 ] . value_id ,
17751772 p[ 2 ] . value_id ,
@@ -1793,13 +1790,13 @@ impl Query {
17931790 p. len( ) - 1
17941791 ) ) ) ;
17951792 }
1796- if p[ 1 ] . type_ != type_capture {
1793+ if p[ 1 ] . type_ != TYPE_CAPTURE {
17971794 return Err ( predicate_error ( row, format ! (
17981795 "First argument to #match? predicate must be a capture name. Got literal \" {}\" ." ,
17991796 string_values[ p[ 1 ] . value_id as usize ] ,
18001797 ) ) ) ;
18011798 }
1802- if p[ 2 ] . type_ == type_capture {
1799+ if p[ 2 ] . type_ == TYPE_CAPTURE {
18031800 return Err ( predicate_error ( row, format ! (
18041801 "Second argument to #match? predicate must be a literal. Got capture @{}." ,
18051802 capture_names[ p[ 2 ] . value_id as usize ] ,
@@ -1850,7 +1847,7 @@ impl Query {
18501847 p. len( ) - 1
18511848 ) ) ) ;
18521849 }
1853- if p[ 1 ] . type_ != type_capture {
1850+ if p[ 1 ] . type_ != TYPE_CAPTURE {
18541851 return Err ( predicate_error ( row, format ! (
18551852 "First argument to #any-of? predicate must be a capture name. Got literal \" {}\" ." ,
18561853 string_values[ p[ 1 ] . value_id as usize ] ,
@@ -1860,7 +1857,7 @@ impl Query {
18601857 let is_positive = operator_name == "any-of?" ;
18611858 let mut values = Vec :: new ( ) ;
18621859 for arg in & p[ 2 ..] {
1863- if arg. type_ == type_capture {
1860+ if arg. type_ == TYPE_CAPTURE {
18641861 return Err ( predicate_error ( row, format ! (
18651862 "Arguments to #any-of? predicate must be literals. Got capture @{}." ,
18661863 capture_names[ arg. value_id as usize ] ,
@@ -1884,7 +1881,7 @@ impl Query {
18841881 args : p[ 1 ..]
18851882 . iter ( )
18861883 . map ( |a| {
1887- if a. type_ == type_capture {
1884+ if a. type_ == TYPE_CAPTURE {
18881885 QueryPredicateArg :: Capture ( a. value_id )
18891886 } else {
18901887 QueryPredicateArg :: String (
@@ -2052,7 +2049,7 @@ impl Query {
20522049 let mut value = None ;
20532050
20542051 for arg in args {
2055- if arg. type_ == ffi:: TSQueryPredicateStepType_TSQueryPredicateStepTypeCapture {
2052+ if arg. type_ == ffi:: TSQueryPredicateStepTypeCapture {
20562053 if capture_id. is_some ( ) {
20572054 return Err ( predicate_error (
20582055 row,
0 commit comments