mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
Issue #1658 - Part 7: Implement support for optional chaining in console autocomplete
This works by stripping the optional chaining characters from the completion part variable, allowing the developer tools' parser to proceed as if it were a regular, non-optional expression. Tests were partially based on: https://bugzilla.mozilla.org/show_bug.cgi?id=1594009 Tests for features that do not apply to our version of developer tools (e.g. autocomplete for integer literals, ignoring spaces between property accessors, etc) were excluded.
This commit is contained in:
parent
cb9809634a
commit
c8d825af39
2 changed files with 48 additions and 0 deletions
|
|
@ -145,6 +145,38 @@ function runChecks(dbgObject, dbgEnv) {
|
|||
do_print("Test that suggestions are not given if there is an hyphen in the chain.");
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "testHyphenated['prop-A'].");
|
||||
do_check_null(results);
|
||||
|
||||
do_print("Test that expression with optional chaining operator are completed");
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "testObject?.prop");
|
||||
test_has_result(results, "propA");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "testObject?.propA[0]?.propB?.to");
|
||||
test_has_result(results, "toString");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "testObject?.propA?.[0]?.propB?.to");
|
||||
test_has_result(results, "toString");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "[1,2,3]?.");
|
||||
test_has_result(results, "indexOf");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "'foo'?.");
|
||||
test_has_result(results, "charAt");
|
||||
|
||||
// Check this doesn't throw since `propC` is not defined.
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "testObject?.propC?.this?.does?.not?.exist?.d");
|
||||
|
||||
// Test more ternary
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "true ? t");
|
||||
test_has_result(results, "testObject");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "true ?? t");
|
||||
test_has_result(results, "testObject");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "true ? /* comment */ t");
|
||||
test_has_result(results, "testObject");
|
||||
|
||||
results = JSPropertyProvider(dbgObject, dbgEnv, "true?<t");
|
||||
test_has_no_results(results);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue