Skip to content

Commit c6ec68d

Browse files
committed
wip
1 parent 82bbdc5 commit c6ec68d

Some content is hidden

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

69 files changed

+8578
-9132
lines changed

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.parse_implementation_from_source ~for_printer:false
15-
~display_filename:"<none>" ~source
14+
Res_driver.parseImplementationFromSource ~forPrinter:false
15+
~displayFilename:"<none>" ~source
1616
in
1717
match hintStructure with
1818
| [{pstr_desc = Pstr_value (_, [{pvb_pat = pattern}])}] -> (

analysis/src/Commands.ml

+4-8
Original file line numberDiff line numberDiff line change
@@ -278,21 +278,17 @@ 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.parsing_engine.parse_implementation ~for_printer:true
281+
Res_driver.parsingEngine.parseImplementation ~forPrinter:true
282282
~filename:path
283283
in
284284
if List.length diagnostics > 0 then ""
285-
else
286-
Res_printer.print_implementation ~width:!Res_cli.ResClflags.width
287-
~comments structure
285+
else Res_printer.printImplementation ~width:80 ~comments structure
288286
else if Filename.check_suffix path ".resi" then
289287
let {Res_driver.parsetree = signature; comments; diagnostics} =
290-
Res_driver.parsing_engine.parse_interface ~for_printer:true ~filename:path
288+
Res_driver.parsingEngine.parseInterface ~forPrinter:true ~filename:path
291289
in
292290
if List.length diagnostics > 0 then ""
293-
else
294-
Res_printer.print_interface ~width:!Res_cli.ResClflags.width ~comments
295-
signature
291+
else Res_printer.printInterface ~width:80 ~comments signature
296292
else ""
297293

298294
let diagnosticSyntax ~path =

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

295295
and exprToContextPath (e : Parsetree.expression) =
296296
match
297-
( Res_parsetree_viewer.has_await_attribute e.pexp_attributes,
297+
( Res_parsetree_viewer.hasAwaitAttribute e.pexp_attributes,
298298
exprToContextPathInner e )
299299
with
300300
| true, Some ctxPath -> Some (CPAwait ctxPath)
@@ -1134,7 +1134,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
11341134
completionContext =
11351135
(if
11361136
isLikelyModulePath
1137-
&& expr |> Res_parsetree_viewer.is_braced_expr
1137+
&& expr |> Res_parsetree_viewer.isBracedExpr
11381138
then ValueOrField
11391139
else Value);
11401140
}))
@@ -1228,7 +1228,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
12281228
}))
12291229
| None -> ())
12301230
| Pexp_apply ({pexp_desc = Pexp_ident compName}, args)
1231-
when Res_parsetree_viewer.is_jsx_expression expr ->
1231+
when Res_parsetree_viewer.isJsxExpression expr ->
12321232
inJsxContext := true;
12331233
let jsxProps = CompletionJsx.extractJsxProps ~compName ~args in
12341234
let compNamePath = flattenLidCheckDot ~jsx:true compName in
@@ -1585,7 +1585,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
15851585

