"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rls-data"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "rls-rustc"
version = "0.2.1"
version = "0.0.0"
dependencies = [
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
"checksum rls-analysis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "38841e3c5271715a574ac220d9b408b59ed9e2626909c3bc54b5853b4eaadb7b"
"checksum rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8024f1feaca72d0aa4ae1e2a8d454a31b9a33ed02f8d0e9c8559bf53c267ec3c"
+"checksum rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bea04462e94b5512a78499837eecb7db182ff082144cd1b4bc32ef5d43de6510"
"checksum rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85cfb9dde19e313da3e47738008f8a472e470cc42d910b71595a9238494701f2"
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
"checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff"
use rustc_serialize::json::as_json;
use rls_data::{self, Analysis, CratePreludeData, Def, DefKind, Import, MacroRef, Ref, RefKind,
- Relation};
+ Relation, Impl};
use rls_data::config::Config;
use rls_span::{Column, Row};
pub fn dump_relation(&mut self, data: Relation) {
self.result.relations.push(data);
}
+
+ pub fn dump_impl(&mut self, data: Impl) {
+ self.result.impls.push(data);
+ }
}
use rustc::ty::{self, TyCtxt};
use rustc_typeck::hir_ty_to_ty;
+use std::cell::Cell;
use std::default::Default;
use std::env;
use std::fs::File;
use span_utils::SpanUtils;
use rls_data::{Def, DefKind, ExternalCrateData, GlobalCrateId, MacroRef, Ref, RefKind, Relation,
- RelationKind, SpanData};
+ RelationKind, SpanData, Impl, ImplKind};
use rls_data::config::Config;
analysis: &'l ty::CrateAnalysis,
span_utils: SpanUtils<'tcx>,
config: Config,
+ impl_counter: Cell<u32>,
}
#[derive(Debug)]
pub enum Data {
RefData(Ref),
DefData(Def),
- RelationData(Relation),
+ RelationData(Relation, Impl),
}
impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
attributes: lower_attributes(item.attrs.to_owned(), self),
}))
}
- ast::ItemKind::Impl(.., ref trait_ref, ref typ, _) => {
+ ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => {
if let ast::TyKind::Path(None, ref path) = typ.node {
// Common case impl for a struct or something basic.
if generated_code(path.span) {
let sub_span = self.span_utils.sub_span_for_type_name(path.span);
filter!(self.span_utils, sub_span, typ.span, None);
+ let impl_id = self.next_impl_id();
+ let span = self.span_from_span(sub_span.unwrap());
+
let type_data = self.lookup_ref_id(typ.id);
type_data.map(|type_data| {
Data::RelationData(Relation {
- kind: RelationKind::Impl,
- span: self.span_from_span(sub_span.unwrap()),
+ kind: RelationKind::Impl {
+ id: impl_id,
+ },
+ span: span.clone(),
from: id_from_def_id(type_data),
to: trait_ref
.as_ref()
.and_then(|t| self.lookup_ref_id(t.ref_id))
.map(id_from_def_id)
.unwrap_or(null_id()),
+ },
+ Impl {
+ id: impl_id,
+ kind: match *trait_ref {
+ Some(_) => ImplKind::Direct,
+ None => ImplKind::Inherent,
+ },
+ span: span,
+ value: String::new(),
+ parent: None,
+ children: impls
+ .iter()
+ .map(|i| id_from_node_id(i.id, self))
+ .collect(),
+ docs: String::new(),
+ sig: None,
+ attributes: vec![],
})
})
} else {
result
}
+
+ fn next_impl_id(&self) -> u32 {
+ let next = self.impl_counter.get();
+ self.impl_counter.set(next + 1);
+ next
+ }
}
fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String {
analysis,
span_utils: SpanUtils::new(&tcx.sess),
config: find_config(config),
+ impl_counter: Cell::new(0),
};
handler.save(save_ctxt, krate, cratename)