Skip to content

Commit 9cc7e65

Browse files
authored
Pull latest parser and compiler helper files (#998)
* wip pull latest parser and compiler helper files * comment out * changelog
1 parent 1e66e7f commit 9cc7e65

File tree

135 files changed

+9841
-9288
lines changed

Some content is hidden

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

135 files changed

+9841
-9288
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
- Add code action for expanding catch-all patterns. https://github.com/rescript-lang/rescript-vscode/pull/987
4343
- Add code actions for removing unused code (per item and for an entire file), driven by `reanalyze`. https://github.com/rescript-lang/rescript-vscode/pull/989
4444

45+
#### :house: Internal
46+
47+
- Update parser and compiler support files to the latest version. https://github.com/rescript-lang/rescript-vscode/pull/998
48+
4549
## 1.50.0
4650

4751
#### :rocket: New Feature

analysis/src/Codemod.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ let transform ~path ~pos ~debug ~typ ~hint =
1111
| AddMissingCases -> (
1212
let source = "let " ^ hint ^ " = ()" in
1313
let {Res_driver.parsetree = hintStructure} =
14-
Res_driver.parseImplementationFromSource ~forPrinter:false
15-
~displayFilename:"<none>" ~source
14+
Res_driver.parse_implementation_from_source ~for_printer:false
15+
~display_filename:"<none>" ~source
1616
in
1717
match hintStructure with
1818
| [{pstr_desc = Pstr_value (_, [{pvb_pat = pattern}])}] -> (

analysis/src/Commands.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,20 @@ let rename ~path ~pos ~newName ~debug =
278278
let format ~path =
279279
if Filename.check_suffix path ".res" then
280280
let {Res_driver.parsetree = structure; comments; diagnostics} =
281-
Res_driver.parsingEngine.parseImplementation ~forPrinter:true
281+
Res_driver.parsing_engine.parse_implementation ~for_printer:true
282282
~filename:path
283283
in
284284
if List.length diagnostics > 0 then ""
285285
else
286-
Res_printer.printImplementation ~width:!Res_cli.ResClflags.width ~comments
287-
structure
286+
Res_printer.print_implementation ~width:!Res_cli.ResClflags.width
287+
~comments structure
288288
else if Filename.check_suffix path ".resi" then
289289
let {Res_driver.parsetree = signature; comments; diagnostics} =
290-
Res_driver.parsingEngine.parseInterface ~forPrinter:true ~filename:path
290+
Res_driver.parsing_engine.parse_interface ~for_printer:true ~filename:path
291291
in
292292
if List.length diagnostics > 0 then ""
293293
else
294-
Res_printer.printInterface ~width:!Res_cli.ResClflags.width ~comments
294+
Res_printer.print_interface ~width:!Res_cli.ResClflags.width ~comments
295295
signature
296296
else ""
297297

analysis/src/CompletionFrontEnd.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ let findArgCompletables ~(args : arg list) ~endPos ~posBeforeCursor
7777
if CursorPosition.locIsEmpty exp.pexp_loc ~pos:posBeforeCursor then
7878
someArgHadEmptyExprLoc := true;
7979

80-
if Res_parsetree_viewer.isTemplateLiteral exp then None
80+
if Res_parsetree_viewer.is_template_literal exp then None
8181
else if exp.pexp_loc |> Loc.hasPos ~pos:posBeforeCursor then (
8282
if Debug.verbose () then
8383
print_endline
@@ -281,7 +281,7 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
281281

282282
and exprToContextPath (e : Parsetree.expression) =
283283
match
284-
( Res_parsetree_viewer.hasAwaitAttribute e.pexp_attributes,
284+
( Res_parsetree_viewer.has_await_attribute e.pexp_attributes,
285285
exprToContextPathInner e )
286286
with
287287
| true, Some ctxPath -> Some (CPAwait ctxPath)
@@ -1072,7 +1072,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
10721072
completionContext =
10731073
(if
10741074
isLikelyModulePath
1075-
&& expr |> Res_parsetree_viewer.isBracedExpr
1075+
&& expr |> Res_parsetree_viewer.is_braced_expr
10761076
then ValueOrField
10771077
else Value);
10781078
}))
@@ -1143,7 +1143,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
11431143
| Some contextPath -> setResult (Cpath (CPField (contextPath, "")))
11441144
| None -> ())
11451145
| Pexp_apply ({pexp_desc = Pexp_ident compName}, args)
1146-
when Res_parsetree_viewer.isJsxExpression expr ->
1146+
when Res_parsetree_viewer.is_jsx_expression expr ->
11471147
inJsxContext := true;
11481148
let jsxProps = CompletionJsx.extractJsxProps ~compName ~args in
11491149
let compNamePath = flattenLidCheckDot ~jsx:true compName in
@@ -1500,7 +1500,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
15001500

15011501
if Filename.check_suffix path ".res" then (
15021502
let parser =
1503-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
1503+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
15041504
in
15051505
let {Res_driver.parsetree = str} = parser ~filename:currentFile in
15061506
iterator.structure iterator str |> ignore;
@@ -1512,7 +1512,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
15121512
if !found = false then if debug then Printf.printf "XXX Not found!\n";
15131513
!result)
15141514
else if Filename.check_suffix path ".resi" then (
1515-
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in
1515+
let parser = Res_driver.parsing_engine.parse_interface ~for_printer:false in
15161516
let {Res_driver.parsetree = signature} = parser ~filename:currentFile in
15171517
iterator.signature iterator signature |> ignore;
15181518
if blankAfterCursor = Some ' ' || blankAfterCursor = Some '\n' then (

analysis/src/CreateInterface.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ let printSignature ~extractor ~signature =
147147

148148
Printtyp.reset_names ();
149149
let sigItemToString (item : Outcometree.out_sig_item) =
150-
item |> Res_outcome_printer.printOutSigItemDoc
151-
|> Res_doc.toString ~width:!Res_cli.ResClflags.width
150+
item |> Res_outcome_printer.print_out_sig_item_doc
151+
|> Res_doc.to_string ~width:!Res_cli.ResClflags.width
152152
in
153153

154154
let genSigStrForInlineAttr lines attributes id vd =

analysis/src/Diagnostics.ml

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ let document_syntax ~path =
33
diagnostics
44
|> List.map (fun diagnostic ->
55
let _, startline, startcol =
6-
Location.get_pos_info (Res_diagnostics.getStartPos diagnostic)
6+
Location.get_pos_info (Res_diagnostics.get_start_pos diagnostic)
77
in
88
let _, endline, endcol =
9-
Location.get_pos_info (Res_diagnostics.getEndPos diagnostic)
9+
Location.get_pos_info (Res_diagnostics.get_end_pos diagnostic)
1010
in
1111
Protocol.stringifyDiagnostic
1212
{
@@ -21,13 +21,14 @@ let document_syntax ~path =
2121
in
2222
if FindFiles.isImplementation path then
2323
let parseImplementation =
24-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
24+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
2525
~filename:path
2626
in
2727
get_diagnostics parseImplementation.diagnostics
2828
else if FindFiles.isInterface path then
2929
let parseInterface =
30-
Res_driver.parsingEngine.parseInterface ~forPrinter:false ~filename:path
30+
Res_driver.parsing_engine.parse_interface ~for_printer:false
31+
~filename:path
3132
in
3233
get_diagnostics parseInterface.diagnostics
3334
else []

analysis/src/DocumentSymbol.ml

+11-9
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,17 @@ let command ~path =
135135
in
136136

137137
(if Filename.check_suffix path ".res" then
138-
let parser =
139-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
140-
in
141-
let {Res_driver.parsetree = structure} = parser ~filename:path in
142-
iterator.structure iterator structure |> ignore
143-
else
144-
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in
145-
let {Res_driver.parsetree = signature} = parser ~filename:path in
146-
iterator.signature iterator signature |> ignore);
138+
let parser =
139+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
140+
in
141+
let {Res_driver.parsetree = structure} = parser ~filename:path in
142+
iterator.structure iterator structure |> ignore
143+
else
144+
let parser =
145+
Res_driver.parsing_engine.parse_interface ~for_printer:false
146+
in
147+
let {Res_driver.parsetree = signature} = parser ~filename:path in
148+
iterator.signature iterator signature |> ignore);
147149
let isInside
148150
({
149151
range =

analysis/src/DumpAst.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ let printStructItem structItem ~pos ~source =
313313

314314
let dump ~currentFile ~pos =
315315
let {Res_driver.parsetree = structure; source} =
316-
Res_driver.parsingEngine.parseImplementation ~forPrinter:true
316+
Res_driver.parsing_engine.parse_implementation ~for_printer:true
317317
~filename:currentFile
318318
in
319319

analysis/src/Hint.ml

+11-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let locItemToTypeHint ~full:{file; package} locItem =
1515
| Const_float _ -> "float"
1616
| Const_int32 _ -> "int32"
1717
| Const_int64 _ -> "int64"
18-
| Const_nativeint _ -> "int")
18+
| Const_bigint _ -> "bigint")
1919
| Typed (_, t, locKind) ->
2020
let fromType typ =
2121
typ |> Shared.typeToString
@@ -71,11 +71,11 @@ let inlay ~path ~pos ~maxLength ~debug =
7171
in
7272
let iterator = {Ast_iterator.default_iterator with value_binding} in
7373
(if Files.classifySourceFile path = Res then
74-
let parser =
75-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
76-
in
77-
let {Res_driver.parsetree = structure} = parser ~filename:path in
78-
iterator.structure iterator structure |> ignore);
74+
let parser =
75+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
76+
in
77+
let {Res_driver.parsetree = structure} = parser ~filename:path in
78+
iterator.structure iterator structure |> ignore);
7979
match Cmt.loadFullCmtFromPath ~path with
8080
| None -> None
8181
| Some full ->
@@ -135,11 +135,11 @@ let codeLens ~path ~debug =
135135
(* We only print code lenses in implementation files. This is because they'd be redundant in interface files,
136136
where the definition itself will be the same thing as what would've been printed in the code lens. *)
137137
(if Files.classifySourceFile path = Res then
138-
let parser =
139-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
140-
in
141-
let {Res_driver.parsetree = structure} = parser ~filename:path in
142-
iterator.structure iterator structure |> ignore);
138+
let parser =
139+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
140+
in
141+
let {Res_driver.parsetree = structure} = parser ~filename:path in
142+
iterator.structure iterator structure |> ignore);
143143
match Cmt.loadFullCmtFromPath ~path with
144144
| None -> None
145145
| Some full ->

analysis/src/Hover.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ let newHover ~full:{file; package} ~supportsMarkdownLinks locItem =
227227
| Const_float _ -> "float"
228228
| Const_int32 _ -> "int32"
229229
| Const_int64 _ -> "int64"
230-
| Const_nativeint _ -> "int"))
230+
| Const_bigint _ -> "bigint"))
231231
| Typed (_, t, locKind) ->
232232
let fromType ~docstring typ =
233233
( hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks typ,

analysis/src/PrintType.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
let printExpr ?(lineWidth = 60) typ =
22
Printtyp.reset_names ();
33
Printtyp.reset_and_mark_loops typ;
4-
Res_doc.toString ~width:lineWidth
5-
(Res_outcome_printer.printOutTypeDoc (Printtyp.tree_of_typexp false typ))
4+
Res_doc.to_string ~width:lineWidth
5+
(Res_outcome_printer.print_out_type_doc (Printtyp.tree_of_typexp false typ))
66

77
let printDecl ?printNameAsIs ~recStatus name decl =
88
Printtyp.reset_names ();
9-
Res_doc.toString ~width:60
10-
(Res_outcome_printer.printOutSigItemDoc ?printNameAsIs
9+
Res_doc.to_string ~width:60
10+
(Res_outcome_printer.print_out_sig_item_doc ?print_name_as_is:printNameAsIs
1111
(Printtyp.tree_of_type_declaration (Ident.create name) decl recStatus))

analysis/src/ProcessCmt.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let mapRecordField {Types.ld_id; ld_type; ld_attributes} =
2222
stamp = astamp;
2323
fname = Location.mknoloc name;
2424
typ = ld_type;
25-
optional = Res_parsetree_viewer.hasOptionalAttribute ld_attributes;
25+
optional = Res_parsetree_viewer.has_optional_attribute ld_attributes;
2626
docstring =
2727
(match ProcessAttributes.findDocAttribute ld_attributes with
2828
| None -> []
@@ -255,7 +255,7 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
255255
typ = f.ld_type.ctyp_type;
256256
optional =
257257
Res_parsetree_viewer
258-
.hasOptionalAttribute
258+
.has_optional_attribute
259259
f.ld_attributes;
260260
docstring =
261261
(match
@@ -302,7 +302,7 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
302302
fname;
303303
typ = ctyp_type;
304304
optional =
305-
Res_parsetree_viewer.hasOptionalAttribute
305+
Res_parsetree_viewer.has_optional_attribute
306306
ld_attributes;
307307
docstring = attrsToDocstring ld_attributes;
308308
deprecated =

analysis/src/SemanticTokens.ml

+15-15
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ let command ~debug ~emitter ~path =
247247
~lid ~debug;
248248
Ast_iterator.default_iterator.expr iterator e
249249
| Pexp_apply ({pexp_desc = Pexp_ident lident; pexp_loc}, args)
250-
when Res_parsetree_viewer.isJsxExpression e ->
250+
when Res_parsetree_viewer.is_jsx_expression e ->
251251
(*
252252
Angled brackets:
253253
- These are handled in the grammar: <> </> </ />
@@ -283,18 +283,18 @@ let command ~debug ~emitter ~path =
283283
(* there's an off-by one somehow in the AST *)
284284
in
285285
(if not selfClosing then
286-
let lineStart, colStart = Loc.start pexp_loc in
287-
let lineEnd, colEnd = Loc.end_ pexp_loc in
288-
let length = if lineStart = lineEnd then colEnd - colStart else 0 in
289-
let lineEndWhole, colEndWhole = Loc.end_ e.pexp_loc in
290-
if length > 0 && colEndWhole > length then (
291-
emitter
292-
|> emitJsxClose ~debug ~lid:lident.txt
293-
~pos:(lineEndWhole, colEndWhole - 1);
294-
emitter (* <foo ...props > <-- *)
295-
|> emitJsxTag ~debug ~name:">" ~pos:posOfGreatherthanAfterProps;
296-
emitter (* <foo> ... </foo> <-- *)
297-
|> emitJsxTag ~debug ~name:">" ~pos:posOfFinalGreatherthan));
286+
let lineStart, colStart = Loc.start pexp_loc in
287+
let lineEnd, colEnd = Loc.end_ pexp_loc in
288+
let length = if lineStart = lineEnd then colEnd - colStart else 0 in
289+
let lineEndWhole, colEndWhole = Loc.end_ e.pexp_loc in
290+
if length > 0 && colEndWhole > length then (
291+
emitter
292+
|> emitJsxClose ~debug ~lid:lident.txt
293+
~pos:(lineEndWhole, colEndWhole - 1);
294+
emitter (* <foo ...props > <-- *)
295+
|> emitJsxTag ~debug ~name:">" ~pos:posOfGreatherthanAfterProps;
296+
emitter (* <foo> ... </foo> <-- *)
297+
|> emitJsxTag ~debug ~name:">" ~pos:posOfFinalGreatherthan));
298298

299299
args |> List.iter (fun (_lbl, arg) -> iterator.expr iterator arg)
300300
| Pexp_apply
@@ -440,7 +440,7 @@ let command ~debug ~emitter ~path =
440440

441441
if Files.classifySourceFile path = Res then (
442442
let parser =
443-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
443+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
444444
in
445445
let {Res_driver.parsetree = structure; diagnostics} =
446446
parser ~filename:path
@@ -450,7 +450,7 @@ let command ~debug ~emitter ~path =
450450
(List.length structure) (List.length diagnostics);
451451
iterator.structure iterator structure |> ignore)
452452
else
453-
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in
453+
let parser = Res_driver.parsing_engine.parse_interface ~for_printer:false in
454454
let {Res_driver.parsetree = signature; diagnostics} =
455455
parser ~filename:path
456456
in

analysis/src/SignatureHelp.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
427427
in
428428
let iterator = {Ast_iterator.default_iterator with expr; pat} in
429429
let parser =
430-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
430+
Res_driver.parsing_engine.parse_implementation ~for_printer:false
431431
in
432432
let {Res_driver.parsetree = structure} = parser ~filename:currentFile in
433433
iterator.structure iterator structure |> ignore;
@@ -456,8 +456,8 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
456456
let fnTypeStr = Shared.typeToString type_expr in
457457
let typeStrForParser = labelPrefix ^ fnTypeStr in
458458
let {Res_driver.parsetree = signature} =
459-
Res_driver.parseInterfaceFromSource ~forPrinter:false
460-
~displayFilename:"<missing-file>" ~source:typeStrForParser
459+
Res_driver.parse_interface_from_source ~for_printer:false
460+
~display_filename:"<missing-file>" ~source:typeStrForParser
461461
in
462462

463463
let parameters =

analysis/src/Utils.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ let printMaybeExoticIdent ?(allowUident = false) txt =
259259
| 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '\'' | '_' -> loop (i + 1)
260260
| _ -> "\"" ^ txt ^ "\""
261261
in
262-
if Res_token.isKeywordTxt txt then "\"" ^ txt ^ "\"" else loop 0
262+
if Res_token.is_keyword_txt txt then "\"" ^ txt ^ "\"" else loop 0
263263

264264
let findPackageJson root =
265265
let path = Uri.toPath root in

0 commit comments

Comments
 (0)