parent
43cbbabccb
commit
b727d079ed
@ -264,9 +264,9 @@ fn print_type(&ps s, &ast::ty ty) {
|
|||||||
fn print_item(&ps s, &@ast::item item) {
|
fn print_item(&ps s, &@ast::item item) {
|
||||||
hardbreak(s.s);
|
hardbreak(s.s);
|
||||||
maybe_print_comment(s, item.span.lo);
|
maybe_print_comment(s, item.span.lo);
|
||||||
|
print_outer_attributes(s, item.attrs);
|
||||||
alt (item.node) {
|
alt (item.node) {
|
||||||
case (ast::item_const(?ty, ?expr)) {
|
case (ast::item_const(?ty, ?expr)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
head(s, "const");
|
head(s, "const");
|
||||||
print_type(s, *ty);
|
print_type(s, *ty);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
@ -280,21 +280,19 @@ fn print_item(&ps s, &@ast::item item) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
case (ast::item_fn(?_fn, ?typarams)) {
|
case (ast::item_fn(?_fn, ?typarams)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
print_fn(s, _fn.decl, _fn.proto, item.ident, typarams);
|
print_fn(s, _fn.decl, _fn.proto, item.ident, typarams);
|
||||||
word(s.s, " ");
|
word(s.s, " ");
|
||||||
print_block(s, _fn.body);
|
print_block(s, _fn.body);
|
||||||
}
|
}
|
||||||
case (ast::item_mod(?_mod)) {
|
case (ast::item_mod(?_mod)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
head(s, "mod");
|
head(s, "mod");
|
||||||
word_nbsp(s, item.ident);
|
word_nbsp(s, item.ident);
|
||||||
bopen(s);
|
bopen(s);
|
||||||
|
print_inner_attributes(s, item.attrs);
|
||||||
for (@ast::item itm in _mod.items) { print_item(s, itm); }
|
for (@ast::item itm in _mod.items) { print_item(s, itm); }
|
||||||
bclose(s, item.span);
|
bclose(s, item.span);
|
||||||
}
|
}
|
||||||
case (ast::item_native_mod(?nmod)) {
|
case (ast::item_native_mod(?nmod)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
head(s, "native");
|
head(s, "native");
|
||||||
alt (nmod.abi) {
|
alt (nmod.abi) {
|
||||||
case (ast::native_abi_rust) { word_nbsp(s, "\"rust\""); }
|
case (ast::native_abi_rust) { word_nbsp(s, "\"rust\""); }
|
||||||
@ -338,7 +336,6 @@ fn print_item(&ps s, &@ast::item item) {
|
|||||||
bclose(s, item.span);
|
bclose(s, item.span);
|
||||||
}
|
}
|
||||||
case (ast::item_ty(?ty, ?params)) {
|
case (ast::item_ty(?ty, ?params)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
ibox(s, 0u);
|
ibox(s, 0u);
|
||||||
word_nbsp(s, "type");
|
word_nbsp(s, "type");
|
||||||
@ -355,7 +352,6 @@ fn print_item(&ps s, &@ast::item item) {
|
|||||||
break_offset(s.s, 0u, 0);
|
break_offset(s.s, 0u, 0);
|
||||||
}
|
}
|
||||||
case (ast::item_tag(?variants, ?params)) {
|
case (ast::item_tag(?variants, ?params)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
head(s, "tag");
|
head(s, "tag");
|
||||||
word(s.s, item.ident);
|
word(s.s, item.ident);
|
||||||
print_type_params(s, params);
|
print_type_params(s, params);
|
||||||
@ -379,7 +375,6 @@ fn print_item(&ps s, &@ast::item item) {
|
|||||||
bclose(s, item.span);
|
bclose(s, item.span);
|
||||||
}
|
}
|
||||||
case (ast::item_obj(?_obj, ?params, _)) {
|
case (ast::item_obj(?_obj, ?params, _)) {
|
||||||
print_outer_attributes(s, item.attrs);
|
|
||||||
head(s, "obj");
|
head(s, "obj");
|
||||||
word(s.s, item.ident);
|
word(s.s, item.ident);
|
||||||
print_type_params(s, params);
|
print_type_params(s, params);
|
||||||
@ -438,6 +433,21 @@ fn print_outer_attributes(&ps s, vec[ast::attribute] attrs) {
|
|||||||
if (count > 0) { hardbreak(s.s); }
|
if (count > 0) { hardbreak(s.s); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_inner_attributes(&ps s, vec[ast::attribute] attrs) {
|
||||||
|
auto count = 0;
|
||||||
|
for (ast::attribute attr in attrs) {
|
||||||
|
alt (attr.node.style) {
|
||||||
|
case (ast::attr_inner) {
|
||||||
|
print_attribute(s, attr);
|
||||||
|
word(s.s, ";");
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
case (_) { /* fallthrough */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count > 0) { hardbreak(s.s); }
|
||||||
|
}
|
||||||
|
|
||||||
fn print_attribute(&ps s, &ast::attribute attr) {
|
fn print_attribute(&ps s, &ast::attribute attr) {
|
||||||
hardbreak(s.s);
|
hardbreak(s.s);
|
||||||
maybe_print_comment(s, attr.span.lo);
|
maybe_print_comment(s, attr.span.lo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user