@@ -114,36 +114,6 @@ impl QuoteOffsets {
114114 }
115115}
116116
117- pub trait HasQuotes : AstToken {
118- fn quote_offsets ( & self ) -> Option < QuoteOffsets > {
119- let text = self . text ( ) . as_str ( ) ;
120- let offsets = QuoteOffsets :: new ( text) ?;
121- let o = self . syntax ( ) . text_range ( ) . start ( ) ;
122- let offsets = QuoteOffsets {
123- quotes : ( offsets. quotes . 0 + o, offsets. quotes . 1 + o) ,
124- contents : offsets. contents + o,
125- } ;
126- Some ( offsets)
127- }
128- fn open_quote_text_range ( & self ) -> Option < TextRange > {
129- self . quote_offsets ( ) . map ( |it| it. quotes . 0 )
130- }
131-
132- fn close_quote_text_range ( & self ) -> Option < TextRange > {
133- self . quote_offsets ( ) . map ( |it| it. quotes . 1 )
134- }
135-
136- fn text_range_between_quotes ( & self ) -> Option < TextRange > {
137- self . quote_offsets ( ) . map ( |it| it. contents )
138- }
139- }
140-
141- impl HasQuotes for ast:: String { }
142-
143- pub trait HasStringValue : HasQuotes {
144- fn value ( & self ) -> Option < Cow < ' _ , str > > ;
145- }
146-
147117impl ast:: String {
148118 pub fn is_raw ( & self ) -> bool {
149119 self . text ( ) . starts_with ( 'r' )
@@ -153,10 +123,8 @@ impl ast::String {
153123 assert ! ( TextRange :: up_to( contents_range. len( ) ) . contains_range( range) ) ;
154124 Some ( range + contents_range. start ( ) )
155125 }
156- }
157126
158- impl HasStringValue for ast:: String {
159- fn value ( & self ) -> Option < Cow < ' _ , str > > {
127+ pub fn value ( & self ) -> Option < Cow < ' _ , str > > {
160128 if self . is_raw ( ) {
161129 let text = self . text ( ) . as_str ( ) ;
162130 let text =
@@ -181,6 +149,26 @@ impl HasStringValue for ast::String {
181149 let res = if buf == text { Cow :: Borrowed ( text) } else { Cow :: Owned ( buf) } ;
182150 Some ( res)
183151 }
152+
153+ pub fn quote_offsets ( & self ) -> Option < QuoteOffsets > {
154+ let text = self . text ( ) . as_str ( ) ;
155+ let offsets = QuoteOffsets :: new ( text) ?;
156+ let o = self . syntax ( ) . text_range ( ) . start ( ) ;
157+ let offsets = QuoteOffsets {
158+ quotes : ( offsets. quotes . 0 + o, offsets. quotes . 1 + o) ,
159+ contents : offsets. contents + o,
160+ } ;
161+ Some ( offsets)
162+ }
163+ pub fn text_range_between_quotes ( & self ) -> Option < TextRange > {
164+ self . quote_offsets ( ) . map ( |it| it. contents )
165+ }
166+ pub fn open_quote_text_range ( & self ) -> Option < TextRange > {
167+ self . quote_offsets ( ) . map ( |it| it. quotes . 0 )
168+ }
169+ pub fn close_quote_text_range ( & self ) -> Option < TextRange > {
170+ self . quote_offsets ( ) . map ( |it| it. quotes . 1 )
171+ }
184172}
185173
186174impl ast:: ByteString {
0 commit comments