@@ -7,7 +7,7 @@ use either::Either;
7
7
use intern:: Interned ;
8
8
use mbe:: { syntax_node_to_token_tree, DelimiterKind , Punct } ;
9
9
use smallvec:: { smallvec, SmallVec } ;
10
- use span:: SyntaxContextId ;
10
+ use span:: Span ;
11
11
use syntax:: { ast, match_ast, AstNode , AstToken , SmolStr , SyntaxNode } ;
12
12
use triomphe:: Arc ;
13
13
@@ -53,7 +53,7 @@ impl RawAttrs {
53
53
id,
54
54
input : Some ( Interned :: new ( AttrInput :: Literal ( SmolStr :: new ( doc) ) ) ) ,
55
55
path : Interned :: new ( ModPath :: from ( crate :: name!( doc) ) ) ,
56
- ctxt : span_map. span_for_range ( comment. syntax ( ) . text_range ( ) ) . ctx ,
56
+ span : span_map. span_for_range ( comment. syntax ( ) . text_range ( ) ) ,
57
57
} ) ,
58
58
} ) ;
59
59
let entries: Arc < [ Attr ] > = Arc :: from_iter ( entries) ;
@@ -120,7 +120,7 @@ impl RawAttrs {
120
120
let attrs =
121
121
parts. enumerate ( ) . take ( 1 << AttrId :: CFG_ATTR_BITS ) . filter_map ( |( idx, attr) | {
122
122
let tree = Subtree {
123
- delimiter : tt:: Delimiter :: dummy_invisible ( ) ,
123
+ delimiter : tt:: Delimiter :: invisible_spanned ( attr . first ( ) ? . first_span ( ) ) ,
124
124
token_trees : attr. to_vec ( ) ,
125
125
} ;
126
126
Attr :: from_tt ( db, & tree, index. with_cfg_attr ( idx) )
@@ -177,7 +177,7 @@ pub struct Attr {
177
177
pub id : AttrId ,
178
178
pub path : Interned < ModPath > ,
179
179
pub input : Option < Interned < AttrInput > > ,
180
- pub ctxt : SyntaxContextId ,
180
+ pub span : Span ,
181
181
}
182
182
183
183
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -206,19 +206,20 @@ impl Attr {
206
206
id : AttrId ,
207
207
) -> Option < Attr > {
208
208
let path = Interned :: new ( ModPath :: from_src ( db, ast. path ( ) ?, span_map) ?) ;
209
+ let span = span_map. span_for_range ( ast. syntax ( ) . text_range ( ) ) ;
209
210
let input = if let Some ( ast:: Expr :: Literal ( lit) ) = ast. expr ( ) {
210
211
let value = match lit. kind ( ) {
211
212
ast:: LiteralKind :: String ( string) => string. value ( ) ?. into ( ) ,
212
213
_ => lit. syntax ( ) . first_token ( ) ?. text ( ) . trim_matches ( '"' ) . into ( ) ,
213
214
} ;
214
215
Some ( Interned :: new ( AttrInput :: Literal ( value) ) )
215
216
} else if let Some ( tt) = ast. token_tree ( ) {
216
- let tree = syntax_node_to_token_tree ( tt. syntax ( ) , span_map) ;
217
+ let tree = syntax_node_to_token_tree ( tt. syntax ( ) , span_map, span ) ;
217
218
Some ( Interned :: new ( AttrInput :: TokenTree ( Box :: new ( tree) ) ) )
218
219
} else {
219
220
None
220
221
} ;
221
- Some ( Attr { id, path, input, ctxt : span_map . span_for_range ( ast . syntax ( ) . text_range ( ) ) . ctx } )
222
+ Some ( Attr { id, path, input, span } )
222
223
}
223
224
224
225
fn from_tt ( db : & dyn ExpandDatabase , tt : & tt:: Subtree , id : AttrId ) -> Option < Attr > {
@@ -266,7 +267,7 @@ impl Attr {
266
267
pub fn parse_path_comma_token_tree < ' a > (
267
268
& ' a self ,
268
269
db : & ' a dyn ExpandDatabase ,
269
- ) -> Option < impl Iterator < Item = ( ModPath , SyntaxContextId ) > + ' a > {
270
+ ) -> Option < impl Iterator < Item = ( ModPath , Span ) > + ' a > {
270
271
let args = self . token_tree_value ( ) ?;
271
272
272
273
if args. delimiter . kind != DelimiterKind :: Parenthesis {
@@ -282,7 +283,7 @@ impl Attr {
282
283
// FIXME: This is necessarily a hack. It'd be nice if we could avoid allocation
283
284
// here or maybe just parse a mod path from a token tree directly
284
285
let subtree = tt:: Subtree {
285
- delimiter : tt:: Delimiter :: dummy_invisible ( ) ,
286
+ delimiter : tt:: Delimiter :: invisible_spanned ( tts . first ( ) ? . first_span ( ) ) ,
286
287
token_trees : tts. to_vec ( ) ,
287
288
} ;
288
289
let ( parse, span_map) =
@@ -294,7 +295,7 @@ impl Attr {
294
295
return None ;
295
296
}
296
297
let path = meta. path ( ) ?;
297
- let call_site = span_map. span_at ( path. syntax ( ) . text_range ( ) . start ( ) ) . ctx ;
298
+ let call_site = span_map. span_at ( path. syntax ( ) . text_range ( ) . start ( ) ) ;
298
299
Some ( (
299
300
ModPath :: from_src ( db, path, SpanMapRef :: ExpansionSpanMap ( & span_map) ) ?,
300
301
call_site,
0 commit comments