15861586
if Filename.check_suffix path ".res" then (
15871587
let parser =
1588-
Res_driver.parsing_engine.parse_implementation ~for_printer:false
1588+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
15891589
in
15901590
let {Res_driver.parsetree = str} = parser ~filename:currentFile in
15911591
iterator.structure iterator str |> ignore;
@@ -1597,7 +1597,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
15971597
if !found = false then if debug then Printf.printf "XXX Not found!\n";
15981598
!result)
15991599
else if Filename.check_suffix path ".resi" then (
1600-
let parser = Res_driver.parsing_engine.parse_interface ~for_printer:false in
1600+
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in
16011601
let {Res_driver.parsetree = signature} = parser ~filename:currentFile in
16021602
iterator.signature iterator signature |> ignore;
16031603
if blankAfterCursor = Some ' ' || blankAfterCursor = Some '\n' then (

analysis/src/CreateInterface.ml

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

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

154153
let genSigStrForInlineAttr lines attributes id vd =

analysis/src/Diagnostics.ml

+4-5
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.get_start_pos diagnostic)
6+
Location.get_pos_info (Res_diagnostics.getStartPos diagnostic)
77
in
88
let _, endline, endcol =
9-
Location.get_pos_info (Res_diagnostics.get_end_pos diagnostic)
9+
Location.get_pos_info (Res_diagnostics.getEndPos diagnostic)
1010
in
1111
Protocol.stringifyDiagnostic
1212
{
@@ -21,14 +21,13 @@ let document_syntax ~path =
2121
in
2222
if FindFiles.isImplementation path then
2323
let parseImplementation =
24-
Res_driver.parsing_engine.parse_implementation ~for_printer:false
24+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
2525
~filename:path
2626
in
2727
get_diagnostics parseImplementation.diagnostics
2828
else if FindFiles.isInterface path then
2929
let parseInterface =
30-
Res_driver.parsing_engine.parse_interface ~for_printer:false
31-
~filename:path
30+
Res_driver.parsingEngine.parseInterface ~forPrinter:false ~filename:path
3231
in
3332
get_diagnostics parseInterface.diagnostics
3433
else []

analysis/src/DocumentSymbol.ml

+2-4
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,12 @@ let command ~path =
136136

137137
(if Filename.check_suffix path ".res" then
138138
let parser =
139-
Res_driver.parsing_engine.parse_implementation ~for_printer:false
139+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
140140
in
141141
let {Res_driver.parsetree = structure} = parser ~filename:path in
142142
iterator.structure iterator structure |> ignore
143143
else
144-
let parser =
145-
Res_driver.parsing_engine.parse_interface ~for_printer:false
146-
in
144+
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in
147145
let {Res_driver.parsetree = signature} = parser ~filename:path in
148146
iterator.signature iterator signature |> ignore);
149147
let isInside

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.parsing_engine.parse_implementation ~for_printer:true
316+
Res_driver.parsingEngine.parseImplementation ~forPrinter:true
317317
~filename:currentFile
318318
in
319319

analysis/src/Hint.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let inlay ~path ~pos ~maxLength ~debug =
7272
let iterator = {Ast_iterator.default_iterator with value_binding} in
7373
(if Files.classifySourceFile path = Res then
7474
let parser =
75-
Res_driver.parsing_engine.parse_implementation ~for_printer:false
75+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
7676
in
7777
let {Res_driver.parsetree = structure} = parser ~filename:path in
7878
iterator.structure iterator structure |> ignore);
@@ -136,7 +136,7 @@ let codeLens ~path ~debug =
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
138138
let parser =
139-
Res_driver.parsing_engine.parse_implementation ~for_printer:false
139+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
140140
in
141141
let {Res_driver.parsetree = structure} = parser ~filename:path in
142142
iterator.structure iterator structure |> ignore);

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.to_string ~width:lineWidth
5-
(Res_outcome_printer.print_out_type_doc (Printtyp.tree_of_typexp false typ))
4+
Res_doc.toString ~width:lineWidth
5+
(Res_outcome_printer.printOutTypeDoc (Printtyp.tree_of_typexp false typ))
66

77
let printDecl ?printNameAsIs ~recStatus name decl =
88
Printtyp.reset_names ();
9-
Res_doc.to_string ~width:60
10-
(Res_outcome_printer.print_out_sig_item_doc ?print_name_as_is:printNameAsIs
9+
Res_doc.toString ~width:60
10+
(Res_outcome_printer.printOutSigItemDoc ?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
@@ -27,7 +27,7 @@ let mapRecordField {Types.ld_id; ld_type; ld_attributes} =
2727
stamp = astamp;
2828
fname = Location.mknoloc name;
2929
typ = ld_type;
30-
optional = Res_parsetree_viewer.has_optional_attribute ld_attributes;
30+
optional = Res_parsetree_viewer.hasOptionalAttribute ld_attributes;
3131
docstring =
3232
(match ProcessAttributes.findDocAttribute ld_attributes with
3333
| None -> []
@@ -261,7 +261,7 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
261261
typ = f.ld_type.ctyp_type;
262262
optional =
263263
Res_parsetree_viewer
264-
.has_optional_attribute
264+
.hasOptionalAttribute
265265
f.ld_attributes;
266266
docstring =
267267
(match
@@ -308,7 +308,7 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
308308
fname;
309309
typ = ctyp_type;
310310
optional =
311-
Res_parsetree_viewer.has_optional_attribute
311+
Res_parsetree_viewer.hasOptionalAttribute
312312
ld_attributes;
313313
docstring = attrsToDocstring ld_attributes;
314314
deprecated =

analysis/src/SemanticTokens.ml

+3-3
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.is_jsx_expression e ->
250+
when Res_parsetree_viewer.isJsxExpression e ->
251251
(*
252252
Angled brackets:
253253
- These are handled in the grammar: <> </> </ />
@@ -440,7 +440,7 @@ let command ~debug ~emitter ~path =
440440

441441
if Files.classifySourceFile path = Res then (
442442
let parser =
443-
Res_driver.parsing_engine.parse_implementation ~for_printer:false
443+
Res_driver.parsingEngine.parseImplementation ~forPrinter: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.parsing_engine.parse_interface ~for_printer:false in
453+
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter: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.parsing_engine.parse_implementation ~for_printer:false
430+
Res_driver.parsingEngine.parseImplementation ~forPrinter: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.parse_interface_from_source ~for_printer:false
460-
~display_filename:"<missing-file>" ~source:typeStrForParser
459+
Res_driver.parseInterfaceFromSource ~forPrinter:false
460+
~displayFilename:"<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.is_keyword_txt txt then "\"" ^ txt ^ "\"" else loop 0
262+
if Res_token.isKeywordTxt txt then "\"" ^ txt ^ "\"" else loop 0
263263

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

analysis/src/Xform.ml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(** Code transformations using the parser/printer and ast operations *)
22

3-
let isBracedExpr = Res_parsetree_viewer.is_braced_expr
3+
let isBracedExpr = Res_parsetree_viewer.isBracedExpr
44

55
let extractTypeFromExpr expr ~debug ~path ~currentFile ~full ~pos =
66
match
@@ -447,7 +447,7 @@ module ExpandCatchAllForVariants = struct
447447
let newText =
448448
missingConstructors
449449
|> List.map (fun (c : SharedTypes.polyVariantConstructor) ->
450-
Res_printer.polyvar_ident_to_string c.name
450+
Res_printer.polyVarIdentToString c.name
451451
^
452452
match c.args with
453453
| [] -> ""
@@ -504,7 +504,7 @@ module ExpandCatchAllForVariants = struct
504504
(fun (c : SharedTypes.polyVariantConstructor) ->
505505
if currentConstructorNames |> List.mem c.name = false then
506506
Some
507-
( Res_printer.polyvar_ident_to_string c.name,
507+
( Res_printer.polyVarIdentToString c.name,
508508
match c.args with
509509
| [] -> false
510510
| _ -> true )
@@ -841,7 +841,7 @@ end
841841

842842
let parseImplementation ~filename =
843843
let {Res_driver.parsetree = structure; comments} =
844-
Res_driver.parsing_engine.parse_implementation ~for_printer:false ~filename
844+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false ~filename
845845
in
846846
let filterComments ~loc comments =
847847
(* Relevant comments in the range of the expression *)
@@ -853,28 +853,28 @@ let parseImplementation ~filename =
853853
let printExpr ~(range : Protocol.range) (expr : Parsetree.expression) =
854854
let structure = [Ast_helper.Str.eval ~loc:expr.pexp_loc expr] in
855855
structure
856-
|> Res_printer.print_implementation ~width:!Res_cli.ResClflags.width
856+
|> Res_printer.printImplementation ~width:80
857857
~comments:(comments |> filterComments ~loc:expr.pexp_loc)
858858
|> Utils.indent range.start.character
859859
in
860860
let printStructureItem ~(range : Protocol.range)
861861
(item : Parsetree.structure_item) =
862862
let structure = [item] in
863863
structure
864-
|> Res_printer.print_implementation ~width:!Res_cli.ResClflags.width
864+
|> Res_printer.printImplementation ~width:80
865865
~comments:(comments |> filterComments ~loc:item.pstr_loc)
866866
|> Utils.indent range.start.character
867867
in
868868
let printStandaloneStructure ~(loc : Location.t) structure =
869869
structure
870-
|> Res_printer.print_implementation ~width:!Res_cli.ResClflags.width
870+
|> Res_printer.printImplementation ~width:80
871871
~comments:(comments |> filterComments ~loc)
872872
in
873873
(structure, printExpr, printStructureItem, printStandaloneStructure)
874874

875875
let parseInterface ~filename =
876876
let {Res_driver.parsetree = structure; comments} =
877-
Res_driver.parsing_engine.parse_interface ~for_printer:false ~filename
877+
Res_driver.parsingEngine.parseInterface ~forPrinter:false ~filename
878878
in
879879
let filterComments ~loc comments =
880880
(* Relevant comments in the range of the expression *)
@@ -887,7 +887,7 @@ let parseInterface ~filename =
887887
(item : Parsetree.signature_item) =
888888
let signature_item = [item] in
889889
signature_item
890-
|> Res_printer.print_interface ~width:!Res_cli.ResClflags.width
890+
|> Res_printer.printInterface ~width:80
891891
~comments:(comments |> filterComments ~loc:item.psig_loc)
892892
|> Utils.indent range.start.character
893893
in

analysis/vendor/ml/ast_async.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ let add_promise_type ?(loc = Location.none) ~async
1414
let add_async_attribute ~async (body : Parsetree.expression) =
1515
if async then
1616
match body.pexp_desc with
17-
| Pexp_construct (x, Some e) when Ast_uncurried.expr_is_uncurried_fun body
18-
->
17+
| Pexp_construct (x, Some e) when Ast_uncurried.exprIsUncurriedFun body ->
1918
{
2019
body with
2120
pexp_desc =

0 commit comments

Comments
 (0)