Skip to content

Commit

Permalink
Rename ns.namedArgLoc to res.namedArgLoc
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed Nov 28, 2022
1 parent 26044dc commit cb18dd2
Show file tree
Hide file tree
Showing 34 changed files with 424 additions and 415 deletions.
40 changes: 20 additions & 20 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49873,9 +49873,9 @@ let filterParsingAttrs attrs =
match attr with
| ( {
Location.txt =
( "bs" | "res.uapp" | "res.braces" | "res.iflet" | "ns.namedArgLoc"
| "res.optional" | "res.ternary" | "res.async" | "res.await"
| "res.template" );
( "bs" | "res.uapp" | "res.braces" | "res.iflet"
| "res.namedArgLoc" | "res.optional" | "res.ternary" | "res.async"
| "res.await" | "res.template" );
},
_ ) ->
false
Expand Down Expand Up @@ -50723,7 +50723,7 @@ let getLoc node =
| CoreType ct -> ct.ptyp_loc
| ExprArgument expr -> (
match expr.Parsetree.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
{loc with loc_end = expr.pexp_loc.loc_end}
| _ -> expr.pexp_loc)
| Expression e -> (
Expand Down Expand Up @@ -51731,7 +51731,7 @@ and walkExpression expr t comments =
let open Parsetree in
let startPos =
match pattern.ppat_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
loc.loc_start
| _ -> pattern.ppat_loc.loc_start
in
Expand Down Expand Up @@ -51790,7 +51790,7 @@ and walkExprPararameter (_attrs, _argLbl, exprOpt, pattern) t comments =

and walkExprArgument expr t comments =
match expr.Parsetree.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
let leading, trailing = partitionLeadingTrailing comments loc in
attach t.leading loc leading;
let afterLabel, rest = partitionAdjacentTrailing loc trailing in
Expand Down Expand Up @@ -52198,7 +52198,7 @@ and walkTypeParameters typeParameters t comments =
visitListButContinueWithRemainingComments
~getLoc:(fun (_, _, typexpr) ->
match typexpr.Parsetree.ptyp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
{loc with loc_end = typexpr.ptyp_loc.loc_end}
| _ -> typexpr.ptyp_loc)
~walkNode:walkTypeParameter ~newlineDelimited:false typeParameters t
Expand Down Expand Up @@ -55147,7 +55147,7 @@ and printTypeParameter ~state (attrs, lbl, typ) cmtTbl =
in
let loc, typ =
match typ.ptyp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: attrs ->
( {loc with loc_end = typ.ptyp_loc.loc_end},
{typ with ptyp_attributes = attrs} )
| _ -> (typ.ptyp_loc, typ)
Expand Down Expand Up @@ -57433,7 +57433,7 @@ and printJsxProps ~state args cmtTbl : Doc.t * Parsetree.expression option =
] ->
let loc =
match expr.Parsetree.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
{loc with loc_end = expr.pexp_loc.loc_end}
| _ -> expr.pexp_loc
in
Expand Down Expand Up @@ -57469,7 +57469,7 @@ and printJsxProp ~state arg cmtTbl =
| ( ((Asttypes.Labelled lblTxt | Optional lblTxt) as lbl),
{
Parsetree.pexp_attributes =
[({Location.txt = "ns.namedArgLoc"; loc = argLoc}, _)];
[({Location.txt = "res.namedArgLoc"; loc = argLoc}, _)];
pexp_desc = Pexp_ident {txt = Longident.Lident ident};
} )
when lblTxt = ident (* jsx punning *) -> (
Expand All @@ -57495,7 +57495,7 @@ and printJsxProp ~state arg cmtTbl =
| lbl, expr ->
let argLoc, expr =
match expr.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: attrs ->
(loc, {expr with pexp_attributes = attrs})
| _ -> (Location.none, expr)
in
Expand Down Expand Up @@ -57792,12 +57792,12 @@ and printArgument ~state (argLbl, arg) cmtTbl =
| ( Asttypes.Labelled lbl,
({
pexp_desc = Pexp_ident {txt = Longident.Lident name};
pexp_attributes = [] | [({Location.txt = "ns.namedArgLoc"}, _)];
pexp_attributes = [] | [({Location.txt = "res.namedArgLoc"}, _)];
} as argExpr) )
when lbl = name && not (ParsetreeViewer.isBracedExpr argExpr) ->
let loc =
match arg.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ -> loc
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ -> loc
| _ -> arg.pexp_loc
in
let doc = Doc.concat [Doc.tilde; printIdentLike lbl] in
Expand All @@ -57811,12 +57811,12 @@ and printArgument ~state (argLbl, arg) cmtTbl =
typ );
pexp_loc;
pexp_attributes =
([] | [({Location.txt = "ns.namedArgLoc"}, _)]) as attrs;
([] | [({Location.txt = "res.namedArgLoc"}, _)]) as attrs;
} )
when lbl = name && not (ParsetreeViewer.isBracedExpr argExpr) ->
let loc =
match attrs with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ ->
{loc with loc_end = pexp_loc.loc_end}
| _ -> arg.pexp_loc
in
Expand All @@ -57834,20 +57834,20 @@ and printArgument ~state (argLbl, arg) cmtTbl =
| ( Asttypes.Optional lbl,
{
pexp_desc = Pexp_ident {txt = Longident.Lident name};
pexp_attributes = [] | [({Location.txt = "ns.namedArgLoc"}, _)];
pexp_attributes = [] | [({Location.txt = "res.namedArgLoc"}, _)];
} )
when lbl = name ->
let loc =
match arg.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ -> loc
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ -> loc
| _ -> arg.pexp_loc
in
let doc = Doc.concat [Doc.tilde; printIdentLike lbl; Doc.question] in
printComments doc cmtTbl loc
| _lbl, expr ->
let argLoc, expr =
match expr.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: attrs ->
(loc, {expr with pexp_attributes = attrs})
| _ -> (expr.pexp_loc, expr)
in
Expand Down Expand Up @@ -58137,13 +58137,13 @@ and printExpFunParameter ~state parameter cmtTbl =
match defaultExpr with
| None -> (
match pattern.ppat_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ ->
{loc with loc_end = pattern.ppat_loc.loc_end}
| _ -> pattern.ppat_loc)
| Some expr ->
let startPos =
match pattern.ppat_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ -> loc.loc_start
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ -> loc.loc_start
| _ -> pattern.ppat_loc.loc_start
in
{
Expand Down
54 changes: 28 additions & 26 deletions lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49873,9 +49873,9 @@ let filterParsingAttrs attrs =
match attr with
| ( {
Location.txt =
( "bs" | "res.uapp" | "res.braces" | "res.iflet" | "ns.namedArgLoc"
| "res.optional" | "res.ternary" | "res.async" | "res.await"
| "res.template" );
( "bs" | "res.uapp" | "res.braces" | "res.iflet"
| "res.namedArgLoc" | "res.optional" | "res.ternary" | "res.async"
| "res.await" | "res.template" );
},
_ ) ->
false
Expand Down Expand Up @@ -50723,7 +50723,7 @@ let getLoc node =
| CoreType ct -> ct.ptyp_loc
| ExprArgument expr -> (
match expr.Parsetree.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
{loc with loc_end = expr.pexp_loc.loc_end}
| _ -> expr.pexp_loc)
| Expression e -> (
Expand Down Expand Up @@ -51731,7 +51731,7 @@ and walkExpression expr t comments =
let open Parsetree in
let startPos =
match pattern.ppat_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
loc.loc_start
| _ -> pattern.ppat_loc.loc_start
in
Expand Down Expand Up @@ -51790,7 +51790,7 @@ and walkExprPararameter (_attrs, _argLbl, exprOpt, pattern) t comments =

and walkExprArgument expr t comments =
match expr.Parsetree.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
let leading, trailing = partitionLeadingTrailing comments loc in
attach t.leading loc leading;
let afterLabel, rest = partitionAdjacentTrailing loc trailing in
Expand Down Expand Up @@ -52198,7 +52198,7 @@ and walkTypeParameters typeParameters t comments =
visitListButContinueWithRemainingComments
~getLoc:(fun (_, _, typexpr) ->
match typexpr.Parsetree.ptyp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
{loc with loc_end = typexpr.ptyp_loc.loc_end}
| _ -> typexpr.ptyp_loc)
~walkNode:walkTypeParameter ~newlineDelimited:false typeParameters t
Expand Down Expand Up @@ -55147,7 +55147,7 @@ and printTypeParameter ~state (attrs, lbl, typ) cmtTbl =
in
let loc, typ =
match typ.ptyp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: attrs ->
( {loc with loc_end = typ.ptyp_loc.loc_end},
{typ with ptyp_attributes = attrs} )
| _ -> (typ.ptyp_loc, typ)
Expand Down Expand Up @@ -57433,7 +57433,7 @@ and printJsxProps ~state args cmtTbl : Doc.t * Parsetree.expression option =
] ->
let loc =
match expr.Parsetree.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _attrs ->
{loc with loc_end = expr.pexp_loc.loc_end}
| _ -> expr.pexp_loc
in
Expand Down Expand Up @@ -57469,7 +57469,7 @@ and printJsxProp ~state arg cmtTbl =
| ( ((Asttypes.Labelled lblTxt | Optional lblTxt) as lbl),
{
Parsetree.pexp_attributes =
[({Location.txt = "ns.namedArgLoc"; loc = argLoc}, _)];
[({Location.txt = "res.namedArgLoc"; loc = argLoc}, _)];
pexp_desc = Pexp_ident {txt = Longident.Lident ident};
} )
when lblTxt = ident (* jsx punning *) -> (
Expand All @@ -57495,7 +57495,7 @@ and printJsxProp ~state arg cmtTbl =
| lbl, expr ->
let argLoc, expr =
match expr.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: attrs ->
(loc, {expr with pexp_attributes = attrs})
| _ -> (Location.none, expr)
in
Expand Down Expand Up @@ -57792,12 +57792,12 @@ and printArgument ~state (argLbl, arg) cmtTbl =
| ( Asttypes.Labelled lbl,
({
pexp_desc = Pexp_ident {txt = Longident.Lident name};
pexp_attributes = [] | [({Location.txt = "ns.namedArgLoc"}, _)];
pexp_attributes = [] | [({Location.txt = "res.namedArgLoc"}, _)];
} as argExpr) )
when lbl = name && not (ParsetreeViewer.isBracedExpr argExpr) ->
let loc =
match arg.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ -> loc
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ -> loc
| _ -> arg.pexp_loc
in
let doc = Doc.concat [Doc.tilde; printIdentLike lbl] in
Expand All @@ -57811,12 +57811,12 @@ and printArgument ~state (argLbl, arg) cmtTbl =
typ );
pexp_loc;
pexp_attributes =
([] | [({Location.txt = "ns.namedArgLoc"}, _)]) as attrs;
([] | [({Location.txt = "res.namedArgLoc"}, _)]) as attrs;
} )
when lbl = name && not (ParsetreeViewer.isBracedExpr argExpr) ->
let loc =
match attrs with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ ->
{loc with loc_end = pexp_loc.loc_end}
| _ -> arg.pexp_loc
in
Expand All @@ -57834,20 +57834,20 @@ and printArgument ~state (argLbl, arg) cmtTbl =
| ( Asttypes.Optional lbl,
{
pexp_desc = Pexp_ident {txt = Longident.Lident name};
pexp_attributes = [] | [({Location.txt = "ns.namedArgLoc"}, _)];
pexp_attributes = [] | [({Location.txt = "res.namedArgLoc"}, _)];
} )
when lbl = name ->
let loc =
match arg.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ -> loc
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ -> loc
| _ -> arg.pexp_loc
in
let doc = Doc.concat [Doc.tilde; printIdentLike lbl; Doc.question] in
printComments doc cmtTbl loc
| _lbl, expr ->
let argLoc, expr =
match expr.pexp_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: attrs ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: attrs ->
(loc, {expr with pexp_attributes = attrs})
| _ -> (expr.pexp_loc, expr)
in
Expand Down Expand Up @@ -58137,13 +58137,13 @@ and printExpFunParameter ~state parameter cmtTbl =
match defaultExpr with
| None -> (
match pattern.ppat_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ ->
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ ->
{loc with loc_end = pattern.ppat_loc.loc_end}
| _ -> pattern.ppat_loc)
| Some expr ->
let startPos =
match pattern.ppat_attributes with
| ({Location.txt = "ns.namedArgLoc"; loc}, _) :: _ -> loc.loc_start
| ({Location.txt = "res.namedArgLoc"; loc}, _) :: _ -> loc.loc_start
| _ -> pattern.ppat_loc.loc_start
in
{
Expand Down Expand Up @@ -163640,7 +163640,7 @@ and parseParameter p =
Parser.next p;
let lblName, loc = parseLident p in
let propLocAttr =
(Location.mkloc "ns.namedArgLoc" loc, Parsetree.PStr [])
(Location.mkloc "res.namedArgLoc" loc, Parsetree.PStr [])
in
match p.Parser.token with
| Comma | Equal | Rparen ->
Expand Down Expand Up @@ -164674,7 +164674,7 @@ and parseJsxProp p =
let optional = Parser.optional p Question in
let name, loc = parseLident p in
let propLocAttr =
(Location.mkloc "ns.namedArgLoc" loc, Parsetree.PStr [])
(Location.mkloc "res.namedArgLoc" loc, Parsetree.PStr [])
in
(* optional punning: <foo ?a /> *)
if optional then
Expand Down Expand Up @@ -164713,7 +164713,7 @@ and parseJsxProp p =
Parser.next p;
let loc = mkLoc p.Parser.startPos p.prevEndPos in
let propLocAttr =
(Location.mkloc "ns.namedArgLoc" loc, Parsetree.PStr [])
(Location.mkloc "res.namedArgLoc" loc, Parsetree.PStr [])
in
let attrExpr =
let e = parsePrimaryExpr ~operand:(parseAtomicExpr p) p in
Expand Down Expand Up @@ -165530,7 +165530,7 @@ and parseArgument2 p ~dotted : argument option =
let endPos = p.prevEndPos in
let loc = mkLoc startPos endPos in
let propLocAttr =
(Location.mkloc "ns.namedArgLoc" loc, Parsetree.PStr [])
(Location.mkloc "res.namedArgLoc" loc, Parsetree.PStr [])
in
let identExpr =
Ast_helper.Exp.ident ~attrs:[propLocAttr] ~loc
Expand Down Expand Up @@ -166135,7 +166135,7 @@ and parseTypeParameter p =
Parser.next p;
let name, loc = parseLident p in
let lblLocAttr =
(Location.mkloc "ns.namedArgLoc" loc, Parsetree.PStr [])
(Location.mkloc "res.namedArgLoc" loc, Parsetree.PStr [])
in
Parser.expect ~grammar:Grammar.TypeExpression Colon p;
let typ =
Expand Down Expand Up @@ -166213,7 +166213,9 @@ and parseEs6ArrowType ~attrs p =
| Tilde ->
Parser.next p;
let name, loc = parseLident p in
let lblLocAttr = (Location.mkloc "ns.namedArgLoc" loc, Parsetree.PStr []) in
let lblLocAttr =
(Location.mkloc "res.namedArgLoc" loc, Parsetree.PStr [])
in
Parser.expect ~grammar:Grammar.TypeExpression Colon p;
let typ =
let typ = parseTypExpr ~alias:false ~es6Arrow:false p in
Expand Down
Loading

0 comments on commit cb18dd2

Please sign in to comment.