Skip to content

Update the vendored parser to the latest version. #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 9, 2023
Merged
2 changes: 1 addition & 1 deletion analysis/reanalyze/src/RunConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ let dce () = runConfig.dce <- true
let exception_ () = runConfig.exception_ <- true
let termination () = runConfig.termination <- true

let transitive b = runConfig.transitive <- b
let transitive b = runConfig.transitive <- b
2 changes: 1 addition & 1 deletion analysis/src/CompletionFrontEnd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
in
let attribute (iterator : Ast_iterator.iterator)
((id, payload) : Parsetree.attribute) =
(if String.length id.txt >= 3 && String.sub id.txt 0 3 = "ns." then
(if String.length id.txt >= 4 && String.sub id.txt 0 4 = "res." then
(* skip: internal parser attribute *) ()
else if id.loc.loc_ghost then ()
else if id.loc |> Loc.hasPos ~pos:posBeforeCursor then
Expand Down
4 changes: 2 additions & 2 deletions analysis/src/CompletionJsx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ let extractJsxProps ~(compName : Longident.t Location.loc) ~args =
| ((Labelled s | Optional s), (eProp : Parsetree.expression)) :: rest -> (
let namedArgLoc =
eProp.pexp_attributes
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "ns.namedArgLoc")
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "res.namedArgLoc")
in
match namedArgLoc with
| Some ({loc}, _) ->
Expand All @@ -911,4 +911,4 @@ let extractJsxProps ~(compName : Longident.t Location.loc) ~args =
| None -> processProps ~acc rest)
| _ -> thisCaseShouldNotHappen
in
args |> processProps ~acc:[]
args |> processProps ~acc:[]
3 changes: 1 addition & 2 deletions analysis/src/Hint.ml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
open SharedTypes

type inlayHintKind = Type | Parameter
type inlayHintKind = Type
let inlayKindToNumber = function
| Type -> 1
| Parameter -> 2

let locItemToTypeHint ~full:{file; package} locItem =
match locItem.locType with
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/Markdown.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ let goToDefinitionText ~env ~pos =
label = "Type definition";
file = Uri.toString env.SharedTypes.QueryEnv.file.uri;
startPos = {line = startLine; character = startCol};
}
}
3 changes: 1 addition & 2 deletions analysis/src/Protocol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ type signatureHelp = {
}

(* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#insertTextFormat *)
type insertTextFormat = PlainText | Snippet
type insertTextFormat = Snippet

let insertTextFormatToInt f =
match f with
| PlainText -> 1
| Snippet -> 2

type completionItem = {
Expand Down
11 changes: 5 additions & 6 deletions analysis/src/SharedTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ module Completion = struct
detail: string option;
}

let create ~kind ~env ?(docstring = []) ?filterText ?insertText ?deprecated
?detail name =
let create ~kind ~env ?(docstring = []) ?insertText ?deprecated ?detail name =
{
name;
env;
Expand All @@ -365,12 +364,12 @@ module Completion = struct
sortText = None;
insertText;
insertTextFormat = None;
filterText;
filterText = None;
detail;
}

let createWithSnippet ~name ?insertText ~kind ~env ?sortText ?deprecated
?filterText ?(docstring = []) () =
?(docstring = []) () =
{
name;
env;
Expand All @@ -380,7 +379,7 @@ module Completion = struct
sortText;
insertText;
insertTextFormat = Some Protocol.Snippet;
filterText;
filterText = None;
detail = None;
}

Expand Down Expand Up @@ -793,7 +792,7 @@ let extractExpApplyArgs ~args =
:: rest -> (
let namedArgLoc =
e.pexp_attributes
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "ns.namedArgLoc")
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "res.namedArgLoc")
in
match namedArgLoc with
| Some ({loc}, _) ->
Expand Down
18 changes: 1 addition & 17 deletions analysis/src/Utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,6 @@ let identifyPpat pat =
| Ppat_extension _ -> "Ppat_extension"
| Ppat_open _ -> "Ppat_open"

let identifyType type_desc =
match type_desc with
| Types.Tvar _ -> "Tvar"
| Tarrow _ -> "Tarrow"
| Ttuple _ -> "Ttuple"
| Tconstr _ -> "Tconstr"
| Tobject _ -> "Tobject"
| Tfield _ -> "Tfield"
| Tnil -> "Tnil"
| Tlink _ -> "Tlink"
| Tsubst _ -> "Tsubst"
| Tvariant _ -> "Tvariant"
| Tunivar _ -> "Tunivar"
| Tpoly _ -> "Tpoly"
| Tpackage _ -> "Tpackage"

let rec skipWhite text i =
if i < 0 then 0
else
Expand All @@ -161,7 +145,7 @@ let rec skipWhite text i =
| _ -> i

let hasBraces attributes =
attributes |> List.exists (fun (loc, _) -> loc.Location.txt = "ns.braces")
attributes |> List.exists (fun (loc, _) -> loc.Location.txt = "res.braces")

let rec unwrapIfOption (t : Types.type_expr) =
match t.desc with
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/Xform.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ module AddBracesToFn = struct
};
}
in
(Location.mkloc "ns.braces" loc, Parsetree.PStr [])
(Location.mkloc "res.braces" loc, Parsetree.PStr [])
in
let isFunction = function
| {Parsetree.pexp_desc = Pexp_fun _} -> true
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
(flags
(-w "+6+26+27+32+33+39"))
; Depends on:
(libraries unix str ext ml jsonlib outcomeprinter reanalyze))
(libraries unix str ext ml jsonlib syntax reanalyze))
1 change: 1 addition & 0 deletions analysis/vendor/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable
2 changes: 1 addition & 1 deletion analysis/vendor/dune
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(dirs compiler-libs-406 ext ml res_outcome_printer json)
(dirs ext ml res_syntax json)
6 changes: 0 additions & 6 deletions analysis/vendor/res_outcome_printer/dune

This file was deleted.

Loading