File tree Expand file tree Collapse file tree 2 files changed +607
-9
lines changed
src/librustc_save_analysis Expand file tree Collapse file tree 2 files changed +607
-9
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,37 @@ use std::hash::Hasher;
1818use rustc:: hir:: def_id:: DefId ;
1919use rustc:: ty;
2020use syntax:: ast:: { CrateNum , NodeId } ;
21- use syntax:: codemap:: Span ;
21+ use syntax:: codemap:: { Span , CodeMap } ;
22+
23+ #[ derive( Debug , Clone , RustcEncodable ) ]
24+ pub struct SpanData {
25+ file_name : String ,
26+ byte_start : u32 ,
27+ byte_end : u32 ,
28+ /// 1-based.
29+ line_start : usize ,
30+ line_end : usize ,
31+ /// 1-based, character offset.
32+ column_start : usize ,
33+ column_end : usize ,
34+ }
35+
36+ impl SpanData {
37+ pub fn from_span ( span : Span , cm : & CodeMap ) -> SpanData {
38+ let start = cm. lookup_char_pos ( span. lo ) ;
39+ let end = cm. lookup_char_pos ( span. hi ) ;
40+
41+ SpanData {
42+ file_name : start. file . name . clone ( ) ,
43+ byte_start : span. lo . 0 ,
44+ byte_end : span. hi . 0 ,
45+ line_start : start. line ,
46+ line_end : end. line ,
47+ column_start : start. col . 0 + 1 ,
48+ column_end : end. col . 0 + 1 ,
49+ }
50+ }
51+ }
2252
2353pub struct CrateData {
2454 pub name : String ,
You can’t perform that action at this time.
0 commit comments