Skip to content

Commit

Permalink
[flow][cleanup] Kill legacy FB extension relatedLocations
Browse files Browse the repository at this point in the history
Summary:
We we running against a fairly recent vscode now, so I don't think we need this anymore.

Changelog: [internal]

Reviewed By: panagosg7

Differential Revision: D57130768

fbshipit-source-id: 38295f96ecd6bd180ce0650dec9c566d067ddadd
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed May 9, 2024
1 parent 2c5d2e2 commit 0c35249
Show file tree
Hide file tree
Showing 22 changed files with 15 additions and 76 deletions.
1 change: 0 additions & 1 deletion newtests/autofix-exports/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ module.exports = (suite(
source: 'Flow',
message: 'Cannot build a typed interface for this module.',
relatedInformation: [],
relatedLocations: [],
},
],
edit: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot call `baz` with object literal bound to `_` because cannot subtype class `A` [1] with object type [2]. Please use an interface instead in property `i`.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot call foo with new A() bound to x because cannot subtype class A [1] with object type [2]. Please use an interface instead.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot call `qux` with object literal bound to `_` because cannot subtype class `A` [1] with object type [2]. Please use an interface instead in property `i`.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot call `bar` with object literal bound to `_` because cannot subtype class `A` [1] with object type [2]. Please use an interface instead in property `i`.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "ParseError",
"source": "Flow",
"message": "You must use `'string-key' as localBinding?: <TYPE>` for props with invalid identifier names.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "ParseError",
"source": "Flow",
"message": "You must use `'string-key' as localBinding: <TYPE>` for props with invalid identifier names.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot access property `Foobat` because `Foobat` is not a member of `enum E`. Did you meanthe member `Foobar`?",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot get `(new A).f` because property `f` [1] cannot be unbound from the context [2] where it was defined.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "ParseError",
"source": "Flow",
"message": "Unexpected token `>`. Did you mean `{'>'}`?",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot get `x.faceboy` because property `faceboy` (did you mean `facebook`?) is missing in object type [1].",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "InferError",
"source": "Flow",
"message": "Cannot get `x.faceboy` because property `faceboy` (did you mean `facebook`?) is missing in object type [1].",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"code": "ParseError",
"source": "Flow",
"message": "Components use `renders` instead of `:` to annotate the render type of a component.",
"relatedInformation": [],
"relatedLocations": []
"relatedInformation": []
}
],
"edit": {
Expand Down
12 changes: 0 additions & 12 deletions newtests/lsp/diagnostics/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,6 @@ module.exports = (suite(
message: '[1] exports',
},
],
relatedLocations: [
{
location: {
uri: '<PLACEHOLDER_PROJECT_URL>/empty.js',
range: {
start: {line: 0, character: 0},
end: {line: 0, character: 0},
},
},
message: '[1] exports',
},
],
},
],
},
Expand Down
1 change: 0 additions & 1 deletion src/common/flow_lsp_conversions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ let diagnostics_of_flow_errors =
message = error.Flow_errors_utils.Lsp_output.message;
tags = [];
relatedInformation;
relatedLocations = relatedInformation (* legacy fb extension *);
}
)
| Error _ -> None
Expand Down
4 changes: 0 additions & 4 deletions src/hack_forked/utils/lsp/lsp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ module PublishDiagnostics = struct
message: string; (** the diagnostic's message *)
tags: DiagnosticTag.t list;
relatedInformation: diagnosticRelatedInformation list;
relatedLocations: relatedLocation list; (** legacy FB extension *)
}

and diagnosticCode =
Expand All @@ -761,9 +760,6 @@ module PublishDiagnostics = struct
relatedLocation: Location.t; (** wire: just "location" *)
relatedMessage: string; (** wire: just "message" *)
}

(* legacy FB extension *)
and relatedLocation = diagnosticRelatedInformation
end

(** DidOpenTextDocument notification, method="textDocument/didOpen" *)
Expand Down
3 changes: 0 additions & 3 deletions src/hack_forked/utils/lsp/lsp.mli
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,12 @@ module PublishDiagnostics : sig
message: string;
tags: DiagnosticTag.t list;
relatedInformation: diagnosticRelatedInformation list;
relatedLocations: relatedLocation list;
}

