@appthreat/atom-parsetools 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -7
- package/astgen.js +297 -57
- package/package.json +9 -6
- package/plugins/composer/installed.php +6 -6
- package/plugins/rubyastgen/Gemfile +6 -4
- package/plugins/rubyastgen/Gemfile.lock +5 -8
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/Gemfile +11 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/exe/ruby_ast_gen +55 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/lib/ruby_ast_gen/cli.rb +133 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/lib/ruby_ast_gen/node_handling.rb +449 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/lib/ruby_ast_gen/version.rb +1 -1
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/lib/ruby_ast_gen.rb +888 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/ruby_ast_gen.gemspec +25 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/current.rb +1 -1
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/version.rb +1 -1
- package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/ast-2.4.3.gemspec +29 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/bundler-2.6.9.gemspec +25 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/ostruct-0.6.3.gemspec +22 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/parser-3.3.12.0.gemspec +37 -0
- package/rbastgen.js +102 -13
- package/scalasem.js +11 -2
- package/plugins/bin/bundler +0 -14
- package/plugins/bin/ruby_ast_gen +0 -14
- package/plugins/rubyastgen/bundle/bundler/setup.rb +0 -44
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-cc312ebf06b4/exe/ruby_ast_gen +0 -63
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-cc312ebf06b4/lib/ruby_ast_gen/node_handling.rb +0 -269
- package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-cc312ebf06b4/lib/ruby_ast_gen.rb +0 -218
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/gem.build_complete +0 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/gem_make.out +0 -44
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/mkmf.log +0 -74
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/prism/prism.so +0 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/racc-1.8.1/gem.build_complete +0 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/racc-1.8.1/gem_make.out +0 -18
- package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/racc-1.8.1/racc/cparse.so +0 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/BSDmakefile +0 -58
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/Makefile +0 -116
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/Makefile +0 -273
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/api_node.c +0 -6945
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/api_pack.c +0 -276
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extconf.rb +0 -127
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extension.c +0 -1427
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extension.h +0 -19
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/ast.h +0 -8254
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/defines.h +0 -260
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/diagnostic.h +0 -458
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/encoding.h +0 -283
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/node.h +0 -129
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/options.h +0 -488
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/pack.h +0 -163
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/parser.h +0 -936
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/prettyprint.h +0 -34
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/regexp.h +0 -43
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/static_literals.h +0 -121
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_buffer.h +0 -236
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_char.h +0 -204
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_constant_pool.h +0 -218
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_integer.h +0 -130
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_list.h +0 -103
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_memchr.h +0 -29
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_newline_list.h +0 -113
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_string.h +0 -200
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_strncasecmp.h +0 -32
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_strpbrk.h +0 -46
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/version.h +0 -29
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism.h +0 -408
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/compiler.rb +0 -801
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/desugar_compiler.rb +0 -392
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/dispatcher.rb +0 -2210
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/dot_visitor.rb +0 -4767
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/dsl.rb +0 -1003
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/ffi.rb +0 -578
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/inspect_visitor.rb +0 -2393
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/lex_compat.rb +0 -911
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/mutation_compiler.rb +0 -772
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/node.rb +0 -19966
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/node_ext.rb +0 -511
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/pack.rb +0 -230
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result/comments.rb +0 -188
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result/errors.rb +0 -66
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result/newlines.rb +0 -155
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result.rb +0 -907
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/pattern.rb +0 -269
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/append_as_bytes.rb +0 -15
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/byteindex.rb +0 -13
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/scan_byte.rb +0 -14
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/unpack1.rb +0 -14
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/warn.rb +0 -36
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/prism.so +0 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/reflection.rb +0 -416
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/relocation.rb +0 -505
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/serialize.rb +0 -2400
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/string_query.rb +0 -31
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser/builder.rb +0 -62
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser/compiler.rb +0 -2234
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser/lexer.rb +0 -820
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser.rb +0 -376
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser_current.rb +0 -26
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser_versions.rb +0 -36
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/filter.rb +0 -53
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/lexer.rb +0 -135
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/sexp.rb +0 -126
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/shim.rb +0 -5
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper.rb +0 -3520
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ruby_parser.rb +0 -1964
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation.rb +0 -18
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/visitor.rb +0 -813
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism.rb +0 -98
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/compiler.rbi +0 -12
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/dsl.rbi +0 -524
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/inspect_visitor.rbi +0 -12
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/node.rbi +0 -8750
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/node_ext.rbi +0 -107
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/parse_result.rbi +0 -404
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/reflection.rbi +0 -58
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/string_query.rbi +0 -12
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/translation/parser.rbi +0 -11
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/translation/parser_versions.rbi +0 -23
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/translation/ripper.rbi +0 -15
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/visitor.rbi +0 -473
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism.rbi +0 -63
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/compiler.rbs +0 -9
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/dispatcher.rbs +0 -19
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/dot_visitor.rbs +0 -6
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/dsl.rbs +0 -351
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/inspect_visitor.rbs +0 -22
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/lex_compat.rbs +0 -10
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/mutation_compiler.rbs +0 -159
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/node.rbs +0 -4042
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/node_ext.rbs +0 -149
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/pack.rbs +0 -43
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/parse_result/comments.rbs +0 -38
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/parse_result.rbs +0 -197
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/pattern.rbs +0 -13
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/reflection.rbs +0 -50
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/relocation.rbs +0 -185
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/serialize.rbs +0 -8
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/string_query.rbs +0 -11
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/visitor.rbs +0 -169
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism.rbs +0 -272
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/diagnostic.c +0 -854
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/encoding.c +0 -5340
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/node.c +0 -8685
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/options.c +0 -338
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/pack.c +0 -509
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/prettyprint.c +0 -8957
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/prism.c +0 -22679
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/regexp.c +0 -790
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/serialize.c +0 -2274
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/static_literals.c +0 -617
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/token_type.c +0 -703
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_buffer.c +0 -357
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_char.c +0 -318
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_constant_pool.c +0 -342
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_integer.c +0 -670
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_list.c +0 -49
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_memchr.c +0 -35
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_newline_list.c +0 -125
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_string.c +0 -381
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_strncasecmp.c +0 -36
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_strpbrk.c +0 -206
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/BSDL +0 -22
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/COPYING +0 -56
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ChangeLog +0 -846
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/README.ja.rdoc +0 -58
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/README.rdoc +0 -60
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/TODO +0 -5
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/bin/racc +0 -320
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse/Makefile +0 -273
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse/cparse.c +0 -840
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse/extconf.rb +0 -8
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/compat.rb +0 -33
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/cparse.so +0 -0
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/debugflags.rb +0 -60
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/exception.rb +0 -16
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/grammar.rb +0 -1191
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/grammarfileparser.rb +0 -667
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/info.rb +0 -18
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/iset.rb +0 -92
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/logfilegenerator.rb +0 -212
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/parser-text.rb +0 -644
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/parser.rb +0 -630
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/parserfilegenerator.rb +0 -473
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/sourcetext.rb +0 -35
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/state.rb +0 -976
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/statetransitiontable.rb +0 -311
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/static.rb +0 -5
- package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc.rb +0 -6
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/.rspec +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/bin/console +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/bin/setup +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/update_version.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/bin/ruby-parse +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/bin/ruby-rewrite +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/gauntlet_parser.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/all.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ast/node.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ast/processor.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/base.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/builders/default.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/clobbering_error.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/color.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/context.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/current_arg_stack.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/deprecation.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/diagnostic/engine.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/diagnostic.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/dedenter.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/explanation.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/literal.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/stack_state.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer-F0.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer-F1.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer-strings.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/macruby.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/max_numparam_stack.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/messages.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/meta.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/rewriter.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby18.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby19.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby20.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby21.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby22.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby23.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby24.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby25.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby26.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby27.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby30.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby31.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby32.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby33.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby34.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/rubymotion.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/runner/ruby_parse.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/runner/ruby_rewrite.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/runner.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/buffer.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/comment/associator.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/comment.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/collection.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/condition.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/constant.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/definition.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/for.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/heredoc.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/index.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/keyword.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/method_definition.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/objc_kwarg.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/operator.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/rescue_body.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/send.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/ternary.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/variable.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/range.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/rewriter/action.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/rewriter.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/tree_rewriter/action.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/tree_rewriter.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/static_environment.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/syntax_error.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/tree_rewriter.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/unknown_encoding_in_magic_comment_error.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/variables_stack.rb +0 -0
- /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser.rb +0 -0
package/README.md
CHANGED
|
@@ -4,9 +4,13 @@ This package hosts a collection of parsing tools that complement the `@appthreat
|
|
|
4
4
|
|
|
5
5
|
- astgen - Generates AST for JavaScript and TypeScript projects in JSON format
|
|
6
6
|
- phpastgen - Generates AST for PHP projects using `php-parse` command from `nikic/php-parser`
|
|
7
|
-
- rbastgen - Generates AST for Ruby projects using
|
|
7
|
+
- rbastgen - Generates AST for Ruby projects using AppThreat's [`ruby_ast_gen`](https://github.com/AppThreat/ruby_ast_gen) gem (2.0.1)
|
|
8
8
|
- scalasem - Generates a custom semantics slice for Scala Projects by utilising scalac command.
|
|
9
9
|
|
|
10
|
+
## Runtime support
|
|
11
|
+
|
|
12
|
+
These tools run on both [Node.js](https://nodejs.org) (>= 22, required by `@babel/parser` 8) and [Bun](https://bun.sh). All commands and the accompanying regression test-suite are exercised under both runtimes in CI, so the commands below can be invoked with either `node` or `bun` interchangeably (for example `bun astgen.js -i .`).
|
|
13
|
+
|
|
10
14
|
## Command usages
|
|
11
15
|
|
|
12
16
|
### astgen
|
|
@@ -25,6 +29,16 @@ Options:
|
|
|
25
29
|
-h Show help [boolean]
|
|
26
30
|
```
|
|
27
31
|
|
|
32
|
+
#### Environment variables
|
|
33
|
+
|
|
34
|
+
| Variable | Default | Purpose |
|
|
35
|
+
| ------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `ASTGEN_TYPE_WORKERS` | `1` (off) | Number of worker threads for the TypeScript type-generation phase, or `auto` to derive it from the available CPUs. The TypeScript checker is single-threaded, so parallelism comes from sharding files across workers, each building its own program. **Opt-in:** sharding changes TypeScript's internal type-id ordering, which reorders the members of a small number of inferred union types (e.g. `A \| B` → `B \| A`; semantically identical). Leave unset for byte-identical output; set it (e.g. `auto` or `8`) to trade that cosmetic reordering for a large speedup on big projects. |
|
|
37
|
+
| `ASTGEN_INCLUDE_TEST_FILES` | `false` | When `true`, do not exclude test files (`*.poku.js`, `*.test.*`, `*.spec.*`, `*.e2e.*`, `__tests__/`, `__mocks__/`) from AST and type generation. They are excluded by default because they are typically the heaviest, lowest-value inputs for type generation. |
|
|
38
|
+
| `ASTGEN_CONCURRENCY` | `10` | Chunk size for the in-thread file loop (bounds peak memory between `gc()` passes). |
|
|
39
|
+
| `ASTGEN_INCLUDE_NODE_MODULES_BUNDLES` | `false` | When `true`, also parse bundled entrypoints inside `node_modules` (files matching `*.(bundle\|dist\|index\|min\|app).(js\|cjs\|mjs)`). Off by default; `node_modules` is otherwise skipped entirely. |
|
|
40
|
+
| `ASTGEN_IGNORE_DIRS` | unset | Comma/space-separated list of directories to ignore. As a side effect, when it is set and does **not** contain `node_modules`, the `node_modules` bundle entrypoints above are included (equivalent to `ASTGEN_INCLUDE_NODE_MODULES_BUNDLES=true`). |
|
|
41
|
+
|
|
28
42
|
### phpastgen
|
|
29
43
|
|
|
30
44
|
```text
|
|
@@ -50,17 +64,90 @@ Operations is a list of the following options (--dump by default):
|
|
|
50
64
|
|
|
51
65
|
### rbastgen
|
|
52
66
|
|
|
67
|
+
Requires Ruby 3.4.x or 4.0.x on the `PATH`, or `ATOM_RUBY_HOME` pointing at an install. The gem and
|
|
68
|
+
its pure-Ruby dependencies are bundled under `plugins/rubyastgen`, so nothing needs to be
|
|
69
|
+
gem-installed, and one build of this package runs under every supported Ruby: the bundle is exposed
|
|
70
|
+
to the interpreter through `GEM_PATH` rather than through bundler's standalone loader, which
|
|
71
|
+
resolved its paths from the ABI of the Ruby that built it.
|
|
72
|
+
|
|
73
|
+
`prism` and `racc` are deliberately **not** bundled. Both carry C extensions, which are built per
|
|
74
|
+
ABI and per platform, and both are default gems in every supported Ruby, so the runtime's own copies
|
|
75
|
+
are used. One consequence is visible: the newest grammar available follows the interpreter's prism,
|
|
76
|
+
so Ruby 3.4 tops out lower than Ruby 4.0 (grammar 3.5 versus 4.1 at the time of writing). Installing
|
|
77
|
+
a newer `prism` gem on the machine raises it, since the caller's `GEM_PATH` is preserved.
|
|
78
|
+
|
|
53
79
|
```text
|
|
54
80
|
node rbastgen.js --help
|
|
55
81
|
Usage:
|
|
56
|
-
-i, --input
|
|
57
|
-
-o, --output
|
|
58
|
-
-e, --exclude The exclusion regex (default: '^(tests?|vendor|spec)')
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
--
|
|
82
|
+
-i, --input <path> The input file or directory (required)
|
|
83
|
+
-o, --output <dir> The output directory (default: '.ast')
|
|
84
|
+
-e, --exclude <regex> The exclusion regex (default: '^(tests?|vendor|spec)')
|
|
85
|
+
-l, --log <level> The logging level: debug, info, warn or error (default: info)
|
|
86
|
+
-d, --debug Enable debug logging (same as --log debug)
|
|
87
|
+
--parser-target <x.y>
|
|
88
|
+
Parse with a specific Ruby grammar (e.g. 3.4, 4.0) instead
|
|
89
|
+
of the newest available
|
|
90
|
+
--max-depth <n> Maximum AST depth before truncation (default: 250)
|
|
91
|
+
--threads <n> Worker threads for a directory run (default: 10)
|
|
92
|
+
--fail-on-error Exit non-zero when any input file failed to parse
|
|
93
|
+
--parser-info Print parser/runtime capability information
|
|
94
|
+
--version Print the version
|
|
95
|
+
--help Print usage
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Problems with individual files are reported and skipped, never fatal; only usage errors (a missing
|
|
99
|
+
`-i`, an unusable `--exclude` regex, an invalid `--parser-target`) exit non-zero. Note that
|
|
100
|
+
`rbastgen` does not propagate the generator's exit status, so `--fail-on-error` is reported in the
|
|
101
|
+
log but the wrapper still exits 0 — call the gem directly if a CI job needs to fail on a parse
|
|
102
|
+
error.
|
|
103
|
+
|
|
104
|
+
#### What the bundled generator emits (ruby_ast_gen 2.0.1)
|
|
105
|
+
|
|
106
|
+
- **Parsing is decoupled from the running Ruby.** When `prism` is available the newest grammar its
|
|
107
|
+
translation layer supports is used, so a 3.4 runtime parses Ruby 4.0/4.1 syntax. `--parser-target
|
|
108
|
+
x.y` pins a grammar instead (down to 1.8 through the `parser` gem), and a file that fails under
|
|
109
|
+
the selected grammar is retried once with the newest one. Every JSON file records the backend
|
|
110
|
+
that produced it in `parser_backend`, alongside `generator_version` and `ruby_version`.
|
|
111
|
+
- **Ruby DSL files are discovered, not just `.rb`.** `Rakefile`, `Gemfile`, `Capfile`,
|
|
112
|
+
`Vagrantfile`, `Fastfile` and friends are matched by basename, plus the `.gemspec`, `.rake`,
|
|
113
|
+
`.ru`, `.rbi`, `.thor`, `.jbuilder`, `.axlsx` and `.rabl` extensions. Vendor and tool
|
|
114
|
+
directories (`.git`, `.bundle`, `.venv`, …) are skipped.
|
|
115
|
+
- **Non-UTF-8 sources survive.** `# coding:` magic comments are honoured and undecodable bytes are
|
|
116
|
+
scrubbed rather than dropping the file, marked with `encoding_scrubbed: true`.
|
|
117
|
+
- **Deeply nested source is truncated, not dropped**, with `truncated: true` on the boundary node
|
|
118
|
+
and a `truncated_nodes` count at the top level (`--max-depth`).
|
|
119
|
+
- **Semantic metadata for consumers**: a `magic_comments` array (Sorbet `typed:` levels,
|
|
120
|
+
`frozen_string_literal`, …), `call_operator`/`has_parentheses` on calls, `percent_array` and
|
|
121
|
+
regexp `options`, heredoc body offsets, and `has_sig: true` on a `def` preceded by a Sorbet `sig`
|
|
122
|
+
block.
|
|
123
|
+
- **Two side-records per run, written inside the output directory**, both ending in `.jsonl` so a
|
|
124
|
+
consumer globbing `*.json` for ASTs never mistakes them for one:
|
|
125
|
+
`ruby_ast_gen_manifest.jsonl` (one object: input/output, backend, counts of parsed, failed,
|
|
126
|
+
skipped, excluded and truncated files, threads, max depth) and
|
|
127
|
+
`ruby_ast_gen_diagnostics.jsonl` (one object per failed file with message, line, column), the
|
|
128
|
+
latter written only when something failed and removed when a later run is clean.
|
|
129
|
+
|
|
130
|
+
To check which backend a machine will use:
|
|
131
|
+
|
|
132
|
+
```shell
|
|
133
|
+
rbastgen --parser-info
|
|
62
134
|
```
|
|
63
135
|
|
|
136
|
+
`Parser gem` and `Prism gem` name the versions actually loaded — the vendored `parser` and the
|
|
137
|
+
runtime's `prism` — so they are the quickest way to tell which copy of each library a machine is
|
|
138
|
+
parsing with. They read `unavailable` only when a library genuinely is not loaded.
|
|
139
|
+
|
|
140
|
+
#### Environment variables
|
|
141
|
+
|
|
142
|
+
| Variable | Default | Purpose |
|
|
143
|
+
| --------------------------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
144
|
+
| `ATOM_RUBY_HOME` | unset | Ruby install directory to use when a suitable `ruby` is not on the `PATH`; its `bin` is prepended to `PATH` for the child process. |
|
|
145
|
+
| `RUBY_CMD` | `ruby` | Ruby interpreter to invoke. Set this (or `ATOM_RUBY_HOME`) when the detected version is not 3.4.x/4.0.x. |
|
|
146
|
+
| `RUBY_ASTGEN_BIN` | bundled `ruby_ast_gen` | The generator script to run. Point it at a checkout's `exe/ruby_ast_gen` to test an unreleased `ruby_ast_gen` without touching this package. |
|
|
147
|
+
| `ATOM_CWD` | `process.cwd()` | Working directory for the generator, which is what relative `-i`/`-o` paths resolve against. |
|
|
148
|
+
| `ATOM_TIMEOUT` / `ASTGEN_TIMEOUT` | unset (no timeout) | Milliseconds before the generator process is killed. `ATOM_TIMEOUT` wins; a non-numeric value is ignored. Also honoured by `scalasem`. |
|
|
149
|
+
| `GEM_PATH` | unset | Preserved and appended to the vendored bundle, so gems installed on the machine (a newer `prism`, for instance) stay reachable. |
|
|
150
|
+
|
|
64
151
|
### scalasem
|
|
65
152
|
|
|
66
153
|
```text
|
|
@@ -73,6 +160,30 @@ Example:
|
|
|
73
160
|
scalasem $(pwd) slices.json
|
|
74
161
|
```
|
|
75
162
|
|
|
163
|
+
## Testing
|
|
164
|
+
|
|
165
|
+
`npm test` covers the JavaScript/TypeScript side and needs nothing but Node. The Ruby workflow tests
|
|
166
|
+
run the `rbastgen` command end to end against `test-fixtures/projects/ruby-parsing`, so they need a
|
|
167
|
+
built plugin bundle and a supported Ruby, and they skip themselves cleanly when either is missing:
|
|
168
|
+
|
|
169
|
+
```shell
|
|
170
|
+
bash build.sh --ruby-only
|
|
171
|
+
npm run test:ruby
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`ci/verify-packed-tarball.sh` is the release check: it packs the tarball, installs it into a scratch
|
|
175
|
+
project and parses the fixture with the installed copy, asserting along the way that the Ruby bundle
|
|
176
|
+
is present and free of compiled extensions. CI runs it, and it runs the same way locally.
|
|
177
|
+
|
|
178
|
+
They assert what a consumer depends on rather than that the command ran: which files are discovered
|
|
179
|
+
(including `Gemfile` and `Rakefile`, matched by basename), that `has_sig`, `magic_comments`,
|
|
180
|
+
`percent_array` and regexp `options` are emitted, that the manifest's counts reconcile, that a
|
|
181
|
+
failed file lands in the diagnostics record while the run still exits 0, that a clean run leaves no
|
|
182
|
+
stale record behind, and that the bundle contains no compiled extension. CI runs them under both
|
|
183
|
+
Ruby 3.4 and Ruby 4.0 against a bundle built with 3.4, and separately installs the packed tarball
|
|
184
|
+
and parses with that, which is the check that catches a bundle usable only on the Ruby that built
|
|
185
|
+
it.
|
|
186
|
+
|
|
76
187
|
## License
|
|
77
188
|
|
|
78
189
|
MIT
|
package/astgen.js
CHANGED
|
@@ -4,8 +4,15 @@ import { join, dirname, relative, resolve, basename } from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { parse } from "@babel/parser";
|
|
6
6
|
import { parse as parseHermes } from "hermes-parser";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// TypeScript 7.0 (the native Go port) ships without a programmatic compiler
|
|
8
|
+
// API, which astgen relies on heavily (createProgram, getTypeChecker,
|
|
9
|
+
// forEachChild, SyntaxKind, TypeFormatFlags, ...). The officially supported
|
|
10
|
+
// bridge until the API returns in TS 7.1 is the @typescript/typescript6
|
|
11
|
+
// package, which is the same TS 6 engine and therefore keeps AST shapes and
|
|
12
|
+
// type-inference accuracy identical.
|
|
13
|
+
import tsc from "@typescript/typescript6";
|
|
14
|
+
import { tmpdir, cpus, availableParallelism } from "os";
|
|
15
|
+
import { Worker, isMainThread, parentPort, workerData } from "worker_threads";
|
|
9
16
|
import {
|
|
10
17
|
readFileSync,
|
|
11
18
|
mkdirSync,
|
|
@@ -18,7 +25,11 @@ import {
|
|
|
18
25
|
} from "fs";
|
|
19
26
|
import { getAllFiles } from "@appthreat/atom-common";
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
// Printed by `astgen --version`. Downstream frontends (e.g. chen's jssrc2cpg)
|
|
29
|
+
// fold this into their parse-cache fingerprint, so it MUST be bumped whenever
|
|
30
|
+
// the emitted AST/type shape changes — otherwise stale cached parses from an
|
|
31
|
+
// older astgen are silently reused. Bumped for the Babel 8 AST-shape change.
|
|
32
|
+
const ASTGEN_VERSION = "4.1.0";
|
|
22
33
|
|
|
23
34
|
const HELP_TEXT = `Options:
|
|
24
35
|
-i, --src Source directory [default: "."]
|
|
@@ -381,6 +392,25 @@ const babelSafeFlowParserOptions = {
|
|
|
381
392
|
]
|
|
382
393
|
};
|
|
383
394
|
|
|
395
|
+
// Test files (e.g. *.poku.js, *.test.ts, *.spec.js, __tests__/*) are
|
|
396
|
+
// test-runner artifacts that are typically the heaviest, lowest-value inputs
|
|
397
|
+
// for type generation (each is often a full twin of a source module wrapped in
|
|
398
|
+
// test scaffolding). They are excluded by default to keep the type-generation
|
|
399
|
+
// phase scalable. Set ASTGEN_INCLUDE_TEST_FILES=true to restore them (e.g. when
|
|
400
|
+
// a downstream consumer wants test files analysed).
|
|
401
|
+
const shouldIncludeTestFiles =
|
|
402
|
+
process.env?.ASTGEN_INCLUDE_TEST_FILES === "true";
|
|
403
|
+
|
|
404
|
+
const TEST_FILE_EXT = "(?:js|jsx|cjs|mjs|ts|tsx|mts|cts)";
|
|
405
|
+
const TEST_FILE_PATTERN = new RegExp(
|
|
406
|
+
`(?:\\.(?:poku|test|spec|e2e|integration|it)\\.${TEST_FILE_EXT}$` +
|
|
407
|
+
`|[\\\\/]__(?:tests|mocks)__[\\\\/])`,
|
|
408
|
+
"i"
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
const isExcludedTestFile = (file) =>
|
|
412
|
+
!shouldIncludeTestFiles && TEST_FILE_PATTERN.test(file);
|
|
413
|
+
|
|
384
414
|
const shouldIncludeNodeModulesBundles =
|
|
385
415
|
process.env?.ASTGEN_INCLUDE_NODE_MODULES_BUNDLES === "true" ||
|
|
386
416
|
(process.env?.ASTGEN_IGNORE_DIRS &&
|
|
@@ -426,7 +456,9 @@ const getAllSrcJSAndTSFiles = (src) => {
|
|
|
426
456
|
// Step 2: Combine both lists
|
|
427
457
|
return Promise.all([allFilesPromise, bundledFilesPromise]).then(
|
|
428
458
|
([allFiles, bundledFiles]) =>
|
|
429
|
-
[...new Set([...allFiles, ...bundledFiles])]
|
|
459
|
+
[...new Set([...allFiles, ...bundledFiles])]
|
|
460
|
+
.filter((file) => !isExcludedTestFile(file))
|
|
461
|
+
.sort()
|
|
430
462
|
);
|
|
431
463
|
};
|
|
432
464
|
|
|
@@ -1087,6 +1119,33 @@ function createTsc(srcFiles, src) {
|
|
|
1087
1119
|
const typeChecker = program.getTypeChecker();
|
|
1088
1120
|
const seenTypes = new Map();
|
|
1089
1121
|
|
|
1122
|
+
// Return-type inference below can re-walk the body of the *same* function
|
|
1123
|
+
// declaration once per referencing call site / initializer (e.g. a helper
|
|
1124
|
+
// called 50 times triggers 50 identical body walks). Since the checker
|
|
1125
|
+
// state is fixed for the lifetime of this program, the inferred string for
|
|
1126
|
+
// a given node is deterministic, so we memoize by node to remove the
|
|
1127
|
+
// redundant re-walks without changing any output. A sentinel distinguishes
|
|
1128
|
+
// "computed and produced undefined" from "not yet computed".
|
|
1129
|
+
const RETURN_TYPE_NOT_COMPUTED = Symbol("returnTypeNotComputed");
|
|
1130
|
+
const memoizeByNode = (fn) => {
|
|
1131
|
+
const cache = new WeakMap();
|
|
1132
|
+
return (node, ...rest) => {
|
|
1133
|
+
if (!node || typeof node !== "object" || rest.length > 0) {
|
|
1134
|
+
return fn(node, ...rest);
|
|
1135
|
+
}
|
|
1136
|
+
const cached = cache.get(node);
|
|
1137
|
+
if (cached !== undefined) {
|
|
1138
|
+
return cached === RETURN_TYPE_NOT_COMPUTED ? undefined : cached;
|
|
1139
|
+
}
|
|
1140
|
+
const result = fn(node);
|
|
1141
|
+
cache.set(
|
|
1142
|
+
node,
|
|
1143
|
+
result === undefined ? RETURN_TYPE_NOT_COMPUTED : result
|
|
1144
|
+
);
|
|
1145
|
+
return result;
|
|
1146
|
+
};
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1090
1149
|
const safeTypeToString = (type, context) => {
|
|
1091
1150
|
try {
|
|
1092
1151
|
return normalizeTypeString(
|
|
@@ -1218,7 +1277,7 @@ function createTsc(srcFiles, src) {
|
|
|
1218
1277
|
return collectedTypes;
|
|
1219
1278
|
};
|
|
1220
1279
|
|
|
1221
|
-
const
|
|
1280
|
+
const inferAsyncReturnTypeFromBodyImpl = (node) => {
|
|
1222
1281
|
if (!node.body) {
|
|
1223
1282
|
return undefined;
|
|
1224
1283
|
}
|
|
@@ -1240,6 +1299,9 @@ function createTsc(srcFiles, src) {
|
|
|
1240
1299
|
? unionType
|
|
1241
1300
|
: `Promise<${unionType}>`;
|
|
1242
1301
|
};
|
|
1302
|
+
const inferAsyncReturnTypeFromBody = memoizeByNode(
|
|
1303
|
+
inferAsyncReturnTypeFromBodyImpl
|
|
1304
|
+
);
|
|
1243
1305
|
|
|
1244
1306
|
const buildFunctionSignatureType = (node, returnTypeStr) => {
|
|
1245
1307
|
if (!node.parameters) {
|
|
@@ -1295,7 +1357,7 @@ function createTsc(srcFiles, src) {
|
|
|
1295
1357
|
return undefined;
|
|
1296
1358
|
};
|
|
1297
1359
|
|
|
1298
|
-
const
|
|
1360
|
+
const inferFunctionDeclarationReturnTypeImpl = (declaration) => {
|
|
1299
1361
|
const signature = typeChecker.getSignatureFromDeclaration(declaration);
|
|
1300
1362
|
if (!signature) {
|
|
1301
1363
|
return undefined;
|
|
@@ -1317,8 +1379,11 @@ function createTsc(srcFiles, src) {
|
|
|
1317
1379
|
}
|
|
1318
1380
|
return inferredType;
|
|
1319
1381
|
};
|
|
1382
|
+
const inferFunctionDeclarationReturnType = memoizeByNode(
|
|
1383
|
+
inferFunctionDeclarationReturnTypeImpl
|
|
1384
|
+
);
|
|
1320
1385
|
|
|
1321
|
-
const
|
|
1386
|
+
const inferAsyncReturnTypeFromSyntaxBodyImpl = (node) => {
|
|
1322
1387
|
if (!node?.body) {
|
|
1323
1388
|
return undefined;
|
|
1324
1389
|
}
|
|
@@ -1361,6 +1426,9 @@ function createTsc(srcFiles, src) {
|
|
|
1361
1426
|
? unionType
|
|
1362
1427
|
: `Promise<${unionType}>`;
|
|
1363
1428
|
};
|
|
1429
|
+
const inferAsyncReturnTypeFromSyntaxBody = memoizeByNode(
|
|
1430
|
+
inferAsyncReturnTypeFromSyntaxBodyImpl
|
|
1431
|
+
);
|
|
1364
1432
|
|
|
1365
1433
|
const addType = (node, currentSeenTypes = seenTypes) => {
|
|
1366
1434
|
// STRUCTURAL/CONTAINER NODES
|
|
@@ -1761,64 +1829,209 @@ function createTsc(srcFiles, src) {
|
|
|
1761
1829
|
}
|
|
1762
1830
|
}
|
|
1763
1831
|
|
|
1832
|
+
/**
|
|
1833
|
+
* Expand the set of output files to include the source files that tsconfig
|
|
1834
|
+
* pulls in (that live under the source root), mirroring the program root names.
|
|
1835
|
+
* Computed from the parsed tsconfig alone so no TypeScript program has to be
|
|
1836
|
+
* built on the main thread.
|
|
1837
|
+
*/
|
|
1838
|
+
const expandSrcFilesWithRootNames = (srcFiles, rootNames, src) => {
|
|
1839
|
+
if (!rootNames) {
|
|
1840
|
+
return srcFiles;
|
|
1841
|
+
}
|
|
1842
|
+
const srcRoot = resolve(src);
|
|
1843
|
+
const srcFileByResolvedPath = new Map(
|
|
1844
|
+
srcFiles.map((file) => [resolve(file), file])
|
|
1845
|
+
);
|
|
1846
|
+
for (const file of rootNames) {
|
|
1847
|
+
const resolvedFile = resolve(file);
|
|
1848
|
+
if (
|
|
1849
|
+
resolvedFile.startsWith(srcRoot) &&
|
|
1850
|
+
/\.(?:js|jsx|cjs|mjs|ts|tsx|mts|cts)$/.test(file) &&
|
|
1851
|
+
!isExcludedTestFile(file) &&
|
|
1852
|
+
!srcFileByResolvedPath.has(resolvedFile)
|
|
1853
|
+
) {
|
|
1854
|
+
srcFileByResolvedPath.set(
|
|
1855
|
+
resolvedFile,
|
|
1856
|
+
join(src, relative(srcRoot, resolvedFile))
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return [...srcFileByResolvedPath.values()].sort();
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1863
|
+
const runGc = () => {
|
|
1864
|
+
if (typeof globalThis.gc === "function") {
|
|
1865
|
+
try {
|
|
1866
|
+
globalThis.gc();
|
|
1867
|
+
} catch (e) {
|
|
1868
|
+
// ignore
|
|
1869
|
+
}
|
|
1870
|
+
} else if (typeof Bun !== "undefined" && typeof Bun.gc === "function") {
|
|
1871
|
+
try {
|
|
1872
|
+
Bun.gc(true);
|
|
1873
|
+
} catch (e) {
|
|
1874
|
+
// ignore
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Process a list of files (AST + optional type generation) on the current
|
|
1881
|
+
* thread, in memory-bounded chunks. `ts` is the shared TypeScript program
|
|
1882
|
+
* instance (or undefined when type generation is disabled).
|
|
1883
|
+
*/
|
|
1884
|
+
const processFilesInline = async (srcFiles, options, ts) => {
|
|
1885
|
+
const CONCURRENCY_LIMIT = Math.max(
|
|
1886
|
+
1,
|
|
1887
|
+
Number.parseInt(process.env.ASTGEN_CONCURRENCY || "10", 10) || 10
|
|
1888
|
+
);
|
|
1889
|
+
for (let i = 0; i < srcFiles.length; i += CONCURRENCY_LIMIT) {
|
|
1890
|
+
const chunk = srcFiles.slice(i, i + CONCURRENCY_LIMIT);
|
|
1891
|
+
await Promise.all(chunk.map((file) => processFile(file, options, ts)));
|
|
1892
|
+
runGc();
|
|
1893
|
+
}
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Decide how many worker threads to use for the type-generation phase.
|
|
1898
|
+
* The TypeScript checker is single-threaded and CPU-bound, so real speedups
|
|
1899
|
+
* only come from running independent programs on separate threads. Each worker
|
|
1900
|
+
* builds its own full program (needed for cross-file type resolution).
|
|
1901
|
+
*
|
|
1902
|
+
* IMPORTANT: parallelism is OPT-IN. When files are sharded across workers,
|
|
1903
|
+
* TypeScript's per-program type-id assignment order changes, which reorders the
|
|
1904
|
+
* members of a small number of inferred union types (e.g. `A | B` -> `B | A`;
|
|
1905
|
+
* semantically identical, textually different). To keep the default output
|
|
1906
|
+
* byte-identical for downstream consumers, workers are only used when
|
|
1907
|
+
* ASTGEN_TYPE_WORKERS is set explicitly. Set it to the desired worker count
|
|
1908
|
+
* (e.g. number of cores) to trade that cosmetic reordering for speed; "auto"
|
|
1909
|
+
* derives the count from the available CPUs. Unset or 1 => single-threaded.
|
|
1910
|
+
*/
|
|
1911
|
+
const resolveTypeWorkerCount = (fileCount) => {
|
|
1912
|
+
const envValue = process.env.ASTGEN_TYPE_WORKERS;
|
|
1913
|
+
if (envValue === undefined || envValue === "") {
|
|
1914
|
+
return 1;
|
|
1915
|
+
}
|
|
1916
|
+
if (envValue.toLowerCase() === "auto") {
|
|
1917
|
+
let cores = 1;
|
|
1918
|
+
try {
|
|
1919
|
+
cores =
|
|
1920
|
+
typeof availableParallelism === "function"
|
|
1921
|
+
? availableParallelism()
|
|
1922
|
+
: cpus().length;
|
|
1923
|
+
} catch (e) {
|
|
1924
|
+
cores = 1;
|
|
1925
|
+
}
|
|
1926
|
+
const autoCount = Math.max(cores - 1, 1);
|
|
1927
|
+
return Math.min(autoCount, Math.max(1, fileCount));
|
|
1928
|
+
}
|
|
1929
|
+
const requested = Number.parseInt(envValue, 10);
|
|
1930
|
+
if (!Number.isFinite(requested) || requested < 1) {
|
|
1931
|
+
return 1;
|
|
1932
|
+
}
|
|
1933
|
+
return Math.min(requested, Math.max(1, fileCount));
|
|
1934
|
+
};
|
|
1935
|
+
|
|
1936
|
+
/**
|
|
1937
|
+
* Run the type-generation phase across worker threads. Files are sharded
|
|
1938
|
+
* round-robin so heavy files spread across workers. Each worker builds its own
|
|
1939
|
+
* program over `projectFiles`; the per-file AST and type set are identical to
|
|
1940
|
+
* the single-threaded path, except that a small number of inferred union types
|
|
1941
|
+
* may have their members printed in a different order (see resolveTypeWorkerCount).
|
|
1942
|
+
* Returns true only if every worker completed cleanly; on any failure the
|
|
1943
|
+
* caller falls back to inline processing (writes are idempotent, so
|
|
1944
|
+
* re-processing is safe).
|
|
1945
|
+
*/
|
|
1946
|
+
const runTypeGenerationInWorkers = (
|
|
1947
|
+
srcFiles,
|
|
1948
|
+
projectFiles,
|
|
1949
|
+
options,
|
|
1950
|
+
workerCount
|
|
1951
|
+
) => {
|
|
1952
|
+
const shards = Array.from({ length: workerCount }, () => []);
|
|
1953
|
+
srcFiles.forEach((file, index) => shards[index % workerCount].push(file));
|
|
1954
|
+
const workerEntry = fileURLToPath(import.meta.url);
|
|
1955
|
+
return Promise.all(
|
|
1956
|
+
shards.map((shard, index) => {
|
|
1957
|
+
if (shard.length === 0) {
|
|
1958
|
+
return Promise.resolve(true);
|
|
1959
|
+
}
|
|
1960
|
+
return new Promise((resolvePromise) => {
|
|
1961
|
+
let settled = false;
|
|
1962
|
+
const settle = (value) => {
|
|
1963
|
+
if (!settled) {
|
|
1964
|
+
settled = true;
|
|
1965
|
+
resolvePromise(value);
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
try {
|
|
1969
|
+
const worker = new Worker(workerEntry, {
|
|
1970
|
+
workerData: {
|
|
1971
|
+
kind: "astgen-typegen",
|
|
1972
|
+
shard,
|
|
1973
|
+
projectFiles,
|
|
1974
|
+
options,
|
|
1975
|
+
index
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
worker.on("error", (err) => {
|
|
1979
|
+
console.error("astgen type worker failed:", err?.message || err);
|
|
1980
|
+
settle(false);
|
|
1981
|
+
});
|
|
1982
|
+
worker.on("exit", (code) => settle(code === 0));
|
|
1983
|
+
} catch (err) {
|
|
1984
|
+
console.error("Unable to start astgen type worker:", err?.message);
|
|
1985
|
+
settle(false);
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
})
|
|
1989
|
+
).then((results) => results.every(Boolean));
|
|
1990
|
+
};
|
|
1991
|
+
|
|
1764
1992
|
/**
|
|
1765
1993
|
* Generate AST for JavaScript or TypeScript
|
|
1766
1994
|
*/
|
|
1767
1995
|
const createJSAst = async (options) => {
|
|
1768
1996
|
try {
|
|
1769
|
-
const
|
|
1770
|
-
let srcFiles =
|
|
1771
|
-
|
|
1772
|
-
if (options.tsTypes) {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
: srcFiles;
|
|
1776
|
-
ts = createTsc(projectFiles, options.src);
|
|
1777
|
-
if (ts?.rootNames) {
|
|
1778
|
-
const srcRoot = resolve(options.src);
|
|
1779
|
-
const srcFileByResolvedPath = new Map(
|
|
1780
|
-
srcFiles.map((file) => [resolve(file), file])
|
|
1781
|
-
);
|
|
1782
|
-
for (const file of ts.rootNames) {
|
|
1783
|
-
const resolvedFile = resolve(file);
|
|
1784
|
-
if (
|
|
1785
|
-
resolvedFile.startsWith(srcRoot) &&
|
|
1786
|
-
/\.(?:js|jsx|cjs|mjs|ts|tsx|mts|cts)$/.test(file) &&
|
|
1787
|
-
!srcFileByResolvedPath.has(resolvedFile)
|
|
1788
|
-
) {
|
|
1789
|
-
srcFileByResolvedPath.set(
|
|
1790
|
-
resolvedFile,
|
|
1791
|
-
join(options.src, relative(srcRoot, resolvedFile))
|
|
1792
|
-
);
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
srcFiles = [...srcFileByResolvedPath.values()].sort();
|
|
1796
|
-
}
|
|
1997
|
+
const discovered = await getAllSrcJSAndTSFiles(options.src);
|
|
1998
|
+
let srcFiles = [...discovered].sort();
|
|
1999
|
+
|
|
2000
|
+
if (!options.tsTypes) {
|
|
2001
|
+
await processFilesInline(srcFiles, options, undefined);
|
|
2002
|
+
return;
|
|
1797
2003
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2004
|
+
|
|
2005
|
+
const projectFiles = !shouldIncludeNodeModulesBundles
|
|
2006
|
+
? srcFiles.filter((file) => !file.includes("node_modules"))
|
|
2007
|
+
: srcFiles;
|
|
2008
|
+
// Compute the program root names from the parsed tsconfig without building
|
|
2009
|
+
// a program on the main thread, then expand the output file set to match.
|
|
2010
|
+
const tscConfig = createTscProgramConfig(projectFiles, options.src);
|
|
2011
|
+
srcFiles = expandSrcFilesWithRootNames(
|
|
2012
|
+
srcFiles,
|
|
2013
|
+
tscConfig?.rootNames,
|
|
2014
|
+
options.src
|
|
1801
2015
|
);
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1814
|
-
} else if (typeof Bun !== "undefined" && typeof Bun.gc === "function") {
|
|
1815
|
-
try {
|
|
1816
|
-
Bun.gc(true);
|
|
1817
|
-
} catch (e) {
|
|
1818
|
-
// ignore
|
|
1819
|
-
}
|
|
2016
|
+
|
|
2017
|
+
const workerCount = resolveTypeWorkerCount(srcFiles.length);
|
|
2018
|
+
if (workerCount > 1) {
|
|
2019
|
+
const ranInParallel = await runTypeGenerationInWorkers(
|
|
2020
|
+
srcFiles,
|
|
2021
|
+
projectFiles,
|
|
2022
|
+
options,
|
|
2023
|
+
workerCount
|
|
2024
|
+
);
|
|
2025
|
+
if (ranInParallel) {
|
|
2026
|
+
return;
|
|
1820
2027
|
}
|
|
2028
|
+
console.error(
|
|
2029
|
+
"Falling back to single-threaded type generation after worker failure."
|
|
2030
|
+
);
|
|
1821
2031
|
}
|
|
2032
|
+
|
|
2033
|
+
const ts = createTsc(projectFiles, options.src);
|
|
2034
|
+
await processFilesInline(srcFiles, options, ts);
|
|
1822
2035
|
} catch (err) {
|
|
1823
2036
|
console.error(err);
|
|
1824
2037
|
}
|
|
@@ -1861,6 +2074,12 @@ const createVueAst = async (options) => {
|
|
|
1861
2074
|
const getCircularReplacer = () => {
|
|
1862
2075
|
const seen = new WeakSet();
|
|
1863
2076
|
return (key, value) => {
|
|
2077
|
+
// Babel 8 emits BigIntLiteral/`extra.value` as a native bigint, which
|
|
2078
|
+
// JSON.stringify cannot serialize. Emit it as a string, which also matches
|
|
2079
|
+
// the Babel 7 shape (BigIntLiteral.value was already a string there).
|
|
2080
|
+
if (typeof value === "bigint") {
|
|
2081
|
+
return value.toString();
|
|
2082
|
+
}
|
|
1864
2083
|
if (typeof value === "object" && value !== null) {
|
|
1865
2084
|
if (seen.has(value)) {
|
|
1866
2085
|
return;
|
|
@@ -1969,4 +2188,25 @@ async function main(argvs) {
|
|
|
1969
2188
|
}
|
|
1970
2189
|
}
|
|
1971
2190
|
|
|
1972
|
-
|
|
2191
|
+
/**
|
|
2192
|
+
* Type-generation worker entry point. Runs in a worker thread spawned by
|
|
2193
|
+
* runTypeGenerationInWorkers: builds its own TypeScript program over the full
|
|
2194
|
+
* project file set and processes only its assigned shard, so cross-file type
|
|
2195
|
+
* resolution is identical to the single-threaded path.
|
|
2196
|
+
*/
|
|
2197
|
+
const runTypeGenWorker = async ({ shard, projectFiles, options }) => {
|
|
2198
|
+
try {
|
|
2199
|
+
const ts = createTsc(projectFiles, options.src);
|
|
2200
|
+
await processFilesInline(shard, options, ts);
|
|
2201
|
+
parentPort?.postMessage({ done: true });
|
|
2202
|
+
} catch (err) {
|
|
2203
|
+
console.error(err);
|
|
2204
|
+
process.exit(1);
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2208
|
+
if (isMainThread) {
|
|
2209
|
+
main(process.argv);
|
|
2210
|
+
} else if (workerData?.kind === "astgen-typegen") {
|
|
2211
|
+
runTypeGenWorker(workerData);
|
|
2212
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appthreat/atom-parsetools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Parsing tools that complement the @appthreat/atom project.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"pretty": "prettier --write *.js --trailing-comma=none",
|
|
9
|
-
"test": "node test-fixtures/astgen-type-regression.js && node test-fixtures/astgen-json-regression.js && node test-fixtures/astgen-vue-regression.js && node test-fixtures/evaluate-astgen.js",
|
|
9
|
+
"test": "node test-fixtures/astgen-type-regression.js && node test-fixtures/astgen-json-regression.js && node test-fixtures/astgen-vue-regression.js && node test-fixtures/astgen-shape-snapshot.js && node test-fixtures/evaluate-astgen.js",
|
|
10
10
|
"test:evaluate": "node test-fixtures/evaluate-astgen.js",
|
|
11
|
+
"test:ruby": "node test-fixtures/rbastgen-regression.js",
|
|
12
|
+
"test:shape": "node test-fixtures/astgen-shape-snapshot.js",
|
|
13
|
+
"test:shape:update": "UPDATE_SHAPE_SNAPSHOT=1 node test-fixtures/astgen-shape-snapshot.js",
|
|
11
14
|
"test:json": "node test-fixtures/astgen-json-regression.js",
|
|
12
15
|
"test:fixtures": "node test-fixtures/test-suite.js",
|
|
13
16
|
"test:vue": "node test-fixtures/astgen-vue-regression.js"
|
|
14
17
|
},
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"@appthreat/atom-common": "^1.1.0",
|
|
17
|
-
"@babel/parser": "^
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
+
"@babel/parser": "^8.0.4",
|
|
21
|
+
"@typescript/typescript6": "^6.0.2",
|
|
22
|
+
"hermes-parser": "^0.37.0"
|
|
20
23
|
},
|
|
21
24
|
"bin": {
|
|
22
25
|
"astgen": "astgen.js",
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
"scalasem": "scalasem.js"
|
|
26
29
|
},
|
|
27
30
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
31
|
+
"node": ">=22.0.0"
|
|
29
32
|
},
|
|
30
33
|
"repository": {
|
|
31
34
|
"type": "git",
|