diff options
author | Bastien Orivel <eijebong@bananium.fr> | 2019-05-15 23:03:25 +0200 |
---|---|---|
committer | Bastien Orivel <eijebong@bananium.fr> | 2019-05-15 23:03:25 +0200 |
commit | 13c632e739c030243bf7295b54597657be17ef79 (patch) | |
tree | 643f1de1654cb9ba4fd252a7bb9b145882181116 /components/script_plugins | |
parent | 965f57e3f8011dd7bdc61b438f95eeb87748319d (diff) | |
download | servo-13c632e739c030243bf7295b54597657be17ef79.tar.gz servo-13c632e739c030243bf7295b54597657be17ef79.zip |
Switch from webidl to weedle in script_plugins
This removes the dependency on lalrpop and should speed up compilation
quite a bit.
Diffstat (limited to 'components/script_plugins')
-rw-r--r-- | components/script_plugins/Cargo.toml | 2 | ||||
-rw-r--r-- | components/script_plugins/lib.rs | 2 | ||||
-rw-r--r-- | components/script_plugins/webidl_must_inherit.rs | 60 |
3 files changed, 19 insertions, 45 deletions
diff --git a/components/script_plugins/Cargo.toml b/components/script_plugins/Cargo.toml index 1999b3e8e82..407d4639939 100644 --- a/components/script_plugins/Cargo.toml +++ b/components/script_plugins/Cargo.toml @@ -14,4 +14,4 @@ unrooted_must_root_lint = [] webidl_lint = [] [dependencies] -webidl = "0.8" +weedle = "0.9" diff --git a/components/script_plugins/lib.rs b/components/script_plugins/lib.rs index 7d0460bf5a1..a696c456d8d 100644 --- a/components/script_plugins/lib.rs +++ b/components/script_plugins/lib.rs @@ -25,7 +25,7 @@ extern crate rustc; extern crate rustc_plugin; extern crate syntax; -extern crate webidl; +extern crate weedle; use rustc_plugin::Registry; use syntax::feature_gate::AttributeType::Whitelisted; diff --git a/components/script_plugins/webidl_must_inherit.rs b/components/script_plugins/webidl_must_inherit.rs index 89233bb943e..7c092fcf0f9 100644 --- a/components/script_plugins/webidl_must_inherit.rs +++ b/components/script_plugins/webidl_must_inherit.rs @@ -13,9 +13,7 @@ use std::fs; use std::io; use std::path; use syntax::ast; -use webidl::ast::*; -use webidl::visitor::*; -use webidl::*; +use weedle; declare_lint!( WEBIDL_INHERIT_CORRECT, @@ -94,10 +92,22 @@ fn is_webidl_ty(cx: &LateContext, ty: &ty::TyS) -> bool { } fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box<Error>> { - let idl = parse_string(code)?; - let mut visitor = InterfaceVisitor::new(name.to_string()); - visitor.visit(&idl); - let inherits = visitor.get_inherits(); + let idl = weedle::parse(code).expect("Invalid webidl provided"); + let mut inherits = ""; + + for def in idl { + if let weedle::Definition::Interface(def) = def { + if let Some(parent) = def.inheritance { + inherits = parent.identifier.0; + break; + } + } else if let weedle::Definition::CallbackInterface(def) = def { + if let Some(parent) = def.inheritance { + inherits = parent.identifier.0; + break; + } + } + } if inherits == parent_name { return Ok(()); @@ -184,39 +194,3 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WebIdlPass { }; } } - -struct InterfaceVisitor { - name: String, - inherits: String, -} - -impl InterfaceVisitor { - pub fn new(name: String) -> Self { - InterfaceVisitor { - name: name, - inherits: String::new(), - } - } - - pub fn get_inherits(&self) -> &String { - &self.inherits - } -} - -impl<'ast> ImmutableVisitor<'ast> for InterfaceVisitor { - fn visit_callback_interface(&mut self, callback_interface: &'ast CallbackInterface) { - if callback_interface.name == self.name { - if let Some(ref inherit) = callback_interface.inherits { - self.inherits = inherit.to_string() - } - } - } - - fn visit_non_partial_interface(&mut self, non_partial_interface: &'ast NonPartialInterface) { - if non_partial_interface.name == self.name { - if let Some(ref inherit) = non_partial_interface.inherits { - self.inherits = inherit.to_string() - } - } - } -} |