From 1ec2220def43e37e5a65b96dde93c19b493258f4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 11 Jul 2026 16:03:05 +0900 Subject: feat(completion): thread Rc through suggest_options InputDefinition stores options as Rc for sharing, so CompletionSuggestions::suggest_option[s] now accepts Rc instead of owned values, resolving the ownership mismatch left as a todo!() in Application::complete and CompleteCommand. --- .../src/symfony/console/command/complete_command.rs | 14 ++++++++------ .../symfony/console/completion/completion_suggestions.rs | 9 +++++---- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console') diff --git a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs index 7df1f802..d64e4a99 100644 --- a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs +++ b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs @@ -151,12 +151,14 @@ fn get_class_of_command(command: &Rc>) -> String { todo!() } -/// $command->getDefinition()->getOptions() -fn get_definition_options(_command: &Rc>) -> Vec { - // TODO: InputDefinition::get_options() returns `&IndexMap>` but - // CompletionSuggestions::suggest_options() takes `Vec`; the option ownership - // model must be reconciled (Phase C). - todo!() +fn get_definition_options(command: &Rc>) -> Vec> { + command + .borrow() + .get_definition() + .get_options() + .values() + .cloned() + .collect() } /// new $completionOutput(); diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs b/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs index 2fb617ab..512056aa 100644 --- a/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs +++ b/crates/shirabe-external-packages/src/symfony/console/completion/completion_suggestions.rs @@ -2,6 +2,7 @@ use crate::symfony::console::completion::suggestion::Suggestion; use crate::symfony::console::input::input_option::InputOption; +use std::rc::Rc; /// PHP union type `string|Suggestion` used by `suggestValue`/`suggestValues`. #[derive(Debug)] @@ -14,7 +15,7 @@ pub enum StringOrSuggestion { #[derive(Debug)] pub struct CompletionSuggestions { value_suggestions: Vec, - option_suggestions: Vec, + option_suggestions: Vec>, } impl Default for CompletionSuggestions { @@ -51,14 +52,14 @@ impl CompletionSuggestions { } /// Add a suggestion for an input option name. - pub fn suggest_option(&mut self, option: InputOption) -> &mut Self { + pub fn suggest_option(&mut self, option: Rc) -> &mut Self { self.option_suggestions.push(option); self } /// Add multiple suggestions for input option names at once. - pub fn suggest_options(&mut self, options: Vec) -> &mut Self { + pub fn suggest_options(&mut self, options: Vec>) -> &mut Self { for option in options { self.suggest_option(option); } @@ -66,7 +67,7 @@ impl CompletionSuggestions { self } - pub fn get_option_suggestions(&self) -> &Vec { + pub fn get_option_suggestions(&self) -> &Vec> { &self.option_suggestions } -- cgit v1.3.1