Add rls-span to do some conversions into rls-data.
And fix some warnings and borrow errors
This commit is contained in:
parent
83f84ff1bc
commit
bf07f1c6bb
|
@ -718,6 +718,7 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"log 0.0.0",
|
||||
"rls-data 0.1.0 (git+https://github.com/nrc/rls-data)",
|
||||
"rls-span 0.1.0 (git+https://github.com/nrc/rls-span)",
|
||||
"rustc 0.0.0",
|
||||
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntax 0.0.0",
|
||||
|
|
|
@ -16,3 +16,4 @@ syntax = { path = "../libsyntax" }
|
|||
rustc-serialize = "0.3"
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rls-data = { git = "https://github.com/nrc/rls-data" }
|
||||
rls-span = { git = "https://github.com/nrc/rls-span" }
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
use rustc::hir;
|
||||
use rustc::hir::def::Def;
|
||||
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::hir::map::{Node, NodeItem};
|
||||
use rustc::session::Session;
|
||||
use rustc::ty::{self, TyCtxt, AssociatedItemContainer};
|
||||
|
|
|
@ -17,11 +17,10 @@ use syntax::print::pprust;
|
|||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use data::{self, Visibility, SigElement};
|
||||
|
||||
use rls_data::{SpanData, CratePreludeData, Attribute};
|
||||
use rls_span::{Column, Row};
|
||||
|
||||
// FIXME: this should be pub(crate), but the current snapshot doesn't allow it yet
|
||||
pub trait Lower {
|
||||
|
@ -48,10 +47,10 @@ pub fn span_from_span(span: Span, cm: &CodeMap) -> SpanData {
|
|||
file_name: start.file.name.clone().into(),
|
||||
byte_start: span.lo.0,
|
||||
byte_end: span.hi.0,
|
||||
line_start: start.line,
|
||||
line_end: end.line,
|
||||
column_start: start.col.0 + 1,
|
||||
column_end: end.col.0 + 1,
|
||||
line_start: Row::new_one_indexed(start.line as u32),
|
||||
line_end: Row::new_one_indexed(end.line as u32),
|
||||
column_start: Column::new_one_indexed(start.col.0 as u32 + 1),
|
||||
column_end: Column::new_one_indexed(end.col.0 as u32 + 1),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ use rustc_serialize::json::as_json;
|
|||
|
||||
use rls_data::{self, Id, Analysis, Import, ImportKind, Def, DefKind, Ref, RefKind, MacroRef,
|
||||
Relation, RelationKind, Signature, SigElement, CratePreludeData};
|
||||
use rls_span::{Column, Row};
|
||||
|
||||
use external_data;
|
||||
use external_data::*;
|
||||
use data::{self, VariableKind};
|
||||
use dump::Dump;
|
||||
use super::Format;
|
||||
|
||||
pub struct JsonDumper<'b, W: Write + 'b> {
|
||||
output: &'b mut W,
|
||||
|
@ -94,7 +94,7 @@ impl<'b, W: Write + 'b> Dump for JsonDumper<'b, W> {
|
|||
sig: Some(data.sig.into()),
|
||||
attributes: data.attributes.into_iter().map(|a| a.into()).collect(),
|
||||
};
|
||||
if data.span.file_name.to_str().unwrap() != def.value {
|
||||
if def.span.file_name.to_str().unwrap() != def.value {
|
||||
// If the module is an out-of-line defintion, then we'll make the
|
||||
// defintion the first character in the module's file and turn the
|
||||
// the declaration into a reference to it.
|
||||
|
@ -108,10 +108,10 @@ impl<'b, W: Write + 'b> Dump for JsonDumper<'b, W> {
|
|||
file_name: def.value.clone().into(),
|
||||
byte_start: 0,
|
||||
byte_end: 0,
|
||||
line_start: 1,
|
||||
line_end: 1,
|
||||
column_start: 1,
|
||||
column_end: 1,
|
||||
line_start: Row::new_one_indexed(1),
|
||||
line_end: Row::new_one_indexed(1),
|
||||
column_start: Column::new_one_indexed(1),
|
||||
column_end: Column::new_one_indexed(1),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ extern crate rustc_serialize;
|
|||
extern crate syntax_pos;
|
||||
|
||||
extern crate rls_data;
|
||||
extern crate rls_span;
|
||||
|
||||
|
||||
mod csv_dumper;
|
||||
|
|
Loading…
Reference in New Issue