Skip to content

Commit

Permalink
Skip unnecessary values when 0
Browse files Browse the repository at this point in the history
These values are assumed to be 0 if they're missing.
  • Loading branch information
amomchilov committed Jan 4, 2024
1 parent b24af44 commit 54b9a5e
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 269 deletions.
9 changes: 4 additions & 5 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,12 @@ def process_dap args
presentationHint: 'locals',
# variablesReference: N, # filled by SESSION
namedVariables: lnum,
indexedVariables: 0,
expensive: false,
}, {
name: 'Global variables',
presentationHint: 'globals',
variablesReference: 1, # GLOBAL
namedVariables: safe_global_variables.size,
indexedVariables: 0,
expensive: false,
}]
when :scope
Expand Down Expand Up @@ -1052,18 +1050,19 @@ def render_variable member
value: member.inspect_value,
type: member.value_type_name,
variablesReference: vid,
indexedVariables: indexedVariables,
namedVariables: namedVariables,
}
else
{
value: member.inspect_value,
type: member.value_type_name,
variablesReference: vid,
indexedVariables: indexedVariables,
namedVariables: namedVariables,
}
end

variable[:indexedVariables] = indexedVariables unless indexedVariables == 0
variable[:namedVariables] = namedVariables unless namedVariables == 0

variable
end
end
Expand Down
3 changes: 0 additions & 3 deletions test/protocol/boot_config_raw_dap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def test_boot_configuration_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 2
},
Expand All @@ -209,7 +208,6 @@ def test_boot_configuration_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -237,7 +235,6 @@ def test_boot_configuration_works_correctly
value: "main",
type: "Object",
variablesReference: 3,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down
21 changes: 0 additions & 21 deletions test/protocol/break_raw_dap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def test_break_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 2
},
Expand All @@ -136,7 +135,6 @@ def test_break_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -164,7 +162,6 @@ def test_break_works_correctly
value: "main",
type: "Object",
variablesReference: 3,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down Expand Up @@ -416,7 +413,6 @@ def test_break_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 4
},
Expand All @@ -425,7 +421,6 @@ def test_break_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -453,15 +448,13 @@ def test_break_works_correctly
value: "Foo",
type: "Module",
variablesReference: 5,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "bar",
value: "nil",
type: "NilClass",
variablesReference: 6,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down Expand Up @@ -595,7 +588,6 @@ def test_break_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 7
},
Expand All @@ -604,7 +596,6 @@ def test_break_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -632,7 +623,6 @@ def test_break_works_correctly
value: "Foo::Bar",
type: "Class",
variablesReference: 8,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down Expand Up @@ -755,7 +745,6 @@ def test_break_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 9
},
Expand All @@ -764,7 +753,6 @@ def test_break_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -792,15 +780,13 @@ def test_break_works_correctly
value: "Foo",
type: "Module",
variablesReference: 10,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "bar",
value: "nil",
type: "NilClass",
variablesReference: 11,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down Expand Up @@ -953,7 +939,6 @@ def test_check_run_to_line_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 2
},
Expand All @@ -962,7 +947,6 @@ def test_check_run_to_line_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -990,7 +974,6 @@ def test_check_run_to_line_works_correctly
value: "main",
type: "Object",
variablesReference: 3,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down Expand Up @@ -1149,7 +1132,6 @@ def test_check_run_to_line_works_correctly
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 4
},
Expand All @@ -1158,7 +1140,6 @@ def test_check_run_to_line_works_correctly
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -1186,15 +1167,13 @@ def test_check_run_to_line_works_correctly
value: "Foo",
type: "Module",
variablesReference: 5,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "bar",
value: "nil",
type: "NilClass",
variablesReference: 6,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down
13 changes: 0 additions & 13 deletions test/protocol/call_stack_raw_dap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def test_call_stack_works_correctly_1643805481
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 2
},
Expand All @@ -136,7 +135,6 @@ def test_call_stack_works_correctly_1643805481
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -164,7 +162,6 @@ def test_call_stack_works_correctly_1643805481
value: "main",
type: "Object",
variablesReference: 3,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down Expand Up @@ -334,7 +331,6 @@ def test_call_stack_works_correctly_1643805481
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 4
},
Expand All @@ -343,7 +339,6 @@ def test_call_stack_works_correctly_1643805481
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -371,7 +366,6 @@ def test_call_stack_works_correctly_1643805481
value: "Foo::Bar",
type: "Class",
variablesReference: 5,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand All @@ -398,7 +392,6 @@ def test_call_stack_works_correctly_1643805481
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 6
},
Expand All @@ -407,7 +400,6 @@ def test_call_stack_works_correctly_1643805481
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -435,15 +427,13 @@ def test_call_stack_works_correctly_1643805481
value: "Foo",
type: "Module",
variablesReference: 7,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "bar",
value: "nil",
type: "NilClass",
variablesReference: 8,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand All @@ -470,7 +460,6 @@ def test_call_stack_works_correctly_1643805481
name: "Local variables",
presentationHint: "locals",
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 9
},
Expand All @@ -479,7 +468,6 @@ def test_call_stack_works_correctly_1643805481
presentationHint: "globals",
variablesReference: 1,
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false
}
]
Expand Down Expand Up @@ -507,7 +495,6 @@ def test_call_stack_works_correctly_1643805481
value: "main",
type: "Object",
variablesReference: 10,
indexedVariables: 0,
namedVariables: /\d+/
}
]
Expand Down
Loading

0 comments on commit 54b9a5e

Please sign in to comment.