Skip to content

Commit bf07f1c

Browse files
committed
Add rls-span to do some conversions into rls-data.
And fix some warnings and borrow errors
1 parent 83f84ff commit bf07f1c

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

src/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_save_analysis/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ syntax = { path = "../libsyntax" }
1616
rustc-serialize = "0.3"
1717
syntax_pos = { path = "../libsyntax_pos" }
1818
rls-data = { git = "https://github.com/nrc/rls-data" }
19+
rls-span = { git = "https://github.com/nrc/rls-span" }

src/librustc_save_analysis/dump_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
use rustc::hir;
3131
use rustc::hir::def::Def;
32-
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
32+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
3333
use rustc::hir::map::{Node, NodeItem};
3434
use rustc::session::Session;
3535
use rustc::ty::{self, TyCtxt, AssociatedItemContainer};

src/librustc_save_analysis/external_data.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ use syntax::print::pprust;
1717
use syntax::symbol::Symbol;
1818
use syntax_pos::Span;
1919

20-
use std::path::PathBuf;
21-
2220
use data::{self, Visibility, SigElement};
2321

2422
use rls_data::{SpanData, CratePreludeData, Attribute};
23+
use rls_span::{Column, Row};
2524

2625
// FIXME: this should be pub(crate), but the current snapshot doesn't allow it yet
2726
pub trait Lower {
@@ -48,10 +47,10 @@ pub fn span_from_span(span: Span, cm: &CodeMap) -> SpanData {
4847
file_name: start.file.name.clone().into(),
4948
byte_start: span.lo.0,
5049
byte_end: span.hi.0,
51-
line_start: start.line,
52-
line_end: end.line,
53-
column_start: start.col.0 + 1,
54-
column_end: end.col.0 + 1,
50+
line_start: Row::new_one_indexed(start.line as u32),
51+
line_end: Row::new_one_indexed(end.line as u32),
52+
column_start: Column::new_one_indexed(start.col.0 as u32 + 1),
53+
column_end: Column::new_one_indexed(end.col.0 as u32 + 1),
5554
}
5655
}
5756

src/librustc_save_analysis/json_dumper.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ use rustc_serialize::json::as_json;
1515

1616
use rls_data::{self, Id, Analysis, Import, ImportKind, Def, DefKind, Ref, RefKind, MacroRef,
1717
Relation, RelationKind, Signature, SigElement, CratePreludeData};
18+
use rls_span::{Column, Row};
1819

1920
use external_data;
2021
use external_data::*;
2122
use data::{self, VariableKind};
2223
use dump::Dump;
23-
use super::Format;
2424

2525
pub struct JsonDumper<'b, W: Write + 'b> {
2626
output: &'b mut W,
@@ -94,7 +94,7 @@ impl<'b, W: Write + 'b> Dump for JsonDumper<'b, W> {
9494
sig: Some(data.sig.into()),
9595
attributes: data.attributes.into_iter().map(|a| a.into()).collect(),
9696
};
97-
if data.span.file_name.to_str().unwrap() != def.value {
97+
if def.span.file_name.to_str().unwrap() != def.value {
9898
// If the module is an out-of-line defintion, then we'll make the
9999
// defintion the first character in the module's file and turn the
100100
// the declaration into a reference to it.
@@ -108,10 +108,10 @@ impl<'b, W: Write + 'b> Dump for JsonDumper<'b, W> {
108108
file_name: def.value.clone().into(),
109109
byte_start: 0,
110110
byte_end: 0,
111-
line_start: 1,
112-
line_end: 1,
113-
column_start: 1,
114-
column_end: 1,
111+
line_start: Row::new_one_indexed(1),
112+
line_end: Row::new_one_indexed(1),
113+
column_start: Column::new_one_indexed(1),
114+
column_end: Column::new_one_indexed(1),
115115
}
116116
}
117117

src/librustc_save_analysis/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern crate rustc_serialize;
3030
extern crate syntax_pos;
3131

3232
extern crate rls_data;
33+
extern crate rls_span;
3334

3435

3536
mod csv_dumper;

0 commit comments

Comments
 (0)