and diagnosticRelatedInformation = {
relatedLocation: Location.t;
relatedMessage: string;
}

and relatedLocation = diagnosticRelatedInformation
end

module DidOpen : sig
Expand Down
7 changes: 1 addition & 6 deletions src/hack_forked/utils/lsp/lsp_fmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ let print_diagnostic (diagnostic : PublishDiagnostics.diagnostic) : json =
| StringCode s -> Some (string_ s)
| NoCode -> None
in
let print_related (related : relatedLocation) : json =
let print_related (related : diagnosticRelatedInformation) : json =
Hh_json.JSON_Object
[
("location", print_location related.relatedLocation);
Expand All @@ -551,9 +551,6 @@ let print_diagnostic (diagnostic : PublishDiagnostics.diagnostic) : json =
( "relatedInformation",
Some (JSON_Array (Base.List.map diagnostic.relatedInformation ~f:print_related))
);
( "relatedLocations",
Some (JSON_Array (Base.List.map diagnostic.relatedLocations ~f:print_related))
);
]
)

Expand Down Expand Up @@ -614,8 +611,6 @@ let parse_diagnostic (j : json option) : PublishDiagnostics.diagnostic =
tags = Jget.array_d j "tags" ~default:[] |> Base.List.filter_map ~f:DiagnosticTagFmt.of_json;
relatedInformation =
Jget.array_d j "relatedInformation" ~default:[] |> Base.List.map ~f:parse_info;
relatedLocations =
Jget.array_d j "relatedLocations" ~default:[] |> Base.List.map ~f:parse_info;
}
)

Expand Down
23 changes: 2 additions & 21 deletions src/hack_forked/utils/lsp/lsp_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -239,33 +239,14 @@ let default_mapper =
(fun _mapper { ConnectionStatus.isConnected } -> { ConnectionStatus.isConnected });
of_diagnostic =
(fun mapper
{
PublishDiagnostics.range;
severity;
code;
source;
message;
tags;
relatedInformation;
relatedLocations;
} ->
{ PublishDiagnostics.range; severity; code; source; message; tags; relatedInformation } ->
let range = mapper.of_range mapper range in
let map_related_info { PublishDiagnostics.relatedLocation; relatedMessage } =
let relatedLocation = mapper.of_location mapper relatedLocation in
{ PublishDiagnostics.relatedLocation; relatedMessage }
in
let relatedInformation = Base.List.map ~f:map_related_info relatedInformation in
let relatedLocations = Base.List.map ~f:map_related_info relatedLocations in
{
PublishDiagnostics.range;
severity;
code;
source;
message;
tags;
relatedInformation;
relatedLocations;
});
{ PublishDiagnostics.range; severity; code; source; message; tags; relatedInformation });
of_definition_params = (fun mapper t -> mapper.of_text_document_position_params mapper t);
of_definition_result =
(fun mapper results -> Base.List.map ~f:(mapper.of_location mapper) results);
Expand Down
2 changes: 0 additions & 2 deletions src/lsp/__tests__/lspErrors_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ let mk_diagnostic { uri = _; kind; msg } =
message = msg;
tags = [];
relatedInformation = [];
relatedLocations = [];
}

(* Take the json output and convert it back into a list of errors *)
Expand All @@ -54,7 +53,6 @@ let error_list_of_json_response json =
("source", JSON_String "Flow");
("message", JSON_String msg);
("relatedInformation", _);
("relatedLocations", _);
] ->
{ uri; kind; msg }
| _ -> assert_failure "Diagnostic JSON doesn't match expected format")
Expand Down
1 change: 0 additions & 1 deletion src/lsp/flowLsp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,6 @@ let diagnostic_of_parse_error (loc, parse_error) : PublishDiagnostics.diagnostic
tags = [];
message = Parse_error.PP.error parse_error;
relatedInformation = [];
relatedLocations = [] (* legacy fb extension *);
}

let live_syntax_errors_enabled (state : server_state) =
Expand Down
1 change: 0 additions & 1 deletion src/lsp/lspErrors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ let limit_errors errors =
tags = [];
message;
relatedInformation = [];
relatedLocations = [];
}
in

Expand Down

0 comments on commit 0c35249

Please sign in to comment.