MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / execute_strategy

Function execute_strategy

src/formatting.rs:267–295  ·  view source on GitHub ↗

Execute the resolved formatting strategy and return `TextEdit`s. This is the main entry point called by the `formatting()` handler.

(
    strategy: &FormattingStrategy,
    content: &str,
    file_path: &Path,
    config: &FormattingConfig,
    php_version: crate::types::PhpVersion,
)

Source from the content-addressed store, hash-verified

265///
266/// This is the main entry point called by the `formatting()` handler.
267pub(crate) fn execute_strategy(
268 strategy: &FormattingStrategy,
269 content: &str,
270 file_path: &Path,
271 config: &FormattingConfig,
272 php_version: crate::types::PhpVersion,
273) -> Result<Option<Vec<TextEdit>>, String> {
274 match strategy {
275 FormattingStrategy::Disabled => Ok(None),
276 FormattingStrategy::External(tools) => {
277 let edits = run_external_pipeline(tools, content, file_path, config)?;
278 if edits.is_empty() {
279 Ok(None)
280 } else {
281 Ok(Some(edits))
282 }
283 }
284 FormattingStrategy::BuiltIn => {
285 let mago_version = to_mago_php_version(php_version);
286 let formatted = format_with_mago(content, mago_version)?;
287 let edits = compute_edits(content, &formatted);
288 if edits.is_empty() {
289 Ok(None)
290 } else {
291 Ok(Some(edits))
292 }
293 }
294 }
295}
296
297/// Run a single tool on the content and return the formatted string.
298fn run_tool(

Calls 5

run_external_pipelineFunction · 0.85
to_mago_php_versionFunction · 0.85
format_with_magoFunction · 0.85
compute_editsFunction · 0.85
is_emptyMethod · 0.45