提交 31100403 编写于 作者: N Nick Cameron

save-analysis: add a `kind` tag to JSON dumps

上级 68d29cba
......@@ -16,6 +16,8 @@
use external_data::*;
use data::{VariableKind, Visibility};
use dump::Dump;
use super::Format;
// A dumper to dump a restricted set of JSON information, designed for use with
// libraries distributed without their source. Clients are likely to use type
......@@ -81,17 +83,25 @@ fn crate_prelude(&mut self, data: CratePreludeData) {
#[derive(Debug, RustcEncodable)]
struct Analysis {
kind: Format,
prelude: Option<CratePreludeData>,
imports: Vec<Import>,
defs: Vec<Def>,
// These two fields are dummies so that clients can parse the two kinds of
// JSON data in the same way.
refs: Vec<()>,
macro_refs: Vec<()>,
}
impl Analysis {
fn new() -> Analysis {
Analysis {
kind: Format::JsonApi,
prelude: None,
imports: vec![],
defs: vec![],
refs: vec![],
macro_refs: vec![],
}
}
}
......
......@@ -16,6 +16,7 @@
use external_data::*;
use data::VariableKind;
use dump::Dump;
use super::Format;
pub struct JsonDumper<'b, W: Write + 'b> {
output: &'b mut W,
......@@ -87,6 +88,7 @@ fn inheritance(&mut self, _data: InheritanceData) {}
#[derive(Debug, RustcEncodable)]
struct Analysis {
kind: Format,
prelude: Option<CratePreludeData>,
imports: Vec<Import>,
defs: Vec<Def>,
......@@ -97,6 +99,7 @@ struct Analysis {
impl Analysis {
fn new() -> Analysis {
Analysis {
kind: Format::Json,
prelude: None,
imports: vec![],
defs: vec![],
......
......@@ -766,7 +766,7 @@ fn docs_for_attrs(attrs: &[Attribute]) -> String {
result
}
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, RustcEncodable)]
pub enum Format {
Csv,
Json,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册