oxc/crates
Miles Johnson c6ad6603a4
feat(semantic): support scope descendents starting from a certain scope. (#1629)
@Boshen 

The `ScopeTree.descendants` function would return all scopes starting
from the root, and wasn't truly descendants from a specific scope. To
improve this, I've renamed this function to `descendants_from_root` and
have introduced a new `descendants` function that does support from a
specific scope.

Furthermore, I've introduced helper functions to `SymbolTree` to make
reading symbols/scopes easier.

To verify this functionality, I enabled the `function_name` transformer
(and fixed it), and ran some example transforms. Here's the input:

```js
let fn;

fn = function (a, b, c) {
  const d = "";
};

const func = function (arg) {
  {
    const value = "";
  }
};

const f = function (f) {};
```

And the output using _the old implementation_. Note that all function
names are suffixed with a number, this is incorrect, since it was
inheriting far too many scopes.

```js
let fn;
fn = function fn1(a, b, c) {
	const d = '';
};
const func = function func1(arg) {
	{
		const value = '';
	}
};
const f = function f2(f) {
};
```

And here's the output with the new implementation. Note that only `f` is
suffixed with a number. That's because it has a shadowed argument of the
same name.

```js
let fn;
fn = function fn(a, b, c) {
	const d = '';
};
const func = function func(arg) {
	{
		const value = '';
	}
};
const f = function f1(f) {
};
```
2023-12-07 17:29:11 +08:00
..
oxc
oxc_allocator
oxc_ast feat(transformer): Start on function_name transform. (#1510) 2023-12-04 13:35:44 +08:00
oxc_cli
oxc_codegen chore(rust): remove unnecessary clippy::non_upper_case_globals (#1557) 2023-11-27 14:31:38 +08:00
oxc_diagnostics
oxc_formatter feat(ast): implement new proposal-import-attributes (#1476) 2023-11-25 15:56:09 +08:00
oxc_index
oxc_js_regex
oxc_linter chore: move oxc_resolver to https://github.com/oxc-project/oxc_resolver (#1636) 2023-12-06 18:52:59 +08:00
oxc_linter_plugin
oxc_macros feat(linter): add a perf category (#1625) 2023-12-04 17:31:34 +08:00
oxc_minifier feat(semantic): support scope descendents starting from a certain scope. (#1629) 2023-12-07 17:29:11 +08:00
oxc_parser feat(parsr): parse let.a = 1 with error recovery (#1587) 2023-11-29 23:21:39 +08:00
oxc_prettier feat(prettier): wrap parameters in indent (#1633) 2023-12-06 10:20:31 +08:00
oxc_query feat(query): Add is_getter, is_setter, is_constructor to all Function implementors (#1526) 2023-11-27 12:22:41 +08:00
oxc_semantic feat(semantic): support scope descendents starting from a certain scope. (#1629) 2023-12-07 17:29:11 +08:00
oxc_span
oxc_syntax feat(prettier): binaryish expressions with parens (#1597) 2023-12-01 13:52:22 +08:00
oxc_transformer feat(semantic): support scope descendents starting from a certain scope. (#1629) 2023-12-07 17:29:11 +08:00
oxc_type_synthesis
oxc_wasm chore(deps): bump the dependencies group with 2 updates (#1623) 2023-12-04 15:26:44 +08:00