Skip to content

Commit be2f85e

Browse files
committed
Update rustdoc_ng to new ast naming
1 parent 136900f commit be2f85e

File tree

3 files changed

+64
-83
lines changed

3 files changed

+64
-83
lines changed

src/rustdoc_ng/clean.rs

Lines changed: 40 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl Clean<VariantKind> for ast::variant_kind {
657657
}
658658
}
659659

660-
impl Clean<~str> for syntax::codemap::span {
660+
impl Clean<~str> for syntax::codemap::Span {
661661
fn clean(&self) -> ~str {
662662
let cm = local_data::get(super::ctxtkey, |x| x.unwrap().clone()).sess.codemap;
663663
cm.span_to_str(*self)
@@ -697,7 +697,7 @@ fn path_to_str(p: &ast::Path) -> ~str {
697697
s
698698
}
699699

700-
impl Clean<~str> for ast::ident {
700+
impl Clean<~str> for ast::Ident {
701701
fn clean(&self) -> ~str {
702702
its(self).to_owned()
703703
}
@@ -779,15 +779,13 @@ impl Clean<Item> for doctree::Static {
779779
pub enum Mutability {
780780
Mutable,
781781
Immutable,
782-
Const,
783782
}
784783

785-
impl Clean<Mutability> for ast::mutability {
784+
impl Clean<Mutability> for ast::Mutability {
786785
fn clean(&self) -> Mutability {
787786
match self {
788-
&ast::m_mutbl => Mutable,
789-
&ast::m_imm => Immutable,
790-
&ast::m_const => Const
787+
&ast::MutMutable => Mutable,
788+
&ast::MutImmutable => Immutable,
791789
}
792790
}
793791
}
@@ -885,7 +883,7 @@ trait ToSource {
885883
fn to_src(&self) -> ~str;
886884
}
887885

888-
impl ToSource for syntax::codemap::span {
886+
impl ToSource for syntax::codemap::Span {
889887
fn to_src(&self) -> ~str {
890888
debug!("converting span %s to snippet", self.clean());
891889
let cm = local_data::get(super::ctxtkey, |x| x.unwrap().clone()).sess.codemap.clone();
@@ -912,23 +910,23 @@ fn lit_to_str(lit: &ast::lit) -> ~str {
912910
}
913911
}
914912

915-
fn name_from_pat(p: &ast::pat) -> ~str {
913+
fn name_from_pat(p: &ast::Pat) -> ~str {
916914
use syntax::ast::*;
917915
match p.node {
918-
pat_wild => ~"_",
919-
pat_ident(_, ref p, _) => path_to_str(p),
920-
pat_enum(ref p, _) => path_to_str(p),
921-
pat_struct(*) => fail!("tried to get argument name from pat_struct, \
922-
which is not allowed in function arguments"),
923-
pat_tup(*) => ~"(tuple arg NYI)",
924-
pat_box(p) => name_from_pat(p),
925-
pat_uniq(p) => name_from_pat(p),
926-
pat_region(p) => name_from_pat(p),
927-
pat_lit(*) => fail!("tried to get argument name from pat_lit, \
928-
which is not allowed in function arguments"),
929-
pat_range(*) => fail!("tried to get argument name from pat_range, \
930-
which is not allowed in function arguments"),
931-
pat_vec(*) => fail!("tried to get argument name from pat_vec, \
916+
PatWild => ~"_",
917+
PatIdent(_, ref p, _) => path_to_str(p),
918+
PatEnum(ref p, _) => path_to_str(p),
919+
PatStruct(*) => fail!("tried to get argument name from pat_struct, \
920+
which is not allowed in function arguments"),
921+
PatTup(*) => ~"(tuple arg NYI)",
922+
PatBox(p) => name_from_pat(p),
923+
PatUniq(p) => name_from_pat(p),
924+
PatRegion(p) => name_from_pat(p),
925+
PatLit(*) => fail!("tried to get argument name from pat_lit, \
926+
which is not allowed in function arguments"),
927+
PatRange(*) => fail!("tried to get argument name from pat_range, \
928+
which is not allowed in function arguments"),
929+
PatVec(*) => fail!("tried to get argument name from pat_vec, \
932930
which is not allowed in function arguments")
933931
}
934932
}
@@ -945,23 +943,6 @@ fn remove_comment_tags(s: &str) -> ~str {
945943
}
946944
}
947945

948-
/*fn collapse_docs(attrs: ~[Attribute]) -> ~[Attribute] {
949-
let mut docstr = ~"";
950-
for at in attrs.iter() {
951-
match *at {
952-
//XXX how should these be separated?
953-
NameValue(~"doc", ref s) => docstr.push_str(fmt!("%s ", clean_comment_body(s.clone()))),
954-
_ => ()
955-
}
956-
}
957-
let mut a = attrs.iter().filter(|&a| match a {
958-
&NameValue(~"doc", _) => false,
959-
_ => true
960-
}).map(|x| x.clone()).collect::<~[Attribute]>();
961-
a.push(NameValue(~"doc", docstr.trim().to_owned()));
962-
a
963-
}*/
964-
965946
/// Given a Type, resolve it using the def_map
966947
fn resolve_type(t: &Type) -> Type {
967948
use syntax::ast::*;
@@ -984,21 +965,21 @@ fn resolve_type(t: &Type) -> Type {
984965
};
985966

986967
let def_id = match *d {
987-
def_fn(i, _) => i,
988-
def_self(i, _) | def_self_ty(i) => return Self(i),
989-
def_ty(i) => i,
990-
def_trait(i) => {
991-
debug!("saw def_trait in def_to_id");
968+
DefFn(i, _) => i,
969+
DefSelf(i, _) | DefSelfTy(i) => return Self(i),
970+
DefTy(i) => i,
971+
DefTrait(i) => {
972+
debug!("saw DefTrait in def_to_id");
992973
i
993974
},
994-
def_prim_ty(p) => match p {
975+
DefPrimTy(p) => match p {
995976
ty_str => return String,
996977
ty_bool => return Bool,
997978
_ => return Primitive(p)
998979
},
999-
def_ty_param(i, _) => return Generic(i.node),
1000-
def_struct(i) => i,
1001-
def_typaram_binder(i) => {
980+
DefTyParam(i, _) => return Generic(i.node),
981+
DefStruct(i) => i,
982+
DefTyParamBinder(i) => {
1002983
debug!("found a typaram_binder, what is it? %d", i);
1003984
return TyParamBinder(i);
1004985
},
@@ -1011,10 +992,10 @@ fn resolve_type(t: &Type) -> Type {
1011992
let mut ty = ~"";
1012993
do csearch::each_path(sess.cstore, def_id.crate) |pathstr, deflike, _vis| {
1013994
match deflike {
1014-
decoder::dl_def(di) => {
995+
decoder::DlDef(di) => {
1015996
let d2 = match di {
1016-
def_fn(i, _) | def_ty(i) | def_trait(i) |
1017-
def_struct(i) | def_mod(i) => Some(i),
997+
DefFn(i, _) | DefTy(i) | DefTrait(i) |
998+
DefStruct(i) | DefMod(i) => Some(i),
1018999
_ => None,
10191000
};
10201001
if d2.is_some() {
@@ -1023,10 +1004,10 @@ fn resolve_type(t: &Type) -> Type {
10231004
debug!("found external def: %?", di);
10241005
path = pathstr.to_owned();
10251006
ty = match di {
1026-
def_fn(*) => ~"fn",
1027-
def_ty(*) => ~"enum",
1028-
def_trait(*) => ~"trait",
1029-
def_prim_ty(p) => match p {
1007+
DefFn(*) => ~"fn",
1008+
DefTy(*) => ~"enum",
1009+
DefTrait(*) => ~"trait",
1010+
DefPrimTy(p) => match p {
10301011
ty_str => ~"str",
10311012
ty_bool => ~"bool",
10321013
ty_int(t) => match t.to_str() {
@@ -1036,9 +1017,9 @@ fn resolve_type(t: &Type) -> Type {
10361017
ty_uint(t) => t.to_str(),
10371018
ty_float(t) => t.to_str()
10381019
},
1039-
def_ty_param(*) => ~"generic",
1040-
def_struct(*) => ~"struct",
1041-
def_typaram_binder(*) => ~"typaram_binder",
1020+
DefTyParam(*) => ~"generic",
1021+
DefStruct(*) => ~"struct",
1022+
DefTyParamBinder(*) => ~"typaram_binder",
10421023
x => fail!("resolved external maps to a weird def %?", x),
10431024
};
10441025

src/rustdoc_ng/doctree.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//! manner (and with prettier names) before cleaning.
33
44
use syntax;
5-
use syntax::codemap::span;
5+
use syntax::codemap::Span;
66
use syntax::ast;
7-
use syntax::ast::{ident, NodeId};
7+
use syntax::ast::{Ident, NodeId};
88

99
pub struct Module {
10-
name: Option<ident>,
10+
name: Option<Ident>,
1111
attrs: ~[ast::Attribute],
12-
where: span,
12+
where: Span,
1313
structs: ~[Struct],
1414
enums: ~[Enum],
1515
fns: ~[Function],
@@ -24,7 +24,7 @@ pub struct Module {
2424
}
2525

2626
impl Module {
27-
pub fn new(name: Option<ident>) -> Module {
27+
pub fn new(name: Option<Ident>) -> Module {
2828
Module {
2929
name : name,
3030
id: 0,
@@ -65,11 +65,11 @@ pub struct Struct {
6565
vis: ast::visibility,
6666
id: NodeId,
6767
struct_type: StructType,
68-
name: ident,
68+
name: Ident,
6969
generics: ast::Generics,
7070
attrs: ~[ast::Attribute],
7171
fields: ~[@ast::struct_field],
72-
where: span,
72+
where: Span,
7373
}
7474

7575
pub struct Enum {
@@ -78,58 +78,58 @@ pub struct Enum {
7878
generics: ast::Generics,
7979
attrs: ~[ast::Attribute],
8080
id: NodeId,
81-
where: span,
82-
name: ident,
81+
where: Span,
82+
name: Ident,
8383
}
8484

8585
pub struct Variant {
86-
name: ident,
86+
name: Ident,
8787
attrs: ~[ast::Attribute],
8888
kind: ast::variant_kind,
8989
id: ast::NodeId,
9090
vis: ast::visibility,
91-
where: span,
91+
where: Span,
9292
}
9393

9494
pub struct Function {
9595
decl: ast::fn_decl,
9696
attrs: ~[ast::Attribute],
9797
id: NodeId,
98-
name: ident,
98+
name: Ident,
9999
vis: ast::visibility,
100-
where: span,
100+
where: Span,
101101
generics: ast::Generics,
102102
}
103103

104104
pub struct Typedef {
105105
ty: ast::Ty,
106106
gen: ast::Generics,
107-
name: ast::ident,
107+
name: Ident,
108108
id: ast::NodeId,
109109
attrs: ~[ast::Attribute],
110-
where: span,
110+
where: Span,
111111
vis: ast::visibility,
112112
}
113113

114114
pub struct Static {
115115
type_: ast::Ty,
116-
mutability: ast::mutability,
117-
expr: @ast::expr,
118-
name: ast::ident,
116+
mutability: ast::Mutability,
117+
expr: @ast::Expr,
118+
name: Ident,
119119
attrs: ~[ast::Attribute],
120120
vis: ast::visibility,
121121
id: ast::NodeId,
122-
where: span,
122+
where: Span,
123123
}
124124

125125
pub struct Trait {
126-
name: ast::ident,
126+
name: Ident,
127127
methods: ~[ast::trait_method], //should be TraitMethod
128128
generics: ast::Generics,
129129
parents: ~[ast::trait_ref],
130130
attrs: ~[ast::Attribute],
131131
id: ast::NodeId,
132-
where: span,
132+
where: Span,
133133
vis: ast::visibility,
134134
}
135135

@@ -139,7 +139,7 @@ pub struct Impl {
139139
for_: ast::Ty,
140140
methods: ~[@ast::method],
141141
attrs: ~[ast::Attribute],
142-
where: span,
142+
where: Span,
143143
vis: ast::visibility,
144144
id: ast::NodeId,
145145
}

src/rustdoc_ng/visit_ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use syntax::abi::AbiSet;
55
use syntax::{ast, ast_map};
6-
use syntax::codemap::span;
6+
use syntax::codemap::Span;
77

88
use doctree::*;
99
use std::local_data;
@@ -79,7 +79,7 @@ impl RustdocVisitor {
7979
}
8080
}
8181

82-
fn visit_mod_contents(span: span, attrs: ~[ast::Attribute], vis:
82+
fn visit_mod_contents(span: Span, attrs: ~[ast::Attribute], vis:
8383
ast::visibility, id: ast::NodeId, m: &ast::_mod) -> Module {
8484
let am = local_data::get(super::ctxtkey, |x| *x.unwrap()).tycx.items;
8585
let name = match am.find(&id) {

0 commit comments

Comments
 (0)