Skip to content

Commit

Permalink
let positioned arg names start with __ because the random name genera…
Browse files Browse the repository at this point in the history
…tor will never come up with names that start with _
  • Loading branch information
jurgenvinju committed Jan 8, 2025
1 parent 48ef6f5 commit e0bfa4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/org/rascalmpl/library/lang/json/IO.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public IValue readJSON(IValue type, ISourceLocation loc, IString dateTimeFormat,
.setParsers(parsers)
.setNulls(unreify(nulls))
.setExplicitConstructorNames(explicitConstructorNames.getValue())
.setExplicitDataTypes(explicitDataTypes.getValue()).read(in, start);
.setExplicitDataTypes(explicitDataTypes.getValue())
.read(in, start);
}
catch (IOException e) {
throw RuntimeExceptionFactory.io(values.string(e.getMessage()), null, null);
Expand Down Expand Up @@ -98,7 +99,8 @@ public IValue parseJSON(IValue type, IString src, IString dateTimeFormat, IBool
.setParsers(parsers)
.setNulls(unreify(nulls))
.setExplicitConstructorNames(explicitConstructorNames.getValue())
.setExplicitDataTypes(explicitDataTypes.getValue()).read(in, start);
.setExplicitDataTypes(explicitDataTypes.getValue())
.read(in, start);
}
catch (IOException e) {
throw RuntimeExceptionFactory.io(values.string(e.getMessage()));
Expand Down Expand Up @@ -142,7 +144,8 @@ public IString asJSON(IValue value, IBool unpackedLocations, IString dateTimeFor
if (indent.intValue() > 0) {
out.setIndent(" ".substring(0, indent.intValue() % 9));
}
new JsonValueWriter().setCalendarFormat(dateTimeFormat.getValue())
new JsonValueWriter()
.setCalendarFormat(dateTimeFormat.getValue())
.setDatesAsInt(dateTimeAsInt.getValue())
.setUnpackedLocations(unpackedLocations.getValue())
.setDropOrigins(dropOrigins.getValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ public IValue visitNode(Type type) throws IOException {
continue;
}

boolean positioned = kwName.startsWith("arg");
boolean positioned = kwName.startsWith("__arg");

if (!isNull()) { // lookahead for null to give default parameters the preference.
IValue val = TF.valueType().accept(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public Void visitNode(INode o) throws IOException {

int i = 0;
for (IValue arg : o) {
out.name("arg" + i++);
out.name("__arg" + i++);
arg.accept(this);
}

Expand Down

0 comments on commit e0bfa4d

Please sign in to comment.