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

Function parse_lint_issues

src/mago.rs:694–740  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

692
693 #[test]
694 fn parse_lint_issues() {
695 let content = "<?php\necho 'hello';\nreturn 42;\n";
696 let file_path = "/tmp/phpantom-mago-abc123.php";
697
698 let json = r#"{
699 "issues": [
700 {
701 "level": "Error",
702 "code": "invalid-return-statement",
703 "message": "Invalid return type.",
704 "notes": [],
705 "help": "",
706 "annotations": [
707 {
708 "message": "This has type int",
709 "kind": "Primary",
710 "span": {
711 "file_id": {
712 "name": "test.php",
713 "path": "/tmp/phpantom-mago-abc123.php",
714 "size": 72,
715 "file_type": "Host"
716 },
717 "start": { "offset": 20, "line": 2 },
718 "end": { "offset": 29, "line": 2 }
719 }
720 }
721 ]
722 }
723 ]
724 }"#;
725
726 let diags = parse_mago_json(json, content, file_path, "mago-lint").unwrap();
727 assert_eq!(diags.len(), 1);
728 assert_eq!(diags[0].severity, Some(DiagnosticSeverity::ERROR));
729 assert_eq!(diags[0].source.as_deref(), Some("mago-lint"));
730 assert_eq!(
731 diags[0].code,
732 Some(NumberOrString::String(
733 "invalid-return-statement".to_string()
734 ))
735 );
736 assert!(diags[0].message.contains("Invalid return type."));
737 assert!(diags[0].message.contains("This has type int"));
738 // Line 2, offset 19 → compute from content
739 assert_eq!(diags[0].range.start.line, 2);
740 }
741
742 // ── parse_mago_json — analyze issues ────────────────────────────
743

Callers

nothing calls this directly

Calls 2

parse_mago_jsonFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected