aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/plugin')
-rw-r--r--crates/shirabe/src/plugin/capability/mod.rs1
-rw-r--r--crates/shirabe/src/plugin/plugin_interface.rs2
-rw-r--r--crates/shirabe/src/plugin/plugin_manager.rs28
3 files changed, 13 insertions, 18 deletions
diff --git a/crates/shirabe/src/plugin/capability/mod.rs b/crates/shirabe/src/plugin/capability/mod.rs
index d9874b4..5b7dcea 100644
--- a/crates/shirabe/src/plugin/capability/mod.rs
+++ b/crates/shirabe/src/plugin/capability/mod.rs
@@ -1,3 +1,4 @@
+#[allow(clippy::module_inception, reason = "to port PHP's structure as it is")]
pub mod capability;
pub mod command_provider;
diff --git a/crates/shirabe/src/plugin/plugin_interface.rs b/crates/shirabe/src/plugin/plugin_interface.rs
index c0212de..d335bf0 100644
--- a/crates/shirabe/src/plugin/plugin_interface.rs
+++ b/crates/shirabe/src/plugin/plugin_interface.rs
@@ -6,7 +6,7 @@ use crate::plugin::Capable;
use std::cell::RefCell;
use std::rc::Rc;
-pub const PLUGIN_API_VERSION: &'static str = "2.9.0";
+pub const PLUGIN_API_VERSION: &str = "2.9.0";
pub trait PluginInterface: std::fmt::Debug {
fn activate(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>);
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs
index 25953ab..e8377f3 100644
--- a/crates/shirabe/src/plugin/plugin_manager.rs
+++ b/crates/shirabe/src/plugin/plugin_manager.rs
@@ -460,7 +460,7 @@ impl PluginManager {
// — add_subscriber here is generic over `S: EventSubscriberInterface` and cannot
// accept a `&dyn EventSubscriberInterface`. Skipped until subscriber dispatch is
// implemented dynamically.
- let _ = (&*plugin).is_event_subscriber_interface();
+ let _ = (*plugin).is_event_subscriber_interface();
self.plugins.push(plugin);
Ok(())
}
@@ -520,10 +520,7 @@ impl PluginManager {
}
}
- let sorted_packages = PackageSorter::sort_packages(
- packages.iter().map(|p| p.clone().into()).collect(),
- weights,
- );
+ let sorted_packages = PackageSorter::sort_packages(packages.to_vec(), weights);
let required_packages: Vec<crate::package::BasePackageHandle> = if !is_global_repo {
// PHP: $requiredPackages = RepositoryUtils::filterRequiredPackages($packages, $rootPackage, true);
let bucket: Vec<crate::package::BasePackageHandle> = vec![];
@@ -582,10 +579,7 @@ impl PluginManager {
// TODO(plugin): deactivate plugins from a repository
let packages = repo.get_packages()?;
// PHP: $sortedPackages = array_reverse(PackageSorter::sortPackages($packages));
- let mut sorted_packages = PackageSorter::sort_packages(
- packages.iter().map(|p| p.clone().into()).collect(),
- IndexMap::new(),
- );
+ let mut sorted_packages = PackageSorter::sort_packages(packages.to_vec(), IndexMap::new());
sorted_packages.reverse();
for package in &sorted_packages {
@@ -615,11 +609,11 @@ impl PluginManager {
.find_packages_with_replacers_and_providers(require_link.get_target(), None)?
{
if !collected.contains_key(&required_package.get_name()) {
- collected.insert(required_package.get_name(), required_package.clone().into());
+ collected.insert(required_package.get_name(), required_package.clone());
collected = self.collect_dependencies(
installed_repo,
collected,
- required_package.clone().into(),
+ required_package.clone(),
)?;
}
}
@@ -794,12 +788,12 @@ impl PluginManager {
}
pub fn are_plugins_disabled(&self, r#type: &str) -> bool {
- match (&self.disable_plugins, r#type) {
- (DisablePlugins::All, _) => true,
- (DisablePlugins::Local, "local") => true,
- (DisablePlugins::Global, "global") => true,
- _ => false,
- }
+ matches!(
+ (&self.disable_plugins, r#type),
+ (DisablePlugins::All, _)
+ | (DisablePlugins::Local, "local")
+ | (DisablePlugins::Global, "global")
+ )
}
pub fn disable_plugins(&mut self) {