ottomated
9d6cc9d3af
feat(estree): ESTree compatibility for all literals ( #7152 )
...
Adds some new estree macro directives:
- `#[estree(via = foo::Foo)`: Uses From to convert this struct to foo::Foo before serialization
- `#[estree(add_ts = "foo: string")]`: Adds additional fields to the typescript definitions
Used these to make all different literals estree-compatible.
2024-11-06 21:25:41 +00:00
ottomated
dc0215c906
feat(ast_tools): Add #[estree(append_to)], remove some custom serialization code ( #7149 )
...
Removed custom logic for ObjectPattern, ArrayPattern, etc. in favor of a custom attribute macro `#[estree(append_to = "foo")]` as part of #6347
2024-11-06 21:09:45 +00:00
overlookmotel
cc8a1917e5
feat(ast): methods on AST nodes to get scope_id etc ( #7127 )
...
Add getter and setter methods to all AST types which have a `ScopeId`, `SymbolId` or `ReferenceId` field to get the contents of that field.
Before:
```rs
let symbol_id = ident.symbol_id.get().unwrap();
```
After:
```rs
let symbol_id = ident.symbol_id();
```
This allows removing boilerplate code from the transformer, and discouraging the anti-pattern of treating these fields as if they may contain either `Some` or `None` (after semantic, they will always be `Some`).
2024-11-05 02:25:27 +00:00
overlookmotel
25d7554ec4
refactor(ast_tools): rename visitable to is_visitable ( #7104 )
...
Pure refactor. Just rename fields and vars from `visitable` to `is_visitable`, to be more descriptive.
2024-11-03 17:20:25 +00:00
overlookmotel
f543a8d495
refactor(ast)!: remove AstBuilder::*_from_* methods ( #7073 )
...
Remove `AstBuilder::*_from_*` methods for constructing enums. In my opinion, it's not a great pattern, and this removes 2000 of lines of code from [ast_builder.rs](https://github.com/oxc-project/oxc/pull/7073/files#diff-e34fd45077ed0a48b7fee440fdbe4c22a01d787a70a311afebfc1d310785fb70 ).
2024-11-02 01:22:56 +00:00
overlookmotel
32b4a53692
refactor(ast_tools): remove LateCtx abstraction ( #7083 )
...
`LateCtx` is just a wrapper around `Schema`. Remove it and use `Schema` instead.
2024-11-01 22:31:03 +00:00
overlookmotel
2eb9aa9b89
refactor(ast_tools): remove dead code ( #7080 )
2024-11-01 21:59:28 +00:00
overlookmotel
d89fe2c326
refactor(ast_tools): shorten code ( #7079 )
...
Shorten code by importing `rust_ast::Module` at top level.
2024-11-01 21:51:29 +00:00
overlookmotel
00cc156fb5
refactor(ast_tools): simplify module loading ( #7078 )
...
Rename var for clarity and remove unnecessary `From` impl.
2024-11-01 21:51:29 +00:00
overlookmotel
f2d10683a8
refactor(ast_tools): remove dead code ( #7077 )
2024-11-01 21:42:14 +00:00
overlookmotel
248ff18ddd
refactor(ast_tools): output progress ( #7076 )
...
Flush `stdout` after writing progress.
2024-11-01 21:26:45 +00:00
ottomated
9725e3c2ec
feat(ast_tools): Add #[estree(always_flatten)] to Span ( #6935 )
...
Part of #6347
Other changes:
- added #[estree(skip)] to thisSpan in TSThisParameter
- Flattened the span in BoundaryAssertion (regex)
2024-10-28 02:13:24 +00:00
ottomated
fbc297ec7b
feat(ast_tools): Move tsify custom types to estree attribute macro ( #6934 )
...
Part of #6347
2024-10-28 01:45:27 +00:00
ottomated
169fa22350
feat(ast_tools): Default enums to rename_all = "camelCase" ( #6933 )
...
Part of #6347
2024-10-28 01:39:25 +00:00
overlookmotel
335eb38be6
refactor(ast_tools): faster formatting Rust code ( #6972 )
...
Speed up formatting Rust code. Don't convert to string and then re-parse, allow `syn` to skip a step by using existing `TokenStream`.
2024-10-28 01:13:36 +00:00
overlookmotel
7fcc4f7211
refactor(ast_tools): one function to add header to generated files ( #6971 )
...
Centralize logic for adding header to generated files.
2024-10-28 00:47:49 +00:00
overlookmotel
c7bec098fa
docs(ast_tools): correct doc comments for Output ( #6970 )
2024-10-28 00:47:48 +00:00
overlookmotel
3aed3eb543
refactor(ast_tools): remove well_known! macro ( #6957 )
...
Remove `well_known!` macro by expanding code manually.
2024-10-28 00:47:46 +00:00
overlookmotel
54e78d9ea3
refactor(ast_tools): reduce macro usage ( #6956 )
...
Pure refactor. Expand simple macros.
2024-10-28 00:47:45 +00:00
overlookmotel
83d1f69f75
refactor(ast_tools): replace str::replace with CowUtils::cow_replace ( #6954 )
...
Obey our clippy-enforced policy to prefer `CowUtils::cow_replace`.
2024-10-28 00:23:34 +00:00
overlookmotel
ac6b3091ab
refactor(ast_tools): remove repeated code in Output methods ( #6953 )
...
`generator_path.replace('\\', "/")` was repeated in each module for that generates outputs. Move it, to reduce repetition.
2024-10-28 00:23:33 +00:00
overlookmotel
2b10e5cd52
refactor(ast_tools): move logger into separate module ( #6952 )
...
Reduce the amount of code in `main.rs` by moving logger functionality to a separate module.
2024-10-28 00:23:33 +00:00
overlookmotel
06f05659c5
refactor(ast_tools): refactor writing outputs ( #6951 )
...
`write_all_to` no longer needs to be public. Remove it, and compact the code for writing files.
2024-10-27 23:56:22 +00:00
overlookmotel
6b88798253
refactor(ast_tools): generate JSON schema as Output::Raw ( #6950 )
...
Add `Output::Raw`, and use it for the JSON schema file.
2024-10-27 23:56:21 +00:00
overlookmotel
2fc6ca374f
refactor(ast_tools): hardcode schema output path ( #6949 )
...
Hard-code the output file path for JSON schema file. This will allow generating it as an `Output`, same as all other generated files.
2024-10-27 23:40:57 +00:00
overlookmotel
ef2f73ebed
refactor(ast_tools): rename Output::into_raw method ( #6948 )
...
Rename `Output::output` to `Output::into_raw` - more descriptive name.
2024-10-27 23:40:56 +00:00
overlookmotel
524d9c069f
refactor(ast_tools): generate CI filter as Output::Yaml ( #6947 )
...
Add `Output::Yaml` and use it for generating CI filter file.
2024-10-27 19:18:10 +00:00
overlookmotel
11539e61fd
refactor(ast_tools): add CI filter file to outputs ( #6946 )
...
Generate CI filter file as a `RawOutput`, same as the rest, rather than
specific code to write it to a file.
2024-10-27 19:09:42 +00:00
overlookmotel
87db9eeeed
refactor(ast_tools): simplify logging ( #6945 )
...
* Replace `logln!` macro with `log_result!` to log result of an action.
* Move logging for writing files into one place.
2024-10-27 18:53:24 +00:00
overlookmotel
dde095c7e1
refactor(ast_tools): combine derives into generators ( #6944 )
...
`Generator`s and `Derive`s now work the same. Combine them into a single `Vec`.
2024-10-27 15:37:25 +00:00
overlookmotel
80a163e691
refactor(ast_tools): reduce repeated code ( #6943 )
...
Use one function to process all passes.
2024-10-27 15:37:24 +00:00
overlookmotel
e1b747ddd6
refactor(ast_tools): all runners produce Vec<Output> ( #6942 )
...
Standardize all the different `Runner`s to produce `Vec<Output>`.
2024-10-27 15:29:17 +00:00
overlookmotel
c83b758507
refactor(ast_tools): simplify Pass ( #6941 )
...
Pure refactor. Remove dead code and structure like the other `Runner`s.
2024-10-27 14:38:18 +00:00
overlookmotel
c4c0865cb3
refactor(ast_tools): clarify code ( #6940 )
...
Small refactor.
2024-10-27 14:30:36 +00:00
overlookmotel
fc07458280
refactor(ast): move custom types .d.ts file ( #6931 )
...
We have a few manually-defined TS types in `oxc_ast` crate. Move that `.d.ts` file out of `src` folder, and name it more descriptively.
2024-10-26 17:10:34 +00:00
overlookmotel
992699012f
refactor(napi): move custom types to bottom of file ( #6930 )
...
Pure refactor. Doesn't matter much but I think it's preferable for the file not to start with the most random weird types.
2024-10-26 17:10:33 +00:00
overlookmotel
23157bde6f
refactor(napi): types file in root of types package ( #6929 )
...
Move `types.d.ts` file to root of `@oxc-project/types` package. I think this is cleaner.
2024-10-26 17:10:31 +00:00
overlookmotel
345b0a6eb0
refactor(ast_tools): shorten code in Visit generator ( #6928 )
...
Remove double line-break which formatting removes anyway.
2024-10-26 14:05:23 +00:00
overlookmotel
ad40ab7874
refactor(ast_tools): remove const params for Visit generator ( #6927 )
...
This function is large, so const param here was probably making the code slower, certainly slower compile time. Use a runtime value instead.
2024-10-26 14:05:20 +00:00
overlookmotel
4cf008573e
refactor(ast_tools): reorder imports in generated code ( #6926 )
...
Pure refactor.
2024-10-26 14:05:18 +00:00
overlookmotel
8101d1b2c4
refactor(ast_tools): handle paths as strings ( #6925 )
...
We were converting back and forwards between strings and `Path`s for no purpose. Just use strings.
2024-10-26 14:05:16 +00:00
overlookmotel
e4a59368f0
refactor(ast_tools): shorten code ( #6924 )
...
Pure refactor.
2024-10-26 14:05:14 +00:00
overlookmotel
73ab6fb13c
refactor(ast_tools): remove temporary vec ( #6923 )
2024-10-26 13:14:39 +00:00
ottomated
ce5b609514
feat(ast): remove explicit untagged marker on enums ( #6915 )
...
This assumes that any enums with exactly one field in each variant are untagged, and they're tagged otherwise.
2024-10-26 08:21:40 +00:00
overlookmotel
6e68c9398b
style(ast_tools): reorder imports ( #6904 )
...
Pure refactor. Re-order imports for clarity.
2024-10-25 21:23:28 +00:00
overlookmotel
45333bc8d2
refactor(ast_tools): shorten code by hoisting imports ( #6903 )
...
Pure refactor.
2024-10-25 21:23:28 +00:00
overlookmotel
07dcc0cae3
refactor(ast_tools): move file_path method to Runner ( #6902 )
...
Centralize this common method, to move responsibility from individual derives/generators.
2024-10-25 21:16:34 +00:00
overlookmotel
5f44d84744
refactor(ast_tools): centralize logic for outputting files ( #6900 )
...
Move all logic related to formatting and outputting files into one
place.
2024-10-25 22:08:58 +01:00
overlookmotel
26de0de326
refactor(ast_tools): simplify define_pass! macro ( #6901 )
2024-10-25 21:04:03 +00:00
overlookmotel
1d981bfa53
refactor(ast_tools): run rustfmt only on generated files ( #6898 )
...
Run `rustfmt` only on individual files which codegen generates, rather than on the whole repo. This speeds up local development of `ast_tools` when you're on a slower machine.
2024-10-25 18:53:05 +00:00