Kevin Newton
804b2a3787
[ruby/prism] Rebase against main
...
813e20d449
2024-02-24 03:39:29 +00:00
Gopal Patel
aa8841405b
[ruby/prism] Less code modifications. More steep:ignore for now
...
7905bdbf83
2024-02-24 03:39:28 +00:00
Gopal Patel
66565e36ea
[ruby/prism] Add documentation for Location#source!
...
467e1cc2c4
2024-02-24 03:39:26 +00:00
Gopal Patel
8fa1843523
[ruby/prism] Relax Location#source to be optional
...
9f00fe7510
2024-02-24 03:39:26 +00:00
Gopal Patel
935d4fab62
[ruby/prism] Remove Ripper from public RBS, type-assert remaining issues
...
5fda7a0760
2024-02-24 03:39:23 +00:00
Gopal Patel
7556fd937c
[ruby/prism] Split private types
...
0209d093ec
2024-02-24 03:39:22 +00:00
Kevin Newton
ae3e82a525
[ruby/prism] Fix up comment state
...
c6561becf0
2024-02-19 19:50:46 +00:00
Kevin Newton
792804e32f
[ruby/prism] Split up comments between leading and trailing
...
Also make them lazy to allocate the array, and also expose ParseResult#encoding.
08ec7683ae
2024-02-18 20:57:13 +00:00
Benoit Daloze
1b9b960963
[ruby/prism] Make location methods thread-safe
...
* Before it could result in NoMethodError if multiple threads were
calling location methods: https://gist.github.com/eregon/b78b7f266d7ee0a278a389cfd1782232
ff762dcccd
2024-02-15 23:04:38 +00:00
Kevin Newton
14a7277da1
[ruby/prism] Speed up creating Ruby AST
...
When creating the Ruby AST, we were previously allocating Location
objects for every node and every inner location. Instead, this
commit changes it to pack both the start offset and length into a
single u64 and pass that into the nodes. Then, when the locations
are requested via a reader method, we lazily allocate the Location
objects.
de203dca83
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-02-15 20:39:50 +00:00
Benoit Daloze
c2d8d6eba6
Initialize the Prism::Source directly with all 3 fields for the C extension
...
* Faster that way:
$ ruby -Ilib -rprism -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("parse") { Prism.parse("1 + 2") } }'
195.722k (± 0.5%) i/s
rb_iv_set():
179.609k (± 0.5%) i/s
rb_funcall():
190.030k (± 0.3%) i/s
before this PR:
183.319k (± 0.4%) i/s
2024-02-14 15:48:33 +00:00
Benoit Daloze
1b2708b123
[ruby/prism] Remove attr_writer's for ParseResult#start_line and #offsets
...
* As the user should not set these.
* Use #instance_variable_set/rb_iv_set() instead internally.
cace09fb8c
2024-02-14 15:48:33 +00:00
Benoit Daloze
f0f6ffef42
[ruby/prism] Serialize the newline_list to avoid recomputing it again later
...
* Fixes https://github.com/ruby/prism/issues/2380
4eaaa90114
2024-02-14 15:48:32 +00:00
Kevin Newton
b1964a9204
[ruby/prism] Add code unit APIs to location
...
LSPs need this because the protocol dictates that you return code
units for offsets. None of our existing APIs provided that
information, and since we hid the source it's not nearly as useful
for them. Now they can pass an encoding directly to:
* Location#start_code_units_offset
* Location#end_code_units_offset
* Location#start_code_units_column
* Location#end_code_units_column
4757a2cc06
Co-Authored-By: Vinicius Stock <vinicius.stock@shopify.com>
2024-02-13 20:10:25 +00:00
Kevin Newton
aad3c36bdf
[ruby/prism] Support for Ruby 2.7
...
1a15b70a8e
2024-02-07 16:54:34 +00:00
Kevin Newton
e337c9478a
[ruby/prism] Error follow-up
...
Split up the diagnostic levels so that error and warning levels
aren't mixed. Also fix up deconstruct_keys implementation.
bd3eeb308d
Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-01-27 18:46:16 +00:00
Benoit Daloze
c2e2d2398b
[ruby/prism] Call #inspect on diagnostic levels
...
* So it's clear it is a Symbol.
Before:
... @level=warning_verbose_true>
After:
... @level=:warning_verbose_true>
84503643b9
2024-01-27 18:41:07 +00:00
Benoit Daloze
de135bc247
[ruby/prism] Add level to warnings and errors to categorize them
...
* Fixes https://github.com/ruby/prism/issues/2082
7a74576357
2024-01-26 21:34:34 +00:00
Kevin Newton
80da9b1547
[ruby/prism] Clarify __END__ comment
...
3e36d5eabc
2024-01-09 19:02:26 +00:00
Kevin Newton
c798943a4a
[ruby/prism] Move DATA parsing into its own parse result field
...
42b60b6e95
2023-11-28 13:25:48 +00:00
Kevin Newton
f2ed7eaba0
[ruby/prism] Add character APIs for locations
...
(https://github.com/ruby/prism/pull/1809 )
d493ccd093
2023-11-20 16:07:06 +00:00
Kevin Newton
4b5f516f2e
[ruby/prism] Split comment
...
We were previously holding a type field on Comment to tell what
kind of comment it was. Instead, let's just use actual classes for
this.
e76830ca6e
2023-11-03 14:35:08 +00:00
Kevin Newton
8587d9a8bf
[ruby/prism] Wire up options through the Java parser
...
13fa262669
2023-11-03 10:13:50 -04:00
Kevin Newton
d7d3243364
[ruby/prism] Properly support the start line option
...
33cc75a4b7
2023-11-03 10:13:50 -04:00
Kevin Newton
79034fbd50
[ruby/prism] More Ruby docs
...
ca9a660f52
2023-11-01 13:10:29 -04:00
Kevin Newton
953138698e
[ruby/prism] Docs for node.rb and parse_result.rb
...
085da4feb9
2023-11-01 13:10:29 -04:00
Kevin Newton
d1bb858d47
[ruby/prism] Match existing Ruby prettyprint
...
6d8358c083
2023-10-26 15:19:43 -04:00
Kevin Newton
5523a23469
[ruby/prism] Attach magic comments to the parse result
...
c7ef25a79a
2023-10-16 15:40:19 -07:00
gazayas
488c0ed051
[ruby/prism] Remove trailing parenthesis in Location#pretty_print
...
8eaa199a28
2023-10-04 17:00:09 +00:00
Kevin Newton
4f73a7c2f7
Sync to prism rename commits
2023-09-27 13:57:38 -04:00
Kevin Newton
8ab56869a6
Rename YARP filepaths to prism filepaths
2023-09-27 13:57:38 -04:00