aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/search_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-22 01:29:48 +0900
committernsfisis <nsfisis@gmail.com>2026-05-22 01:43:48 +0900
commit0b06f54103490e3ce5658e82bbc0119633e26cd8 (patch)
tree687b075131d3679725e77e0931ff7c503a6c3034 /crates/shirabe/src/command/search_command.rs
parent2914770fba6b3cc03a68fae493f60470a41962ec (diff)
downloadphp-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.gz
php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.zst
php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.zip
refactor(composer): unify Composer/PartialComposer via Rc handles
Model PHP's `Composer extends PartialComposer` as a PartialOrFullComposer enum and merge partial_composer.rs into composer.rs. Introduce ComposerHandle / PartialComposerHandle (plus their Weak variants) so the graph can be shared, and build it at once with Rc::new_cyclic in the factory to resolve the back-reference cycles. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/search_command.rs')
-rw-r--r--crates/shirabe/src/command/search_command.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs
index 16df221..fb6b047 100644
--- a/crates/shirabe/src/command/search_command.rs
+++ b/crates/shirabe/src/command/search_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/SearchCommand.php
use crate::command::{BaseCommand, BaseCommandData, HasBaseCommandData};
-use crate::composer::Composer;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterface;
@@ -77,21 +76,27 @@ impl SearchCommand {
let io_box = self.get_io().clone_box();
self.create_composer_instance(input, io_box.as_ref(), None, false, None)?
};
+ let composer_ref = crate::command::composer_full(&composer);
// TODO(phase-b): get_local_repository returns &dyn InstalledRepositoryInterface but we need Box<dyn RepositoryInterface>
let local_repo: Box<dyn RepositoryInterface> =
todo!("share local_repo as RepositoryInterface");
let installed_repo = CompositeRepository::new(vec![local_repo, Box::new(platform_repo)]);
let mut all_repos: Vec<Box<dyn RepositoryInterface>> = vec![Box::new(installed_repo)];
// TODO(phase-b): get_repositories returns &Vec<Box<...>>; needs ownership reshape
- for r in composer.get_repository_manager().get_repositories() {
+ for r in composer_ref
+ .get_repository_manager()
+ .borrow()
+ .get_repositories()
+ {
all_repos.push(r.clone_box());
}
let repos = CompositeRepository::new(all_repos);
// TODO(plugin): dispatch CommandEvent for search command
let command_event = CommandEvent::new(PluginEvents::COMMAND, "search", input, output);
- composer
- .get_event_dispatcher()
+ let dispatcher = composer_ref.get_event_dispatcher().clone();
+ drop(composer_ref);
+ dispatcher
.borrow_mut()
.dispatch(Some(command_event.get_name()), None);