Skip to content

Commit e5d0050

Browse files
authored
Update the vendored parser to the latest version. (#745)
* Update the vendored parser to the latest version. There are a bunch of changes that one needs to look into. * Backward-compatible check for optional fields. * Backwards-compatible check for braces attribute. * The updated parser gives res.namedArgLoc * One more ns.namedArgLoc * ns.braces * Internal attributes are res. * sync dune file with compiler repo * Rename res_outcome_printer to res_syntax, like in the compiler. * format * More format. * Dead code.
1 parent 0247cce commit e5d0050

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1759
-2820
lines changed

analysis/reanalyze/src/RunConfig.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ let dce () = runConfig.dce <- true
3030
let exception_ () = runConfig.exception_ <- true
3131
let termination () = runConfig.termination <- true
3232

33-
let transitive b = runConfig.transitive <- b
33+
let transitive b = runConfig.transitive <- b

analysis/src/CompletionFrontEnd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
566566
in
567567
let attribute (iterator : Ast_iterator.iterator)
568568
((id, payload) : Parsetree.attribute) =
569-
(if String.length id.txt >= 3 && String.sub id.txt 0 3 = "ns." then
569+
(if String.length id.txt >= 4 && String.sub id.txt 0 4 = "res." then
570570
(* skip: internal parser attribute *) ()
571571
else if id.loc.loc_ghost then ()
572572
else if id.loc |> Loc.hasPos ~pos:posBeforeCursor then

analysis/src/CompletionJsx.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ let extractJsxProps ~(compName : Longident.t Location.loc) ~args =
894894
| ((Labelled s | Optional s), (eProp : Parsetree.expression)) :: rest -> (
895895
let namedArgLoc =
896896
eProp.pexp_attributes
897-
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "ns.namedArgLoc")
897+
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "res.namedArgLoc")
898898
in
899899
match namedArgLoc with
900900
| Some ({loc}, _) ->
@@ -911,4 +911,4 @@ let extractJsxProps ~(compName : Longident.t Location.loc) ~args =
911911
| None -> processProps ~acc rest)
912912
| _ -> thisCaseShouldNotHappen
913913
in
914-
args |> processProps ~acc:[]
914+
args |> processProps ~acc:[]

analysis/src/Hint.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
open SharedTypes
22

3-
type inlayHintKind = Type | Parameter
3+
type inlayHintKind = Type
44
let inlayKindToNumber = function
55
| Type -> 1
6-
| Parameter -> 2
76

87
let locItemToTypeHint ~full:{file; package} locItem =
98
match locItem.locType with

analysis/src/Markdown.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ let goToDefinitionText ~env ~pos =
2020
label = "Type definition";
2121
file = Uri.toString env.SharedTypes.QueryEnv.file.uri;
2222
startPos = {line = startLine; character = startCol};
23-
}
23+
}

analysis/src/Protocol.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ type signatureHelp = {
3434
}
3535

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

3939
let insertTextFormatToInt f =
4040
match f with
41-
| PlainText -> 1
4241
| Snippet -> 2
4342

4443
type completionItem = {

analysis/src/SharedTypes.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ module Completion = struct
354354
detail: string option;
355355
}
356356

357-
let create ~kind ~env ?(docstring = []) ?filterText ?insertText ?deprecated
358-
?detail name =
357+
let create ~kind ~env ?(docstring = []) ?insertText ?deprecated ?detail name =
359358
{
360359
name;
361360
env;
@@ -365,12 +364,12 @@ module Completion = struct
365364
sortText = None;
366365
insertText;
367366
insertTextFormat = None;
368-
filterText;
367+
filterText = None;
369368
detail;
370369
}
371370

372371
let createWithSnippet ~name ?insertText ~kind ~env ?sortText ?deprecated
373-
?filterText ?(docstring = []) () =
372+
?(docstring = []) () =
374373
{
375374
name;
376375
env;
@@ -380,7 +379,7 @@ module Completion = struct
380379
sortText;
381380
insertText;
382381
insertTextFormat = Some Protocol.Snippet;
383-
filterText;
382+
filterText = None;
384383
detail = None;
385384
}
386385

@@ -793,7 +792,7 @@ let extractExpApplyArgs ~args =
793792
:: rest -> (
794793
let namedArgLoc =
795794
e.pexp_attributes
796-
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "ns.namedArgLoc")
795+
|> List.find_opt (fun ({Asttypes.txt}, _) -> txt = "res.namedArgLoc")
797796
in
798797
match namedArgLoc with
799798
| Some ({loc}, _) ->

analysis/src/Utils.ml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,6 @@ let identifyPpat pat =
137137
| Ppat_extension _ -> "Ppat_extension"
138138
| Ppat_open _ -> "Ppat_open"
139139

140-
let identifyType type_desc =
141-
match type_desc with
142-
| Types.Tvar _ -> "Tvar"
143-
| Tarrow _ -> "Tarrow"
144-
| Ttuple _ -> "Ttuple"
145-
| Tconstr _ -> "Tconstr"
146-
| Tobject _ -> "Tobject"
147-
| Tfield _ -> "Tfield"
148-
| Tnil -> "Tnil"
149-
| Tlink _ -> "Tlink"
150-
| Tsubst _ -> "Tsubst"
151-
| Tvariant _ -> "Tvariant"
152-
| Tunivar _ -> "Tunivar"
153-
| Tpoly _ -> "Tpoly"
154-
| Tpackage _ -> "Tpackage"
155-
156140
let rec skipWhite text i =
157141
if i < 0 then 0
158142
else
@@ -161,7 +145,7 @@ let rec skipWhite text i =
161145
| _ -> i
162146

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

166150
let rec unwrapIfOption (t : Types.type_expr) =
167151
match t.desc with

analysis/src/Xform.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ module AddBracesToFn = struct
146146
};
147147
}
148148
in
149-
(Location.mkloc "ns.braces" loc, Parsetree.PStr [])
149+
(Location.mkloc "res.braces" loc, Parsetree.PStr [])
150150
in
151151
let isFunction = function
152152
| {Parsetree.pexp_desc = Pexp_fun _} -> true

analysis/src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
(flags
77
(-w "+6+26+27+32+33+39"))
88
; Depends on:
9-
(libraries unix str ext ml jsonlib outcomeprinter reanalyze))
9+
(libraries unix str ext ml jsonlib syntax reanalyze))

analysis/vendor/.ocamlformat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
disable

analysis/vendor/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(dirs compiler-libs-406 ext ml res_outcome_printer json)
1+
(dirs ext ml res_syntax json)

analysis/vendor/res_outcome_printer/dune

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)