Skip to content

Commit 5dc9658

Browse files
committed
Switch node ID flag to a positive condition
1 parent dfbd3c5 commit 5dc9658

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

templates/java/api/src/main/java-templates/org/ruby_lang/prism/Loader.java.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ public class Loader {
326326
}
327327

328328
<%-
329-
base_params = [*("nodeId" unless Prism::Template::OMIT_NODE_ID), "startOffset", "length"]
329+
base_params = [*("nodeId" if Prism::Template::INCLUDE_NODE_ID), "startOffset", "length"]
330330
base_params_sig = base_params.map { "int #{_1}" }.join(", ")
331331
-%>
332332
private Nodes.Node loadNode() {
333333
int type = buffer.get() & 0xFF;
334-
<%- unless Prism::Template::OMIT_NODE_ID -%>
334+
<%- if Prism::Template::INCLUDE_NODE_ID -%>
335335
int nodeId = loadVarUInt();
336336
<%- end -%>
337337
int startOffset = loadVarUInt();
@@ -343,7 +343,7 @@ public class Loader {
343343
case <%= index + 1 %>:
344344
<%-
345345
params = []
346-
params << "nodeId" unless Prism::Template::OMIT_NODE_ID
346+
params << "nodeId" if Prism::Template::INCLUDE_NODE_ID
347347
params << "startOffset" << "length"
348348
params << "buffer.getInt()" << "null" if node.needs_serialized_length?
349349
params << "loadFlags()" if node.flags

templates/java/api/src/main/java-templates/org/ruby_lang/prism/Nodes.java.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ public abstract class Nodes {
8989

9090
public static final Node[] EMPTY_ARRAY = {};
9191

92-
<%- unless Prism::Template::OMIT_NODE_ID -%>
92+
<%- if Prism::Template::INCLUDE_NODE_ID -%>
9393
public final int nodeId;
9494
<%- end -%>
9595
public final int startOffset;
9696
public final int length;
9797
private boolean newLineFlag = false;
9898

99-
<%- unless Prism::Template::OMIT_NODE_ID -%>
99+
<%- if Prism::Template::INCLUDE_NODE_ID -%>
100100
public Node(int nodeId, int startOffset, int length) {
101101
this.nodeId = nodeId;
102102
<%- else -%>
@@ -246,7 +246,7 @@ public abstract class Nodes {
246246

247247
<%-
248248
params = []
249-
params << "int nodeId" unless Prism::Template::OMIT_NODE_ID
249+
params << "int nodeId" if Prism::Template::INCLUDE_NODE_ID
250250
params << "int startOffset" << "int length"
251251
if node.needs_serialized_length?
252252
params << "int serializedLength"
@@ -256,7 +256,7 @@ public abstract class Nodes {
256256
params.concat(node.semantic_fields.map { |field| "#{field.java_type} #{field.name}" })
257257
-%>
258258
public <%= node.name -%>(<%= params.join(", ") %>) {
259-
<%- unless Prism::Template::OMIT_NODE_ID -%>
259+
<%- if Prism::Template::INCLUDE_NODE_ID -%>
260260
super(nodeId, startOffset, length);
261261
<%- else -%>
262262
super(startOffset, length);
@@ -281,7 +281,7 @@ public abstract class Nodes {
281281
282282
public <%= node.name -%> getNonLazy() {
283283
if (isLazy()) {
284-
return loader.createDefNodeFromSavedPosition(<%= "nodeId, " unless Prism::Template::OMIT_NODE_ID %>startOffset, length, -serializedLength);
284+
return loader.createDefNodeFromSavedPosition(<%= "nodeId, " if Prism::Template::INCLUDE_NODE_ID %>startOffset, length, -serializedLength);
285285
} else {
286286
return this;
287287
}

templates/src/serialize.c.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void
7373
pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
7474
pm_buffer_append_byte(buffer, (uint8_t) PM_NODE_TYPE(node));
7575

76-
<%- unless Prism::Template::OMIT_NODE_ID -%>
76+
<%- if Prism::Template::INCLUDE_NODE_ID -%>
7777
pm_buffer_append_varuint(buffer, node->node_id);
7878
<%- end -%>
7979
pm_serialize_location(&node->location, buffer);

templates/template.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Template # :nodoc: all
1111

1212
JAVA_BACKEND = ENV["PRISM_JAVA_BACKEND"] || "default"
1313
JAVA_IDENTIFIER_TYPE = JAVA_BACKEND == "truffleruby" ? "String" : "byte[]"
14-
OMIT_NODE_ID = ENV.fetch("PRISM_OMIT_NODE_ID", false)
14+
INCLUDE_NODE_ID = ENV.fetch("PRISM_INCLUDE_NODE_ID", "true") != "false"
1515

1616
COMMON_FLAGS_COUNT = 2
1717

0 commit comments

Comments
 (0)