mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
remove pluginmanager
This commit is contained in:
parent
2e6fc3e2c0
commit
86d2ba4f59
@ -90,7 +90,6 @@ pub mod html {
|
||||
}
|
||||
pub mod markdown;
|
||||
pub mod passes;
|
||||
pub mod plugins;
|
||||
pub mod visit_ast;
|
||||
pub mod visit_lib;
|
||||
pub mod test;
|
||||
@ -750,25 +749,27 @@ where R: 'static + Send,
|
||||
eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
|
||||
}
|
||||
|
||||
// Load all plugins/passes into a PluginManager
|
||||
let mut pm = plugins::PluginManager::new();
|
||||
info!("Executing passes");
|
||||
|
||||
for pass in &passes {
|
||||
let plugin = match passes::PASSES.iter()
|
||||
// determine if we know about this pass
|
||||
let pass = match passes::PASSES.iter().find(|(p, ..)| p == pass) {
|
||||
/*
|
||||
.position(|&(p, ..)| {
|
||||
p == *pass
|
||||
}) {
|
||||
Some(i) => passes::PASSES[i].1,
|
||||
*/
|
||||
Some(pass) => pass.1,
|
||||
None => {
|
||||
error!("unknown pass {}, skipping", *pass);
|
||||
|
||||
continue
|
||||
},
|
||||
};
|
||||
pm.add_plugin(plugin);
|
||||
}
|
||||
|
||||
// Run everything!
|
||||
info!("Executing passes/plugins");
|
||||
let krate = pm.run_plugins(krate);
|
||||
// run it
|
||||
krate = pass(krate);
|
||||
}
|
||||
|
||||
tx.send(f(Output { krate: krate, renderinfo: renderinfo, passes: passes })).unwrap();
|
||||
}));
|
||||
|
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
use clean::{self, DocFragment, Item};
|
||||
use plugins;
|
||||
use fold;
|
||||
use fold::DocFolder;
|
||||
use std::mem::replace;
|
||||
@ -31,7 +30,7 @@ impl DocFragment {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
|
||||
pub fn collapse_docs(krate: clean::Crate) -> clean::Crate {
|
||||
Collapser.fold_crate(krate)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ use std::mem;
|
||||
use clean::{self, GetDefId, Item};
|
||||
use fold;
|
||||
use fold::FoldItem::Strip;
|
||||
use plugins;
|
||||
|
||||
mod collapse_docs;
|
||||
pub use self::collapse_docs::collapse_docs;
|
||||
@ -37,7 +36,7 @@ mod propagate_doc_cfg;
|
||||
pub use self::propagate_doc_cfg::propagate_doc_cfg;
|
||||
|
||||
type Pass = (&'static str, // name
|
||||
fn(clean::Crate) -> plugins::PluginResult, // fn
|
||||
fn(clean::Crate) -> clean::Crate, // fn
|
||||
&'static str); // description
|
||||
|
||||
pub const PASSES: &'static [Pass] = &[
|
||||
|
@ -13,9 +13,8 @@ use std::sync::Arc;
|
||||
use clean::{Crate, Item};
|
||||
use clean::cfg::Cfg;
|
||||
use fold::DocFolder;
|
||||
use plugins::PluginResult;
|
||||
|
||||
pub fn propagate_doc_cfg(cr: Crate) -> PluginResult {
|
||||
pub fn propagate_doc_cfg(cr: Crate) -> Crate {
|
||||
CfgPropagator { parent_cfg: None }.fold_crate(cr)
|
||||
}
|
||||
|
||||
|
@ -13,14 +13,13 @@ use std::mem;
|
||||
|
||||
use clean::{self, AttributesExt, NestedAttributesExt};
|
||||
use clean::Item;
|
||||
use plugins;
|
||||
use fold;
|
||||
use fold::DocFolder;
|
||||
use fold::FoldItem::Strip;
|
||||
use passes::ImplStripper;
|
||||
|
||||
/// Strip items marked `#[doc(hidden)]`
|
||||
pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
|
||||
pub fn strip_hidden(krate: clean::Crate) -> clean::Crate {
|
||||
let mut retained = DefIdSet();
|
||||
|
||||
// strip all #[doc(hidden)] items
|
||||
|
@ -10,9 +10,8 @@
|
||||
|
||||
use clean;
|
||||
use fold::DocFolder;
|
||||
use plugins;
|
||||
use passes::ImportStripper;
|
||||
|
||||
pub fn strip_priv_imports(krate: clean::Crate) -> plugins::PluginResult {
|
||||
pub fn strip_priv_imports(krate: clean::Crate) -> clean::Crate {
|
||||
ImportStripper.fold_crate(krate)
|
||||
}
|
||||
|
@ -11,13 +11,12 @@
|
||||
use rustc::util::nodemap::DefIdSet;
|
||||
|
||||
use clean;
|
||||
use plugins;
|
||||
use fold::DocFolder;
|
||||
use passes::{ImplStripper, ImportStripper, Stripper};
|
||||
|
||||
/// Strip private items from the point of view of a crate or externally from a
|
||||
/// crate, specified by the `xcrate` flag.
|
||||
pub fn strip_private(mut krate: clean::Crate) -> plugins::PluginResult {
|
||||
pub fn strip_private(mut krate: clean::Crate) -> clean::Crate {
|
||||
// This stripper collects all *retained* nodes.
|
||||
let mut retained = DefIdSet();
|
||||
let access_levels = krate.access_levels.clone();
|
||||
|
@ -13,10 +13,9 @@ use std::string::String;
|
||||
use std::usize;
|
||||
|
||||
use clean::{self, DocFragment, Item};
|
||||
use plugins;
|
||||
use fold::{self, DocFolder};
|
||||
|
||||
pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult {
|
||||
pub fn unindent_comments(krate: clean::Crate) -> clean::Crate {
|
||||
CommentCleaner.fold_crate(krate)
|
||||
}
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(deprecated)]
|
||||
|
||||
use clean;
|
||||
|
||||
pub type PluginResult = clean::Crate;
|
||||
pub type PluginCallback = fn (clean::Crate) -> PluginResult;
|
||||
|
||||
/// Manages loading and running of plugins
|
||||
pub struct PluginManager {
|
||||
callbacks: Vec<PluginCallback> ,
|
||||
}
|
||||
|
||||
impl PluginManager {
|
||||
/// Create a new plugin manager
|
||||
pub fn new() -> PluginManager {
|
||||
PluginManager {
|
||||
callbacks: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Load a normal Rust function as a plugin.
|
||||
///
|
||||
/// This is to run passes over the cleaned crate. Plugins run this way
|
||||
/// correspond to the A-aux tag on Github.
|
||||
pub fn add_plugin(&mut self, plugin: PluginCallback) {
|
||||
self.callbacks.push(plugin);
|
||||
}
|
||||
/// Run all the loaded plugins over the crate, returning their results
|
||||
pub fn run_plugins(&self, mut krate: clean::Crate) -> clean::Crate {
|
||||
for &callback in &self.callbacks {
|
||||
krate = callback(krate);
|
||||
}
|
||||
krate
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user