From dcfb0915946aff54b01b6040427e56a66d82cb93 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 4 Feb 2016 17:13:14 +0100 Subject: [PATCH] Remove the casing plugin --- components/plugins/casing.rs | 59 ------------------------------------ components/plugins/lib.rs | 6 ++-- 2 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 components/plugins/casing.rs diff --git a/components/plugins/casing.rs b/components/plugins/casing.rs deleted file mode 100644 index 8a535cabf00..00000000000 --- a/components/plugins/casing.rs +++ /dev/null @@ -1,59 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use syntax::ast; -use syntax::codemap::Span; -use syntax::ext::base; -use syntax::ext::base::ExtCtxt; -use syntax::ext::build::AstBuilder; -use syntax::parse::token; - -pub fn expand_lower<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { - expand_cased(cx, sp, tts, |s| { s.to_lowercase() }) -} - -pub fn expand_upper<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { - expand_cased(cx, sp, tts, |s| { s.to_uppercase() }) -} - -fn expand_cased<'cx, T>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree], transform: T) - -> Box - where T: Fn(&str) -> String -{ - let es = match base::get_exprs_from_tts(cx, sp, tts) { - Some(e) => e, - None => return base::DummyResult::expr(sp) - }; - - let mut it = es.iter(); - let res = if let Some(expr) = it.next() { - if let ast::ExprLit(ref lit) = expr.node { - if let ast::LitStr(ref s, _) = lit.node { - Some((s, lit.span)) - } else { - cx.span_err(expr.span, "expected a string literal"); - None - } - } else { - cx.span_err(expr.span, "expected a string literal"); - None - } - } else { - cx.span_err(sp, "expected 1 argument, found 0"); - None - }; - match (res, it.count()) { - (Some((s, span)), 0) => { - base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(&transform(&s)))) - } - (_, rest) => { - if rest > 0 { - cx.span_err(sp, &format!("expected 1 argument, found {}", rest + 1)); - } - base::DummyResult::expr(sp) - } - } -} diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index 25181f2197c..7534b6e5f37 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -39,9 +39,9 @@ pub mod jstraceable; pub mod lints; /// Autogenerates implementations of Reflectable on DOM structs pub mod reflector; -/// Utilities for writing plugins -pub mod casing; +/// The `url!` plugin. mod url_plugin; +/// Utilities for writing plugins pub mod utils; #[plugin_registrar] @@ -49,8 +49,6 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct)); reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable)); reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector)); - reg.register_macro("to_lower", casing::expand_lower); - reg.register_macro("to_upper", casing::expand_upper); reg.register_macro("url", url_plugin::expand_url); reg.register_late_lint_pass(box lints::transmute_type::TransmutePass); reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());