parent
6c6d7c3916
commit
df6ec4f8ea
1 changed files with 47 additions and 15 deletions
|
@ -257,7 +257,8 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
hardbreak(s.s);
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
alt (item.node) {
|
||||
case (ast::item_const(?id, ?ty, ?expr, _, _, _)) {
|
||||
case (ast::item_const(?id, ?ty, ?expr, ?attrs, _, _)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
head(s, "const");
|
||||
print_type(s, *ty);
|
||||
space(s.s);
|
||||
|
@ -268,19 +269,22 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
word(s.s, ";");
|
||||
end(s); // end the outer cbox
|
||||
}
|
||||
case (ast::item_fn(?name,?_fn,?typarams,_,_,_)) {
|
||||
case (ast::item_fn(?name,?_fn,?typarams,?attrs,_,_)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
print_fn(s, _fn.decl, _fn.proto, name, typarams);
|
||||
word(s.s, " ");
|
||||
print_block(s, _fn.body);
|
||||
}
|
||||
case (ast::item_mod(?id,?_mod,_,_)) {
|
||||
case (ast::item_mod(?id,?_mod,?attrs,_)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
head(s, "mod");
|
||||
word_nbsp(s, id);
|
||||
bopen(s);
|
||||
for (@ast::item itm in _mod.items) {print_item(s, itm);}
|
||||
bclose(s, item.span);
|
||||
}
|
||||
case (ast::item_native_mod(?id,?nmod,_,_)) {
|
||||
case (ast::item_native_mod(?id,?nmod,?attrs,_)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
head(s, "native");
|
||||
alt (nmod.abi) {
|
||||
case (ast::native_abi_rust) {word_nbsp(s, "\"rust\"");}
|
||||
|
@ -317,7 +321,8 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
}
|
||||
bclose(s, item.span);
|
||||
}
|
||||
case (ast::item_ty(?id,?ty,?params,_,_,_)) {
|
||||
case (ast::item_ty(?id,?ty,?params,?attrs,_,_)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
ibox(s, indent_unit);
|
||||
ibox(s, 0u);
|
||||
word_nbsp(s, "type");
|
||||
|
@ -331,7 +336,8 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
end(s); // end the outer ibox
|
||||
break_offset(s.s, 0u, 0);
|
||||
}
|
||||
case (ast::item_tag(?id,?variants,?params,_,_,_)) {
|
||||
case (ast::item_tag(?id,?variants,?params,?attrs,_,_)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
head(s, "tag");
|
||||
word(s.s, id);
|
||||
print_type_params(s, params);
|
||||
|
@ -354,7 +360,8 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
}
|
||||
bclose(s, item.span);
|
||||
}
|
||||
case (ast::item_obj(?id,?_obj,?params,_,_,_)) {
|
||||
case (ast::item_obj(?id,?_obj,?params,?attrs,_,_)) {
|
||||
print_outer_attributes(s, attrs);
|
||||
head(s, "obj");
|
||||
word(s.s, id);
|
||||
print_type_params(s, params);
|
||||
|
@ -401,6 +408,30 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_outer_attributes(&ps s, vec[ast::attribute] attrs) {
|
||||
auto count = 0;
|
||||
for (ast::attribute attr in attrs) {
|
||||
alt (attr.node.style) {
|
||||
case (ast::attr_outer) {
|
||||
print_attribute(s, attr);
|
||||
count += 1;
|
||||
}
|
||||
case (_) { /* fallthrough */ }
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
hardbreak(s.s);
|
||||
}
|
||||
}
|
||||
|
||||
fn print_attribute(&ps s, &ast::attribute attr) {
|
||||
hardbreak(s.s);
|
||||
maybe_print_comment(s, attr.span.lo);
|
||||
word(s.s, "#[");
|
||||
print_meta_item(s, @attr.node.value);
|
||||
word(s.s, "]");
|
||||
}
|
||||
|
||||
fn print_stmt(&ps s, &ast::stmt st) {
|
||||
maybe_print_comment(s, st.span.lo);
|
||||
alt (st.node) {
|
||||
|
@ -987,6 +1018,14 @@ fn print_type_params(&ps s, &vec[ast::ty_param] params) {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_meta_item(&ps s, &@ast::meta_item item) {
|
||||
ibox(s, indent_unit);
|
||||
word_space(s, item.node.key);
|
||||
word_space(s, "=");
|
||||
print_string(s, item.node.value);
|
||||
end(s);
|
||||
}
|
||||
|
||||
fn print_view_item(&ps s, &@ast::view_item item) {
|
||||
hardbreak(s.s);
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
|
@ -996,14 +1035,7 @@ fn print_view_item(&ps s, &@ast::view_item item) {
|
|||
word(s.s, id);
|
||||
if (vec::len(mta) > 0u) {
|
||||
popen(s);
|
||||
fn print_meta(&ps s, &@ast::meta_item item) {
|
||||
ibox(s, indent_unit);
|
||||
word_space(s, item.node.key);
|
||||
word_space(s, "=");
|
||||
print_string(s, item.node.value);
|
||||
end(s);
|
||||
}
|
||||
commasep(s, consistent, mta, print_meta);
|
||||
commasep(s, consistent, mta, print_meta_item);
|
||||
pclose(s);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue