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

Function collects_non_static

src/code_actions/generate_constructor.rs:869–902  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

867
868 #[test]
869 fn collects_non_static() {
870 let arena = Box::leak(Box::new(Bump::new()));
871 let file_id = mago_database::file::FileId::new("input.php");
872 let php = "<?php\nclass Foo {\n public string $name;\n private int $age;\n}";
873 let program = mago_syntax::parser::parse_file_content(arena, file_id, php);
874
875 let ctx = find_cursor_context(&program.statements, 20);
876 if let CursorContext::InClassLike { all_members, .. } = &ctx {
877 let props = collect_qualifying_properties(all_members, php, program.trivia.as_slice());
878 assert_eq!(props.len(), 2);
879 assert_eq!(props[0].name, "name");
880 assert_eq!(
881 props[0]
882 .type_hint
883 .as_ref()
884 .map(|t| t.to_string())
885 .as_deref(),
886 Some("string")
887 );
888 assert_eq!(props[0].visibility, "public");
889 assert_eq!(props[1].name, "age");
890 assert_eq!(
891 props[1]
892 .type_hint
893 .as_ref()
894 .map(|t| t.to_string())
895 .as_deref(),
896 Some("int")
897 );
898 assert_eq!(props[1].visibility, "private");
899 } else {
900 panic!("should find class");
901 }
902 }
903
904 #[test]
905 fn skips_static_properties() {

Callers

nothing calls this directly

Calls 2

find_cursor_contextFunction · 0.85

Tested by

no test coverage detected