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

Function single_variable_in_function

src/selection_range.rs:920–947  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

918
919 #[test]
920 fn single_variable_in_function() {
921 let content = r#"<?php
922function hello() {
923 $name = "world";
924 echo $name;
925}
926"#;
927 // Position cursor on `$name` in the echo statement (line 3, char 9).
928 let results = selection_ranges(content, &[Position::new(3, 9)]);
929 assert_eq!(results.len(), 1);
930 let ranges = flatten(&results[0]);
931
932 // Should have multiple levels: at minimum variable → expression → statement → block → function → file.
933 assert!(
934 ranges.len() >= 3,
935 "Expected at least 3 selection range levels, got {}",
936 ranges.len()
937 );
938
939 // The innermost range should be smaller than the outermost.
940 let innermost = &ranges[0];
941 let outermost = ranges.last().unwrap();
942 assert!(
943 innermost.start.line >= outermost.start.line
944 || innermost.start.character >= outermost.start.character,
945 "Innermost range should be within outermost"
946 );
947 }
948
949 #[test]
950 fn class_method_body() {

Callers

nothing calls this directly

Calls 4

selection_rangesFunction · 0.85
flattenFunction · 0.85
lastMethod · 0.80
unwrapMethod · 0.45

Tested by

no test coverage detected