diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89f7c4836..f5e70e597 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,8 +45,14 @@ jobs: - name: Render Templates run: bundle exec rake templates + # TODO: Drop `BUNDLE_GEMFILE` and the separate cop test run once https://github.com/rubocop/rubocop-ast/pull/420 is released. - name: RuboCop - run: bundle exec rubocop + env: + BUNDLE_GEMFILE: gemfiles/rubocop.gemfile + run: |- + bundle install + bundle exec rubocop + bundle exec ruby test/rubocop/includes_assertion_test.rb - name: Yerba run: bundle exec yerba check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d334abb63..e749f1110 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ If you encounter any issues when following along with this file please don't hes - [**Clang 21**](https://clang.llvm.org): The compiler used to build this project. - [**Clang Format 21**](https://clang.llvm.org/docs/ClangFormat.html): For formatting the project. - [**Clang Tidy 21**](https://clang.llvm.org/extra/clang-tidy/): For linting the project. -- [**Prism Ruby Parser v1.9.0**](https://github.com/ruby/prism/releases/tag/v1.9.0): We use Prism for Parsing the Ruby Source Code in the HTML+ERB files. +- [**Prism Ruby Parser v2.0.0**](https://github.com/ruby/prism/releases/tag/v2.0.0): We use Prism for Parsing the Ruby Source Code in the HTML+ERB files. - [**Ruby**](https://www.ruby-lang.org/en/): We need Ruby as a dependency for `bundler`. - [**Bundler**](https://bundler.io): We are using `bundler` to build [`prism`](https://github.com/ruby/prism) from source so we can build `herb` against it. - [**Emscripten 5**](https://emscripten.org): For the WebAssembly build of `libherb` so it can be used in the browser using the [`@herb-tools/browser`](https://github.com/marcoroth/herb/blob/main/javascript/packages/browser) package. diff --git a/Gemfile b/Gemfile index 19f515205..95fe6de3f 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" gemspec -gem "prism", github: "ruby/prism", tag: "v1.9.0" +gem "prism", github: "ruby/prism", tag: "v2.0.0" gem "actionview", "~> 8.1", require: "action_view" gem "benchmark" @@ -20,6 +20,7 @@ gem "maxitest", "~> 6.0" gem "minitest-difftastic", "~> 0.2" gem "nokogiri", "~> 1.19" gem "oxc", "~> 0.149.0" +gem "parallel", "~> 1.27" gem "rake", "~> 13.4" gem "rake-compiler", "~> 1.3" gem "rake-compiler-dock", "~> 1.12" @@ -28,8 +29,7 @@ gem "rbs-inline", "~> 0.14" gem "reactionview", github: "marcoroth/reactionview", branch: "herb-v0.11" gem "reline", "~> 0.7" gem "rolldown", "~> 1.2" -gem "rubocop", "~> 1.72" -gem "rubocop-performance", "~> 1.26.0" +# TODO: Move `rubocop` and `rubocop-performance` back here from `gemfiles/rubocop.gemfile` once https://github.com/rubocop/rubocop-ast/pull/420 is released. gem "sorbet" gem "steep", "~> 2.1" gem "turbo-rails", "~> 2.0", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 0a3369fc0..c9d5d832f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,10 +11,10 @@ GIT GIT remote: https://github.com/ruby/prism.git - revision: c0e37816e97e23e92524a4070e1b99a4025bc63f - tag: v1.9.0 + revision: e2727368fd9fc2486e2acc8aa513f0cd9e7e02cf + tag: v2.0.0 specs: - prism (1.9.0) + prism (2.0.0) PATH remote: . @@ -154,7 +154,6 @@ GEM lightningcss (1.33.0-x86_64-darwin) lightningcss (1.33.0-x86_64-linux-gnu) lightningcss (1.33.0-x86_64-linux-musl) - lint_roller (1.1.0) lipgloss (0.2.2-aarch64-linux-gnu) lipgloss (0.2.2-aarch64-linux-musl) lipgloss (0.2.2-arm64-darwin) @@ -255,7 +254,6 @@ GEM erb psych (>= 4.0.0) tsort - regexp_parser (2.11.3) reline (0.7.0) io-console (~> 0.5) rolldown (1.2.8-aarch64-linux-gnu) @@ -264,25 +262,6 @@ GEM rolldown (1.2.8-x86_64-darwin) rolldown (1.2.8-x86_64-linux-gnu) rolldown (1.2.8-x86_64-linux-musl) - rubocop (1.92.0) - json (>= 2.3) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.1.0) - parallel (>= 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.11.3, < 3.0) - rubocop-ast (>= 1.49.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.49.0) - parser (>= 3.3.7.2) - prism (~> 1.7) - rubocop-performance (1.26.1) - lint_roller (~> 1.1) - rubocop (>= 1.75.0, < 2.0) - rubocop-ast (>= 1.47.1, < 2.0) - ruby-progressbar (1.13.0) securerandom (0.4.1) sorbet (0.6.13466) sorbet-static (= 0.6.13466) @@ -358,6 +337,7 @@ DEPENDENCIES minitest-difftastic (~> 0.2) nokogiri (~> 1.19) oxc (~> 0.149.0) + parallel (~> 1.27) prism! rake (~> 13.4) rake-compiler (~> 1.3) @@ -367,8 +347,6 @@ DEPENDENCIES reactionview! reline (~> 0.7) rolldown (~> 1.2) - rubocop (~> 1.72) - rubocop-performance (~> 1.26.0) sorbet steep (~> 2.1) turbo-rails (~> 2.0) diff --git a/Rakefile b/Rakefile index ab561137a..305e174f6 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,8 @@ require "rake/testtask" Rake::TestTask.new(:test) do |t| t.libs << "test" t.libs << "lib" - t.test_files = FileList["test/**/*_test.rb"] + # TODO: Drop the `test/rubocop` exclusion once https://github.com/rubocop/rubocop-ast/pull/420 is released and RuboCop is back in the main `Gemfile`. + t.test_files = FileList["test/**/*_test.rb"].exclude("test/rubocop/**/*") end Rake::TestTask.new("test:engine") do |t| @@ -25,7 +26,8 @@ end Rake::TestTask.new("test:all") do |t| t.libs << "test" t.libs << "lib" - t.test_files = FileList["test/**/*_test.rb"] + # TODO: Drop the `test/rubocop` exclusion once https://github.com/rubocop/rubocop-ast/pull/420 is released and RuboCop is back in the main `Gemfile`. + t.test_files = FileList["test/**/*_test.rb"].exclude("test/rubocop/**/*") end task "make" do diff --git a/bin/integration b/bin/integration index fab5b3c74..c9f0d15af 100755 --- a/bin/integration +++ b/bin/integration @@ -19,7 +19,9 @@ bin/leaks_parse examples/test.html.erb bin/lint bin/tidy -bundle exec rubocop +# TODO: Back to `bundle exec rubocop` once https://github.com/rubocop/rubocop-ast/pull/420 is released. +BUNDLE_GEMFILE=gemfiles/rubocop.gemfile bundle exec rubocop +BUNDLE_GEMFILE=gemfiles/rubocop.gemfile bundle exec ruby test/rubocop/includes_assertion_test.rb echo "" echo "Integration successful!" diff --git a/ext/herb/extconf.rb b/ext/herb/extconf.rb index 8dbc37131..dfe873726 100644 --- a/ext/herb/extconf.rb +++ b/ext/herb/extconf.rb @@ -19,7 +19,7 @@ Add it to your Gemfile before the herb git reference: - gem "prism", github: "ruby/prism", tag: "v1.9.0" + gem "prism", github: "ruby/prism", tag: "v2.0.0" gem "herb", github: "...", branch: "..." Then run `bundle install` again. @@ -55,13 +55,10 @@ $VPATH << "$(srcdir)/../../src/prism" $VPATH << "$(srcdir)/../../src/lib" $VPATH << "$(srcdir)/../../src/util" -$VPATH << prism_src_path -$VPATH << "#{prism_src_path}/util" $INCFLAGS << " -I#{prism_include_path}" $INCFLAGS << " -I#{include_path}" $INCFLAGS << " -I#{prism_src_path}" -$INCFLAGS << " -I#{prism_src_path}/util" $CFLAGS << " -fvisibility=hidden" $CFLAGS << " -DHERB_EXCLUDE_PRETTYPRINT" @@ -71,32 +68,11 @@ herb_src_files = Dir.glob("#{$srcdir}/../../src/**/*.c").map { |file| file.delete_prefix("../../../../ext/herb/") }.sort -prism_main_files = [ - "diagnostic.c", - "encoding.c", - "node.c", - "options.c", - "pack.c", - "prettyprint.c", - "prism.c", - "regexp.c", - "serialize.c", - "static_literals.c", - "token_type.c" -] - -prism_util_files = [ - "pm_buffer.c", - "pm_char.c", - "pm_constant_pool.c", - "pm_integer.c", - "pm_list.c", - "pm_memchr.c", - "pm_newline_list.c", - "pm_string.c", - "pm_strncasecmp.c", - "pm_strpbrk.c" -] +prism_src_files = Dir.glob("#{prism_src_path}/*.c").map do |file| + wrapper = "prism_#{File.basename(file)}" + File.write(wrapper, "#include \"#{file}\"\n") + wrapper +end core_src_files = [ "extension.c", @@ -106,7 +82,7 @@ "parser_options_helpers.c" ] -$srcs = core_src_files + herb_src_files + prism_main_files + prism_util_files +$srcs = core_src_files + herb_src_files + prism_src_files puts "Sources to be compiled: #{$srcs.inspect}" diff --git a/gemfiles/rubocop.gemfile b/gemfiles/rubocop.gemfile new file mode 100644 index 000000000..033c00369 --- /dev/null +++ b/gemfiles/rubocop.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# TODO: Move these gems back into the main `Gemfile` and delete this file once https://github.com/rubocop/rubocop-ast/pull/420 is released. + +gem "maxitest", "~> 6.0" +gem "rubocop", "~> 1.72" +gem "rubocop-performance", "~> 1.26.0" diff --git a/gemfiles/rubocop.gemfile.lock b/gemfiles/rubocop.gemfile.lock new file mode 100644 index 000000000..9a9ca9022 --- /dev/null +++ b/gemfiles/rubocop.gemfile.lock @@ -0,0 +1,78 @@ +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.3) + json (2.21.2) + language_server-protocol (3.17.0.6) + lint_roller (1.1.0) + maxitest (6.2.0) + minitest (>= 5.20.0, < 5.28.0) + minitest (5.27.0) + parallel (1.28.0) + parser (3.3.13.0) + ast (~> 2.4.1) + racc + prism (1.9.0) + racc (1.8.1) + rainbow (3.1.1) + regexp_parser (2.13.1) + rubocop (1.92.0) + json (>= 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.11.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.0) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + ruby-progressbar (1.13.0) + unicode-display_width (3.3.0) + unicode-emoji (~> 4.3) + unicode-emoji (4.3.0) + +PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm64-darwin + ruby + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + maxitest (~> 6.0) + rubocop (~> 1.72) + rubocop-performance (~> 1.26.0) + +CHECKSUMS + ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 + bundler (4.0.19) sha256=b48056e4c77fb3853cc47775b5447ede44aaa4f53c32f168014ab4fe86587d47 + json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a + language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0 + lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 + maxitest (6.2.0) sha256=bb66472dd3f6565e4db5246826a05ce9096958d9e26ba9a8fdcae20288be1f4f + minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5 + parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970 + parser (3.3.13.0) sha256=e02f9b63c2fe05b0c68f692ba4df89b3cb113b663964f75d988fbebfd6c3deca + prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 + racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f + rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a + regexp_parser (2.13.1) sha256=5aedb6b7c35688f51e86eef17a15374dfd287c83f4ca644b2c5f3ec50a33b44b + rubocop (1.92.0) sha256=2af68041fb2e70bd9321d0479b49fad07f8008a3d0758c83347b4917128c56e0 + rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd + rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 + ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 + unicode-display_width (3.3.0) sha256=4b7aa66a4b11db50f6f7e98411215cd0dd10eaecb665d36eec5bcacb3fa0b613 + unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce + +BUNDLED WITH + 4.0.19 diff --git a/java/herb_jni.c b/java/herb_jni.c index a56b3606f..c89a5a3b6 100644 --- a/java/herb_jni.c +++ b/java/herb_jni.c @@ -139,17 +139,18 @@ Java_org_herb_Herb_parseRuby(JNIEnv* env, jclass clazz, jstring source) { return NULL; } - pm_buffer_t buffer = { 0 }; - pm_serialize(&parse_result->parser, parse_result->root, &buffer); + pm_buffer_t* buffer = pm_buffer_new(); + pm_serialize(parse_result->parser, parse_result->root, buffer); jbyteArray result = NULL; + size_t length = pm_buffer_length(buffer); - if (buffer.length > 0) { - result = (*env)->NewByteArray(env, (jsize) buffer.length); - (*env)->SetByteArrayRegion(env, result, 0, (jsize) buffer.length, (const jbyte*) buffer.value); + if (length > 0) { + result = (*env)->NewByteArray(env, (jsize) length); + (*env)->SetByteArrayRegion(env, result, 0, (jsize) length, (const jbyte*) pm_buffer_value(buffer)); } - pm_buffer_free(&buffer); + pm_buffer_free(buffer); herb_free_ruby_parse_result(parse_result); (*env)->ReleaseStringUTFChars(env, source, src); diff --git a/javascript/packages/browser/package.json b/javascript/packages/browser/package.json index fa0e63caa..76c322334 100644 --- a/javascript/packages/browser/package.json +++ b/javascript/packages/browser/package.json @@ -36,7 +36,7 @@ }, "dependencies": { "@herb-tools/core": "0.11.1", - "@ruby/prism": "^1.9.0" + "@ruby/prism": "^2.0.0" }, "files": [ "package.json", diff --git a/javascript/packages/browser/test/browser.test.ts b/javascript/packages/browser/test/browser.test.ts index 760820a7b..9b75122ab 100644 --- a/javascript/packages/browser/test/browser.test.ts +++ b/javascript/packages/browser/test/browser.test.ts @@ -17,7 +17,7 @@ describe("@herb-tools/browser", () => { test("version() returns a string", async () => { const version = Herb.version expect(typeof version).toBe("string") - expect(version).toBe("@herb-tools/browser@0.11.1, @herb-tools/core@0.11.1, libprism@1.9.0, libherb@0.11.1 (WebAssembly)") + expect(version).toBe("@herb-tools/browser@0.11.1, @herb-tools/core@0.11.1, libprism@2.0.0, libherb@0.11.1 (WebAssembly)") }) test("parse() can process a simple template", async () => { diff --git a/javascript/packages/core/package.json b/javascript/packages/core/package.json index 6f322800b..22732a0f8 100644 --- a/javascript/packages/core/package.json +++ b/javascript/packages/core/package.json @@ -32,7 +32,7 @@ } }, "dependencies": { - "@ruby/prism": "^1.9.0" + "@ruby/prism": "^2.0.0" }, "devDependencies": {}, "files": [ diff --git a/javascript/packages/core/test/prism-visitor.test.ts b/javascript/packages/core/test/prism-visitor.test.ts index bcfb56678..4aaaa3105 100644 --- a/javascript/packages/core/test/prism-visitor.test.ts +++ b/javascript/packages/core/test/prism-visitor.test.ts @@ -5,7 +5,7 @@ import { PrismVisitor } from "../src/prism/index.js" import type { PrismNodes, PrismParseResult } from "../src/prism/index.js" -let parse: (source: string) => PrismParseResult +let parse: (source: Uint8Array) => PrismParseResult class CollectingVisitor extends PrismVisitor { public names: string[] = [] @@ -28,7 +28,7 @@ class CollectingVisitor extends PrismVisitor { const collect = (source: string): string[] => { const visitor = new CollectingVisitor() - visitor.visit(parse(source).value) + visitor.visit(parse(new TextEncoder().encode(source)).value) return visitor.names } diff --git a/javascript/packages/formatter/package.json b/javascript/packages/formatter/package.json index 3d483c3a7..a4a1edecd 100644 --- a/javascript/packages/formatter/package.json +++ b/javascript/packages/formatter/package.json @@ -42,7 +42,7 @@ "@herb-tools/node-wasm": "0.11.1", "@herb-tools/printer": "0.11.1", "@herb-tools/rewriter": "0.11.1", - "@ruby/prism": "^1.9.0", + "@ruby/prism": "^2.0.0", "tinyglobby": "^0.2.15" }, "files": [ diff --git a/javascript/packages/linter/docs/rules/erb-strict-locals-comment-syntax.md b/javascript/packages/linter/docs/rules/erb-strict-locals-comment-syntax.md index 8b0264a4d..137b8efbf 100644 --- a/javascript/packages/linter/docs/rules/erb-strict-locals-comment-syntax.md +++ b/javascript/packages/linter/docs/rules/erb-strict-locals-comment-syntax.md @@ -162,7 +162,9 @@ Single splat argument: Note: Double-splat (`**attributes`) IS supported for optional keyword arguments. -#### Invalid Ruby syntax +#### Extra commas + +Ruby 4.1 accepts a trailing comma in a parameter list, but every earlier version rejects it. The rule flags it regardless of the Ruby version, so the declaration keeps working on any Ruby the partial is rendered with. Trailing comma: diff --git a/javascript/packages/linter/package.json b/javascript/packages/linter/package.json index 70a52291c..a8bd1c50d 100644 --- a/javascript/packages/linter/package.json +++ b/javascript/packages/linter/package.json @@ -61,7 +61,7 @@ "@herb-tools/node-wasm": "0.11.1", "@herb-tools/printer": "0.11.1", "@herb-tools/rewriter": "0.11.1", - "@ruby/prism": "^1.9.0", + "@ruby/prism": "^2.0.0", "picomatch": "^4.0.7", "postcss": "^8.5.29", "postcss-selector-parser": "^7.1.7", diff --git a/javascript/packages/linter/src/rules/erb-strict-locals-comment-syntax.ts b/javascript/packages/linter/src/rules/erb-strict-locals-comment-syntax.ts index c90c48d34..0369a44e9 100644 --- a/javascript/packages/linter/src/rules/erb-strict-locals-comment-syntax.ts +++ b/javascript/packages/linter/src/rules/erb-strict-locals-comment-syntax.ts @@ -349,6 +349,7 @@ class ERBStrictLocalsCommentSyntaxVisitor extends BaseRuleVisitor error.type === "RUBY_PARSE_ERROR", @@ -431,18 +447,6 @@ class ERBStrictLocalsCommentSyntaxVisitor extends BaseRuleVisitor 0) { - this.addOffense( - "Remove the extra comma from the strict locals parameters.", - contentLocation(node, extraCommas[0].start), - this.contextFor(node, { type: "remove-extra-commas" }), - ) - - return true - } - this.addOffense( `Invalid Ruby syntax in the strict locals declaration: ${syntaxErrors[0].error_message}.`, syntaxErrors[0].location, diff --git a/javascript/packages/node-wasm/package.json b/javascript/packages/node-wasm/package.json index 25fce75eb..c74b2abc1 100644 --- a/javascript/packages/node-wasm/package.json +++ b/javascript/packages/node-wasm/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@herb-tools/core": "0.11.1", - "@ruby/prism": "^1.9.0" + "@ruby/prism": "^2.0.0" }, "files": [ "package.json", diff --git a/javascript/packages/node-wasm/test/node-wasm.test.ts b/javascript/packages/node-wasm/test/node-wasm.test.ts index 3e154e35f..611bac36a 100644 --- a/javascript/packages/node-wasm/test/node-wasm.test.ts +++ b/javascript/packages/node-wasm/test/node-wasm.test.ts @@ -20,7 +20,7 @@ describe("@herb-tools/node-wasm", () => { test("version() returns a string", async () => { const version = Herb.version expect(typeof version).toBe("string") - expect(version).toBe("@herb-tools/node-wasm@0.11.1, @herb-tools/core@0.11.1, libprism@1.9.0, libherb@0.11.1 (WebAssembly)") + expect(version).toBe("@herb-tools/node-wasm@0.11.1, @herb-tools/core@0.11.1, libprism@2.0.0, libherb@0.11.1 (WebAssembly)") }) test("parse() can process a simple template", async () => { diff --git a/javascript/packages/node/bin/vendor.cjs b/javascript/packages/node/bin/vendor.cjs index 830c46662..ff2317f72 100644 --- a/javascript/packages/node/bin/vendor.cjs +++ b/javascript/packages/node/bin/vendor.cjs @@ -26,7 +26,6 @@ console.log(`Found Prism at: ${prismPath}`) const targetDir = path.resolve(__dirname, "../extension/prism") const targetIncludeDir = path.resolve(targetDir, "include") const targetSrcDir = path.resolve(targetDir, "src") -const targetUtilDir = path.resolve(targetSrcDir, "util") function ensureDirectoryExists(dir) { if (!fs.existsSync(dir)) { @@ -37,7 +36,6 @@ function ensureDirectoryExists(dir) { ensureDirectoryExists(targetIncludeDir) ensureDirectoryExists(targetSrcDir) -ensureDirectoryExists(targetUtilDir) ensureDirectoryExists(libherbTargetDir) function safeCopyFile(sourcePath, targetPath) { diff --git a/javascript/packages/node/binding.gyp b/javascript/packages/node/binding.gyp index d44cc288b..080c6da4f 100644 --- a/javascript/packages/node/binding.gyp +++ b/javascript/packages/node/binding.gyp @@ -84,38 +84,42 @@ "./extension/libherb/util/util.c", "./extension/libherb/visitor.c", - # Prism main source files + # Prism source files + "./extension/prism/src/arena.c", + "./extension/prism/src/buffer.c", + "./extension/prism/src/char.c", + "./extension/prism/src/comments.c", + "./extension/prism/src/constant_pool.c", "./extension/prism/src/diagnostic.c", "./extension/prism/src/encoding.c", + "./extension/prism/src/errors_format.c", + "./extension/prism/src/integer.c", + "./extension/prism/src/json.c", + "./extension/prism/src/line_offset_list.c", + "./extension/prism/src/list.c", + "./extension/prism/src/memchr.c", "./extension/prism/src/node.c", "./extension/prism/src/options.c", - "./extension/prism/src/pack.c", + "./extension/prism/src/parser.c", "./extension/prism/src/prettyprint.c", "./extension/prism/src/prism.c", "./extension/prism/src/regexp.c", "./extension/prism/src/serialize.c", + "./extension/prism/src/source.c", "./extension/prism/src/static_literals.c", - "./extension/prism/src/token_type.c", - - # Prism util source files - "./extension/prism/src/util/pm_buffer.c", - "./extension/prism/src/util/pm_char.c", - "./extension/prism/src/util/pm_constant_pool.c", - "./extension/prism/src/util/pm_integer.c", - "./extension/prism/src/util/pm_list.c", - "./extension/prism/src/util/pm_memchr.c", - "./extension/prism/src/util/pm_newline_list.c", - "./extension/prism/src/util/pm_string.c", - "./extension/prism/src/util/pm_strncasecmp.c", - "./extension/prism/src/util/pm_strpbrk.c" + "./extension/prism/src/string_query.c", + "./extension/prism/src/stringy.c", + "./extension/prism/src/strncasecmp.c", + "./extension/prism/src/strpbrk.c", + "./extension/prism/src/tokens.c", + "./extension/prism/src/xxh3.c" ], "include_dirs": [ "parser, parse_result->root, &buffer); + pm_buffer_t* buffer = pm_buffer_new(); + pm_serialize(parse_result->parser, parse_result->root, buffer); napi_value result = nullptr; - if (buffer.length > 0) { + if (pm_buffer_length(buffer) > 0) { void* data; - napi_create_buffer_copy(env, buffer.length, buffer.value, &data, &result); + napi_create_buffer_copy(env, pm_buffer_length(buffer), pm_buffer_value(buffer), &data, &result); } - pm_buffer_free(&buffer); + pm_buffer_free(buffer); herb_free_ruby_parse_result(parse_result); free(string); diff --git a/javascript/packages/node/test/node.test.ts b/javascript/packages/node/test/node.test.ts index 38028b0f7..d00981067 100644 --- a/javascript/packages/node/test/node.test.ts +++ b/javascript/packages/node/test/node.test.ts @@ -18,7 +18,7 @@ describe("@herb-tools/node", () => { test("version() returns a string", async () => { const version = Herb.version expect(typeof version).toBe("string") - expect(version).toBe("@herb-tools/node@0.11.1, @herb-tools/core@0.11.1, libprism@1.9.0, libherb@0.11.1 (Node.js C++ native extension)") + expect(version).toBe("@herb-tools/node@0.11.1, @herb-tools/core@0.11.1, libprism@2.0.0, libherb@0.11.1 (Node.js C++ native extension)") }) test("parse() can process a simple template", async () => { diff --git a/javascript/packages/rewriter/package.json b/javascript/packages/rewriter/package.json index bf3fff9da..c67ce9150 100644 --- a/javascript/packages/rewriter/package.json +++ b/javascript/packages/rewriter/package.json @@ -42,7 +42,7 @@ "@herb-tools/core": "0.11.1", "@herb-tools/printer": "0.11.1", "@herb-tools/tailwind-class-sorter": "0.11.1", - "@ruby/prism": "^1.9.0", + "@ruby/prism": "^2.0.0", "tinyglobby": "^0.2.15" }, "files": [ diff --git a/rbs_collection.lock.yaml b/rbs_collection.lock.yaml index 114aa78a5..6ce5a27bd 100644 --- a/rbs_collection.lock.yaml +++ b/rbs_collection.lock.yaml @@ -25,14 +25,6 @@ gems: revision: 82762423fc5694b82888ea89a972847cf19838c2 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems -- name: ast - version: '2.4' - source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems - name: base64 version: 0.3.0 source: @@ -137,14 +129,6 @@ gems: version: 0.1.1 source: type: rubygems -- name: lint_roller - version: '1.1' - source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems - name: lipgloss version: 0.2.2 source: @@ -189,20 +173,16 @@ gems: version: '0' source: type: stdlib +- name: oxc + version: 0.149.0 + source: + type: rubygems - name: parallel version: '1.20' source: type: git name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems -- name: parser - version: '3.2' - source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 + revision: ddaa559df3fbd84ca630e937e2eb59b3e1b62e3b remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: pp @@ -214,7 +194,7 @@ gems: source: type: stdlib - name: prism - version: 1.9.0 + version: 2.0.0 source: type: rubygems - name: pstore @@ -229,6 +209,14 @@ gems: version: '0' source: type: stdlib +- name: racc + version: '1.8' + source: + type: git + name: ruby/gem_rbs_collection + revision: ddaa559df3fbd84ca630e937e2eb59b3e1b62e3b + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems - name: rack version: '2.2' source: @@ -253,14 +241,6 @@ gems: revision: 82762423fc5694b82888ea89a972847cf19838c2 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems -- name: rainbow - version: '3.0' - source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems - name: rake version: '13.0' source: @@ -289,30 +269,10 @@ gems: version: 0.3.0 source: type: rubygems -- name: regexp_parser - version: '2.8' - source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems -- name: rubocop - version: '1.57' - source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems -- name: rubocop-ast - version: '1.46' +- name: rolldown + version: 1.2.8 source: - type: git - name: ruby/gem_rbs_collection - revision: 82762423fc5694b82888ea89a972847cf19838c2 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems + type: rubygems - name: securerandom version: '0' source: diff --git a/rust/build.rs b/rust/build.rs index af88fd9a4..ccd95a664 100644 --- a/rust/build.rs +++ b/rust/build.rs @@ -135,6 +135,9 @@ fn main() { .allowlist_function("pm_prettyprint") .allowlist_function("pm_serialize") .allowlist_function("pm_buffer_free") + .allowlist_function("pm_buffer_new") + .allowlist_function("pm_buffer_value") + .allowlist_function("pm_buffer_length") .allowlist_var("PRISM_VERSION_.*") .allowlist_var("AST_.*") .allowlist_var("ERROR_.*") @@ -143,6 +146,7 @@ fn main() { .allowlist_var("HERB_EXTRACT_.*") .derive_debug(true) .derive_default(false) + .generate_comments(false) .prepend_enum_name(false) .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())); diff --git a/rust/herb-analysis/Cargo.toml b/rust/herb-analysis/Cargo.toml index d817d5428..d93a53f38 100644 --- a/rust/herb-analysis/Cargo.toml +++ b/rust/herb-analysis/Cargo.toml @@ -25,7 +25,10 @@ cli = ["dep:colored"] colored = { version = "3", optional = true } herb = { path = ".." } herb-config = { path = "../herb-config" } -rubydex = { git = "https://github.com/Shopify/rubydex", tag = "v0.4.1" } +rubydex = { git = "https://github.com/Shopify/rubydex", tag = "v0.4.3" } +# TODO: Drop these pins once the `Gemfile` moves to Prism `v2.1.0`, since rubydex has to link the same Prism as herb. +ruby-prism = "=2.0.0" +ruby-prism-sys = "=2.0.0" [dev-dependencies] insta = "1.40" diff --git a/rust/herb-analysis/src/analysis.rs b/rust/herb-analysis/src/analysis.rs index e8f31dbc5..9fa4eb992 100644 --- a/rust/herb-analysis/src/analysis.rs +++ b/rust/herb-analysis/src/analysis.rs @@ -45,7 +45,7 @@ impl Analysis { let started = Instant::now(); for (uri, source) in sources { - indexing::index_source(&mut graph, uri, source, &LanguageId::Ruby); + indexing::index_source(&mut graph, (*uri).into(), source, &LanguageId::Ruby); } Self { @@ -303,7 +303,7 @@ impl Analysis { pub fn update_document(&mut self, uri: &str, source: &str) { self.graph.delete_document(uri); - indexing::index_source(&mut self.graph, uri, source, &LanguageId::Ruby); + indexing::index_source(&mut self.graph, uri.into(), source, &LanguageId::Ruby); } pub fn remove_document(&mut self, uri: &str) { diff --git a/rust/herb-analysis/src/lib.rs b/rust/herb-analysis/src/lib.rs index 2466e8b98..c381193d4 100644 --- a/rust/herb-analysis/src/lib.rs +++ b/rust/herb-analysis/src/lib.rs @@ -20,7 +20,7 @@ pub fn prism_link_check(erb: &str, ruby: &str) -> (usize, usize) { let erb_children = parsed.value.children.len(); let mut graph = rubydex::model::graph::Graph::new(); - rubydex::indexing::index_source(&mut graph, "file:///link_check.rb", ruby, &rubydex::indexing::LanguageId::Ruby); + rubydex::indexing::index_source(&mut graph, "file:///link_check.rb".into(), ruby, &rubydex::indexing::LanguageId::Ruby); rubydex::resolution::Resolver::new(&mut graph).resolve(); (erb_children, graph.declarations().len()) diff --git a/rust/src/ffi.rs b/rust/src/ffi.rs index 05a1f6c7c..35cd30dc5 100644 --- a/rust/src/ffi.rs +++ b/rust/src/ffi.rs @@ -2,5 +2,5 @@ pub use crate::bindings::{ ast_node_free, hb_allocator_T, hb_allocator_destroy, hb_allocator_init, hb_array_get, hb_array_size, hb_buffer_free, hb_buffer_init, hb_buffer_value, hb_string_T, herb_diff, herb_diff_operation_at, herb_diff_operation_count, herb_diff_operation_type_to_string, herb_diff_trees_identical, herb_extract, herb_extract_ruby_to_buffer_with_options, herb_free_ruby_parse_result, herb_free_tokens, herb_lex, herb_parse, herb_parse_ruby, herb_prism_version, - herb_version, pm_buffer_free, pm_buffer_t, pm_prettyprint, token_type_to_string, HB_ALLOCATOR_ARENA, + herb_version, pm_buffer_free, pm_buffer_length, pm_buffer_new, pm_buffer_value, pm_prettyprint, token_type_to_string, HB_ALLOCATOR_ARENA, }; diff --git a/rust/src/herb.rs b/rust/src/herb.rs index fa1e94076..d5cb39737 100644 --- a/rust/src/herb.rs +++ b/rust/src/herb.rs @@ -153,18 +153,21 @@ pub struct RubyParseResult { impl RubyParseResult { pub fn prettyprint(&self) -> String { unsafe { - let mut buffer: crate::ffi::pm_buffer_t = std::mem::zeroed(); + let buffer = crate::ffi::pm_buffer_new(); - crate::ffi::pm_prettyprint(&mut buffer, &(*self.pointer).parser, (*self.pointer).root); + crate::ffi::pm_prettyprint(buffer, (*self.pointer).parser, (*self.pointer).root); - let output = if !buffer.value.is_null() && buffer.length > 0 { - let slice = std::slice::from_raw_parts(buffer.value as *const u8, buffer.length); + let value = crate::ffi::pm_buffer_value(buffer); + let length = crate::ffi::pm_buffer_length(buffer); + + let output = if !value.is_null() && length > 0 { + let slice = std::slice::from_raw_parts(value as *const u8, length); String::from_utf8_lossy(slice).into_owned() } else { String::new() }; - crate::ffi::pm_buffer_free(&mut buffer); + crate::ffi::pm_buffer_free(buffer); crate::nodes::prettify_prism_tree(&output) } diff --git a/rust/src/prism/buffer.rs b/rust/src/prism/buffer.rs index 346ea022e..f31fe1046 100644 --- a/rust/src/prism/buffer.rs +++ b/rust/src/prism/buffer.rs @@ -12,6 +12,14 @@ impl<'a> SerializationBuffer<'a> { Self { source, array, index: 0 } } + pub(crate) fn position(&self) -> usize { + self.index + } + + pub(crate) fn set_position(&mut self, index: usize) { + self.index = index; + } + pub(crate) fn read_byte(&mut self) -> u8 { let byte = self.array.get(self.index).copied().unwrap_or(0); self.index += 1; @@ -81,42 +89,20 @@ impl<'a> SerializationBuffer<'a> { } pub(crate) fn read_string_field(&mut self, flags: u32) -> String { - match self.read_byte() { - 1 => { - let start = self.read_var_int(); - let length = self.read_var_int(); - let end = (start + length).min(self.source.len()); - let start = start.min(end); - - decode(&self.source[start..end], flags) - } - - 2 => { - let length = self.read_var_int(); - let bytes = self.read_bytes(length); - - decode(bytes, flags) - } + let length = self.read_var_int(); + let bytes = self.read_bytes(length); - other => panic!("unknown serialized string type: {other}"), - } + decode(bytes, flags) } pub(crate) fn scan_constant(&self, constant_pool_offset: usize, constant_index: usize) -> String { let offset = constant_pool_offset + constant_index * 8; - let mut start = self.scan_uint32(offset) as usize; + let start = self.scan_uint32(offset) as usize; let length = self.scan_uint32(offset + 4) as usize; - let bytes = if start & (1 << 31) != 0 { - start &= (1 << 31) - 1; - let end = (start + length).min(self.array.len()); - &self.array[start.min(end)..end] - } else { - let end = (start + length).min(self.source.len()); - &self.source[start.min(end)..end] - }; + let end = (start + length).min(self.array.len()); - String::from_utf8_lossy(bytes).into_owned() + String::from_utf8_lossy(&self.array[start.min(end)..end]).into_owned() } } @@ -127,10 +113,6 @@ fn decode(bytes: &[u8], flags: u32) -> String { } impl SerializationBuffer<'_> { - pub(crate) fn peek_byte(&self) -> u8 { - self.array.get(self.index).copied().unwrap_or(0) - } - pub(crate) fn read_required_constant(&mut self, pool: usize) -> String { let index = self.read_var_int(); self.scan_constant(pool, index.saturating_sub(1)) diff --git a/rust/src/prism/deserialize.rs b/rust/src/prism/deserialize.rs index bb47b2152..d72ea8ec4 100644 --- a/rust/src/prism/deserialize.rs +++ b/rust/src/prism/deserialize.rs @@ -1,8 +1,8 @@ use super::buffer::SerializationBuffer; use super::PrismNode; -const MAJOR_VERSION: u8 = 1; -const MINOR_VERSION: u8 = 9; +const MAJOR_VERSION: u8 = 2; +const MINOR_VERSION: u8 = 0; const PATCH_VERSION: u8 = 0; const _: () = assert!( @@ -22,8 +22,26 @@ include!("generated_deserialize.rs"); pub fn deserialize(bytes: &[u8], source: &str) -> Option { let (mut buffer, pool) = skip_header(SerializationBuffer::new(source.as_bytes(), bytes))?; + let mut stack: Vec> = Vec::new(); + + while buffer.position() < pool { + match buffer.read_byte() { + 0 => stack.push(None), + 255 => { + buffer.read_bytes(8); + } + type_id => { + let node = read_node(&mut buffer, type_id, pool, &mut stack); + stack.push(Some(node)); + } + } + } - Some(read_node(&mut buffer, pool)) + if stack.len() != 1 { + return None; + } + + stack.pop().flatten() } fn skip_header(mut buffer: SerializationBuffer<'_>) -> Option<(SerializationBuffer<'_>, usize)> { @@ -43,6 +61,7 @@ fn skip_header(mut buffer: SerializationBuffer<'_>) -> Option<(SerializationBuff buffer.read_bytes(encoding_length); buffer.read_var_int(); // start line + buffer.read_bytes(8); // checksum let line_offsets = buffer.read_var_int(); for _ in 0..line_offsets { @@ -55,6 +74,16 @@ fn skip_header(mut buffer: SerializationBuffer<'_>) -> Option<(SerializationBuff buffer.read_location(); } + let attached_nodes = buffer.read_var_int(); + for _ in 0..attached_nodes { + buffer.read_var_int(); + + let attached_comments = buffer.read_var_int(); + for _ in 0..attached_comments { + buffer.read_var_int(); + } + } + let magic_comments = buffer.read_var_int(); for _ in 0..magic_comments { buffer.read_location(); @@ -75,15 +104,15 @@ fn skip_header(mut buffer: SerializationBuffer<'_>) -> Option<(SerializationBuff } } + buffer.read_byte(); // continuable + let pool = buffer.read_uint32() as usize; buffer.read_var_int(); Some((buffer, pool)) } -fn read_node(buffer: &mut SerializationBuffer, pool: usize) -> PrismNode { - let type_id = buffer.read_byte(); - +fn read_node(buffer: &mut SerializationBuffer, type_id: u8, pool: usize, stack: &mut Vec>) -> PrismNode { buffer.read_var_int(); // node id let (start_offset, length) = buffer.read_location(); @@ -101,7 +130,7 @@ fn read_node(buffer: &mut SerializationBuffer, pool: usize) -> PrismNode { children: Vec::new(), }; - read_node_body(buffer, type_id, pool, &mut node); + read_node_body(buffer, type_id, pool, &mut node, stack); node } @@ -126,25 +155,76 @@ fn newline_offsets(source: &str) -> Vec { source.bytes().enumerate().filter(|(_, byte)| *byte == b'\n').map(|(index, _)| index).collect() } -fn prettyprint_node(buffer: &mut SerializationBuffer, pool: usize, output: &mut String, prefix: &mut String, newlines: &[usize]) { - let type_id = buffer.read_byte(); +struct PrismRecord { + type_id: u8, + offset: usize, + children: Vec>, +} + +fn index_records(buffer: &mut SerializationBuffer, pool: usize) -> Option { + let mut stack: Vec> = Vec::new(); + + while buffer.position() < pool { + match buffer.read_byte() { + 0 => stack.push(None), + 255 => { + buffer.read_bytes(8); + } + type_id => { + let offset = buffer.position(); + + buffer.read_var_int(); + buffer.read_location(); + + let count = record_child_count(buffer, type_id, pool); + let children = stack.split_off(stack.len().saturating_sub(count)); + + stack.push(Some(PrismRecord { type_id, offset, children })); + } + } + } + + if stack.len() != 1 { + return None; + } + + stack.pop().flatten() +} + +fn prettyprint_record(record: PrismRecord, buffer: &mut SerializationBuffer, pool: usize, output: &mut String, prefix: &mut String, newlines: &[usize]) { + let resume = buffer.position(); + buffer.set_position(record.offset); buffer.read_var_int(); let (start_offset, length) = buffer.read_location(); + let mut children = record.children.into_iter(); + + prettyprint_body( + buffer, + record.type_id, + pool, + output, + prefix, + start_offset, + start_offset + length, + newlines, + &mut children, + ); - prettyprint_body(buffer, type_id, pool, output, prefix, start_offset, start_offset + length, newlines); + buffer.set_position(resume); } /// pm_prettyprint pub fn prettyprint(bytes: &[u8], source: &str) -> Option { let (mut buffer, pool) = skip_header(SerializationBuffer::new(source.as_bytes(), bytes))?; + let root = index_records(&mut buffer, pool)?; let newlines = newline_offsets(source); let mut output = String::new(); let mut prefix = String::new(); - prettyprint_node(&mut buffer, pool, &mut output, &mut prefix, &newlines); + prettyprint_record(root, &mut buffer, pool, &mut output, &mut prefix, &newlines); Some(output) } diff --git a/rust/src/prism/mod.rs b/rust/src/prism/mod.rs index c9d2d66fd..3421d9d26 100644 --- a/rust/src/prism/mod.rs +++ b/rust/src/prism/mod.rs @@ -92,17 +92,20 @@ pub unsafe fn serialize(prism_node: herb_prism_node_T) -> Option> { return None; } - let mut buffer: pm_buffer_t = std::mem::zeroed(); + let buffer = pm_buffer_new(); - herb_prism_node_serialize(prism_node, &mut buffer); + herb_prism_node_serialize(prism_node, buffer); - let output = if buffer.length > 0 && !buffer.value.is_null() { - Some(std::slice::from_raw_parts(buffer.value as *const u8, buffer.length).to_vec()) + let value = pm_buffer_value(buffer); + let length = pm_buffer_length(buffer); + + let output = if length > 0 && !value.is_null() { + Some(std::slice::from_raw_parts(value as *const u8, length).to_vec()) } else { None }; - pm_buffer_free(&mut buffer); + pm_buffer_free(buffer); output } diff --git a/rust/tests/cli_commands_test.rs b/rust/tests/cli_commands_test.rs index a60fd0474..ddd74440e 100644 --- a/rust/tests/cli_commands_test.rs +++ b/rust/tests/cli_commands_test.rs @@ -2,7 +2,7 @@ use herb::{extract_html, extract_ruby, version}; #[test] fn test_version_functions() { - assert_eq!(version(), "herb rust v0.11.1, libprism v1.9.0, libherb v0.11.1 (Rust FFI)"); + assert_eq!(version(), "herb rust v0.11.1, libprism v2.0.0, libherb v0.11.1 (Rust FFI)"); } #[test] diff --git a/rust/tests/snapshots/prism_nodes_deep_test__case_when.snap b/rust/tests/snapshots/prism_nodes_deep_test__case_when.snap index e6533ff2a..2154a08fb 100644 --- a/rust/tests/snapshots/prism_nodes_deep_test__case_when.snap +++ b/rust/tests/snapshots/prism_nodes_deep_test__case_when.snap @@ -25,7 +25,7 @@ expression: result.inspect() │ │ ├── block: nil │ ├── conditions: (length: 2) │ │ ├── @ WhenNode (location: (0,18)-(0,44)) - │ │ │ ├── keyword_loc: (0,18)-(0,22) = "when" + │ │ │ ├── when_keyword_loc: (0,18)-(0,22) = "when" │ │ │ ├── conditions: (length: 1) │ │ │ │ └── @ StringNode (location: (0,23)-(0,30)) │ │ │ │ ├── StringFlags: frozen @@ -44,7 +44,7 @@ expression: result.inspect() │ │ │ ├── closing_loc: (0,43)-(0,44) = "\"" │ │ │ └── unescaped: "Admin" │ │ └── @ WhenNode (location: (0,50)-(0,74)) - │ │ ├── keyword_loc: (0,50)-(0,54) = "when" + │ │ ├── when_keyword_loc: (0,50)-(0,54) = "when" │ │ ├── conditions: (length: 1) │ │ │ └── @ StringNode (location: (0,55)-(0,61)) │ │ │ ├── StringFlags: frozen diff --git a/rust/tests/snapshots/prism_nodes_test__case_when.snap b/rust/tests/snapshots/prism_nodes_test__case_when.snap index 35248f370..a673d36aa 100644 --- a/rust/tests/snapshots/prism_nodes_test__case_when.snap +++ b/rust/tests/snapshots/prism_nodes_test__case_when.snap @@ -25,7 +25,7 @@ expression: result.inspect() │ │ ├── block: nil │ ├── conditions: (length: 2) │ │ ├── @ WhenNode (location: (0,18)-(0,30)) - │ │ │ ├── keyword_loc: (0,18)-(0,22) = "when" + │ │ │ ├── when_keyword_loc: (0,18)-(0,22) = "when" │ │ │ ├── conditions: (length: 1) │ │ │ │ └── @ StringNode (location: (0,23)-(0,30)) │ │ │ │ ├── StringFlags: frozen @@ -36,7 +36,7 @@ expression: result.inspect() │ │ │ ├── then_keyword_loc: nil │ │ │ └── statements: nil │ │ └── @ WhenNode (location: (0,50)-(0,61)) - │ │ ├── keyword_loc: (0,50)-(0,54) = "when" + │ │ ├── when_keyword_loc: (0,50)-(0,54) = "when" │ │ ├── conditions: (length: 1) │ │ │ └── @ StringNode (location: (0,55)-(0,61)) │ │ │ ├── StringFlags: frozen diff --git a/rust/tests/snapshots/prism_nodes_test__unless_statement.snap b/rust/tests/snapshots/prism_nodes_test__unless_statement.snap index c78025f8b..8cc5cf24c 100644 --- a/rust/tests/snapshots/prism_nodes_test__unless_statement.snap +++ b/rust/tests/snapshots/prism_nodes_test__unless_statement.snap @@ -11,7 +11,7 @@ expression: result.inspect() ├── then_keyword: ∅ ├── prism_node: │ └── @ UnlessNode (location: (0,3)-(0,40)) - │ ├── keyword_loc: (0,3)-(0,9) = "unless" + │ ├── unless_keyword_loc: (0,3)-(0,9) = "unless" │ ├── predicate: │ │ @ CallNode (location: (0,10)-(0,17)) │ │ ├── CallNodeFlags: ignore_visibility diff --git a/rust/tests/snapshots/prism_nodes_test__until_loop.snap b/rust/tests/snapshots/prism_nodes_test__until_loop.snap index 870e6332c..134938c1e 100644 --- a/rust/tests/snapshots/prism_nodes_test__until_loop.snap +++ b/rust/tests/snapshots/prism_nodes_test__until_loop.snap @@ -11,9 +11,9 @@ expression: result.inspect() ├── prism_node: │ └── @ UntilNode (location: (0,3)-(0,38)) │ ├── LoopFlags: nil - │ ├── keyword_loc: (0,3)-(0,8) = "until" + │ ├── until_keyword_loc: (0,3)-(0,8) = "until" │ ├── do_keyword_loc: nil - │ ├── closing_loc: (0,35)-(0,38) = "end" + │ ├── end_keyword_loc: (0,35)-(0,38) = "end" │ ├── predicate: │ │ @ CallNode (location: (0,9)-(0,14)) │ │ ├── CallNodeFlags: ignore_visibility diff --git a/rust/tests/snapshots/prism_nodes_test__while_loop.snap b/rust/tests/snapshots/prism_nodes_test__while_loop.snap index a6ee2f6bd..805734eac 100644 --- a/rust/tests/snapshots/prism_nodes_test__while_loop.snap +++ b/rust/tests/snapshots/prism_nodes_test__while_loop.snap @@ -11,9 +11,9 @@ expression: result.inspect() ├── prism_node: │ └── @ WhileNode (location: (0,3)-(0,39)) │ ├── LoopFlags: nil - │ ├── keyword_loc: (0,3)-(0,8) = "while" + │ ├── while_keyword_loc: (0,3)-(0,8) = "while" │ ├── do_keyword_loc: nil - │ ├── closing_loc: (0,36)-(0,39) = "end" + │ ├── end_keyword_loc: (0,36)-(0,39) = "end" │ ├── predicate: │ │ @ CallNode (location: (0,9)-(0,17)) │ │ ├── CallNodeFlags: ignore_visibility diff --git a/rust/tests/snapshots/snapshot_test__prism_version_output.snap b/rust/tests/snapshots/snapshot_test__prism_version_output.snap index 8517052ef..f6a75140c 100644 --- a/rust/tests/snapshots/snapshot_test__prism_version_output.snap +++ b/rust/tests/snapshots/snapshot_test__prism_version_output.snap @@ -2,4 +2,4 @@ source: tests/snapshot_test.rs expression: output --- -1.9.0 +2.0.0 diff --git a/rust/tests/snapshots/snapshot_test__version_output.snap b/rust/tests/snapshots/snapshot_test__version_output.snap index 8e1b54171..e95393e25 100644 --- a/rust/tests/snapshots/snapshot_test__version_output.snap +++ b/rust/tests/snapshots/snapshot_test__version_output.snap @@ -2,4 +2,4 @@ source: tests/snapshot_test.rs expression: output --- -herb rust v0.11.1, libprism v1.9.0, libherb v0.11.1 (Rust FFI) +herb rust v0.11.1, libprism v2.0.0, libherb v0.11.1 (Rust FFI) diff --git a/sorbet/rbi/prism.rbi b/sorbet/rbi/prism.rbi deleted file mode 100644 index 10eaa3aca..000000000 --- a/sorbet/rbi/prism.rbi +++ /dev/null @@ -1,9 +0,0 @@ -# typed: true - -# Shim for Prism::LexCompat which was removed in newer versions -# but is still referenced in the vendored prism RBI files. -module Prism - module LexCompat - Result = Prism::LexResult - end -end diff --git a/src/analyze/action_view/attribute_extraction_helpers.c b/src/analyze/action_view/attribute_extraction_helpers.c index f2d48d91d..c94f4cb27 100644 --- a/src/analyze/action_view/attribute_extraction_helpers.c +++ b/src/analyze/action_view/attribute_extraction_helpers.c @@ -4,10 +4,12 @@ #include "../../include/lib/hb_array.h" #include "../../include/lib/hb_buffer.h" #include "../../include/lib/hb_string.h" +#include "../../include/prism/prism_helpers.h" #include "../../include/util/html_util.h" #include "../../include/util/util.h" #include +#include #include #include @@ -39,14 +41,14 @@ static void compute_position_pair( position_T* out_end ) { *out_start = prism_location_to_position_with_offset(location, original_source, erb_content_offset, source); - pm_location_t end_location = { .start = location->end, .end = location->end }; + pm_location_t end_location = { .start = herb_prism_location_end(*location), .length = 0 }; *out_end = prism_location_to_position_with_offset(&end_location, original_source, erb_content_offset, source); } static void extract_key_name_location(pm_node_t* key, pm_location_t* out_name_loc) { if (key->type == PM_SYMBOL_NODE) { pm_symbol_node_t* symbol = (pm_symbol_node_t*) key; - *out_name_loc = symbol->value_loc; + *out_name_loc = symbol->content_loc; } else if (key->type == PM_STRING_NODE) { pm_string_node_t* string_node = (pm_string_node_t*) key; *out_name_loc = string_node->content_loc; @@ -69,7 +71,7 @@ static void compute_separator_info( *out_separator_end = prism_location_to_position_with_offset(&assoc->value->location, original_source, erb_content_offset, source); - if (assoc->operator_loc.start != NULL) { + if (herb_prism_location_assigned(assoc->operator_loc)) { *out_separator_string = " => "; *out_separator_type = TOKEN_EQUALS; *out_separator_start = key_end; @@ -78,8 +80,8 @@ static void compute_separator_info( *out_separator_type = TOKEN_COLON; pm_location_t colon_loc = { - .start = assoc->key->location.end - 1, - .end = assoc->key->location.end - 1, + .start = herb_prism_location_end(assoc->key->location) - 1, + .length = 0, }; *out_separator_start = @@ -102,7 +104,7 @@ static void extract_delimited_locations( pm_symbol_node_t* symbol_node = (pm_symbol_node_t*) node; *out_opening = &symbol_node->opening_loc; *out_closing = &symbol_node->closing_loc; - *out_content = &symbol_node->value_loc; + *out_content = &symbol_node->content_loc; } else { *out_opening = NULL; *out_closing = NULL; @@ -127,7 +129,8 @@ static void compute_value_positions( extract_delimited_locations(value_node, &opening_loc, &closing_loc, &content_loc); - if (opening_loc && opening_loc->start != NULL && closing_loc && closing_loc->start != NULL) { + if (opening_loc && herb_prism_location_assigned(*opening_loc) && closing_loc + && herb_prism_location_assigned(*closing_loc)) { compute_position_pair( &*opening_loc, source, @@ -167,7 +170,7 @@ static void fill_attribute_positions( ); position_T key_end; - pm_location_t key_end_loc = { .start = assoc->key->location.end, .end = assoc->key->location.end }; + pm_location_t key_end_loc = { .start = herb_prism_location_end(assoc->key->location), .length = 0 }; key_end = prism_location_to_position_with_offset(&key_end_loc, original_source, erb_content_offset, source); compute_separator_info( @@ -246,6 +249,7 @@ static char* join_static_string_array(pm_array_node_t* array, hb_allocator_T* al static AST_NODE_T* create_attribute_from_value( const char* name_string, pm_node_t* value_node, + const uint8_t* source, attribute_positions_T* positions, hb_allocator_T* allocator, bool is_nested @@ -281,8 +285,8 @@ static AST_NODE_T* create_attribute_from_value( return (AST_NODE_T*) create_html_attribute_node_precise(name_string, "false", positions, allocator); } else if (value_node->type == PM_INTEGER_NODE) { - size_t value_length = value_node->location.end - value_node->location.start; - char* value_string = hb_allocator_strndup(allocator, (const char*) value_node->location.start, value_length); + char* value_string = + hb_allocator_strndup(allocator, (const char*) (source + value_node->location.start), value_node->location.length); if (!value_string) { return NULL; } AST_HTML_ATTRIBUTE_NODE_T* attribute = @@ -294,15 +298,17 @@ static AST_NODE_T* create_attribute_from_value( return (AST_NODE_T*) create_html_attribute_with_interpolated_value( name_string, (pm_interpolated_string_node_t*) value_node, + source, positions->name_start, positions->value_end, allocator ); } else { - size_t value_length = value_node->location.end - value_node->location.start; - char* raw_content = hb_allocator_strndup(allocator, (const char*) value_node->location.start, value_length); + size_t value_length = value_node->location.length; + char* raw_content = + hb_allocator_strndup(allocator, (const char*) (source + value_node->location.start), value_length); - if (raw_content && value_node->location.start) { + if (raw_content && herb_prism_location_assigned(value_node->location)) { char* ruby_content = raw_content; hb_buffer_T wrapper; bool wrapped = false; @@ -488,8 +494,14 @@ AST_NODE_T* extract_html_attribute_from_assoc( fill_attribute_positions(assoc, source, original_source, erb_content_offset, &positions); char* dashed_name = convert_underscores_to_dashes(name_string); - AST_NODE_T* attribute_node = - create_attribute_from_value(dashed_name ? dashed_name : name_string, assoc->value, &positions, allocator, false); + AST_NODE_T* attribute_node = create_attribute_from_value( + dashed_name ? dashed_name : name_string, + assoc->value, + source, + &positions, + allocator, + false + ); if (dashed_name) { free(dashed_name); } hb_allocator_dealloc(allocator, name_string); @@ -516,8 +528,9 @@ hb_array_T* extract_html_attributes_from_keyword_hash( pm_assoc_splat_node_t* splat = (pm_assoc_splat_node_t*) element; if (splat->value) { - size_t value_length = splat->value->location.end - splat->value->location.start; - char* value_source = hb_allocator_strndup(allocator, (const char*) splat->value->location.start, value_length); + size_t value_length = splat->value->location.length; + char* value_source = + hb_allocator_strndup(allocator, (const char*) (source + splat->value->location.start), value_length); if (value_source) { hb_buffer_T wrapped; @@ -560,9 +573,9 @@ hb_array_T* extract_html_attributes_from_keyword_hash( pm_assoc_splat_node_t* splat = (pm_assoc_splat_node_t*) hash_element; if (splat->value) { - size_t value_length = splat->value->location.end - splat->value->location.start; + size_t value_length = splat->value->location.length; char* value_source = - hb_allocator_strndup(allocator, (const char*) splat->value->location.start, value_length); + hb_allocator_strndup(allocator, (const char*) (source + splat->value->location.start), value_length); if (value_source) { hb_buffer_T wrapped; @@ -612,8 +625,14 @@ hb_array_T* extract_html_attributes_from_keyword_hash( attribute_positions_T hash_positions; fill_attribute_positions(hash_assoc, source, original_source, erb_content_offset, &hash_positions); - AST_NODE_T* attribute = - create_attribute_from_value(attribute_key_string, hash_assoc->value, &hash_positions, allocator, true); + AST_NODE_T* attribute = create_attribute_from_value( + attribute_key_string, + hash_assoc->value, + source, + &hash_positions, + allocator, + true + ); if (attribute) { hb_array_append(attributes, attribute); } hb_allocator_dealloc(allocator, attribute_key_string); diff --git a/src/analyze/action_view/image_tag.c b/src/analyze/action_view/image_tag.c index b83844ccf..8a6ce9229 100644 --- a/src/analyze/action_view/image_tag.c +++ b/src/analyze/action_view/image_tag.c @@ -5,7 +5,7 @@ #include #include -char* extract_image_tag_src(pm_call_node_t* call_node, pm_parser_t* _parser, hb_allocator_T* allocator) { +char* extract_image_tag_src(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { if (!call_node || !call_node->arguments) { return NULL; } pm_arguments_node_t* arguments = call_node->arguments; @@ -20,9 +20,13 @@ char* extract_image_tag_src(pm_call_node_t* call_node, pm_parser_t* _parser, hb_ return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = first_argument->location.end - first_argument->location.start; + const uint8_t* source = pm_parser_start(parser); - return hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + return hb_allocator_strndup( + allocator, + (const char*) (source + first_argument->location.start), + first_argument->location.length + ); } bool image_tag_source_is_url(const char* source, size_t length) { diff --git a/src/analyze/action_view/javascript_include_tag.c b/src/analyze/action_view/javascript_include_tag.c index 8200db0ca..08a67eb58 100644 --- a/src/analyze/action_view/javascript_include_tag.c +++ b/src/analyze/action_view/javascript_include_tag.c @@ -6,7 +6,6 @@ #include char* extract_javascript_include_tag_src(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { - (void) parser; if (!call_node || !call_node->arguments) { return NULL; } @@ -22,8 +21,12 @@ char* extract_javascript_include_tag_src(pm_call_node_t* call_node, pm_parser_t* return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = first_argument->location.end - first_argument->location.start; - return hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + const uint8_t* source = pm_parser_start(parser); + return hb_allocator_strndup( + allocator, + (const char*) (source + first_argument->location.start), + first_argument->location.length + ); } bool javascript_include_tag_source_is_url(const char* source, size_t length) { diff --git a/src/analyze/action_view/link_to.c b/src/analyze/action_view/link_to.c index b11f9d350..74ab2ac18 100644 --- a/src/analyze/action_view/link_to.c +++ b/src/analyze/action_view/link_to.c @@ -25,9 +25,10 @@ char* wrap_in_url_for(const char* source, size_t source_length, hb_allocator_T* bool detect_link_to(pm_call_node_t* call_node, pm_parser_t* parser) { if (!call_node || !call_node->name) { return false; } - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call_node->name); + const pm_constant_t* constant = pm_parser_constant(parser, call_node->name); - return constant && constant->length == 7 && strncmp((const char*) constant->start, "link_to", 7) == 0; + return constant && pm_constant_length(constant) == 7 + && strncmp((const char*) pm_constant_start(constant), "link_to", 7) == 0; } bool is_route_helper_node(pm_node_t* node, pm_parser_t* parser) { @@ -36,11 +37,11 @@ bool is_route_helper_node(pm_node_t* node, pm_parser_t* parser) { pm_call_node_t* call = (pm_call_node_t*) node; if (!call->name) { return false; } - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call->name); - if (!constant || constant->length < 5) { return false; } + const pm_constant_t* constant = pm_parser_constant(parser, call->name); + if (!constant || pm_constant_length(constant) < 5) { return false; } - const char* name = (const char*) constant->start; - size_t length = constant->length; + const char* name = (const char*) pm_constant_start(constant); + size_t length = pm_constant_length(constant); return (length >= 5 && strncmp(name + length - 5, "_path", 5) == 0) || (length >= 4 && strncmp(name + length - 4, "_url", 4) == 0); @@ -54,11 +55,9 @@ char* extract_link_to_tag_name(pm_call_node_t* call_node, pm_parser_t* parser, h } char* extract_link_to_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { - (void) parser; - if (!call_node) { return NULL; } - char* block_content = extract_inline_block_content(call_node, allocator); + char* block_content = extract_inline_block_content(call_node, parser, allocator); if (block_content) { return block_content; } if (!call_node->arguments) { return NULL; } @@ -76,7 +75,8 @@ char* extract_link_to_content(pm_call_node_t* call_node, pm_parser_t* parser, hb return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = first_argument->location.end - first_argument->location.start; + const uint8_t* source = pm_parser_start(parser); + size_t source_length = first_argument->location.length; // Format: ".to_s" if (arguments->arguments.size == 1) { @@ -85,21 +85,21 @@ char* extract_link_to_content(pm_call_node_t* call_node, pm_parser_t* parser, hb size_t total_length = source_length + suffix_len; char* ruby_expression = hb_allocator_alloc(allocator, total_length + 1); - memcpy(ruby_expression, (const char*) first_argument->location.start, source_length); + memcpy(ruby_expression, (const char*) (source + first_argument->location.start), source_length); memcpy(ruby_expression + source_length, suffix, suffix_len); ruby_expression[total_length] = '\0'; return ruby_expression; } - return hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + return hb_allocator_strndup(allocator, (const char*) (source + first_argument->location.start), source_length); } char* extract_link_to_href(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { - (void) parser; - if (!call_node || !call_node->arguments) { return NULL; } + const uint8_t* source = pm_parser_start(parser); + pm_arguments_node_t* arguments = call_node->arguments; bool has_inline_block = call_node->block && call_node->block->type == PM_BLOCK_NODE; @@ -112,13 +112,13 @@ char* extract_link_to_href(pm_call_node_t* call_node, pm_parser_t* parser, hb_al return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = first_argument->location.end - first_argument->location.start; + size_t source_length = first_argument->location.length; if (is_route_helper_node(first_argument, parser)) { - return hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + return hb_allocator_strndup(allocator, (const char*) (source + first_argument->location.start), source_length); } - return wrap_in_url_for((const char*) first_argument->location.start, source_length, allocator); + return wrap_in_url_for((const char*) (source + first_argument->location.start), source_length, allocator); } // Format: "url_for()" @@ -127,13 +127,13 @@ char* extract_link_to_href(pm_call_node_t* call_node, pm_parser_t* parser, hb_al if (first_argument->type == PM_STRING_NODE || first_argument->type == PM_NIL_NODE) { return NULL; } - size_t source_length = first_argument->location.end - first_argument->location.start; + size_t source_length = first_argument->location.length; if (is_route_helper_node(first_argument, parser)) { - return hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + return hb_allocator_strndup(allocator, (const char*) (source + first_argument->location.start), source_length); } - return wrap_in_url_for((const char*) first_argument->location.start, source_length, allocator); + return wrap_in_url_for((const char*) (source + first_argument->location.start), source_length, allocator); } if (arguments->arguments.size < 2) { return NULL; } @@ -146,13 +146,13 @@ char* extract_link_to_href(pm_call_node_t* call_node, pm_parser_t* parser, hb_al return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = second_argument->location.end - second_argument->location.start; + size_t source_length = second_argument->location.length; if (!is_route_helper_node(second_argument, parser)) { - return wrap_in_url_for((const char*) second_argument->location.start, source_length, allocator); + return wrap_in_url_for((const char*) (source + second_argument->location.start), source_length, allocator); } - return hb_allocator_strndup(allocator, (const char*) second_argument->location.start, source_length); + return hb_allocator_strndup(allocator, (const char*) (source + second_argument->location.start), source_length); } bool link_to_supports_block(void) { diff --git a/src/analyze/action_view/registry.c b/src/analyze/action_view/registry.c index e148d1505..5ab19e038 100644 --- a/src/analyze/action_view/registry.c +++ b/src/analyze/action_view/registry.c @@ -59,7 +59,7 @@ size_t get_tag_helper_handlers_count(void) { return handlers_count; } -char* extract_inline_block_content(pm_call_node_t* call_node, hb_allocator_T* allocator) { +char* extract_inline_block_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { if (!call_node || !call_node->block || call_node->block->type != PM_BLOCK_NODE) { return NULL; } pm_block_node_t* block_node = (pm_block_node_t*) call_node->block; @@ -78,6 +78,10 @@ char* extract_inline_block_content(pm_call_node_t* call_node, hb_allocator_T* al return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = statement->location.end - statement->location.start; - return hb_allocator_strndup(allocator, (const char*) statement->location.start, source_length); + const uint8_t* source = pm_parser_start(parser); + return hb_allocator_strndup( + allocator, + (const char*) (source + statement->location.start), + statement->location.length + ); } diff --git a/src/analyze/action_view/tag_helper_node_builders.c b/src/analyze/action_view/tag_helper_node_builders.c index fff9add6a..24a9554ff 100644 --- a/src/analyze/action_view/tag_helper_node_builders.c +++ b/src/analyze/action_view/tag_helper_node_builders.c @@ -304,6 +304,7 @@ AST_HTML_ATTRIBUTE_NODE_T* create_html_attribute_with_ruby_literal( static AST_HTML_ATTRIBUTE_VALUE_NODE_T* create_interpolated_attribute_value( pm_interpolated_string_node_t* interpolated_node, + const uint8_t* source, position_T start_position, position_T end_position, hb_allocator_T* allocator @@ -338,19 +339,10 @@ static AST_HTML_ATTRIBUTE_VALUE_NODE_T* create_interpolated_attribute_value( } } else if (part->type == PM_EMBEDDED_STATEMENTS_NODE) { pm_embedded_statements_node_t* embedded = (pm_embedded_statements_node_t*) part; - const uint8_t* content_start; - const uint8_t* content_end; - - if (embedded->statements) { - content_start = embedded->statements->base.location.start; - content_end = embedded->statements->base.location.end; - } else { - content_start = part->location.start; - content_end = part->location.end; - } + pm_location_t content_location = embedded->statements ? embedded->statements->base.location : part->location; - size_t ruby_length = content_end - content_start; - char* ruby_content = hb_allocator_strndup(allocator, (const char*) content_start, ruby_length); + char* ruby_content = + hb_allocator_strndup(allocator, (const char*) (source + content_location.start), content_location.length); if (ruby_content) { AST_RUBY_LITERAL_NODE_T* ruby_node = ast_ruby_literal_node_init( @@ -386,6 +378,7 @@ static AST_HTML_ATTRIBUTE_VALUE_NODE_T* create_interpolated_attribute_value( AST_HTML_ATTRIBUTE_NODE_T* create_html_attribute_with_interpolated_value( const char* name_string, pm_interpolated_string_node_t* interpolated_node, + const uint8_t* source, position_T start_position, position_T end_position, hb_allocator_T* allocator @@ -396,7 +389,7 @@ AST_HTML_ATTRIBUTE_NODE_T* create_html_attribute_with_interpolated_value( create_attribute_name_node(name_string, start_position, end_position, allocator); AST_HTML_ATTRIBUTE_VALUE_NODE_T* value_node = - create_interpolated_attribute_value(interpolated_node, start_position, end_position, allocator); + create_interpolated_attribute_value(interpolated_node, source, start_position, end_position, allocator); token_T* equals_token = create_synthetic_token(allocator, "=", TOKEN_EQUALS, start_position, end_position); diff --git a/src/analyze/action_view/tag_helpers.c b/src/analyze/action_view/tag_helpers.c index 183d9bc43..eca17d235 100644 --- a/src/analyze/action_view/tag_helpers.c +++ b/src/analyze/action_view/tag_helpers.c @@ -18,6 +18,8 @@ #include "../../include/util/util.h" #include "../../include/visitor.h" +#include "../../include/prism/prism_helpers.h" + #include #include #include @@ -42,7 +44,9 @@ extern char* wrap_in_stylesheet_path(const char*, size_t, const char*, hb_alloca extern bool stylesheet_link_tag_source_is_url(const char*, size_t); typedef struct { - pm_parser_t parser; + pm_arena_t* arena; + pm_parser_t* parser; + pm_options_t* options; pm_node_t* root; const uint8_t* prism_source; char* content_string; @@ -60,46 +64,42 @@ typedef struct { } local_read_search_T; static void append_local_read_constant(local_read_search_T* search, pm_constant_id_t constant_id) { - pm_constant_t* constant = pm_constant_pool_id_to_constant(&search->scope->parser.constant_pool, constant_id); + const pm_constant_t* constant = pm_parser_constant(search->scope->parser, constant_id); + + if (!constant || pm_constant_length(constant) == 0) { return; } - if (!constant || constant->length == 0) { return; } + size_t length = pm_constant_length(constant); for (size_t index = 0; index < hb_array_size(search->constants); index++) { - pm_constant_t* existing = hb_array_get(search->constants, index); + const pm_constant_t* existing = hb_array_get(search->constants, index); - if (existing && existing->length == constant->length - && memcmp(existing->start, constant->start, constant->length) == 0) { + if (existing && pm_constant_length(existing) == length + && memcmp(pm_constant_start(existing), pm_constant_start(constant), length) == 0) { return; } } - hb_array_append(search->constants, constant); + hb_array_append(search->constants, (void*) constant); } -static bool search_local_variable_reads(const pm_node_t* node, void* data) { +static pm_visit_result_t search_local_variable_reads(const pm_node_t* node, void* data) { local_read_search_T* search = (local_read_search_T*) data; - const uint8_t* base = (const uint8_t*) search->scope->buffer.value; - size_t start = (size_t) (node->location.start - base); - size_t end = (size_t) (node->location.end - base); + size_t start = node->location.start; + size_t end = herb_prism_location_end(node->location); - if (end <= search->from || start >= search->to) { return false; } + if (end <= search->from || start >= search->to) { return PM_VISIT_SKIP; } if (PM_NODE_TYPE(node) == PM_LOCAL_VARIABLE_READ_NODE && start >= search->from && end <= search->to) { append_local_read_constant(search, ((pm_local_variable_read_node_t*) node)->name); } - return true; + return PM_VISIT_DESCEND; } -static bool build_scope_options_from_context( - analyze_ruby_context_T* context, - pm_options_t* options, - size_t from, - size_t to -) { - if (!context || !context->tag_helper_scope || !context->tag_helper_scope->root) { return false; } - if (to <= from) { return false; } +static pm_options_t* build_scope_options_from_context(analyze_ruby_context_T* context, size_t from, size_t to) { + if (!context || !context->tag_helper_scope || !context->tag_helper_scope->root) { return NULL; } + if (to <= from) { return NULL; } local_read_search_T search = { .scope = context->tag_helper_scope, .constants = hb_array_init(4, context->allocator), @@ -109,27 +109,33 @@ static bool build_scope_options_from_context( pm_visit_node(context->tag_helper_scope->root, search_local_variable_reads, &search); size_t locals_count = hb_array_size(search.constants); - bool built = false; + pm_options_t* options = NULL; + + if (locals_count > 0) { + options = pm_options_new(); - if (locals_count > 0 && pm_options_scopes_init(options, 1)) { - pm_options_scope_t* scope = &options->scopes[0]; + if (pm_options_scopes_init(options, 1)) { + pm_options_scope_t* scope = pm_options_scope_mut(options, 0); + pm_options_scope_init(scope, locals_count); - if (pm_options_scope_init(scope, locals_count)) { for (size_t index = 0; index < locals_count; index++) { - pm_constant_t* constant = hb_array_get(search.constants, index); + const pm_constant_t* constant = hb_array_get(search.constants, index); - pm_string_constant_init(&scope->locals[index], (const char*) constant->start, constant->length); + pm_string_init( + pm_options_scope_local_mut(scope, index), + pm_constant_start(constant), + pm_constant_length(constant) + ); } - - built = true; } else { pm_options_free(options); + options = NULL; } } hb_array_free(&search.constants); - return built; + return options; } static bool symbol_node_equals(pm_node_t* node, const char* name) { @@ -195,22 +201,18 @@ static tag_helper_parse_context_T* parse_tag_helper_content( size_t content_length = strlen(parse_context->content_string); - pm_options_t options = { 0 }; - bool has_scope_options = - build_scope_options_from_context(context, &options, erb_content_offset, erb_content_offset + content_length); - - pm_parser_init( - &parse_context->parser, - parse_context->prism_source, - content_length, - has_scope_options ? &options : NULL - ); - parse_context->root = pm_parse(&parse_context->parser); + parse_context->options = + build_scope_options_from_context(context, erb_content_offset, erb_content_offset + content_length); - if (has_scope_options) { pm_options_free(&options); } + parse_context->arena = pm_arena_new(); + parse_context->parser = + pm_parser_new(parse_context->arena, parse_context->prism_source, content_length, parse_context->options); + parse_context->root = pm_parse(parse_context->parser); if (!parse_context->root) { - pm_parser_free(&parse_context->parser); + pm_parser_free(parse_context->parser); + pm_arena_free(parse_context->arena); + if (parse_context->options) { pm_options_free(parse_context->options); } hb_allocator_dealloc(allocator, parse_context->content_string); hb_allocator_dealloc(allocator, parse_context); return NULL; @@ -220,7 +222,7 @@ static tag_helper_parse_context_T* parse_tag_helper_content( tag_helper_search_data_T search = { .tag_helper_node = NULL, .source = parse_context->prism_source, - .parser = &parse_context->parser, + .parser = parse_context->parser, .info = parse_context->info, .found = false }; pm_visit_node(parse_context->root, search_tag_helper_node, &search); @@ -228,8 +230,9 @@ static tag_helper_parse_context_T* parse_tag_helper_content( if (!search.found || asset_tag_resolves_at_render_time(parse_context->info->call_node, search.matched_handler->name)) { tag_helper_info_free(&parse_context->info); - pm_node_destroy(&parse_context->parser, parse_context->root); - pm_parser_free(&parse_context->parser); + pm_parser_free(parse_context->parser); + pm_arena_free(parse_context->arena); + if (parse_context->options) { pm_options_free(parse_context->options); } hb_allocator_dealloc(allocator, parse_context->content_string); hb_allocator_dealloc(allocator, parse_context); return NULL; @@ -245,8 +248,9 @@ static void free_tag_helper_parse_context(tag_helper_parse_context_T* parse_cont hb_allocator_T* allocator = parse_context->info ? parse_context->info->allocator : NULL; tag_helper_info_free(&parse_context->info); - pm_node_destroy(&parse_context->parser, parse_context->root); - pm_parser_free(&parse_context->parser); + pm_parser_free(parse_context->parser); + pm_arena_free(parse_context->arena); + if (parse_context->options) { pm_options_free(parse_context->options); } if (allocator) { hb_allocator_dealloc(allocator, parse_context->content_string); @@ -254,7 +258,7 @@ static void free_tag_helper_parse_context(tag_helper_parse_context_T* parse_cont } } -bool search_tag_helper_node(const pm_node_t* node, void* data) { +pm_visit_result_t search_tag_helper_node(const pm_node_t* node, void* data) { tag_helper_search_data_T* search_data = (tag_helper_search_data_T*) data; if (node->type == PM_CALL_NODE) { @@ -280,16 +284,16 @@ bool search_tag_helper_node(const pm_node_t* node, void* data) { search_data->info->has_block = handlers[i]->supports_block(); } - return false; + return PM_VISIT_SKIP; } } - return false; + return PM_VISIT_SKIP; } pm_visit_child_nodes(node, search_tag_helper_node, search_data); - return search_data->found; + return search_data->found ? PM_VISIT_DESCEND : PM_VISIT_SKIP; } position_T byte_offset_to_position(const char* source, size_t offset) { @@ -321,9 +325,11 @@ position_T prism_location_to_position_with_offset( ) { position_T default_position = { .line = 1, .column = 1 }; - if (!pm_location || !pm_location->start || !original_source || !erb_content_source) { return default_position; } + if (!pm_location || !herb_prism_location_assigned(*pm_location) || !original_source || !erb_content_source) { + return default_position; + } - size_t offset_in_erb = (size_t) (pm_location->start - erb_content_source); + size_t offset_in_erb = pm_location->start; size_t total_offset = erb_content_offset + offset_in_erb; if (strnlen(original_source, total_offset) < total_offset) { @@ -375,7 +381,7 @@ static void prism_node_location_to_positions( parse_context->prism_source ); - pm_location_t end_location = { .start = location->end, .end = location->end }; + pm_location_t end_location = { .start = herb_prism_location_end(*location), .length = 0 }; *out_end = prism_location_to_position_with_offset( &end_location, parse_context->original_source, @@ -394,7 +400,7 @@ static void calculate_tag_name_positions( *out_start = default_start; *out_end = default_end; - if (parse_context->info->call_node && parse_context->info->call_node->message_loc.start) { + if (parse_context->info->call_node && herb_prism_location_assigned(parse_context->info->call_node->message_loc)) { prism_node_location_to_positions(&parse_context->info->call_node->message_loc, parse_context, out_start, out_end); } } @@ -405,6 +411,7 @@ static const char* IMAGE_TAG_PATH_OPTIONS[] = { "skip_pipeline", NULL }; static char* extract_path_options_from_keyword_hash( pm_call_node_t* call_node, + const uint8_t* source, const char** option_names, hb_allocator_T* allocator ) { @@ -449,12 +456,18 @@ static char* extract_path_options_from_keyword_hash( if (!first) { hb_buffer_append(&buffer, ", "); } first = false; - size_t key_source_length = assoc->key->location.end - assoc->key->location.start; - hb_buffer_append_with_length(&buffer, (const char*) assoc->key->location.start, key_source_length); + hb_buffer_append_with_length( + &buffer, + (const char*) (source + assoc->key->location.start), + assoc->key->location.length + ); hb_buffer_append(&buffer, " "); - size_t value_source_length = assoc->value->location.end - assoc->value->location.start; - hb_buffer_append_with_length(&buffer, (const char*) assoc->value->location.start, value_source_length); + hb_buffer_append_with_length( + &buffer, + (const char*) (source + assoc->value->location.start), + assoc->value->location.length + ); } if (first) { @@ -512,8 +525,11 @@ static hb_array_T* prepend_stylesheet_link_tag_attributes( size_t length = pm_string_length(&string_node->unescaped); source_value = hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } else { - size_t length = source_argument->location.end - source_argument->location.start; - source_value = hb_allocator_strndup(allocator, (const char*) source_argument->location.start, length); + source_value = hb_allocator_strndup( + allocator, + (const char*) (parse_context->prism_source + source_argument->location.start), + source_argument->location.length + ); } if (!source_value) { return attributes; } @@ -523,7 +539,7 @@ static hb_array_T* prepend_stylesheet_link_tag_attributes( size_t source_length = strlen(source_value); bool is_url = stylesheet_link_tag_source_is_url(source_value, source_length); - bool source_is_path_helper = is_route_helper_node(source_argument, &parse_context->parser); + bool source_is_path_helper = is_route_helper_node(source_argument, parse_context->parser); char* href_value = source_value; @@ -603,6 +619,7 @@ static AST_NODE_T* transform_tag_helper_with_attributes( if (attributes && handler->name && strcmp(handler->name, "javascript_include_tag") == 0) { path_options = extract_path_options_from_keyword_hash( parse_context->info->call_node, + parse_context->prism_source, JAVASCRIPT_INCLUDE_TAG_PATH_OPTIONS, allocator ); @@ -616,6 +633,7 @@ static AST_NODE_T* transform_tag_helper_with_attributes( if (attributes && handler->name && strcmp(handler->name, "stylesheet_link_tag") == 0) { path_options = extract_path_options_from_keyword_hash( parse_context->info->call_node, + parse_context->prism_source, STYLESHEET_LINK_TAG_PATH_OPTIONS, allocator ); @@ -627,8 +645,12 @@ static AST_NODE_T* transform_tag_helper_with_attributes( } if (attributes && handler->name && strcmp(handler->name, "image_tag") == 0) { - path_options = - extract_path_options_from_keyword_hash(parse_context->info->call_node, IMAGE_TAG_PATH_OPTIONS, allocator); + path_options = extract_path_options_from_keyword_hash( + parse_context->info->call_node, + parse_context->prism_source, + IMAGE_TAG_PATH_OPTIONS, + allocator + ); discard_attribute_by_name(attributes, "skip-pipeline", allocator); AST_NODE_T* size_node = remove_attribute_by_name(attributes, "size"); @@ -722,7 +744,7 @@ static AST_NODE_T* transform_tag_helper_with_attributes( bool content_is_ruby_expression = false; if (parse_context->info->call_node && handler->extract_content) { - helper_content = handler->extract_content(parse_context->info->call_node, &parse_context->parser, allocator); + helper_content = handler->extract_content(parse_context->info->call_node, parse_context->parser, allocator); if (helper_content) { pm_call_node_t* call = parse_context->info->call_node; @@ -751,8 +773,8 @@ static AST_NODE_T* transform_tag_helper_with_attributes( } } - if (detect_turbo_frame_tag(parse_context->info->call_node, &parse_context->parser)) { - char* id_value = extract_turbo_frame_tag_id(parse_context->info->call_node, &parse_context->parser, allocator); + if (detect_turbo_frame_tag(parse_context->info->call_node, parse_context->parser)) { + char* id_value = extract_turbo_frame_tag_id(parse_context->info->call_node, parse_context->parser, allocator); if (id_value) { if (!attributes) { attributes = hb_array_init(4, allocator); } @@ -780,10 +802,10 @@ static AST_NODE_T* transform_tag_helper_with_attributes( } } - if (detect_javascript_include_tag(parse_context->info->call_node, &parse_context->parser) + if (detect_javascript_include_tag(parse_context->info->call_node, parse_context->parser) && parse_context->info->call_node->arguments && parse_context->info->call_node->arguments->arguments.size >= 1) { char* source_value = - extract_javascript_include_tag_src(parse_context->info->call_node, &parse_context->parser, allocator); + extract_javascript_include_tag_src(parse_context->info->call_node, parse_context->parser, allocator); if (source_value) { if (!attributes) { attributes = hb_array_init(4, allocator); } @@ -821,9 +843,9 @@ static AST_NODE_T* transform_tag_helper_with_attributes( } } - if (detect_image_tag(parse_context->info->call_node, &parse_context->parser) + if (detect_image_tag(parse_context->info->call_node, parse_context->parser) && parse_context->info->call_node->arguments && parse_context->info->call_node->arguments->arguments.size >= 1) { - char* source_value = extract_image_tag_src(parse_context->info->call_node, &parse_context->parser, allocator); + char* source_value = extract_image_tag_src(parse_context->info->call_node, parse_context->parser, allocator); if (source_value) { if (!attributes) { attributes = hb_array_init(4, allocator); } @@ -832,7 +854,7 @@ static AST_NODE_T* transform_tag_helper_with_attributes( position_T source_start, source_end; prism_node_location_to_positions(&first_argument->location, parse_context, &source_start, &source_end); bool source_is_string = (first_argument->type == PM_STRING_NODE); - bool source_is_path_helper = is_route_helper_node(first_argument, &parse_context->parser); + bool source_is_path_helper = is_route_helper_node(first_argument, parse_context->parser); size_t source_length = strlen(source_value); bool is_url = image_tag_source_is_url(source_value, source_length); @@ -865,7 +887,7 @@ static AST_NODE_T* transform_tag_helper_with_attributes( } } - if (detect_stylesheet_link_tag(parse_context->info->call_node, &parse_context->parser) + if (detect_stylesheet_link_tag(parse_context->info->call_node, parse_context->parser) && parse_context->info->call_node->arguments && parse_context->info->call_node->arguments->arguments.size >= 1) { pm_node_t* first_argument = parse_context->info->call_node->arguments->arguments.nodes[0]; @@ -1056,8 +1078,11 @@ static AST_NODE_T* create_javascript_include_tag_element( size_t length = pm_string_length(&string_node->unescaped); source_value = hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } else { - size_t source_length = source_argument->location.end - source_argument->location.start; - source_value = hb_allocator_strndup(allocator, (const char*) source_argument->location.start, source_length); + source_value = hb_allocator_strndup( + allocator, + (const char*) (parse_context->prism_source + source_argument->location.start), + source_argument->location.length + ); } position_T source_start, source_end; @@ -1164,8 +1189,12 @@ static hb_array_T* transform_javascript_include_tag_multi_source( if (source_count == 0) { return NULL; } - char* path_options = - extract_path_options_from_keyword_hash(call_node, JAVASCRIPT_INCLUDE_TAG_PATH_OPTIONS, allocator); + char* path_options = extract_path_options_from_keyword_hash( + call_node, + parse_context->prism_source, + JAVASCRIPT_INCLUDE_TAG_PATH_OPTIONS, + allocator + ); hb_array_T* elements = hb_array_init(source_count * 2, allocator); for (size_t i = 0; i < source_count; i++) { @@ -1264,7 +1293,12 @@ static hb_array_T* transform_stylesheet_link_tag_multi_source( if (source_count == 0) { return NULL; } - char* path_options = extract_path_options_from_keyword_hash(call_node, STYLESHEET_LINK_TAG_PATH_OPTIONS, allocator); + char* path_options = extract_path_options_from_keyword_hash( + call_node, + parse_context->prism_source, + STYLESHEET_LINK_TAG_PATH_OPTIONS, + allocator + ); hb_array_T* elements = hb_array_init(source_count * 2, allocator); for (size_t i = 0; i < source_count; i++) { @@ -1371,16 +1405,17 @@ static AST_NODE_T* transform_erb_block_to_tag_helper( resolve_nonce_attribute(attributes, allocator); } - if (detect_link_to(parse_context->info->call_node, &parse_context->parser) - && parse_context->info->call_node->arguments && parse_context->info->call_node->arguments->arguments.size >= 1) { + if (detect_link_to(parse_context->info->call_node, parse_context->parser) && parse_context->info->call_node->arguments + && parse_context->info->call_node->arguments->arguments.size >= 1) { pm_node_t* first_argument = parse_context->info->call_node->arguments->arguments.nodes[0]; - size_t source_length = first_argument->location.end - first_argument->location.start; + size_t source_length = first_argument->location.length; + const char* first_argument_source = (const char*) (parse_context->prism_source + first_argument->location.start); char* href = NULL; - if (first_argument->type != PM_STRING_NODE && !is_route_helper_node(first_argument, &parse_context->parser)) { - href = wrap_in_url_for((const char*) first_argument->location.start, source_length, allocator); + if (first_argument->type != PM_STRING_NODE && !is_route_helper_node(first_argument, parse_context->parser)) { + href = wrap_in_url_for(first_argument_source, source_length, allocator); } else { - href = hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + href = hb_allocator_strndup(allocator, first_argument_source, source_length); } if (href) { @@ -1406,8 +1441,8 @@ static AST_NODE_T* transform_erb_block_to_tag_helper( } } - if (detect_turbo_frame_tag(parse_context->info->call_node, &parse_context->parser)) { - char* id_value = extract_turbo_frame_tag_id(parse_context->info->call_node, &parse_context->parser, allocator); + if (detect_turbo_frame_tag(parse_context->info->call_node, parse_context->parser)) { + char* id_value = extract_turbo_frame_tag_id(parse_context->info->call_node, parse_context->parser, allocator); if (id_value) { if (!attributes) { attributes = hb_array_init(4, allocator); } @@ -1575,7 +1610,7 @@ static AST_NODE_T* transform_link_to_helper( hb_allocator_T* allocator = context->allocator; tag_helper_info_T* info = parse_context->info; - char* href = extract_link_to_href(info->call_node, &parse_context->parser, allocator); + char* href = extract_link_to_href(info->call_node, parse_context->parser, allocator); hb_array_T* attributes = NULL; pm_arguments_node_t* link_arguments = info->call_node->arguments; @@ -1603,8 +1638,12 @@ static AST_NODE_T* transform_link_to_helper( if (second_arg->type != PM_KEYWORD_HASH_NODE && second_arg->type != PM_HASH_NODE && second_arg->type != PM_STRING_NODE && second_arg->type != PM_SYMBOL_NODE) { - size_t source_length = second_arg->location.end - second_arg->location.start; - char* content = hb_allocator_strndup(allocator, (const char*) second_arg->location.start, source_length); + size_t source_length = second_arg->location.length; + char* content = hb_allocator_strndup( + allocator, + (const char*) (parse_context->prism_source + second_arg->location.start), + source_length + ); if (content) { hb_buffer_T wrapped; diff --git a/src/analyze/action_view/turbo_frame_tag.c b/src/analyze/action_view/turbo_frame_tag.c index 7236d31a2..5227566a8 100644 --- a/src/analyze/action_view/turbo_frame_tag.c +++ b/src/analyze/action_view/turbo_frame_tag.c @@ -24,14 +24,15 @@ char* extract_turbo_frame_tag_id(pm_call_node_t* call_node, pm_parser_t* parser, return hb_allocator_strndup(allocator, (const char*) pm_string_source(&symbol_node->unescaped), length); } - size_t source_length = first_argument->location.end - first_argument->location.start; - const char* source = (const char*) first_argument->location.start; + size_t source_length = first_argument->location.length; + const char* source = (const char*) (pm_parser_start(parser) + first_argument->location.start); if (first_argument->type == PM_CALL_NODE) { pm_call_node_t* call = (pm_call_node_t*) first_argument; - pm_constant_t* call_constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call->name); + const pm_constant_t* call_constant = pm_parser_constant(parser, call->name); - if (call_constant && call_constant->length == 6 && strncmp((const char*) call_constant->start, "dom_id", 6) == 0) { + if (call_constant && pm_constant_length(call_constant) == 6 + && strncmp((const char*) pm_constant_start(call_constant), "dom_id", 6) == 0) { return hb_allocator_strndup(allocator, source, source_length); } } diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index d8a7595c6..1282787f1 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1189,14 +1189,18 @@ static tag_helper_scope_T* tag_helper_scope_init(const char* source, hb_allocato return NULL; } - pm_options_partial_script_set(&scope->options, true); - pm_parser_init(&scope->parser, (const uint8_t*) scope->buffer.value, scope->buffer.length, &scope->options); + scope->arena = pm_arena_new(); + scope->options = pm_options_new(); + pm_options_partial_script_set(scope->options, true); + scope->parser = + pm_parser_new(scope->arena, (const uint8_t*) scope->buffer.value, scope->buffer.length, scope->options); - scope->root = pm_parse(&scope->parser); + scope->root = pm_parse(scope->parser); if (!scope->root) { - pm_parser_free(&scope->parser); - pm_options_free(&scope->options); + pm_parser_free(scope->parser); + pm_arena_free(scope->arena); + pm_options_free(scope->options); hb_buffer_free(&scope->buffer); hb_allocator_dealloc(allocator, scope); @@ -1209,9 +1213,9 @@ static tag_helper_scope_T* tag_helper_scope_init(const char* source, hb_allocato static void tag_helper_scope_free(tag_helper_scope_T* scope, hb_allocator_T* allocator) { if (!scope) { return; } - pm_node_destroy(&scope->parser, scope->root); - pm_parser_free(&scope->parser); - pm_options_free(&scope->options); + pm_parser_free(scope->parser); + pm_arena_free(scope->arena); + pm_options_free(scope->options); hb_buffer_free(&scope->buffer); hb_allocator_dealloc(allocator, scope); } diff --git a/src/analyze/analyze_helpers.c b/src/analyze/analyze_helpers.c index dde93a11f..71474eb32 100644 --- a/src/analyze/analyze_helpers.c +++ b/src/analyze/analyze_helpers.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -94,22 +95,21 @@ bool has_inline_case_condition(analyzed_ruby_T* analyzed) { } typedef struct { - const uint8_t* source_start; uint32_t offset; bool found; } inline_condition_offset_T; -static bool search_inline_condition_offset(const pm_node_t* node, void* data) { +static pm_visit_result_t search_inline_condition_offset(const pm_node_t* node, void* data) { inline_condition_offset_T* context = (inline_condition_offset_T*) data; uint32_t keyword_offset = UINT32_MAX; if (node->type == PM_WHEN_NODE) { - keyword_offset = (uint32_t) (((const pm_when_node_t*) node)->keyword_loc.start - context->source_start); + keyword_offset = ((const pm_when_node_t*) node)->when_keyword_loc.start; } else if (node->type == PM_IN_NODE) { - keyword_offset = (uint32_t) (((const pm_in_node_t*) node)->in_loc.start - context->source_start); + keyword_offset = ((const pm_in_node_t*) node)->in_keyword_loc.start; } else if (node->type == PM_MATCH_PREDICATE_NODE) { - keyword_offset = (uint32_t) (((const pm_match_predicate_node_t*) node)->operator_loc.start - context->source_start); + keyword_offset = ((const pm_match_predicate_node_t*) node)->keyword_loc.start; } if (keyword_offset != UINT32_MAX && (!context->found || keyword_offset < context->offset)) { @@ -119,7 +119,7 @@ static bool search_inline_condition_offset(const pm_node_t* node, void* data) { pm_visit_child_nodes(node, search_inline_condition_offset, context); - return false; + return PM_VISIT_SKIP; } static hb_string_T control_continuation_keywords[] = HB_STRING_LIST("else", "elsif", "when", "in", "rescue", "ensure"); @@ -157,19 +157,18 @@ bool control_role_split_offset(const analyzed_ruby_T* analyzed, uint32_t* offset uint32_t second = UINT32_MAX; bool first_continues = false; - for (const pm_diagnostic_t* diagnostic = (const pm_diagnostic_t*) analyzed->parser.error_list.head; - diagnostic != NULL; - diagnostic = (const pm_diagnostic_t*) diagnostic->node.next) { + const uint8_t* source = pm_parser_start(analyzed->parser); + + for (const pm_diagnostic_t* diagnostic = pm_parser_errors_first(analyzed->parser); diagnostic != NULL; + diagnostic = pm_diagnostic_next(diagnostic)) { if (diagnostic->diag_id != PM_ERR_UNEXPECTED_TOKEN_IGNORE) { continue; } - hb_string_T keyword = hb_string_from_data( - (const char*) diagnostic->location.start, - (size_t) (diagnostic->location.end - diagnostic->location.start) - ); + hb_string_T keyword = + hb_string_from_data((const char*) (source + diagnostic->location.start), diagnostic->location.length); if (!is_control_role_keyword(keyword)) { continue; } - uint32_t start = (uint32_t) (diagnostic->location.start - analyzed->parser.start); + uint32_t start = diagnostic->location.start; if (start < first) { second = first; @@ -203,7 +202,6 @@ bool inline_condition_keyword_offset(const analyzed_ruby_T* analyzed, uint32_t* if (!analyzed || !analyzed->root || !offset) { return false; } inline_condition_offset_T context = { - .source_start = analyzed->parser.start, .offset = UINT32_MAX, .found = false, }; @@ -218,89 +216,76 @@ bool inline_condition_keyword_offset(const analyzed_ruby_T* analyzed, uint32_t* } bool has_error_message(analyzed_ruby_T* analyzed, const char* message) { - for (const pm_diagnostic_t* error = (const pm_diagnostic_t*) analyzed->parser.error_list.head; error != NULL; - error = (const pm_diagnostic_t*) error->node.next) { - if (string_equals(error->message, message)) { return true; } + for (const pm_diagnostic_t* error = pm_parser_errors_first(analyzed->parser); error != NULL; + error = pm_diagnostic_next(error)) { + if (string_equals(pm_diagnostic_message(error), message)) { return true; } } return false; } -bool is_do_block(pm_location_t opening_location) { - size_t length = opening_location.end - opening_location.start; - - return length == 2 && opening_location.start[0] == 'd' && opening_location.start[1] == 'o'; +static bool location_matches(const uint8_t* source, pm_location_t location, const char* text, size_t length) { + return location.length == length && memcmp(source + location.start, text, length) == 0; } -bool is_brace_block(pm_location_t opening_location) { - size_t length = opening_location.end - opening_location.start; - - return length == 1 && opening_location.start[0] == '{'; +bool is_do_block(const uint8_t* source, pm_location_t opening_location) { + return location_matches(source, opening_location, "do", 2); } -static bool has_location(pm_location_t location) { - return location.start != NULL && location.end != NULL && (location.end - location.start) > 0; +bool is_brace_block(const uint8_t* source, pm_location_t opening_location) { + return location_matches(source, opening_location, "{", 1); } -static bool is_end_keyword(pm_location_t location) { - if (location.start == NULL || location.end == NULL) { return false; } - - size_t length = location.end - location.start; - - return length == 3 && location.start[0] == 'e' && location.start[1] == 'n' && location.start[2] == 'd'; +static bool is_end_keyword(const uint8_t* source, pm_location_t location) { + return location_matches(source, location, "end", 3); } -bool is_closing_brace(pm_location_t location) { - if (location.start == NULL || location.end == NULL) { return false; } - - size_t length = location.end - location.start; - - return length == 1 && location.start[0] == '}'; +bool is_closing_brace(const uint8_t* source, pm_location_t location) { + return location_matches(source, location, "}", 1); } -bool has_valid_block_closing(pm_location_t opening_loc, pm_location_t closing_loc) { - if (is_do_block(opening_loc)) { - return is_end_keyword(closing_loc); - } else if (is_brace_block(opening_loc)) { - return is_closing_brace(closing_loc); +bool has_valid_block_closing(const uint8_t* source, pm_location_t opening_loc, pm_location_t closing_loc) { + if (is_do_block(source, opening_loc)) { + return is_end_keyword(source, closing_loc); + } else if (is_brace_block(source, opening_loc)) { + return is_closing_brace(source, closing_loc); } return false; } -static bool has_keyword_location(pm_location_t location) { - return location.start != NULL && location.end != NULL; -} - -static bool is_unclosed_block(pm_location_t opening_loc, pm_location_t closing_loc) { - bool has_opening = is_do_block(opening_loc) || is_brace_block(opening_loc); +static bool is_unclosed_block(const uint8_t* source, pm_location_t opening_loc, pm_location_t closing_loc) { + bool has_opening = is_do_block(source, opening_loc) || is_brace_block(source, opening_loc); - return has_opening && !has_valid_block_closing(opening_loc, closing_loc); + return has_opening && !has_valid_block_closing(source, opening_loc, closing_loc); } -bool search_control_flow_nodes(const pm_node_t* node, void* data) { +pm_visit_result_t search_control_flow_nodes(const pm_node_t* node, void* data) { analyzed_ruby_T* analyzed = (analyzed_ruby_T*) data; + const uint8_t* source = pm_parser_start(analyzed->parser); switch (node->type) { case PM_IF_NODE: { const pm_if_node_t* if_node = (const pm_if_node_t*) node; - if (has_keyword_location(if_node->if_keyword_loc) && has_keyword_location(if_node->end_keyword_loc)) { + if (herb_prism_location_assigned(if_node->if_keyword_loc) + && herb_prism_location_assigned(if_node->end_keyword_loc)) { analyzed->if_node_count++; } - if (has_keyword_location(if_node->then_keyword_loc)) { analyzed->then_keyword_count++; } + if (herb_prism_location_assigned(if_node->then_keyword_loc)) { analyzed->then_keyword_count++; } break; } case PM_UNLESS_NODE: { const pm_unless_node_t* unless_node = (const pm_unless_node_t*) node; - if (has_keyword_location(unless_node->keyword_loc) && has_keyword_location(unless_node->end_keyword_loc)) { + if (herb_prism_location_assigned(unless_node->unless_keyword_loc) + && herb_prism_location_assigned(unless_node->end_keyword_loc)) { analyzed->unless_node_count++; } - if (has_keyword_location(unless_node->then_keyword_loc)) { analyzed->then_keyword_count++; } + if (herb_prism_location_assigned(unless_node->then_keyword_loc)) { analyzed->then_keyword_count++; } break; } @@ -309,21 +294,23 @@ bool search_control_flow_nodes(const pm_node_t* node, void* data) { analyzed->when_node_count++; - if (has_keyword_location(when_node->then_keyword_loc)) { analyzed->then_keyword_count++; } + if (herb_prism_location_assigned(when_node->then_keyword_loc)) { analyzed->then_keyword_count++; } break; } case PM_BLOCK_NODE: { const pm_block_node_t* block_node = (const pm_block_node_t*) node; - if (is_unclosed_block(block_node->opening_loc, block_node->closing_loc)) { analyzed->block_node_count++; } + if (is_unclosed_block(source, block_node->opening_loc, block_node->closing_loc)) { analyzed->block_node_count++; } break; } case PM_LAMBDA_NODE: { const pm_lambda_node_t* lambda_node = (const pm_lambda_node_t*) node; - if (is_unclosed_block(lambda_node->opening_loc, lambda_node->closing_loc)) { analyzed->block_node_count++; } + if (is_unclosed_block(source, lambda_node->opening_loc, lambda_node->closing_loc)) { + analyzed->block_node_count++; + } break; } @@ -351,7 +338,7 @@ bool search_control_flow_nodes(const pm_node_t* node, void* data) { pm_visit_child_nodes(node, search_control_flow_nodes, analyzed); - return false; + return PM_VISIT_SKIP; } void search_unexpected_keyword_errors(analyzed_ruby_T* analyzed) { @@ -365,9 +352,9 @@ void search_unexpected_keyword_errors(analyzed_ruby_T* analyzed) { bool unexpected_rescue = false; bool unexpected_ensure = false; - for (const pm_diagnostic_t* error = (const pm_diagnostic_t*) analyzed->parser.error_list.head; error != NULL; - error = (const pm_diagnostic_t*) error->node.next) { - const char* message = error->message; + for (const pm_diagnostic_t* error = pm_parser_errors_first(analyzed->parser); error != NULL; + error = pm_diagnostic_next(error)) { + const char* message = pm_diagnostic_message(error); if (string_equals(message, "unexpected 'elsif', ignoring it")) { unexpected_elsif = true; @@ -406,16 +393,17 @@ static bool is_postfix_conditional(const pm_statements_node_t* statements, pm_lo return statements->base.location.start < keyword_location.start; } -bool search_unclosed_control_flows(const pm_node_t* node, void* data) { +pm_visit_result_t search_unclosed_control_flows(const pm_node_t* node, void* data) { analyzed_ruby_T* analyzed = (analyzed_ruby_T*) data; + const uint8_t* source = pm_parser_start(analyzed->parser); - if (analyzed->unclosed_control_flow_count >= 2) { return false; } + if (analyzed->unclosed_control_flow_count >= 2) { return PM_VISIT_SKIP; } switch (node->type) { case PM_IF_NODE: { const pm_if_node_t* if_node = (const pm_if_node_t*) node; - if (has_location(if_node->if_keyword_loc) && !is_end_keyword(if_node->end_keyword_loc)) { + if (herb_prism_location_present(if_node->if_keyword_loc) && !is_end_keyword(source, if_node->end_keyword_loc)) { if (!is_postfix_conditional(if_node->statements, if_node->if_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -427,8 +415,9 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_UNLESS_NODE: { const pm_unless_node_t* unless_node = (const pm_unless_node_t*) node; - if (has_location(unless_node->keyword_loc) && !is_end_keyword(unless_node->end_keyword_loc)) { - if (!is_postfix_conditional(unless_node->statements, unless_node->keyword_loc)) { + if (herb_prism_location_present(unless_node->unless_keyword_loc) + && !is_end_keyword(source, unless_node->end_keyword_loc)) { + if (!is_postfix_conditional(unless_node->statements, unless_node->unless_keyword_loc)) { analyzed->unclosed_control_flow_count++; } } @@ -439,7 +428,8 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_CASE_NODE: { const pm_case_node_t* case_node = (const pm_case_node_t*) node; - if (has_location(case_node->case_keyword_loc) && !is_end_keyword(case_node->end_keyword_loc)) { + if (herb_prism_location_present(case_node->case_keyword_loc) + && !is_end_keyword(source, case_node->end_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -449,7 +439,8 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_CASE_MATCH_NODE: { const pm_case_match_node_t* case_match_node = (const pm_case_match_node_t*) node; - if (has_location(case_match_node->case_keyword_loc) && !is_end_keyword(case_match_node->end_keyword_loc)) { + if (herb_prism_location_present(case_match_node->case_keyword_loc) + && !is_end_keyword(source, case_match_node->end_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -459,7 +450,8 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_WHILE_NODE: { const pm_while_node_t* while_node = (const pm_while_node_t*) node; - if (has_location(while_node->keyword_loc) && !is_end_keyword(while_node->closing_loc)) { + if (herb_prism_location_present(while_node->while_keyword_loc) + && !is_end_keyword(source, while_node->end_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -469,7 +461,8 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_UNTIL_NODE: { const pm_until_node_t* until_node = (const pm_until_node_t*) node; - if (has_location(until_node->keyword_loc) && !is_end_keyword(until_node->closing_loc)) { + if (herb_prism_location_present(until_node->until_keyword_loc) + && !is_end_keyword(source, until_node->end_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -479,7 +472,8 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_FOR_NODE: { const pm_for_node_t* for_node = (const pm_for_node_t*) node; - if (has_location(for_node->for_keyword_loc) && !is_end_keyword(for_node->end_keyword_loc)) { + if (herb_prism_location_present(for_node->for_keyword_loc) + && !is_end_keyword(source, for_node->end_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -489,7 +483,8 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_BEGIN_NODE: { const pm_begin_node_t* begin_node = (const pm_begin_node_t*) node; - if (has_location(begin_node->begin_keyword_loc) && !is_end_keyword(begin_node->end_keyword_loc)) { + if (herb_prism_location_present(begin_node->begin_keyword_loc) + && !is_end_keyword(source, begin_node->end_keyword_loc)) { analyzed->unclosed_control_flow_count++; } @@ -498,9 +493,10 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_BLOCK_NODE: { const pm_block_node_t* block_node = (const pm_block_node_t*) node; - bool has_opening = is_do_block(block_node->opening_loc) || is_brace_block(block_node->opening_loc); + bool has_opening = + is_do_block(source, block_node->opening_loc) || is_brace_block(source, block_node->opening_loc); - if (has_opening && !has_valid_block_closing(block_node->opening_loc, block_node->closing_loc)) { + if (has_opening && !has_valid_block_closing(source, block_node->opening_loc, block_node->closing_loc)) { analyzed->unclosed_control_flow_count++; } @@ -509,9 +505,10 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { case PM_LAMBDA_NODE: { const pm_lambda_node_t* lambda_node = (const pm_lambda_node_t*) node; - bool has_opening = is_do_block(lambda_node->opening_loc) || is_brace_block(lambda_node->opening_loc); + bool has_opening = + is_do_block(source, lambda_node->opening_loc) || is_brace_block(source, lambda_node->opening_loc); - if (has_opening && !has_valid_block_closing(lambda_node->opening_loc, lambda_node->closing_loc)) { + if (has_opening && !has_valid_block_closing(source, lambda_node->opening_loc, lambda_node->closing_loc)) { analyzed->unclosed_control_flow_count++; } @@ -523,7 +520,7 @@ bool search_unclosed_control_flows(const pm_node_t* node, void* data) { pm_visit_child_nodes(node, search_unclosed_control_flows, analyzed); - return false; + return PM_VISIT_SKIP; } static pm_block_node_t* find_first_block_node(pm_node_t* node) { @@ -552,28 +549,21 @@ static pm_block_node_t* find_first_block_node(pm_node_t* node) { return NULL; } -static position_T prism_to_source_position( - const uint8_t* prism_pointer, - const uint8_t* prism_source_start, - size_t source_base_offset, - const char* source -) { - if (!source || !prism_source_start) { return (position_T) { .line = 1, .column = 0 }; } +static position_T prism_to_source_position(uint32_t prism_offset, size_t source_base_offset, const char* source) { + if (!source) { return (position_T) { .line = 1, .column = 0 }; } - size_t prism_offset = (size_t) (prism_pointer - prism_source_start); return byte_offset_to_position(source, source_base_offset + prism_offset); } static token_T* create_parameter_name_token( pm_location_t location, const char* name, - const uint8_t* prism_source_start, size_t source_base_offset, const char* source, hb_allocator_T* allocator ) { - position_T start = prism_to_source_position(location.start, prism_source_start, source_base_offset, source); - position_T end = prism_to_source_position(location.end, prism_source_start, source_base_offset, source); + position_T start = prism_to_source_position(location.start, source_base_offset, source); + position_T end = prism_to_source_position(herb_prism_location_end(location), source_base_offset, source); return create_synthetic_token(allocator, name, TOKEN_IDENTIFIER, start, end); } @@ -639,20 +629,21 @@ static void append_multi_target_parameters( if (splat->expression && splat->expression->type == PM_REQUIRED_PARAMETER_NODE) { pm_required_parameter_node_t* required = (pm_required_parameter_node_t*) splat->expression; - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, required->name); + const pm_constant_t* constant = pm_parser_constant(parser, required->name); if (constant) { - char* name = hb_allocator_strndup(allocator, (const char*) constant->start, constant->length); + char* name = + hb_allocator_strndup(allocator, (const char*) pm_constant_start(constant), pm_constant_length(constant)); pm_node_t* node = splat->expression; append_parameter( result, - create_parameter_name_token(node->location, name, prism_source_start, source_base_offset, source, allocator), + create_parameter_name_token(node->location, name, source_base_offset, source, allocator), NULL, "rest", false, - prism_to_source_position(node->location.start, prism_source_start, source_base_offset, source), - prism_to_source_position(node->location.end, prism_source_start, source_base_offset, source), + prism_to_source_position(node->location.start, source_base_offset, source), + prism_to_source_position(herb_prism_location_end(node->location), source_base_offset, source), allocator ); @@ -700,19 +691,19 @@ static void append_required_positional( if (node->type != PM_REQUIRED_PARAMETER_NODE) { return; } pm_required_parameter_node_t* required = (pm_required_parameter_node_t*) node; - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, required->name); + const pm_constant_t* constant = pm_parser_constant(parser, required->name); if (!constant) { return; } - char* name = hb_allocator_strndup(allocator, (const char*) constant->start, constant->length); + char* name = hb_allocator_strndup(allocator, (const char*) pm_constant_start(constant), pm_constant_length(constant)); append_parameter( result, - create_parameter_name_token(node->location, name, prism_source_start, source_base_offset, source, allocator), + create_parameter_name_token(node->location, name, source_base_offset, source, allocator), NULL, "positional", true, - prism_to_source_position(node->location.start, prism_source_start, source_base_offset, source), - prism_to_source_position(node->location.end, prism_source_start, source_base_offset, source), + prism_to_source_position(node->location.start, source_base_offset, source), + prism_to_source_position(herb_prism_location_end(node->location), source_base_offset, source), allocator ); @@ -755,21 +746,25 @@ hb_array_T* extract_parameters_from_prism( if (node->type != PM_OPTIONAL_PARAMETER_NODE) { continue; } pm_optional_parameter_node_t* optional = (pm_optional_parameter_node_t*) node; - size_t name_length = (size_t) (optional->name_loc.end - optional->name_loc.start); - char* name = hb_allocator_strndup(allocator, (const char*) optional->name_loc.start, name_length); + size_t name_length = optional->name_loc.length; + char* name = + hb_allocator_strndup(allocator, (const char*) (prism_source_start + optional->name_loc.start), name_length); - position_T start = prism_to_source_position(node->location.start, prism_source_start, source_base_offset, source); - position_T end = prism_to_source_position(node->location.end, prism_source_start, source_base_offset, source); + position_T start = prism_to_source_position(node->location.start, source_base_offset, source); + position_T end = prism_to_source_position(herb_prism_location_end(node->location), source_base_offset, source); AST_RUBY_LITERAL_NODE_T* default_value = NULL; if (optional->value) { - size_t value_length = (size_t) (optional->value->location.end - optional->value->location.start); - char* value_string = hb_allocator_strndup(allocator, (const char*) optional->value->location.start, value_length); - position_T value_start = - prism_to_source_position(optional->value->location.start, prism_source_start, source_base_offset, source); + size_t value_length = optional->value->location.length; + char* value_string = hb_allocator_strndup( + allocator, + (const char*) (prism_source_start + optional->value->location.start), + value_length + ); + position_T value_start = prism_to_source_position(optional->value->location.start, source_base_offset, source); position_T value_end = - prism_to_source_position(optional->value->location.end, prism_source_start, source_base_offset, source); + prism_to_source_position(herb_prism_location_end(optional->value->location), source_base_offset, source); default_value = ast_ruby_literal_node_init( hb_string_from_c_string(value_string), @@ -783,7 +778,7 @@ hb_array_T* extract_parameters_from_prism( append_parameter( result, - create_parameter_name_token(optional->name_loc, name, prism_source_start, source_base_offset, source, allocator), + create_parameter_name_token(optional->name_loc, name, source_base_offset, source, allocator), default_value, "positional", false, @@ -800,17 +795,17 @@ hb_array_T* extract_parameters_from_prism( pm_rest_parameter_node_t* rest = (pm_rest_parameter_node_t*) parameters->rest; if (rest->name) { - size_t name_length = (size_t) (rest->name_loc.end - rest->name_loc.start); - char* name = hb_allocator_strndup(allocator, (const char*) rest->name_loc.start, name_length); + size_t name_length = rest->name_loc.length; + char* name = + hb_allocator_strndup(allocator, (const char*) (prism_source_start + rest->name_loc.start), name_length); - position_T start = - prism_to_source_position(parameters->rest->location.start, prism_source_start, source_base_offset, source); + position_T start = prism_to_source_position(parameters->rest->location.start, source_base_offset, source); position_T end = - prism_to_source_position(parameters->rest->location.end, prism_source_start, source_base_offset, source); + prism_to_source_position(herb_prism_location_end(parameters->rest->location), source_base_offset, source); append_parameter( result, - create_parameter_name_token(rest->name_loc, name, prism_source_start, source_base_offset, source, allocator), + create_parameter_name_token(rest->name_loc, name, source_base_offset, source, allocator), NULL, "rest", false, @@ -827,8 +822,8 @@ hb_array_T* extract_parameters_from_prism( NULL, "rest", false, - prism_to_source_position(parameters->rest->location.start, prism_source_start, source_base_offset, source), - prism_to_source_position(parameters->rest->location.end, prism_source_start, source_base_offset, source), + prism_to_source_position(parameters->rest->location.start, source_base_offset, source), + prism_to_source_position(herb_prism_location_end(parameters->rest->location), source_base_offset, source), allocator ); } @@ -863,21 +858,18 @@ hb_array_T* extract_parameters_from_prism( name_location = optional_keyword->name_loc; if (optional_keyword->value) { - size_t value_length = - (size_t) (optional_keyword->value->location.end - optional_keyword->value->location.start); - char* value_string = - hb_allocator_strndup(allocator, (const char*) optional_keyword->value->location.start, value_length); - - position_T value_start = prism_to_source_position( - optional_keyword->value->location.start, - prism_source_start, - source_base_offset, - source + size_t value_length = optional_keyword->value->location.length; + char* value_string = hb_allocator_strndup( + allocator, + (const char*) (prism_source_start + optional_keyword->value->location.start), + value_length ); + position_T value_start = + prism_to_source_position(optional_keyword->value->location.start, source_base_offset, source); + position_T value_end = prism_to_source_position( - optional_keyword->value->location.end, - prism_source_start, + herb_prism_location_end(optional_keyword->value->location), source_base_offset, source ); @@ -896,17 +888,16 @@ hb_array_T* extract_parameters_from_prism( continue; } - size_t name_length = (size_t) (name_location.end - name_location.start); - if (name_length > 0 && name_location.start[name_length - 1] == ':') { name_length--; } - char* name = hb_allocator_strndup(allocator, (const char*) name_location.start, name_length); + size_t name_length = name_location.length; + if (name_length > 0 && prism_source_start[name_location.start + name_length - 1] == ':') { name_length--; } + char* name = hb_allocator_strndup(allocator, (const char*) (prism_source_start + name_location.start), name_length); - position_T start = - prism_to_source_position(keyword->location.start, prism_source_start, source_base_offset, source); - position_T end = prism_to_source_position(keyword->location.end, prism_source_start, source_base_offset, source); + position_T start = prism_to_source_position(keyword->location.start, source_base_offset, source); + position_T end = prism_to_source_position(herb_prism_location_end(keyword->location), source_base_offset, source); append_parameter( result, - create_parameter_name_token(name_location, name, prism_source_start, source_base_offset, source, allocator), + create_parameter_name_token(name_location, name, source_base_offset, source, allocator), default_value, "keyword", is_required, @@ -922,30 +913,19 @@ hb_array_T* extract_parameters_from_prism( if (parameters->keyword_rest && parameters->keyword_rest->type == PM_KEYWORD_REST_PARAMETER_NODE) { pm_keyword_rest_parameter_node_t* keyword_rest = (pm_keyword_rest_parameter_node_t*) parameters->keyword_rest; - position_T start = prism_to_source_position( - parameters->keyword_rest->location.start, - prism_source_start, - source_base_offset, - source - ); + position_T start = prism_to_source_position(parameters->keyword_rest->location.start, source_base_offset, source); position_T end = - prism_to_source_position(parameters->keyword_rest->location.end, prism_source_start, source_base_offset, source); + prism_to_source_position(herb_prism_location_end(parameters->keyword_rest->location), source_base_offset, source); if (keyword_rest->name) { - size_t name_length = (size_t) (keyword_rest->name_loc.end - keyword_rest->name_loc.start); - char* name = hb_allocator_strndup(allocator, (const char*) keyword_rest->name_loc.start, name_length); + size_t name_length = keyword_rest->name_loc.length; + char* name = + hb_allocator_strndup(allocator, (const char*) (prism_source_start + keyword_rest->name_loc.start), name_length); append_parameter( result, - create_parameter_name_token( - keyword_rest->name_loc, - name, - prism_source_start, - source_base_offset, - source, - allocator - ), + create_parameter_name_token(keyword_rest->name_loc, name, source_base_offset, source, allocator), NULL, "keyword_rest", false, @@ -962,28 +942,21 @@ hb_array_T* extract_parameters_from_prism( } // Block: |&blk| - if (parameters->block) { - pm_block_parameter_node_t* block_param = parameters->block; + if (parameters->block && parameters->block->type == PM_BLOCK_PARAMETER_NODE) { + pm_block_parameter_node_t* block_param = (pm_block_parameter_node_t*) parameters->block; if (block_param->name) { - size_t name_length = (size_t) (block_param->name_loc.end - block_param->name_loc.start); - char* name = hb_allocator_strndup(allocator, (const char*) block_param->name_loc.start, name_length); + size_t name_length = block_param->name_loc.length; + char* name = + hb_allocator_strndup(allocator, (const char*) (prism_source_start + block_param->name_loc.start), name_length); - position_T start = - prism_to_source_position(block_param->base.location.start, prism_source_start, source_base_offset, source); + position_T start = prism_to_source_position(block_param->base.location.start, source_base_offset, source); position_T end = - prism_to_source_position(block_param->base.location.end, prism_source_start, source_base_offset, source); + prism_to_source_position(herb_prism_location_end(block_param->base.location), source_base_offset, source); append_parameter( result, - create_parameter_name_token( - block_param->name_loc, - name, - prism_source_start, - source_base_offset, - source, - allocator - ), + create_parameter_name_token(block_param->name_loc, name, source_base_offset, source, allocator), NULL, "block", false, @@ -1000,8 +973,8 @@ hb_array_T* extract_parameters_from_prism( NULL, "block", false, - prism_to_source_position(block_param->base.location.start, prism_source_start, source_base_offset, source), - prism_to_source_position(block_param->base.location.end, prism_source_start, source_base_offset, source), + prism_to_source_position(block_param->base.location.start, source_base_offset, source), + prism_to_source_position(herb_prism_location_end(block_param->base.location), source_base_offset, source), allocator ); } @@ -1018,7 +991,7 @@ hb_array_T* extract_block_arguments_from_erb_node( ) { if (!erb_node || !erb_node->analyzed_ruby || !erb_node->analyzed_ruby->parsed) { return hb_array_init(0, allocator); } - pm_parser_t* parser = &erb_node->analyzed_ruby->parser; + pm_parser_t* parser = erb_node->analyzed_ruby->parser; pm_block_node_t* block_node = find_first_block_node(erb_node->analyzed_ruby->root); if (!block_node || !block_node->parameters) { return hb_array_init(0, allocator); } @@ -1031,17 +1004,17 @@ hb_array_T* extract_block_arguments_from_erb_node( erb_content_offset = calculate_byte_offset_from_position(source, erb_node->content->location.start); } - const uint8_t* prism_source_start = (const uint8_t*) parser->start; + const uint8_t* prism_source_start = pm_parser_start(parser); if (errors) { - for (const pm_diagnostic_t* error = (const pm_diagnostic_t*) parser->error_list.head; error != NULL; - error = (const pm_diagnostic_t*) error->node.next) { + for (const pm_diagnostic_t* error = pm_parser_errors_first(parser); error != NULL; + error = pm_diagnostic_next(error)) { if (error->diag_id == PM_ERR_BLOCK_TERM_END) { continue; } if (error->diag_id == PM_ERR_BLOCK_TERM_BRACE) { continue; } if (error->diag_id == PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT) { continue; } - size_t error_start_offset = (size_t) (error->location.start - prism_source_start); - size_t error_end_offset = (size_t) (error->location.end - prism_source_start); + size_t error_start_offset = error->location.start; + size_t error_end_offset = herb_prism_location_end(error->location); position_T error_start = byte_offset_to_position(source, erb_content_offset + error_start_offset); position_T error_end = byte_offset_to_position(source, erb_content_offset + error_end_offset); @@ -1100,7 +1073,7 @@ static bool is_plain_decimal_integer(hb_string_T source) { return true; } -static bool prism_node_static_output(const pm_node_t* node, hb_string_T* output) { +static bool prism_node_static_output(const uint8_t* source, const pm_node_t* node, hb_string_T* output) { if (!node || !output) { return false; } switch (node->type) { @@ -1119,12 +1092,11 @@ static bool prism_node_static_output(const pm_node_t* node, hb_string_T* output) } case PM_INTEGER_NODE: { - hb_string_T source = - hb_string_from_data((const char*) node->location.start, (size_t) (node->location.end - node->location.start)); + hb_string_T integer = hb_string_from_data((const char*) (source + node->location.start), node->location.length); - if (!is_plain_decimal_integer(source)) { return false; } + if (!is_plain_decimal_integer(integer)) { return false; } - *output = source; + *output = integer; break; } @@ -1173,17 +1145,18 @@ bool append_static_output_node( if (body->body.size != 1) { return false; } const pm_node_t* literal = body->body.nodes[0]; - const uint8_t* parser_start = analyzed->parser.start; + const uint8_t* parser_start = pm_parser_start(analyzed->parser); + size_t source_length = (size_t) (pm_parser_end(analyzed->parser) - parser_start); - if (literal->location.start < parser_start || literal->location.end > analyzed->parser.end) { return false; } + if (herb_prism_location_end(literal->location) > source_length) { return false; } hb_string_T content; - if (!prism_node_static_output(literal, &content)) { return false; } + if (!prism_node_static_output(parser_start, literal, &content)) { return false; } if (content.length == 0) { return true; } - size_t offset = (size_t) (literal->location.start - parser_start); - size_t length = (size_t) (literal->location.end - literal->location.start); + size_t offset = literal->location.start; + size_t length = literal->location.length; position_T start_position = { .line = content_start.line, .column = content_start.column + (uint32_t) offset }; position_T end_position = { .line = content_start.line, diff --git a/src/analyze/analyzed_ruby.c b/src/analyze/analyzed_ruby.c index 22612b67c..be81b1964 100644 --- a/src/analyze/analyzed_ruby.c +++ b/src/analyze/analyzed_ruby.c @@ -9,10 +9,11 @@ analyzed_ruby_T* init_analyzed_ruby(hb_string_T source) { if (!analyzed) { return NULL; } - pm_parser_init(&analyzed->parser, (const uint8_t*) source.data, source.length, NULL); + analyzed->arena = pm_arena_new(); + analyzed->parser = pm_parser_new(analyzed->arena, (const uint8_t*) source.data, source.length, NULL); - analyzed->root = pm_parse(&analyzed->parser); - analyzed->valid = (analyzed->parser.error_list.size == 0); + analyzed->root = pm_parse(analyzed->parser); + analyzed->valid = (pm_parser_errors_size(analyzed->parser) == 0); analyzed->parsed = true; analyzed->if_node_count = 0; analyzed->elsif_node_count = 0; @@ -43,9 +44,8 @@ analyzed_ruby_T* init_analyzed_ruby(hb_string_T source) { void free_analyzed_ruby(analyzed_ruby_T* analyzed) { if (!analyzed) { return; } - if (analyzed->parsed && analyzed->root != NULL) { pm_node_destroy(&analyzed->parser, analyzed->root); } - - pm_parser_free(&analyzed->parser); + pm_parser_free(analyzed->parser); + pm_arena_free(analyzed->arena); free(analyzed); } diff --git a/src/analyze/control_type.c b/src/analyze/control_type.c index fbff894b4..fbf23e68f 100644 --- a/src/analyze/control_type.c +++ b/src/analyze/control_type.c @@ -6,6 +6,8 @@ #include "../include/errors.h" #include "../include/lib/hb_array.h" +#include "../include/prism/prism_helpers.h" + #include #include #include @@ -29,8 +31,8 @@ static bool control_type_is_yield(control_type_t type) { return type == CONTROL_TYPE_YIELD; } -static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* data) { - if (!node) { return true; } +static pm_visit_result_t find_earliest_control_keyword_walker(const pm_node_t* node, void* data) { + if (!node) { return PM_VISIT_DESCEND; } location_walker_context_T* context = (location_walker_context_T*) data; earliest_control_keyword_T* result = context->result; @@ -41,50 +43,52 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da switch (node->type) { case PM_IF_NODE: { pm_if_node_t* if_node = (pm_if_node_t*) node; + if (!herb_prism_location_assigned(if_node->if_keyword_loc)) { break; } + current_type = CONTROL_TYPE_IF; - keyword_offset = (uint32_t) (if_node->if_keyword_loc.start - context->source_start); + keyword_offset = if_node->if_keyword_loc.start; break; } case PM_UNLESS_NODE: { pm_unless_node_t* unless_node = (pm_unless_node_t*) node; current_type = CONTROL_TYPE_UNLESS; - keyword_offset = (uint32_t) (unless_node->keyword_loc.start - context->source_start); + keyword_offset = unless_node->unless_keyword_loc.start; break; } case PM_CASE_NODE: { pm_case_node_t* case_node = (pm_case_node_t*) node; current_type = CONTROL_TYPE_CASE; - keyword_offset = (uint32_t) (case_node->case_keyword_loc.start - context->source_start); + keyword_offset = case_node->case_keyword_loc.start; break; } case PM_CASE_MATCH_NODE: { pm_case_match_node_t* case_match_node = (pm_case_match_node_t*) node; current_type = CONTROL_TYPE_CASE_MATCH; - keyword_offset = (uint32_t) (case_match_node->case_keyword_loc.start - context->source_start); + keyword_offset = case_match_node->case_keyword_loc.start; break; } case PM_WHILE_NODE: { pm_while_node_t* while_node = (pm_while_node_t*) node; current_type = CONTROL_TYPE_WHILE; - keyword_offset = (uint32_t) (while_node->keyword_loc.start - context->source_start); + keyword_offset = while_node->while_keyword_loc.start; break; } case PM_UNTIL_NODE: { pm_until_node_t* until_node = (pm_until_node_t*) node; current_type = CONTROL_TYPE_UNTIL; - keyword_offset = (uint32_t) (until_node->keyword_loc.start - context->source_start); + keyword_offset = until_node->until_keyword_loc.start; break; } case PM_FOR_NODE: { pm_for_node_t* for_node = (pm_for_node_t*) node; current_type = CONTROL_TYPE_FOR; - keyword_offset = (uint32_t) (for_node->for_keyword_loc.start - context->source_start); + keyword_offset = for_node->for_keyword_loc.start; break; } @@ -92,17 +96,17 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da pm_begin_node_t* begin_node = (pm_begin_node_t*) node; current_type = CONTROL_TYPE_BEGIN; - if (begin_node->begin_keyword_loc.start != NULL) { - keyword_offset = (uint32_t) (begin_node->begin_keyword_loc.start - context->source_start); + if (herb_prism_location_assigned(begin_node->begin_keyword_loc)) { + keyword_offset = begin_node->begin_keyword_loc.start; } else { - keyword_offset = (uint32_t) (node->location.start - context->source_start); + keyword_offset = node->location.start; } break; } case PM_YIELD_NODE: { current_type = CONTROL_TYPE_YIELD; - keyword_offset = (uint32_t) (node->location.start - context->source_start); + keyword_offset = node->location.start; break; } @@ -112,12 +116,14 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da if (call->block != NULL && call->block->type == PM_BLOCK_NODE) { pm_block_node_t* block_node = (pm_block_node_t*) call->block; - bool has_opening = is_do_block(block_node->opening_loc) || is_brace_block(block_node->opening_loc); - bool is_unclosed = !has_valid_block_closing(block_node->opening_loc, block_node->closing_loc); + bool has_opening = is_do_block(context->source_start, block_node->opening_loc) + || is_brace_block(context->source_start, block_node->opening_loc); + bool is_unclosed = + !has_valid_block_closing(context->source_start, block_node->opening_loc, block_node->closing_loc); if (has_opening && is_unclosed) { current_type = CONTROL_TYPE_BLOCK; - keyword_offset = (uint32_t) (node->location.start - context->source_start); + keyword_offset = node->location.start; } } break; @@ -126,12 +132,13 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da case PM_LAMBDA_NODE: { pm_lambda_node_t* lambda = (pm_lambda_node_t*) node; - bool has_opening = is_do_block(lambda->opening_loc) || is_brace_block(lambda->opening_loc); - bool is_unclosed = !has_valid_block_closing(lambda->opening_loc, lambda->closing_loc); + bool has_opening = is_do_block(context->source_start, lambda->opening_loc) + || is_brace_block(context->source_start, lambda->opening_loc); + bool is_unclosed = !has_valid_block_closing(context->source_start, lambda->opening_loc, lambda->closing_loc); if (has_opening && is_unclosed) { current_type = CONTROL_TYPE_BLOCK; - keyword_offset = (uint32_t) (node->location.start - context->source_start); + keyword_offset = node->location.start; } break; @@ -141,7 +148,7 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da case PM_BREAK_NODE: case PM_RETURN_NODE: { current_type = CONTROL_TYPE_UNKNOWN; - keyword_offset = (uint32_t) (node->location.start - context->source_start); + keyword_offset = node->location.start; break; } @@ -166,7 +173,7 @@ static bool find_earliest_control_keyword_walker(const pm_node_t* node, void* da } } - return true; + return PM_VISIT_DESCEND; } static control_type_t find_earliest_control_keyword(pm_node_t* root, const uint8_t* source_start) { @@ -210,7 +217,7 @@ static control_type_t detect_analyzed_control_type(analyzed_ruby_T* ruby) { if (ruby->unclosed_control_flow_count == 0 && !has_yield_node(ruby)) { return CONTROL_TYPE_UNKNOWN; } - return find_earliest_control_keyword(root, ruby->parser.start); + return find_earliest_control_keyword(root, pm_parser_start(ruby->parser)); } control_type_t detect_control_type(AST_ERB_CONTENT_NODE_T* erb_node) { diff --git a/src/analyze/herb_directives.c b/src/analyze/herb_directives.c index 23ce52294..f79f10055 100644 --- a/src/analyze/herb_directives.c +++ b/src/analyze/herb_directives.c @@ -17,6 +17,7 @@ #include "../include/prism/prism_helpers.h" #include +#include #include #include @@ -152,14 +153,11 @@ hb_string_T herb_directive_kind_for_prism_node(const pm_node_t* node) { } typedef struct { - const uint8_t* synthetic_start; size_t signature_start; size_t prefix_length; } synthetic_mapping_T; -static size_t synthetic_to_content_offset(const synthetic_mapping_T* mapping, const uint8_t* pointer) { - size_t offset = (size_t) (pointer - mapping->synthetic_start); - +static size_t synthetic_to_content_offset(const synthetic_mapping_T* mapping, uint32_t offset) { if (offset < mapping->prefix_length) { return mapping->signature_start; } return mapping->signature_start + offset - mapping->prefix_length; @@ -172,7 +170,7 @@ static AST_RUBY_LITERAL_NODE_T* create_default_value_node( hb_allocator_T* allocator ) { size_t start = synthetic_to_content_offset(mapping, value->location.start); - size_t end = synthetic_to_content_offset(mapping, value->location.end); + size_t end = synthetic_to_content_offset(mapping, herb_prism_location_end(value->location)); char* source = hb_allocator_strndup(allocator, content->bytes + start, end - start); @@ -212,12 +210,12 @@ static void append_state_declaration( } size_t name_start = synthetic_to_content_offset(mapping, name_location.start); - size_t name_end = synthetic_to_content_offset(mapping, name_location.end); + size_t name_end = synthetic_to_content_offset(mapping, herb_prism_location_end(name_location)); if (name_end > name_start && content->bytes[name_end - 1] == ':') { name_end--; } size_t declaration_start = synthetic_to_content_offset(mapping, keyword->location.start); - size_t declaration_end = synthetic_to_content_offset(mapping, keyword->location.end); + size_t declaration_end = synthetic_to_content_offset(mapping, herb_prism_location_end(keyword->location)); if (!value) { append_herb_state_invalid_parameter_error( @@ -257,7 +255,7 @@ static void append_invalid_parameter_error( if (!parameter) { return; } size_t start = synthetic_to_content_offset(mapping, parameter->location.start); - size_t end = synthetic_to_content_offset(mapping, parameter->location.end); + size_t end = synthetic_to_content_offset(mapping, herb_prism_location_end(parameter->location)); append_herb_state_invalid_parameter_error( content_slice(content, start, end), @@ -560,29 +558,28 @@ static AST_NODE_T* create_herb_state_directive_node( hb_buffer_append_with_length(&synthetic, content->bytes + signature_start, signature_length); hb_buffer_append(&synthetic, SYNTHETIC_SUFFIX); - pm_parser_t parser; - pm_options_t prism_options = { 0 }; - - pm_parser_init(&parser, (const uint8_t*) hb_buffer_value(&synthetic), hb_buffer_length(&synthetic), &prism_options); + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = + pm_parser_new(arena, (const uint8_t*) hb_buffer_value(&synthetic), hb_buffer_length(&synthetic), NULL); - pm_node_t* root = pm_parse(&parser); + pm_node_t* root = pm_parse(parser); synthetic_mapping_T mapping = { - .synthetic_start = parser.start, .signature_start = signature_start, .prefix_length = strlen(SYNTHETIC_PREFIX), }; bool parsed = true; - for (const pm_diagnostic_t* error = (const pm_diagnostic_t*) parser.error_list.head; error != NULL; - error = (const pm_diagnostic_t*) error->node.next) { + for (const pm_diagnostic_t* error = pm_parser_errors_first(parser); error != NULL; + error = pm_diagnostic_next(error)) { if (error->diag_id == PM_ERR_DEF_TERM) { continue; } parsed = false; position_T error_start = content_position(content, synthetic_to_content_offset(&mapping, error->location.start)); - position_T error_end = content_position(content, synthetic_to_content_offset(&mapping, error->location.end)); + position_T error_end = + content_position(content, synthetic_to_content_offset(&mapping, herb_prism_location_end(error->location))); hb_array_append(errors, ruby_parse_error_from_prism_error_with_positions(error, error_start, error_end, allocator)); } @@ -591,9 +588,8 @@ static AST_NODE_T* create_herb_state_directive_node( parsed ? extract_state_declarations(find_parameters_node(root), content, &mapping, &errors, allocator, options) : hb_array_init(0, allocator); - pm_node_destroy(&parser, root); - pm_parser_free(&parser); - pm_options_free(&prism_options); + pm_parser_free(parser); + pm_arena_free(arena); hb_buffer_free(&synthetic); return (AST_NODE_T*) ast_herb_state_directive_node_init( diff --git a/src/analyze/iteration_nodes.c b/src/analyze/iteration_nodes.c index d56ad7263..3ab85a06d 100644 --- a/src/analyze/iteration_nodes.c +++ b/src/analyze/iteration_nodes.c @@ -6,6 +6,7 @@ #include "../include/lib/hb_allocator.h" #include "../include/lib/hb_array.h" #include "../include/lib/hb_string.h" +#include "../include/prism/prism_helpers.h" #include "../include/visitor.h" #include @@ -20,14 +21,13 @@ static token_T* create_token_from_prism_location( const uint8_t* erb_content_source, hb_allocator_T* allocator ) { - if (location.start == NULL || location.end == NULL) { return NULL; } + if (!herb_prism_location_assigned(location)) { return NULL; } if (!source || !erb_content_source) { return NULL; } - size_t length = (size_t) (location.end - location.start); - char* value = hb_allocator_strndup(allocator, (const char*) location.start, length); + char* value = hb_allocator_strndup(allocator, (const char*) (erb_content_source + location.start), location.length); - size_t total_start = erb_content_offset + (size_t) (location.start - erb_content_source); - size_t total_end = erb_content_offset + (size_t) (location.end - erb_content_source); + size_t total_start = erb_content_offset + location.start; + size_t total_end = erb_content_offset + herb_prism_location_end(location); position_T start = byte_offset_to_position(source, total_start); position_T end = byte_offset_to_position(source, total_end); @@ -59,15 +59,18 @@ static hb_array_T* extract_call_arguments( const pm_node_t* argument = call->arguments->arguments.nodes[index]; if (!argument) { continue; } - size_t length = (size_t) (argument->location.end - argument->location.start); - char* value = hb_allocator_strndup(allocator, (const char*) argument->location.start, length); + char* value = hb_allocator_strndup( + allocator, + (const char*) (erb_content_source + argument->location.start), + argument->location.length + ); position_T start = { .line = 1, .column = 1 }; position_T end = { .line = 1, .column = 1 }; if (source && erb_content_source) { - size_t total_start = erb_content_offset + (size_t) (argument->location.start - erb_content_source); - size_t total_end = erb_content_offset + (size_t) (argument->location.end - erb_content_source); + size_t total_start = erb_content_offset + argument->location.start; + size_t total_end = erb_content_offset + herb_prism_location_end(argument->location); start = byte_offset_to_position(source, total_start); end = byte_offset_to_position(source, total_end); @@ -113,7 +116,9 @@ static bool is_iteration_method(const pm_constant_t* constant) { const char* name = ITERATION_METHODS[index]; size_t length = strlen(name); - if (constant->length == length && memcmp(constant->start, name, length) == 0) { return true; } + if (pm_constant_length(constant) == length && memcmp(pm_constant_start(constant), name, length) == 0) { + return true; + } } return false; @@ -125,7 +130,7 @@ static bool is_iteration_call(const pm_call_node_t* call, const pm_parser_t* par if (call->block == NULL || call->block->type != PM_BLOCK_NODE) { return false; } pm_constant_id_t name_id = call->name; - const pm_constant_t* constant = pm_constant_pool_id_to_constant(&((pm_parser_t*) parser)->constant_pool, name_id); + const pm_constant_t* constant = pm_parser_constant(parser, name_id); if (!constant) { return false; } @@ -173,15 +178,15 @@ static AST_ERB_ITERATION_BLOCK_NODE_T* try_transform_block_node( const char* ruby_source = block_node->content->value.data; size_t ruby_length = block_node->content->value.length; - pm_parser_t parser; - pm_parser_init(&parser, (const uint8_t*) ruby_source, ruby_length, NULL); - pm_node_t* root = pm_parse(&parser); + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) ruby_source, ruby_length, NULL); + pm_node_t* root = pm_parse(parser); - pm_call_node_t* iteration_call = find_iteration_call(root, &parser); + pm_call_node_t* iteration_call = find_iteration_call(root, parser); if (!iteration_call) { - pm_node_destroy(&parser, root); - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return NULL; } @@ -192,7 +197,7 @@ static AST_ERB_ITERATION_BLOCK_NODE_T* try_transform_block_node( erb_content_offset = calculate_byte_offset_from_position(context->source, block_node->content->location.start); } - const uint8_t* erb_content_source = (const uint8_t*) parser.start; + const uint8_t* erb_content_source = pm_parser_start(parser); token_T* receiver = create_token_from_prism_location( iteration_call->receiver->location, @@ -260,8 +265,8 @@ static AST_ERB_ITERATION_BLOCK_NODE_T* try_transform_block_node( allocator ); - pm_node_destroy(&parser, root); - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return iteration_block_node; } diff --git a/src/analyze/parse_errors.c b/src/analyze/parse_errors.c index a5c8ef368..cb85140e1 100644 --- a/src/analyze/parse_errors.c +++ b/src/analyze/parse_errors.c @@ -9,6 +9,7 @@ #include "../include/prism/prism_helpers.h" #include +#include #include #include @@ -52,13 +53,14 @@ static void parse_erb_content_errors(AST_NODE_T* erb_node, const char* source, h char* content = hb_string_to_c_string_using_malloc(content_node->content->value); if (!content) { return; } - pm_parser_t parser; - pm_options_t options = { 0, .partial_script = true }; - pm_parser_init(&parser, (const uint8_t*) content, strlen(content), &options); + pm_arena_t* arena = pm_arena_new(); + pm_options_t* options = pm_options_new(); + pm_options_partial_script_set(options, true); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) content, strlen(content), options); - pm_node_t* root = pm_parse(&parser); + pm_parse(parser); - const pm_diagnostic_t* error = (const pm_diagnostic_t*) parser.error_list.head; + const pm_diagnostic_t* error = pm_parser_errors_first(parser); if (error != NULL) { RUBY_PARSE_ERROR_T* parse_error = ruby_parse_error_from_prism_error_with_positions( @@ -71,9 +73,9 @@ static void parse_erb_content_errors(AST_NODE_T* erb_node, const char* source, h hb_array_append_lazy(&erb_node->errors, parse_error, allocator); } - pm_node_destroy(&parser, root); - pm_parser_free(&parser); - pm_options_free(&options); + pm_parser_free(parser); + pm_arena_free(arena); + pm_options_free(options); free(content); } @@ -95,19 +97,20 @@ void herb_analyze_parse_errors( bool strict_locals_enabled = parser_options && parser_options->strict_locals; bool has_anonymous_keyword_rest = strict_locals_enabled && document_has_anonymous_keyword_rest(document); - pm_parser_t parser; - pm_options_t options = { 0, .partial_script = true }; - pm_parser_init(&parser, (const uint8_t*) extracted_ruby, strlen(extracted_ruby), &options); + pm_arena_t* arena = pm_arena_new(); + pm_options_t* options = pm_options_new(); + pm_options_partial_script_set(options, true); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) extracted_ruby, strlen(extracted_ruby), options); - pm_node_t* root = pm_parse(&parser); + pm_parse(parser); - for (const pm_diagnostic_t* error = (const pm_diagnostic_t*) parser.error_list.head; error != NULL; - error = (const pm_diagnostic_t*) error->node.next) { + for (const pm_diagnostic_t* error = pm_parser_errors_first(parser); error != NULL; + error = pm_diagnostic_next(error)) { if (should_skip_forwarding_error(error, strict_locals_enabled, has_anonymous_keyword_rest)) { continue; } - size_t error_offset = (size_t) (error->location.start - parser.start); + size_t error_offset = error->location.start; - if (strstr(error->message, "unexpected ';'") != NULL) { + if (strstr(pm_diagnostic_message(error), "unexpected ';'") != NULL) { if (error_offset < strlen(extracted_ruby) && extracted_ruby[error_offset] == ';') { if (error_offset >= strlen(source) || source[error_offset] != ';') { AST_NODE_T* erb_node = find_erb_content_at_offset(document, source, error_offset); @@ -120,12 +123,12 @@ void herb_analyze_parse_errors( } RUBY_PARSE_ERROR_T* parse_error = - ruby_parse_error_from_prism_error(error, (AST_NODE_T*) document, source, &parser, allocator); + ruby_parse_error_from_prism_error(error, (AST_NODE_T*) document, source, parser, allocator); hb_array_append_lazy(&document->base.errors, parse_error, allocator); } - pm_node_destroy(&parser, root); - pm_parser_free(&parser); - pm_options_free(&options); + pm_parser_free(parser); + pm_arena_free(arena); + pm_options_free(options); hb_allocator_dealloc(allocator, extracted_ruby); } diff --git a/src/analyze/postfix_conditionals.c b/src/analyze/postfix_conditionals.c index 319299bf8..25ebb2605 100644 --- a/src/analyze/postfix_conditionals.c +++ b/src/analyze/postfix_conditionals.c @@ -9,6 +9,7 @@ #include "../include/lib/hb_array.h" #include "../include/lib/hb_string.h" #include "../include/prism/herb_prism_node.h" +#include "../include/prism/prism_helpers.h" #include "../include/visitor.h" #include @@ -27,11 +28,17 @@ static pm_node_t* find_postfix_conditional_statement(analyzed_ruby_T* analyzed) if (statement->type == PM_IF_NODE) { pm_if_node_t* if_node = (pm_if_node_t*) statement; - if (if_node->if_keyword_loc.start != NULL && if_node->end_keyword_loc.start == NULL) { return statement; } + if (herb_prism_location_assigned(if_node->if_keyword_loc) + && !herb_prism_location_assigned(if_node->end_keyword_loc)) { + return statement; + } } else if (statement->type == PM_UNLESS_NODE) { pm_unless_node_t* unless_node = (pm_unless_node_t*) statement; - if (unless_node->keyword_loc.start != NULL && unless_node->end_keyword_loc.start == NULL) { return statement; } + if (herb_prism_location_assigned(unless_node->unless_keyword_loc) + && !herb_prism_location_assigned(unless_node->end_keyword_loc)) { + return statement; + } } return NULL; @@ -55,11 +62,11 @@ static body_info_T extract_statements_body_info( pm_node_t* first = statements->body.nodes[0]; pm_node_t* last = statements->body.nodes[statements->body.size - 1]; - const uint8_t* start = first->location.start; - const uint8_t* end = last->location.end; + const uint8_t* parser_start = pm_parser_start(analyzed->parser); + size_t source_length = (size_t) (pm_parser_end(analyzed->parser) - parser_start); - const uint8_t* parser_start = analyzed->parser.start; - size_t source_length = (size_t) (analyzed->parser.end - parser_start); + const uint8_t* start = herb_prism_location_start_pointer(parser_start, first->location); + const uint8_t* end = herb_prism_location_end_pointer(parser_start, last->location); if (start < parser_start || end > parser_start + source_length) { return info; } @@ -98,13 +105,13 @@ static body_info_T extract_body_info( hb_allocator_dealloc(allocator, (void*) info.source); - info.source = hb_allocator_strndup(allocator, (const char*) analyzed->parser.start, info.length); + info.source = hb_allocator_strndup(allocator, (const char*) pm_parser_start(analyzed->parser), info.length); } return info; } -static char* extract_condition_source(pm_node_t* conditional_node, hb_allocator_T* allocator) { +static char* extract_condition_source(const uint8_t* source, pm_node_t* conditional_node, hb_allocator_T* allocator) { pm_node_t* predicate = NULL; if (conditional_node->type == PM_IF_NODE) { @@ -115,9 +122,11 @@ static char* extract_condition_source(pm_node_t* conditional_node, hb_allocator_ if (!predicate) { return NULL; } - size_t length = (size_t) (predicate->location.end - predicate->location.start); - - return hb_allocator_strndup(allocator, (const char*) predicate->location.start, length); + return hb_allocator_strndup( + allocator, + (const char*) (source + predicate->location.start), + predicate->location.length + ); } static const char* condition_keyword(pm_node_t* conditional_node) { @@ -150,7 +159,7 @@ static pm_if_node_t* find_nested_ternary(pm_node_t* conditional_node) { pm_if_node_t* if_node = (pm_if_node_t*) body_node; - if (if_node->if_keyword_loc.start == NULL && if_node->subsequent != NULL) { return if_node; } + if (!herb_prism_location_assigned(if_node->if_keyword_loc) && if_node->subsequent != NULL) { return if_node; } return NULL; } @@ -215,7 +224,8 @@ static AST_NODE_T* transform_conditional( static_output_node_type_T static_node_type, hb_allocator_T* allocator ) { - char* condition_source = extract_condition_source(conditional_node, allocator); + char* condition_source = + extract_condition_source(pm_parser_start(erb_node->analyzed_ruby->parser), conditional_node, allocator); if (!condition_source) { return NULL; } const char* keyword = condition_keyword(conditional_node); diff --git a/src/analyze/prism_annotate.c b/src/analyze/prism_annotate.c index 79604ef63..fd496fa29 100644 --- a/src/analyze/prism_annotate.c +++ b/src/analyze/prism_annotate.c @@ -204,10 +204,10 @@ static void set_prism_node(AST_NODE_T* node, herb_prism_node_T prism_ref) { } } -static size_t prism_node_start(pm_parser_t* parser, hb_narray_T* node_list, size_t index) { +static size_t prism_node_start(hb_narray_T* node_list, size_t index) { pm_node_t* prism_node = *(pm_node_t**) hb_narray_get(node_list, index); - return (size_t) (prism_node->location.start - parser->start); + return prism_node->location.start; } static herb_prism_node_T find_prism_node_for_herb_node( @@ -229,17 +229,17 @@ static herb_prism_node_T find_prism_node_for_herb_node( while (low < high) { size_t middle = low + (high - low) / 2; - if (prism_node_start(parser, node_list, middle) < content_from) { + if (prism_node_start(node_list, middle) < content_from) { low = middle + 1; } else { high = middle; } } - if (low >= hb_narray_size(node_list) || prism_node_start(parser, node_list, low) >= content_to) { return result; } + if (low >= hb_narray_size(node_list) || prism_node_start(node_list, low) >= content_to) { return result; } pm_node_t* prism_node = *(pm_node_t**) hb_narray_get(node_list, low); - size_t prism_end = (size_t) (prism_node->location.end - parser->start); + size_t prism_end = (size_t) prism_node->location.start + prism_node->location.length; result.node = prism_node; result.parser = parser; @@ -332,23 +332,20 @@ void herb_annotate_prism_nodes( return; } - memset(&context->pm_opts, 0, sizeof(pm_options_t)); - pm_options_line_set(&context->pm_opts, 1); - pm_options_partial_script_set(&context->pm_opts, true); - pm_parser_init( - &context->parser, - (const uint8_t*) context->ruby_buf.value, - context->ruby_buf.length, - &context->pm_opts - ); - context->root = pm_parse(&context->parser); + context->arena = pm_arena_new(); + context->pm_opts = pm_options_new(); + pm_options_line_set(context->pm_opts, 1); + pm_options_partial_script_set(context->pm_opts, true); + context->parser = + pm_parser_new(context->arena, (const uint8_t*) context->ruby_buf.value, context->ruby_buf.length, context->pm_opts); + context->root = pm_parse(context->parser); if (!context->root || context->root->type != PM_PROGRAM_NODE) { - pm_node_destroy(&context->parser, context->root); context->root = NULL; - pm_parser_free(&context->parser); - pm_options_free(&context->pm_opts); + pm_parser_free(context->parser); + pm_arena_free(context->arena); + pm_options_free(context->pm_opts); hb_buffer_free(&context->ruby_buf); hb_allocator_dealloc(allocator, context); @@ -361,7 +358,7 @@ void herb_annotate_prism_nodes( if (prism_program) { herb_prism_node_T program_ref = { .node = context->root, - .parser = &context->parser, + .parser = context->parser, }; document->prism_node = program_ref; @@ -393,18 +390,19 @@ void herb_annotate_prism_nodes( } } - memset(&context->structural_pm_opts, 0, sizeof(pm_options_t)); - pm_options_line_set(&context->structural_pm_opts, 1); - pm_options_partial_script_set(&context->structural_pm_opts, true); + context->structural_arena = pm_arena_new(); + context->structural_pm_opts = pm_options_new(); + pm_options_line_set(context->structural_pm_opts, 1); + pm_options_partial_script_set(context->structural_pm_opts, true); - pm_parser_init( - &context->structural_parser, + context->structural_parser = pm_parser_new( + context->structural_arena, (const uint8_t*) context->structural_buf.value, context->structural_buf.length, - &context->structural_pm_opts + context->structural_pm_opts ); - context->structural_root = pm_parse(&context->structural_parser); + context->structural_root = pm_parse(context->structural_parser); context->has_structural = true; if (context->structural_root && context->structural_root->type == PM_PROGRAM_NODE) { @@ -416,8 +414,8 @@ void herb_annotate_prism_nodes( } prism_annotate_context_T annotate_context = { - .parser = &context->parser, - .structural_parser = prism_nodes_deep ? &context->parser : &context->structural_parser, + .parser = context->parser, + .structural_parser = prism_nodes_deep ? context->parser : context->structural_parser, .node_list = &node_list, .structural_node_list = prism_nodes_deep ? &node_list : &structural_node_list, .prism_nodes_deep = prism_nodes_deep, diff --git a/src/analyze/render_nodes.c b/src/analyze/render_nodes.c index 240cd5ae7..4343ea27f 100644 --- a/src/analyze/render_nodes.c +++ b/src/analyze/render_nodes.c @@ -13,6 +13,8 @@ #include "../include/lib/string.h" #include "../include/visitor.h" +#include "../include/prism/prism_helpers.h" + #include #include #include @@ -50,9 +52,10 @@ static bool is_render_call(pm_call_node_t* call_node, pm_parser_t* parser) { if (!call_node || !call_node->name) { return false; } if (call_node->receiver && call_node->receiver->type != PM_SELF_NODE) { return false; } - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call_node->name); + const pm_constant_t* constant = pm_parser_constant(parser, call_node->name); - return constant && constant->length == 6 && strncmp((const char*) constant->start, "render", 6) == 0; + return constant && pm_constant_length(constant) == 6 + && strncmp((const char*) pm_constant_start(constant), "render", 6) == 0; } static pm_call_node_t* find_render_call(pm_node_t* node, pm_parser_t* parser) { @@ -117,11 +120,14 @@ static char* extract_string_value(pm_node_t* node, hb_allocator_T* allocator) { return NULL; } -static char* extract_source_expression(pm_node_t* node, hb_allocator_T* allocator) { +static char* extract_source_expression(const uint8_t* erb_content_source, pm_node_t* node, hb_allocator_T* allocator) { if (!node) { return NULL; } - size_t length = node->location.end - node->location.start; - return hb_allocator_strndup(allocator, (const char*) node->location.start, length); + return hb_allocator_strndup( + allocator, + (const char*) (erb_content_source + node->location.start), + node->location.length + ); } static token_T* create_token_from_prism_node( @@ -137,8 +143,8 @@ static token_T* create_token_from_prism_node( position_T end = { .line = 1, .column = 1 }; if (node && source && erb_content_source) { - size_t start_offset_in_erb = (size_t) (node->location.start - erb_content_source); - size_t end_offset_in_erb = (size_t) (node->location.end - erb_content_source); + size_t start_offset_in_erb = node->location.start; + size_t end_offset_in_erb = herb_prism_location_end(node->location); size_t total_start = erb_content_offset + start_offset_in_erb; size_t total_end = erb_content_offset + end_offset_in_erb; @@ -160,6 +166,7 @@ static pm_keyword_hash_node_t* find_keyword_hash(pm_arguments_node_t* arguments) } static keyword_result_T find_keyword_value( + const uint8_t* erb_content_source, pm_keyword_hash_node_t* keyword_hash, const char* key, hb_allocator_T* allocator @@ -184,7 +191,7 @@ static keyword_result_T find_keyword_value( if (string_value) { result.value = string_value; } else { - result.value = extract_source_expression(assoc->value, allocator); + result.value = extract_source_expression(erb_content_source, assoc->value, allocator); } return result; @@ -228,11 +235,12 @@ static bool extract_assoc_parts( AST_RUBY_LITERAL_NODE_T** value_node ) { char* name = extract_string_value(assoc->key, allocator); - if (!name) { name = extract_source_expression(assoc->key, allocator); } + if (!name) { name = extract_source_expression(erb_content_source, assoc->key, allocator); } if (!name) { return false; } bool shorthand = assoc->value && assoc->value->type == PM_IMPLICIT_NODE; - char* value = shorthand ? hb_allocator_strdup(allocator, name) : extract_source_expression(assoc->value, allocator); + char* value = shorthand ? hb_allocator_strdup(allocator, name) + : extract_source_expression(erb_content_source, assoc->value, allocator); if (!value) { hb_allocator_dealloc(allocator, name); @@ -254,8 +262,8 @@ static bool extract_assoc_parts( pm_node_t* spanned = shorthand ? assoc->key : assoc->value; if (spanned && source && erb_content_source) { - size_t start_offset = (size_t) (spanned->location.start - erb_content_source); - size_t end_offset = (size_t) (spanned->location.end - erb_content_source); + size_t start_offset = spanned->location.start; + size_t end_offset = herb_prism_location_end(spanned->location); if (shorthand && end_offset > start_offset && erb_content_source[end_offset - 1] == ':') { end_offset--; } @@ -348,7 +356,7 @@ static token_T* extract_keyword_token( const uint8_t* erb_content_source, hb_allocator_T* allocator ) { - keyword_result_T keyword = find_keyword_value(keyword_hash, keyword_name, allocator); + keyword_result_T keyword = find_keyword_value(erb_content_source, keyword_hash, keyword_name, allocator); if (!keyword.value) { return NULL; } token_T* token = create_token_from_prism_node( @@ -405,7 +413,7 @@ static void append_unusable_state_entry( hb_allocator_T* allocator ) { pm_node_t* named = element->type == PM_ASSOC_NODE ? ((pm_assoc_node_t*) element)->key : element; - char* name = extract_source_expression(named, allocator); + char* name = extract_source_expression(erb_content_source, named, allocator); if (!name) { return; } @@ -423,8 +431,8 @@ static void append_unusable_state_entry( position_T end = start; if (source && erb_content_source) { - size_t start_offset = (size_t) (element->location.start - erb_content_source); - size_t end_offset = (size_t) (element->location.end - erb_content_source); + size_t start_offset = element->location.start; + size_t end_offset = herb_prism_location_end(element->location); start = byte_offset_to_position(source, erb_content_offset + start_offset); end = byte_offset_to_position(source, erb_content_offset + end_offset); @@ -512,8 +520,8 @@ static location_T* prism_node_location( ) { if (!node || !source || !erb_content_source) { return NULL; } - size_t start_offset = (size_t) (node->location.start - erb_content_source); - size_t end_offset = (size_t) (node->location.end - erb_content_source); + size_t start_offset = node->location.start; + size_t end_offset = herb_prism_location_end(node->location); return location_create( byte_offset_to_position(source, erb_content_offset + start_offset), @@ -595,7 +603,7 @@ static AST_ERB_RENDER_NODE_T* create_render_node_from_call( hb_allocator_dealloc(allocator, partial_string); } } else if (first_argument->type != PM_KEYWORD_HASH_NODE) { - char* object_string = extract_source_expression(first_argument, allocator); + char* object_string = extract_source_expression(erb_content_source, first_argument, allocator); if (object_string) { object = create_token_from_prism_node( @@ -614,7 +622,7 @@ static AST_ERB_RENDER_NODE_T* create_render_node_from_call( if (keyword_hash) { if (has_positional_partial) { - keyword_result_T partial_kw = find_keyword_value(keyword_hash, "partial", allocator); + keyword_result_T partial_kw = find_keyword_value(erb_content_source, keyword_hash, "partial", allocator); if (partial_kw.value) { has_keyword_partial = true; } pm_hash_node_t* locals_hash = find_locals_hash(keyword_hash, allocator); @@ -691,7 +699,7 @@ static AST_ERB_RENDER_NODE_T* create_render_node_from_call( hb_array_T* errors = NULL; if (!has_keyword_partial && partial && keyword_hash) { - keyword_result_T locals_keyword = find_keyword_value(keyword_hash, "locals", allocator); + keyword_result_T locals_keyword = find_keyword_value(erb_content_source, keyword_hash, "locals", allocator); if (locals_keyword.value) { hb_string_T partial_name = partial->value; @@ -797,7 +805,7 @@ static AST_ERB_RENDER_NODE_T* create_render_node_from_call( } if (has_positional_partial && has_keyword_partial && keyword_hash) { - keyword_result_T keyword_partial = find_keyword_value(keyword_hash, "partial", allocator); + keyword_result_T keyword_partial = find_keyword_value(erb_content_source, keyword_hash, "partial", allocator); append_render_conflicting_partial_error( partial->value, @@ -875,7 +883,7 @@ static AST_ERB_RENDER_NODE_T* create_render_node_from_call( pm_block_node_t* inline_block = find_block_on_render_call(call_node); if (inline_block) { - const uint8_t* content_source = erb_content_source ? erb_content_source : (const uint8_t*) parser->start; + const uint8_t* content_source = erb_content_source ? erb_content_source : pm_parser_start(parser); if (inline_block->parameters && inline_block->parameters->type == PM_BLOCK_PARAMETERS_NODE) { pm_block_parameters_node_t* block_parameters = (pm_block_parameters_node_t*) inline_block->parameters; @@ -893,16 +901,18 @@ static AST_ERB_RENDER_NODE_T* create_render_node_from_call( } if (inline_block->body) { - size_t body_length = (size_t) (inline_block->body->location.end - inline_block->body->location.start); - char* body_source = - hb_allocator_strndup(allocator, (const char*) inline_block->body->location.start, body_length); + char* body_source = hb_allocator_strndup( + allocator, + (const char*) (content_source + inline_block->body->location.start), + inline_block->body->location.length + ); position_T body_start = { .line = 1, .column = 1 }; position_T body_end = { .line = 1, .column = 1 }; if (source && content_source) { - size_t start_offset = (size_t) (inline_block->body->location.start - content_source); - size_t end_offset = (size_t) (inline_block->body->location.end - content_source); + size_t start_offset = inline_block->body->location.start; + size_t end_offset = herb_prism_location_end(inline_block->body->location); body_start = byte_offset_to_position(source, erb_content_offset + start_offset); body_end = byte_offset_to_position(source, erb_content_offset + end_offset); } @@ -1012,7 +1022,7 @@ static AST_ERB_RENDER_NODE_T* try_transform_content_node( if (is_erb_comment_tag(erb_node->tag_opening)) { return NULL; } if (token_is_escaped_erb_tag_opening(erb_node->tag_opening)) { return NULL; } - pm_call_node_t* render_call = find_render_call(erb_node->analyzed_ruby->root, &erb_node->analyzed_ruby->parser); + pm_call_node_t* render_call = find_render_call(erb_node->analyzed_ruby->root, erb_node->analyzed_ruby->parser); if (!render_call) { return NULL; } size_t erb_content_offset = 0; @@ -1021,12 +1031,12 @@ static AST_ERB_RENDER_NODE_T* try_transform_content_node( erb_content_offset = calculate_byte_offset_from_pos(context->source, erb_node->content->location.start); } - const uint8_t* erb_content_source = (const uint8_t*) erb_node->analyzed_ruby->parser.start; + const uint8_t* erb_content_source = pm_parser_start(erb_node->analyzed_ruby->parser); return create_render_node_from_call( erb_node, render_call, - &erb_node->analyzed_ruby->parser, + erb_node->analyzed_ruby->parser, context->source, erb_content_offset, erb_content_source, @@ -1046,15 +1056,15 @@ static AST_ERB_RENDER_NODE_T* try_transform_block_node( const char* ruby_source = block_node->content->value.data; size_t ruby_length = block_node->content->value.length; - pm_parser_t parser; - pm_parser_init(&parser, (const uint8_t*) ruby_source, ruby_length, NULL); - pm_node_t* root = pm_parse(&parser); + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) ruby_source, ruby_length, NULL); + pm_node_t* root = pm_parse(parser); - pm_call_node_t* render_call = find_render_call(root, &parser); + pm_call_node_t* render_call = find_render_call(root, parser); if (!render_call) { - pm_node_destroy(&parser, root); - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return NULL; } @@ -1075,7 +1085,7 @@ static AST_ERB_RENDER_NODE_T* try_transform_block_node( erb_content_offset = calculate_byte_offset_from_pos(context->source, block_node->content->location.start); } - const uint8_t* erb_content_source = (const uint8_t*) parser.start; + const uint8_t* erb_content_source = pm_parser_start(parser); render_block_fields_T block_fields = { .block_body = block_node->body, @@ -1089,7 +1099,7 @@ static AST_ERB_RENDER_NODE_T* try_transform_block_node( AST_ERB_RENDER_NODE_T* render_node = create_render_node_from_call( &content_view, render_call, - &parser, + parser, context->source, erb_content_offset, erb_content_source, @@ -1098,8 +1108,8 @@ static AST_ERB_RENDER_NODE_T* try_transform_block_node( context->options ); - pm_node_destroy(&parser, root); - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return render_node; } diff --git a/src/analyze/strict_locals.c b/src/analyze/strict_locals.c index 4526ee3ac..6c84f208d 100644 --- a/src/analyze/strict_locals.c +++ b/src/analyze/strict_locals.c @@ -16,6 +16,7 @@ #include "../include/prism/prism_helpers.h" #include +#include #include #include @@ -211,17 +212,16 @@ static AST_ERB_STRICT_LOCALS_NODE_T* create_strict_locals_node( hb_buffer_T synthetic_buffer; if (!build_synthetic_ruby(params_open, params_length, &synthetic_buffer, allocator)) { return NULL; } - pm_parser_t parser; - pm_options_t options = { 0 }; - pm_parser_init( - &parser, + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = pm_parser_new( + arena, (const uint8_t*) hb_buffer_value(&synthetic_buffer), hb_buffer_length(&synthetic_buffer), - &options + NULL ); - pm_node_t* root = pm_parse(&parser); + pm_node_t* root = pm_parse(parser); - const uint8_t* synthetic_start = parser.start; + const uint8_t* synthetic_start = pm_parser_start(parser); pm_parameters_node_t* params_node = find_parameters_node(root); size_t erb_content_byte_offset = calculate_byte_offset_from_position(source, erb_node->content->location.start); @@ -230,12 +230,12 @@ static AST_ERB_STRICT_LOCALS_NODE_T* create_strict_locals_node( size_t params_in_content = (size_t) (params_open - content_bytes); size_t prefix_length = strlen(SYNTHETIC_PREFIX); - for (const pm_diagnostic_t* error = (const pm_diagnostic_t*) parser.error_list.head; error != NULL; - error = (const pm_diagnostic_t*) error->node.next) { + for (const pm_diagnostic_t* error = pm_parser_errors_first(parser); error != NULL; + error = pm_diagnostic_next(error)) { if (error->diag_id == PM_ERR_DEF_TERM) { continue; } - size_t error_start_in_synthetic = (size_t) (error->location.start - synthetic_start); - size_t error_end_in_synthetic = (size_t) (error->location.end - synthetic_start); + size_t error_start_in_synthetic = error->location.start; + size_t error_end_in_synthetic = herb_prism_location_end(error->location); size_t error_content_start = params_in_content + (error_start_in_synthetic > prefix_length ? error_start_in_synthetic - prefix_length : 0); @@ -258,7 +258,7 @@ static AST_ERB_STRICT_LOCALS_NODE_T* create_strict_locals_node( } else { locals = extract_strict_locals( params_node, - &parser, + parser, source, erb_content_byte_offset, content_bytes, @@ -270,9 +270,8 @@ static AST_ERB_STRICT_LOCALS_NODE_T* create_strict_locals_node( ); } - pm_node_destroy(&parser, root); - pm_parser_free(&parser); - pm_options_free(&options); + pm_parser_free(parser); + pm_arena_free(arena); hb_buffer_free(&synthetic_buffer); return ast_erb_strict_locals_node_init( diff --git a/src/analyze/ternary_conditionals.c b/src/analyze/ternary_conditionals.c index b45d3e8e9..7b5532094 100644 --- a/src/analyze/ternary_conditionals.c +++ b/src/analyze/ternary_conditionals.c @@ -8,6 +8,7 @@ #include "../include/lib/hb_array.h" #include "../include/lib/hb_string.h" #include "../include/prism/herb_prism_node.h" +#include "../include/prism/prism_helpers.h" #include "../include/visitor.h" #include @@ -26,7 +27,7 @@ static pm_node_t* find_ternary_statement(analyzed_ruby_T* analyzed) { if (statement->type != PM_IF_NODE) { return NULL; } pm_if_node_t* if_node = (pm_if_node_t*) statement; - if (if_node->if_keyword_loc.start == NULL && if_node->subsequent != NULL) { return statement; } + if (!herb_prism_location_assigned(if_node->if_keyword_loc) && if_node->subsequent != NULL) { return statement; } return NULL; } @@ -49,11 +50,11 @@ static body_info_T extract_statements_body_info( pm_node_t* first = statements->body.nodes[0]; pm_node_t* last = statements->body.nodes[statements->body.size - 1]; - const uint8_t* start = first->location.start; - const uint8_t* end = last->location.end; + const uint8_t* parser_start = pm_parser_start(analyzed->parser); + size_t source_length = (size_t) (pm_parser_end(analyzed->parser) - parser_start); - const uint8_t* parser_start = analyzed->parser.start; - size_t source_length = (size_t) (analyzed->parser.end - parser_start); + const uint8_t* start = herb_prism_location_start_pointer(parser_start, first->location); + const uint8_t* end = herb_prism_location_end_pointer(parser_start, last->location); if (start < parser_start || end > parser_start + source_length) { return info; } @@ -83,14 +84,16 @@ static body_info_T extract_statements_body_info( return info; } -static char* extract_condition_source(pm_if_node_t* if_node, hb_allocator_T* allocator) { +static char* extract_condition_source(const uint8_t* source, pm_if_node_t* if_node, hb_allocator_T* allocator) { pm_node_t* predicate = if_node->predicate; if (!predicate) { return NULL; } - size_t length = (size_t) (predicate->location.end - predicate->location.start); - - return hb_allocator_strndup(allocator, (const char*) predicate->location.start, length); + return hb_allocator_strndup( + allocator, + (const char*) (source + predicate->location.start), + predicate->location.length + ); } static bool append_branch_statement( @@ -156,7 +159,8 @@ AST_NODE_T* transform_ternary_expression( pm_else_node_t* else_node = (pm_else_node_t*) if_node->subsequent; if (!else_node) { return NULL; } - char* condition_source = extract_condition_source(if_node, allocator); + char* condition_source = + extract_condition_source(pm_parser_start(erb_node->analyzed_ruby->parser), if_node, allocator); if (!condition_source) { return NULL; } position_T start = erb_node->base.location.start; diff --git a/src/herb.c b/src/herb.c index 54efabbbd..a17f5a1dd 100644 --- a/src/herb.c +++ b/src/herb.c @@ -136,9 +136,11 @@ HERB_EXPORTED_FUNCTION herb_ruby_parse_result_T* herb_parse_ruby(const char* sou herb_ruby_parse_result_T* result = malloc(sizeof(herb_ruby_parse_result_T)); if (!result) { return NULL; } - memset(&result->options, 0, sizeof(pm_options_t)); - pm_parser_init(&result->parser, (const uint8_t*) source, length, &result->options); - result->root = pm_parse(&result->parser); + result->arena = pm_arena_new(); + result->options = pm_options_new(); + pm_options_line_set(result->options, 0); + result->parser = pm_parser_new(result->arena, (const uint8_t*) source, length, result->options); + result->root = pm_parse(result->parser); return result; } @@ -146,9 +148,8 @@ HERB_EXPORTED_FUNCTION herb_ruby_parse_result_T* herb_parse_ruby(const char* sou HERB_EXPORTED_FUNCTION void herb_free_ruby_parse_result(herb_ruby_parse_result_T* result) { if (!result) { return; } - if (result->root) { pm_node_destroy(&result->parser, result->root); } - - pm_parser_free(&result->parser); - pm_options_free(&result->options); + pm_parser_free(result->parser); + pm_arena_free(result->arena); + pm_options_free(result->options); free(result); } diff --git a/src/include/analyze/action_view/tag_helper_handler.h b/src/include/analyze/action_view/tag_helper_handler.h index 75a4ca119..2658e29a1 100644 --- a/src/include/analyze/action_view/tag_helper_handler.h +++ b/src/include/analyze/action_view/tag_helper_handler.h @@ -38,7 +38,7 @@ void tag_helper_info_free(tag_helper_info_T** info); const tag_helper_handler_T* const* get_tag_helper_handlers(void); size_t get_tag_helper_handlers_count(void); -char* extract_inline_block_content(pm_call_node_t* call_node, hb_allocator_T* allocator); +char* extract_inline_block_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator); struct AST_NODE_STRUCT; bool wrap_javascript_tag_body_visitor(const struct AST_NODE_STRUCT* node, void* data); diff --git a/src/include/analyze/action_view/tag_helper_node_builders.h b/src/include/analyze/action_view/tag_helper_node_builders.h index 49cf0da6a..7dd0f9f20 100644 --- a/src/include/analyze/action_view/tag_helper_node_builders.h +++ b/src/include/analyze/action_view/tag_helper_node_builders.h @@ -58,6 +58,7 @@ AST_HTML_ATTRIBUTE_NODE_T* create_html_attribute_with_ruby_literal( AST_HTML_ATTRIBUTE_NODE_T* create_html_attribute_with_interpolated_value( const char* name_string, pm_interpolated_string_node_t* interpolated_node, + const uint8_t* source, position_T start_position, position_T end_position, hb_allocator_T* allocator diff --git a/src/include/analyze/action_view/tag_helpers.h b/src/include/analyze/action_view/tag_helpers.h index 4836050af..2dcc1ac05 100644 --- a/src/include/analyze/action_view/tag_helpers.h +++ b/src/include/analyze/action_view/tag_helpers.h @@ -19,7 +19,7 @@ typedef struct { bool found; } tag_helper_search_data_T; -bool search_tag_helper_node(const pm_node_t* node, void* data); +pm_visit_result_t search_tag_helper_node(const pm_node_t* node, void* data); position_T prism_location_to_position_with_offset( const pm_location_t* pm_location, diff --git a/src/include/analyze/analyze.h b/src/include/analyze/analyze.h index e8a4419fa..4432d37d9 100644 --- a/src/include/analyze/analyze.h +++ b/src/include/analyze/analyze.h @@ -10,8 +10,9 @@ typedef struct TAG_HELPER_SCOPE_STRUCT { hb_buffer_T buffer; - pm_options_t options; - pm_parser_t parser; + pm_arena_t* arena; + pm_options_t* options; + pm_parser_t* parser; pm_node_t* root; } tag_helper_scope_T; diff --git a/src/include/analyze/analyzed_ruby.h b/src/include/analyze/analyzed_ruby.h index 15efe6e00..e0d789f08 100644 --- a/src/include/analyze/analyzed_ruby.h +++ b/src/include/analyze/analyzed_ruby.h @@ -30,7 +30,8 @@ typedef enum { } control_type_t; typedef struct ANALYZED_RUBY_STRUCT { - pm_parser_t parser; + pm_arena_t* arena; + pm_parser_t* parser; pm_node_t* root; bool valid; bool parsed; diff --git a/src/include/analyze/helpers.h b/src/include/analyze/helpers.h index f2964f551..23c51431f 100644 --- a/src/include/analyze/helpers.h +++ b/src/include/analyze/helpers.h @@ -37,13 +37,13 @@ bool control_role_split_offset(const analyzed_ruby_T* analyzed, uint32_t* offset bool has_error_message(analyzed_ruby_T* anlayzed, const char* message); -bool is_do_block(pm_location_t opening_location); -bool is_brace_block(pm_location_t opening_location); -bool is_closing_brace(pm_location_t location); -bool has_valid_block_closing(pm_location_t opening_loc, pm_location_t closing_loc); +bool is_do_block(const uint8_t* source, pm_location_t opening_location); +bool is_brace_block(const uint8_t* source, pm_location_t opening_location); +bool is_closing_brace(const uint8_t* source, pm_location_t location); +bool has_valid_block_closing(const uint8_t* source, pm_location_t opening_loc, pm_location_t closing_loc); -bool search_control_flow_nodes(const pm_node_t* node, void* data); -bool search_unclosed_control_flows(const pm_node_t* node, void* data); +pm_visit_result_t search_control_flow_nodes(const pm_node_t* node, void* data); +pm_visit_result_t search_unclosed_control_flows(const pm_node_t* node, void* data); void search_unexpected_keyword_errors(analyzed_ruby_T* analyzed); void check_erb_node_for_missing_end(const AST_NODE_T* node, hb_allocator_T* allocator, const parser_options_T* options); diff --git a/src/include/herb.h b/src/include/herb.h index 74492af53..f8465a0fd 100644 --- a/src/include/herb.h +++ b/src/include/herb.h @@ -36,9 +36,10 @@ HERB_EXPORTED_FUNCTION const char* herb_version(void); HERB_EXPORTED_FUNCTION const char* herb_prism_version(void); typedef struct { - pm_parser_t parser; + pm_arena_t* arena; + pm_parser_t* parser; pm_node_t* root; - pm_options_t options; + pm_options_t* options; } herb_ruby_parse_result_T; HERB_EXPORTED_FUNCTION herb_ruby_parse_result_T* herb_parse_ruby(const char* source, size_t length); diff --git a/src/include/prism/prism_context.h b/src/include/prism/prism_context.h index 48a6b8692..6943746e5 100644 --- a/src/include/prism/prism_context.h +++ b/src/include/prism/prism_context.h @@ -7,14 +7,16 @@ #include typedef struct { - pm_parser_t parser; - pm_options_t pm_opts; + pm_arena_t* arena; + pm_parser_t* parser; + pm_options_t* pm_opts; pm_node_t* root; hb_buffer_T ruby_buf; bool has_structural; - pm_parser_t structural_parser; - pm_options_t structural_pm_opts; + pm_arena_t* structural_arena; + pm_parser_t* structural_parser; + pm_options_t* structural_pm_opts; pm_node_t* structural_root; hb_buffer_T structural_buf; @@ -24,17 +26,15 @@ typedef struct { static inline void herb_prism_context_free(herb_prism_context_T* context) { if (!context) { return; } - if (context->root) { pm_node_destroy(&context->parser, context->root); } - - pm_parser_free(&context->parser); - pm_options_free(&context->pm_opts); + if (context->parser) { pm_parser_free(context->parser); } + if (context->arena) { pm_arena_free(context->arena); } + if (context->pm_opts) { pm_options_free(context->pm_opts); } hb_buffer_free(&context->ruby_buf); if (context->has_structural) { - if (context->structural_root) { pm_node_destroy(&context->structural_parser, context->structural_root); } - - pm_parser_free(&context->structural_parser); - pm_options_free(&context->structural_pm_opts); + if (context->structural_parser) { pm_parser_free(context->structural_parser); } + if (context->structural_arena) { pm_arena_free(context->structural_arena); } + if (context->structural_pm_opts) { pm_options_free(context->structural_pm_opts); } if (context->structural_buf.value) { hb_buffer_free(&context->structural_buf); } } diff --git a/src/include/prism/prism_helpers.h b/src/include/prism/prism_helpers.h index fc1f8b28e..9ec0353ed 100644 --- a/src/include/prism/prism_helpers.h +++ b/src/include/prism/prism_helpers.h @@ -10,6 +10,26 @@ #include +static inline bool herb_prism_location_present(pm_location_t location) { + return location.length > 0; +} + +static inline bool herb_prism_location_assigned(pm_location_t location) { + return location.start != 0 || location.length != 0; +} + +static inline uint32_t herb_prism_location_end(pm_location_t location) { + return location.start + location.length; +} + +static inline const uint8_t* herb_prism_location_start_pointer(const uint8_t* base, pm_location_t location) { + return base + location.start; +} + +static inline const uint8_t* herb_prism_location_end_pointer(const uint8_t* base, pm_location_t location) { + return base + location.start + location.length; +} + hb_string_T pm_error_level_to_string(pm_error_level_t level); RUBY_PARSE_ERROR_T* ruby_parse_error_from_prism_error( diff --git a/src/prism/prism_helpers.c b/src/prism/prism_helpers.c index 168b95bd3..8f5e05d8e 100644 --- a/src/prism/prism_helpers.c +++ b/src/prism/prism_helpers.c @@ -7,6 +7,8 @@ #include "../include/location/position.h" #include +#include +#include #include #include @@ -25,16 +27,17 @@ RUBY_PARSE_ERROR_T* ruby_parse_error_from_prism_error( pm_parser_t* parser, hb_allocator_T* allocator ) { - size_t start_offset = (size_t) (error->location.start - parser->start); - size_t end_offset = (size_t) (error->location.end - parser->start); + (void) parser; - position_T start = position_from_source_with_offset(source, start_offset); - position_T end = position_from_source_with_offset(source, end_offset); + pm_location_t location = pm_diagnostic_location(error); + + position_T start = position_from_source_with_offset(source, location.start); + position_T end = position_from_source_with_offset(source, herb_prism_location_end(location)); return ruby_parse_error_init( - hb_string(error->message), - hb_string(pm_diagnostic_id_human(error->diag_id)), - pm_error_level_to_string(error->level), + hb_string(pm_diagnostic_message(error)), + hb_string(pm_diagnostic_type(error)), + pm_error_level_to_string(pm_diagnostic_error_level(error)), start, end, allocator @@ -48,9 +51,9 @@ RUBY_PARSE_ERROR_T* ruby_parse_error_from_prism_error_with_positions( hb_allocator_T* allocator ) { return ruby_parse_error_init( - hb_string(error->message), - hb_string(pm_diagnostic_id_human(error->diag_id)), - pm_error_level_to_string(error->level), + hb_string(pm_diagnostic_message(error)), + hb_string(pm_diagnostic_type(error)), + pm_error_level_to_string(pm_diagnostic_error_level(error)), start, end, allocator @@ -62,55 +65,51 @@ typedef struct { bool found; } then_keyword_search_context_T; -static bool has_pm_location(pm_location_t location) { - return location.start != NULL && location.end != NULL && (location.end - location.start) > 0; -} - -static bool search_then_keyword_location(const pm_node_t* node, void* data) { +static pm_visit_result_t search_then_keyword_location(const pm_node_t* node, void* data) { then_keyword_search_context_T* context = (then_keyword_search_context_T*) data; - if (context->found) { return false; } + if (context->found) { return PM_VISIT_SKIP; } switch (node->type) { case PM_IF_NODE: { const pm_if_node_t* if_node = (const pm_if_node_t*) node; - if (!has_pm_location(if_node->if_keyword_loc)) { break; } + if (!herb_prism_location_present(if_node->if_keyword_loc)) { break; } - if (has_pm_location(if_node->then_keyword_loc)) { + if (herb_prism_location_present(if_node->then_keyword_loc)) { context->then_keyword_loc = if_node->then_keyword_loc; context->found = true; - return false; + return PM_VISIT_SKIP; } break; } case PM_UNLESS_NODE: { const pm_unless_node_t* unless_node = (const pm_unless_node_t*) node; - if (has_pm_location(unless_node->then_keyword_loc)) { + if (herb_prism_location_present(unless_node->then_keyword_loc)) { context->then_keyword_loc = unless_node->then_keyword_loc; context->found = true; - return false; + return PM_VISIT_SKIP; } break; } case PM_WHEN_NODE: { const pm_when_node_t* when_node = (const pm_when_node_t*) node; - if (has_pm_location(when_node->then_keyword_loc)) { + if (herb_prism_location_present(when_node->then_keyword_loc)) { context->then_keyword_loc = when_node->then_keyword_loc; context->found = true; - return false; + return PM_VISIT_SKIP; } break; } case PM_IN_NODE: { const pm_in_node_t* in_node = (const pm_in_node_t*) node; - if (has_pm_location(in_node->then_loc)) { - context->then_keyword_loc = in_node->then_loc; + if (herb_prism_location_present(in_node->then_keyword_loc)) { + context->then_keyword_loc = in_node->then_keyword_loc; context->found = true; - return false; + return PM_VISIT_SKIP; } break; } @@ -120,23 +119,20 @@ static bool search_then_keyword_location(const pm_node_t* node, void* data) { pm_visit_child_nodes(node, search_then_keyword_location, context); - return false; + return PM_VISIT_SKIP; } location_T* get_then_keyword_location(analyzed_ruby_T* analyzed, const char* source, hb_allocator_T* allocator) { if (analyzed == NULL || analyzed->root == NULL || source == NULL) { return NULL; } - then_keyword_search_context_T context = { .then_keyword_loc = { .start = NULL, .end = NULL }, .found = false }; + then_keyword_search_context_T context = { .then_keyword_loc = { .start = 0, .length = 0 }, .found = false }; pm_visit_child_nodes(analyzed->root, search_then_keyword_location, &context); if (!context.found) { return NULL; } - size_t start_offset = (size_t) (context.then_keyword_loc.start - analyzed->parser.start); - size_t end_offset = (size_t) (context.then_keyword_loc.end - analyzed->parser.start); - - position_T start_position = position_from_source_with_offset(source, start_offset); - position_T end_position = position_from_source_with_offset(source, end_offset); + position_T start_position = position_from_source_with_offset(source, context.then_keyword_loc.start); + position_T end_position = position_from_source_with_offset(source, herb_prism_location_end(context.then_keyword_loc)); return location_create(start_position, end_position, allocator); } @@ -150,25 +146,26 @@ static location_T* parse_wrapped_and_find_then_keyword( size_t adjustment_amount, hb_allocator_T* allocator ) { - pm_parser_t parser; - pm_parser_init(&parser, (const uint8_t*) hb_buffer_value(buffer), hb_buffer_length(buffer), NULL); - pm_node_t* root = pm_parse(&parser); + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) hb_buffer_value(buffer), hb_buffer_length(buffer), NULL); + pm_node_t* root = pm_parse(parser); if (root == NULL) { - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return NULL; } - then_keyword_search_context_T context = { .then_keyword_loc = { .start = NULL, .end = NULL }, .found = false }; + then_keyword_search_context_T context = { .then_keyword_loc = { .start = 0, .length = 0 }, .found = false }; pm_visit_child_nodes(root, search_then_keyword_location, &context); location_T* location = NULL; if (context.found) { - size_t start_offset = (size_t) (context.then_keyword_loc.start - parser.start); - size_t end_offset = (size_t) (context.then_keyword_loc.end - parser.start); + size_t start_offset = context.then_keyword_loc.start; + size_t end_offset = herb_prism_location_end(context.then_keyword_loc); if (start_offset >= prefix_length && end_offset >= prefix_length) { start_offset -= prefix_length; @@ -188,8 +185,8 @@ static location_T* parse_wrapped_and_find_then_keyword( } } - pm_node_destroy(&parser, root); - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return location; } @@ -245,7 +242,7 @@ location_T* get_then_keyword_location_elsif_wrapped(const char* source, hb_alloc return location; } -static size_t newline_index_for_offset(const pm_newline_list_t* newlines, size_t offset) { +static size_t newline_index_for_offset(const pm_line_offset_list_t* newlines, size_t offset) { size_t low = 0; size_t high = newlines->size; @@ -267,12 +264,12 @@ void herb_prism_node_serialize(herb_prism_node_T prism_node, pm_buffer_t* buffer pm_parser_t* parser = prism_node.parser; - if (prism_node.source_end == 0 || parser->newline_list.size == 0) { + if (prism_node.source_end == 0 || parser->line_offsets.size == 0) { pm_serialize(parser, prism_node.node, buffer); return; } - const pm_newline_list_t* newlines = &parser->newline_list; + const pm_line_offset_list_t* newlines = &parser->line_offsets; size_t first_line = newline_index_for_offset(newlines, prism_node.source_start); size_t last_line = newline_index_for_offset(newlines, prism_node.source_end); size_t line_count = last_line - first_line + 1; @@ -281,21 +278,22 @@ void herb_prism_node_serialize(herb_prism_node_T prism_node, pm_buffer_t* buffer pm_parser_t view = *parser; - view.newline_list.offsets = newlines->offsets + first_line; - view.newline_list.size = line_count; - view.newline_list.capacity = line_count; + view.line_offsets.offsets = newlines->offsets + first_line; + view.line_offsets.size = line_count; + view.line_offsets.capacity = line_count; view.start_line = parser->start_line + (int32_t) first_line; memset(&view.magic_comment_list, 0, sizeof(pm_list_t)); memset(&view.error_list, 0, sizeof(pm_list_t)); memset(&view.warning_list, 0, sizeof(pm_list_t)); memset(&view.comment_list, 0, sizeof(pm_list_t)); + memset(&view.comment_attachments, 0, sizeof(view.comment_attachments)); size_t comment_count = 0; for (pm_list_node_t* entry = parser->comment_list.head; entry; entry = entry->next) { pm_comment_t* comment = (pm_comment_t*) entry; - size_t start = (size_t) (comment->location.start - parser->start); + size_t start = comment->location.start; if (start >= prism_node.source_start && start < prism_node.source_end) { comment_count++; } } @@ -314,7 +312,7 @@ void herb_prism_node_serialize(herb_prism_node_T prism_node, pm_buffer_t* buffer for (pm_list_node_t* entry = parser->comment_list.head; entry; entry = entry->next) { pm_comment_t* comment = (pm_comment_t*) entry; - size_t start = (size_t) (comment->location.start - parser->start); + size_t start = comment->location.start; if (start < prism_node.source_start || start >= prism_node.source_end) { continue; } diff --git a/src/prism/ruby_parser.c b/src/prism/ruby_parser.c index 4936055aa..e30a9752a 100644 --- a/src/prism/ruby_parser.c +++ b/src/prism/ruby_parser.c @@ -2,51 +2,51 @@ #include #include +#include #include #include -static bool herb_prism_visit(const pm_node_t* node, void* data) { +static pm_visit_result_t herb_prism_visit(const pm_node_t* node, void* data) { const size_t* indent = (size_t*) data; for (size_t i = 0; i < *indent * 2; i++) { putc(' ', stdout); } - printf("%s\n", pm_node_type_to_str(node->type)); + printf("%s\n", pm_node_type(node->type)); size_t next_indent = *indent + 1; size_t* next_data = &next_indent; pm_visit_child_nodes(node, herb_prism_visit, next_data); - return false; + return PM_VISIT_SKIP; } void herb_parse_ruby_to_stdout(char* source) { size_t length = strlen(source); - pm_parser_t parser; - pm_parser_init(&parser, (const uint8_t*) source, length, NULL); + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) source, length, NULL); - pm_buffer_t buffer; - pm_buffer_init(&buffer); + pm_buffer_t* buffer = pm_buffer_new(); size_t indent = 0; - pm_node_t* root = pm_parse(&parser); + pm_node_t* root = pm_parse(parser); size_t* data = &indent; - const char* root_type = pm_node_type_to_str(root->type); + const char* root_type = pm_node_type(root->type); printf("Root Type: %s\n", root_type); pm_visit_node(root, herb_prism_visit, data); #ifndef PRISM_EXCLUDE_PRETTYPRINT - pm_prettyprint(&buffer, &parser, root); - printf("%s\n", buffer.value); + pm_prettyprint(buffer, parser, root); + printf("%.*s\n", (int) pm_buffer_length(buffer), pm_buffer_value(buffer)); #endif - pm_buffer_free(&buffer); - pm_node_destroy(&parser, root); - pm_parser_free(&parser); + pm_buffer_free(buffer); + pm_parser_free(parser); + pm_arena_free(arena); } static const char* const RUBY_FRAGMENT_PREFIXES[] = { @@ -56,14 +56,14 @@ static const char* const RUBY_FRAGMENT_PREFIXES[] = { static const char* const RUBY_FRAGMENT_SUFFIXES[] = { "", "\nend", "", "\nend", "\nend", "\nend" }; static bool ruby_source_parses(const char* source, size_t length) { - pm_parser_t parser; - pm_parser_init(&parser, (const uint8_t*) source, length, NULL); + pm_arena_t* arena = pm_arena_new(); + pm_parser_t* parser = pm_parser_new(arena, (const uint8_t*) source, length, NULL); - pm_node_t* root = pm_parse(&parser); - bool parses = (parser.error_list.size == 0); + pm_parse(parser); + bool parses = (pm_parser_errors_size(parser) == 0); - if (root != NULL) { pm_node_destroy(&parser, root); } - pm_parser_free(&parser); + pm_parser_free(parser); + pm_arena_free(arena); return parses; } diff --git a/templates/ext/herb/nodes.c.erb b/templates/ext/herb/nodes.c.erb index eaa9a622b..24acc5f86 100644 --- a/templates/ext/herb/nodes.c.erb +++ b/templates/ext/herb/nodes.c.erb @@ -69,17 +69,17 @@ static VALUE rb_<%= node.human %>_from_c_struct(<%= node.struct_type %>* <%= nod <%- when Herb::Template::PrismNodeField -%> VALUE <%= node.human %>_<%= field.name %>; if (<%= node.human %>-><%= field.name %>.node != NULL && <%= node.human %>-><%= field.name %>.parser != NULL) { - pm_buffer_t pm_buffer = { 0 }; - herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, &pm_buffer); + pm_buffer_t* pm_buffer = pm_buffer_new(); + herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, pm_buffer); - if (pm_buffer.length > 0) { - <%= node.human %>_<%= field.name %> = rb_str_new(pm_buffer.value, pm_buffer.length); + if (pm_buffer_length(pm_buffer) > 0) { + <%= node.human %>_<%= field.name %> = rb_str_new(pm_buffer_value(pm_buffer), pm_buffer_length(pm_buffer)); rb_enc_associate(<%= node.human %>_<%= field.name %>, rb_ascii8bit_encoding()); OBJ_FREEZE(<%= node.human %>_<%= field.name %>); } else { <%= node.human %>_<%= field.name %> = Qnil; } - pm_buffer_free(&pm_buffer); + pm_buffer_free(pm_buffer); } else { <%= node.human %>_<%= field.name %> = Qnil; } diff --git a/templates/java/nodes.c.erb b/templates/java/nodes.c.erb index b5e92acae..587fe295b 100644 --- a/templates/java/nodes.c.erb +++ b/templates/java/nodes.c.erb @@ -49,15 +49,15 @@ jobject <%= node.name %>FromCStruct(JNIEnv* env, <%= node.struct_type %>* <%= no <%- elsif field.is_a?(Herb::Template::PrismNodeField) -%> jbyteArray <%= field.name %>; if (<%= node.human %>-><%= field.name %>.node != NULL && <%= node.human %>-><%= field.name %>.parser != NULL) { - pm_buffer_t pm_buffer = { 0 }; - herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, &pm_buffer); - if (pm_buffer.length > 0) { - <%= field.name %> = (*env)->NewByteArray(env, (jsize)pm_buffer.length); - (*env)->SetByteArrayRegion(env, <%= field.name %>, 0, (jsize)pm_buffer.length, (const jbyte*)pm_buffer.value); + pm_buffer_t* pm_buffer = pm_buffer_new(); + herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, pm_buffer); + if (pm_buffer_length(pm_buffer) > 0) { + <%= field.name %> = (*env)->NewByteArray(env, (jsize)pm_buffer_length(pm_buffer)); + (*env)->SetByteArrayRegion(env, <%= field.name %>, 0, (jsize)pm_buffer_length(pm_buffer), (const jbyte*)pm_buffer_value(pm_buffer)); } else { <%= field.name %> = NULL; } - pm_buffer_free(&pm_buffer); + pm_buffer_free(pm_buffer); } else { <%= field.name %> = NULL; } diff --git a/templates/javascript/packages/node/extension/nodes.cpp.erb b/templates/javascript/packages/node/extension/nodes.cpp.erb index e2c46d2ff..433d36877 100644 --- a/templates/javascript/packages/node/extension/nodes.cpp.erb +++ b/templates/javascript/packages/node/extension/nodes.cpp.erb @@ -89,17 +89,17 @@ napi_value <%= node.human %>NodeFromCStruct(napi_env env, <%= node.struct_type % <%- when Herb::Template::PrismNodeField -%> napi_value <%= field.name %>; if (<%= node.human %>-><%= field.name %>.node != NULL && <%= node.human %>-><%= field.name %>.parser != NULL) { - pm_buffer_t pm_buffer = { 0 }; - herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, &pm_buffer); + pm_buffer_t* pm_buffer = pm_buffer_new(); + herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, pm_buffer); - if (pm_buffer.length > 0) { + if (pm_buffer_length(pm_buffer) > 0) { void* buffer_data; - napi_create_buffer_copy(env, pm_buffer.length, pm_buffer.value, &buffer_data, &<%= field.name %>); + napi_create_buffer_copy(env, pm_buffer_length(pm_buffer), pm_buffer_value(pm_buffer), &buffer_data, &<%= field.name %>); } else { napi_get_null(env, &<%= field.name %>); } - pm_buffer_free(&pm_buffer); + pm_buffer_free(pm_buffer); } else { napi_get_null(env, &<%= field.name %>); } diff --git a/templates/rust/src/prism/generated_deserialize.rs.erb b/templates/rust/src/prism/generated_deserialize.rs.erb index 0fd517843..3597accba 100644 --- a/templates/rust/src/prism/generated_deserialize.rs.erb +++ b/templates/rust/src/prism/generated_deserialize.rs.erb @@ -1,55 +1,21 @@ -fn read_node_body(buffer: &mut SerializationBuffer, type_id: u8, pool: usize, node: &mut PrismNode) { +fn read_node_body( + buffer: &mut SerializationBuffer, + type_id: u8, + pool: usize, + node: &mut PrismNode, + stack: &mut Vec>, +) { match type_id { <%- prism_nodes.each do |prism_node| -%> <%= prism_node.type_id %> => { - <%- if prism_node.name == "DefNode" -%> - buffer.read_uint32(); - <%- end -%> - let flags = buffer.read_var_int() as u32; node.flags = flags; <%- prism_node.fields.each do |field| -%> <%- case field.type -%> - <%- when "node" -%> - { - let child = read_node(buffer, pool); - node.children.push(child); - } - - <%- if field.name == "receiver" -%> - node.receiver_index = Some(node.children.len() - 1); - <%- elsif prism_node.name == "AssocNode" && field.name == "key" -%> - node.key = Some(Box::new(node.children[node.children.len() - 1].clone())); - <%- end -%> - - <%- when "node?" -%> - if buffer.peek_byte() != 0 { - let child = read_node(buffer, pool); - node.children.push(child); - <%- if field.name == "block" -%> - node.has_block = true; - <%- end -%> - - <%- if field.name == "receiver" -%> - node.receiver_index = Some(node.children.len() - 1); - <%- elsif prism_node.name == "AssocNode" && field.name == "key" -%> - node.key = Some(Box::new(node.children[node.children.len() - 1].clone())); - <%- end -%> - - } else { - buffer.read_byte(); - } - <%- when "node[]" -%> - { - let count = buffer.read_var_int(); - - for _ in 0..count { - let child = read_node(buffer, pool); - node.children.push(child); - } - } - + <%- when "node", "node?" -%> + <%- when "node[]" -%> + let <%= field.name %>_count = buffer.read_var_int(); <%- when "string" -%> <%- if field.name == "unescaped" -%> node.unescaped = Some(buffer.read_string_field(flags)); @@ -93,12 +59,92 @@ fn read_node_body(buffer: &mut SerializationBuffer, type_id: u8, pool: usize, no <%- raise "unhandled prism field type: #{field.type}" -%> <%- end -%> <%- end -%> + + <%- prism_node.fields.reverse.each do |field| -%> + <%- case field.type -%> + <%- when "node", "node?" -%> + let <%= field.name %>_child = stack.pop().flatten(); + <%- when "node[]" -%> + let <%= field.name %>_children = stack.split_off(stack.len().saturating_sub(<%= field.name %>_count)); + <%- end -%> + <%- end -%> + + <%- prism_node.fields.each do |field| -%> + <%- case field.type -%> + <%- when "node", "node?" -%> + if let Some(child) = <%= field.name %>_child { + node.children.push(child); + <%- if field.name == "block" && field.type == "node?" -%> + node.has_block = true; + <%- end -%> + <%- if field.name == "receiver" -%> + node.receiver_index = Some(node.children.len() - 1); + <%- elsif prism_node.name == "AssocNode" && field.name == "key" -%> + node.key = Some(Box::new(node.children[node.children.len() - 1].clone())); + <%- end -%> + } + + <%- when "node[]" -%> + node.children.extend(<%= field.name %>_children.into_iter().flatten()); + + <%- end -%> + <%- end -%> } <%- end -%> _ => {} } } +fn record_child_count(buffer: &mut SerializationBuffer, type_id: u8, pool: usize) -> usize { + #[allow(unused_mut)] + let mut count = 0; + + match type_id { + <%- prism_nodes.each do |prism_node| -%> + <%= prism_node.type_id %> => { + buffer.read_var_int(); + + <%- prism_node.fields.each do |field| -%> + <%- case field.type -%> + <%- when "node", "node?" -%> + count += 1; + <%- when "node[]" -%> + count += buffer.read_var_int(); + <%- when "string" -%> + buffer.read_string_field(0); + <%- when "constant" -%> + buffer.read_required_constant(pool); + <%- when "constant?" -%> + buffer.read_optional_constant(pool); + <%- when "constant[]" -%> + for _ in 0..buffer.read_var_int() { + buffer.read_required_constant(pool); + } + <%- when "location" -%> + buffer.read_location(); + <%- when "location?" -%> + buffer.read_optional_location(); + <%- when "uint8" -%> + buffer.read_byte(); + <%- when "uint32" -%> + buffer.read_var_int(); + <%- when "integer" -%> + buffer.read_integer(); + <%- when "double" -%> + buffer.read_double(); + <%- when "flags" -%> + <%- else -%> + <%- raise "unhandled prism field type: #{field.type}" -%> + <%- end -%> + <%- end -%> + } + <%- end -%> + _ => {} + } + + count +} + fn node_type_name_for(type_id: u8) -> String { match type_id { <%- prism_nodes.each do |prism_node| -%> diff --git a/templates/rust/src/prism/generated_prettyprint.rs.erb b/templates/rust/src/prism/generated_prettyprint.rs.erb index 80e2adf7a..484f4e58f 100644 --- a/templates/rust/src/prism/generated_prettyprint.rs.erb +++ b/templates/rust/src/prism/generated_prettyprint.rs.erb @@ -8,14 +8,12 @@ fn prettyprint_body( start_offset: usize, end_offset: usize, newlines: &[usize], + children: &mut std::vec::IntoIter>, ) { match type_id { <%- prism_nodes.each do |prism_node| -%> <%- entries = prism_node.entries -%> <%= prism_node.type_id %> => { - <%- if prism_node.name == "DefNode" -%> - buffer.read_uint32(); - <%- end -%> #[allow(unused_variables)] let flags = buffer.read_var_int() as u32; output.push_str(&format!("@ <%= prism_node.name %> (location: {})\n", location_string(start_offset, end_offset, newlines))); @@ -45,29 +43,18 @@ fn prettyprint_body( output.push('\n'); } - <%- when "node" -%> - output.push('\n'); - - { - let saved = prefix.len(); - prefix.push_str("<%= preadd %>"); - let copy = prefix.clone(); - output.push_str(©); - prettyprint_node(buffer, pool, output, prefix, newlines); - prefix.truncate(saved); - } - <%- when "node?" -%> - if buffer.peek_byte() == 0 { - buffer.read_byte(); - output.push_str(" nil\n"); - } else { - output.push('\n'); - let saved = prefix.len(); - prefix.push_str("<%= preadd %>"); - let copy = prefix.clone(); - output.push_str(©); - prettyprint_node(buffer, pool, output, prefix, newlines); - prefix.truncate(saved); + <%- when "node", "node?" -%> + match children.next().flatten() { + None => output.push_str(" nil\n"), + Some(child) => { + output.push('\n'); + let saved = prefix.len(); + prefix.push_str("<%= preadd %>"); + let copy = prefix.clone(); + output.push_str(©); + prettyprint_record(child, buffer, pool, output, prefix, newlines); + prefix.truncate(saved); + } } <%- when "node[]" -%> { @@ -81,7 +68,11 @@ fn prettyprint_body( output.push_str(©); output.push_str("+-- "); prefix.push_str(if index == count - 1 { " " } else { "| " }); - prettyprint_node(buffer, pool, output, prefix, newlines); + + if let Some(child) = children.next().flatten() { + prettyprint_record(child, buffer, pool, output, prefix, newlines); + } + prefix.truncate(saved); } } diff --git a/templates/src/analyze/action_view/generated_handlers.c.erb b/templates/src/analyze/action_view/generated_handlers.c.erb index 10f0df0f8..2723e4063 100644 --- a/templates/src/analyze/action_view/generated_handlers.c.erb +++ b/templates/src/analyze/action_view/generated_handlers.c.erb @@ -16,9 +16,9 @@ bool detect_<%= helper.safe_name %>(pm_call_node_t* call_node, pm_parser_t* parser) { if (!call_node || !call_node->name) { return false; } - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call_node->name); + const pm_constant_t* constant = pm_parser_constant(parser, call_node->name); - return constant && constant->length == <%= helper.name.length %> && strncmp((const char*) constant->start, "<%= helper.name %>", <%= helper.name.length %>) == 0; + return constant && pm_constant_length(constant) == <%= helper.name.length %> && strncmp((const char*) pm_constant_start(constant), "<%= helper.name %>", <%= helper.name.length %>) == 0; } <%- elsif helper.receiver_call_detect? -%> @@ -29,9 +29,9 @@ bool detect_<%= helper.safe_name %>(pm_call_node_t* call_node, pm_parser_t* pars pm_call_node_t* receiver_node = (pm_call_node_t*) call_node->receiver; if (!receiver_node->name) { return false; } - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, receiver_node->name); + const pm_constant_t* constant = pm_parser_constant(parser, receiver_node->name); - return constant && constant->length == 3 && strncmp((const char*) constant->start, "tag", 3) == 0; + return constant && pm_constant_length(constant) == 3 && strncmp((const char*) pm_constant_start(constant), "tag", 3) == 0; } <%- end -%> <%- end -%> @@ -79,14 +79,17 @@ extern bool is_ruby_introspection_method(hb_string_T method_name); static char* extract_<%= helper.safe_name %>_tag_name(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { if (!call_node || !call_node->name) { return NULL; } - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call_node->name); + const pm_constant_t* constant = pm_parser_constant(parser, call_node->name); if (!constant) { return NULL; } - if (is_ruby_introspection_method(hb_string_from_data((const char*) constant->start, constant->length))) { return NULL; } + const char* constant_start = (const char*) pm_constant_start(constant); + size_t constant_length = pm_constant_length(constant); - char* name = hb_allocator_strndup(allocator, (const char*) constant->start, constant->length); + if (is_ruby_introspection_method(hb_string_from_data(constant_start, constant_length))) { return NULL; } - for (size_t i = 0; i < constant->length && name[i] != '\0'; i++) { + char* name = hb_allocator_strndup(allocator, constant_start, constant_length); + + for (size_t i = 0; i < constant_length && name[i] != '\0'; i++) { if (name[i] == '_') { name[i] = '-'; } } @@ -111,9 +114,7 @@ static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* _call_node, } <%- elsif content.first_arg? -%> -static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, pm_parser_t* _parser, hb_allocator_T* allocator) { - (void) _parser; - +static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { if (!call_node || !call_node->arguments) { return NULL; } pm_arguments_node_t* arguments = call_node->arguments; @@ -131,27 +132,26 @@ static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = first_argument->location.end - first_argument->location.start; - return hb_allocator_strndup(allocator, (const char*) first_argument->location.start, source_length); + const uint8_t* source = pm_parser_start(parser); + size_t source_length = first_argument->location.length; + return hb_allocator_strndup(allocator, (const char*) (source + first_argument->location.start), source_length); } <%- elsif content.block_or_arg? -%> -static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, pm_parser_t* <%= helper.receiver_call_detect? ? "parser" : "_parser" %>, hb_allocator_T* allocator) { - (void) <%= helper.receiver_call_detect? ? "parser" : "_parser" %>; - +static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) { if (!call_node) { return NULL; } <%- if helper.receiver_call_detect? -%> if (call_node->name) { - pm_constant_t* constant = pm_constant_pool_id_to_constant(&parser->constant_pool, call_node->name); + const pm_constant_t* constant = pm_parser_constant(parser, call_node->name); - if (constant && is_ruby_introspection_method(hb_string_from_data((const char*) constant->start, constant->length))) { + if (constant && is_ruby_introspection_method(hb_string_from_data((const char*) pm_constant_start(constant), pm_constant_length(constant)))) { return NULL; } } <%- end -%> - char* block_content = extract_inline_block_content(call_node, allocator); + char* block_content = extract_inline_block_content(call_node, parser, allocator); if (block_content) { return block_content; } <%- arg_index = (content.arg_position || 1) - 1 -%> @@ -173,7 +173,8 @@ static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length); } - size_t source_length = argument->location.end - argument->location.start; + const uint8_t* source = pm_parser_start(parser); + size_t source_length = argument->location.length; <%- if content.to_s_suffix_when_single -%> if (arguments->arguments.size == 1 && argument->type != PM_NIL_NODE) { @@ -182,7 +183,7 @@ static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, size_t total_length = source_length + suffix_length; char* ruby_expression = hb_allocator_alloc(allocator, total_length + 1); - memcpy(ruby_expression, (const char*) argument->location.start, source_length); + memcpy(ruby_expression, (const char*) (source + argument->location.start), source_length); memcpy(ruby_expression + source_length, suffix, suffix_length); ruby_expression[total_length] = '\0'; @@ -190,7 +191,7 @@ static char* extract_<%= helper.safe_name %>_content(pm_call_node_t* call_node, } <%- end -%> - return hb_allocator_strndup(allocator, (const char*) argument->location.start, source_length); + return hb_allocator_strndup(allocator, (const char*) (source + argument->location.start), source_length); <%- if content.skip_if_hash -%> } diff --git a/templates/wasm/nodes.cpp.erb b/templates/wasm/nodes.cpp.erb index 8a2a0e04f..a1ddfa0be 100644 --- a/templates/wasm/nodes.cpp.erb +++ b/templates/wasm/nodes.cpp.erb @@ -54,17 +54,17 @@ val <%= node.name %>FromCStruct(<%= node.struct_type %>* <%= node.human %>, cons } <%- when Herb::Template::PrismNodeField -%> if (<%= node.human %>-><%= field.name %>.node != NULL && <%= node.human %>-><%= field.name %>.parser != NULL) { - pm_buffer_t pm_buffer = { 0 }; - herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, &pm_buffer); + pm_buffer_t* pm_buffer = pm_buffer_new(); + herb_prism_node_serialize(<%= node.human %>-><%= field.name %>, pm_buffer); - if (pm_buffer.length > 0) { - val view = val(typed_memory_view(pm_buffer.length, (const uint8_t*) pm_buffer.value)); + if (pm_buffer_length(pm_buffer) > 0) { + val view = val(typed_memory_view(pm_buffer_length(pm_buffer), (const uint8_t*) pm_buffer_value(pm_buffer))); result.set("<%= field.name %>", val::global("Uint8Array").new_(view)); } else { result.set("<%= field.name %>", val::null()); } - pm_buffer_free(&pm_buffer); + pm_buffer_free(pm_buffer); } else { result.set("<%= field.name %>", val::null()); } diff --git a/test/herb_test.rb b/test/herb_test.rb index f63021cf4..8416c0a07 100644 --- a/test/herb_test.rb +++ b/test/herb_test.rb @@ -4,7 +4,7 @@ class HerbTest < Minitest::Spec test "version" do - assert_equal "herb gem v0.11.1, libprism v1.9.0, libherb v0.11.1 (Ruby C native extension)", Herb.version + assert_equal "herb gem v0.11.1, libprism v2.0.0, libherb v0.11.1 (Ruby C native extension)", Herb.version end test "ensure_installed requires available gems without loading bundler/inline" do diff --git a/test/rubocop/includes_assertion_test.rb b/test/rubocop/includes_assertion_test.rb index 1c4ff6e37..ba408ecad 100644 --- a/test/rubocop/includes_assertion_test.rb +++ b/test/rubocop/includes_assertion_test.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true -require_relative "../test_helper" - +# TODO: Go back to `require_relative "../test_helper"` and drop the `test` alias below once https://github.com/rubocop/rubocop-ast/pull/420 is released. +require "maxitest/autorun" require "rubocop" require_relative "../../rubocop/cop/herb/includes_assertion" +Minitest::Spec::DSL.send(:alias_method, :test, :it) + class IncludesAssertionCopTest < Minitest::Spec test "registers an offense for assert_includes" do offenses = investigate(<<~RUBY) diff --git a/test/snapshots/analyze/render_test/test_0030_render_with_render_nodes_and_prism_nodes_1cbdeb2ec047a828841beece6d4bf600-7ab8c9055f911c17dec2d857cced9a8c.txt b/test/snapshots/analyze/render_test/test_0030_render_with_render_nodes_and_prism_nodes_1cbdeb2ec047a828841beece6d4bf600-7ab8c9055f911c17dec2d857cced9a8c.txt index ea5b4ff71..7799f0fb3 100644 --- a/test/snapshots/analyze/render_test/test_0030_render_with_render_nodes_and_prism_nodes_1cbdeb2ec047a828841beece6d4bf600-7ab8c9055f911c17dec2d857cced9a8c.txt +++ b/test/snapshots/analyze/render_test/test_0030_render_with_render_nodes_and_prism_nodes_1cbdeb2ec047a828841beece6d4bf600-7ab8c9055f911c17dec2d857cced9a8c.txt @@ -26,23 +26,33 @@ options: {render_nodes: true, prism_nodes: true} │ │ │ │ ├── key: │ │ │ │ │ └── @ SymbolNode (location: (1:11)-(1:19)) │ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ │ ├── value_loc: (1:11)-(1:18) + │ │ │ │ │ ├── content_loc: (1:11)-(1:18) │ │ │ │ │ ├── closing_loc: (1:18)-(1:19) - │ │ │ │ │ └── unescaped: "partial" + │ │ │ │ │ ├── unescaped: "partial" + │ │ │ │ │ ├── opening: ∅ + │ │ │ │ │ ├── content: "partial" + │ │ │ │ │ └── closing: ":" │ │ │ │ ├── value: │ │ │ │ │ └── @ StringNode (location: (1:20)-(1:26)) │ │ │ │ │ ├── opening_loc: (1:20)-(1:21) │ │ │ │ │ ├── content_loc: (1:21)-(1:25) │ │ │ │ │ ├── closing_loc: (1:25)-(1:26) - │ │ │ │ │ └── unescaped: "card" - │ │ │ │ └── operator_loc: ∅ + │ │ │ │ │ ├── unescaped: "card" + │ │ │ │ │ ├── opening: "\"" + │ │ │ │ │ ├── content: "card" + │ │ │ │ │ └── closing: "\"" + │ │ │ │ ├── operator_loc: ∅ + │ │ │ │ └── operator: ∅ │ │ │ └── @ AssocNode (location: (1:28)-(1:53)) │ │ │ ├── key: │ │ │ │ └── @ SymbolNode (location: (1:28)-(1:35)) │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ ├── value_loc: (1:28)-(1:34) + │ │ │ │ ├── content_loc: (1:28)-(1:34) │ │ │ │ ├── closing_loc: (1:34)-(1:35) - │ │ │ │ └── unescaped: "locals" + │ │ │ │ ├── unescaped: "locals" + │ │ │ │ ├── opening: ∅ + │ │ │ │ ├── content: "locals" + │ │ │ │ └── closing: ":" │ │ │ ├── value: │ │ │ │ └── @ HashNode (location: (1:36)-(1:53)) │ │ │ │ ├── opening_loc: (1:36)-(1:37) @@ -51,18 +61,30 @@ options: {render_nodes: true, prism_nodes: true} │ │ │ │ │ ├── key: │ │ │ │ │ │ └── @ SymbolNode (location: (1:38)-(1:44)) │ │ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ │ │ ├── value_loc: (1:38)-(1:43) + │ │ │ │ │ │ ├── content_loc: (1:38)-(1:43) │ │ │ │ │ │ ├── closing_loc: (1:43)-(1:44) - │ │ │ │ │ │ └── unescaped: "title" + │ │ │ │ │ │ ├── unescaped: "title" + │ │ │ │ │ │ ├── opening: ∅ + │ │ │ │ │ │ ├── content: "title" + │ │ │ │ │ │ └── closing: ":" │ │ │ │ │ ├── value: │ │ │ │ │ │ └── @ InstanceVariableReadNode (location: (1:45)-(1:51)) │ │ │ │ │ │ └── name: :@title - │ │ │ │ │ └── operator_loc: ∅ - │ │ │ │ └── closing_loc: (1:52)-(1:53) - │ │ │ └── operator_loc: ∅ + │ │ │ │ │ ├── operator_loc: ∅ + │ │ │ │ │ └── operator: ∅ + │ │ │ │ ├── closing_loc: (1:52)-(1:53) + │ │ │ │ ├── opening: "{" + │ │ │ │ └── closing: "}" + │ │ │ ├── operator_loc: ∅ + │ │ │ └── operator: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "render" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── keywords: │ │ └── @ RubyRenderKeywordsNode (location: (1:0)-(1:56)) │ │ ├── partial: "card" (location: (1:20)-(1:26)) diff --git a/test/snapshots/analyze/strict_locals_test/test_0042_trailing_comma_in_parameters_produces_errors_64c9f1031dfbabf01af2e35bed636686-be06ef2eb1a2807fc4c599b8cd1ada02.txt b/test/snapshots/analyze/strict_locals_test/test_0042_trailing_comma_in_parameters_produces_errors_64c9f1031dfbabf01af2e35bed636686-be06ef2eb1a2807fc4c599b8cd1ada02.txt index 811e0ddf9..125a8cde9 100644 --- a/test/snapshots/analyze/strict_locals_test/test_0042_trailing_comma_in_parameters_produces_errors_64c9f1031dfbabf01af2e35bed636686-be06ef2eb1a2807fc4c599b8cd1ada02.txt +++ b/test/snapshots/analyze/strict_locals_test/test_0042_trailing_comma_in_parameters_produces_errors_64c9f1031dfbabf01af2e35bed636686-be06ef2eb1a2807fc4c599b8cd1ada02.txt @@ -7,17 +7,16 @@ options: {strict_locals: true} @ DocumentNode (location: (1:0)-(2:0)) └── children: (2 items) ├── @ ERBStrictLocalsNode (location: (1:0)-(1:23)) - │ ├── errors: (1 error) - │ │ └── @ RubyParseError (location: (1:18)-(1:19)) - │ │ ├── message: "parameter_wild_loose_comma: unexpected `,` in parameters" - │ │ ├── error_message: "unexpected `,` in parameters" - │ │ ├── diagnostic_id: "parameter_wild_loose_comma" - │ │ └── level: "syntax" - │ │ │ ├── tag_opening: "<%#" (location: (1:0)-(1:3)) │ ├── content: " locals: (user:,) " (location: (1:3)-(1:21)) │ ├── tag_closing: "%>" (location: (1:21)-(1:23)) - │ └── locals: [] + │ └── locals: (1 item) + │ └── @ RubyParameterNode (location: (1:13)-(1:18)) + │ ├── name: "user" (location: (1:13)-(1:18)) + │ ├── default_value: ∅ + │ ├── kind: "keyword" + │ └── required: true + │ │ └── @ HTMLTextNode (location: (1:23)-(2:0)) └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/analyze/strict_locals_test/test_0044_double_comma_in_parameters_produces_errors_b51a8413269884e2e641d2682b170190-be06ef2eb1a2807fc4c599b8cd1ada02.txt b/test/snapshots/analyze/strict_locals_test/test_0044_double_comma_in_parameters_produces_errors_b51a8413269884e2e641d2682b170190-be06ef2eb1a2807fc4c599b8cd1ada02.txt index 0409dee95..f599ce298 100644 --- a/test/snapshots/analyze/strict_locals_test/test_0044_double_comma_in_parameters_produces_errors_b51a8413269884e2e641d2682b170190-be06ef2eb1a2807fc4c599b8cd1ada02.txt +++ b/test/snapshots/analyze/strict_locals_test/test_0044_double_comma_in_parameters_produces_errors_b51a8413269884e2e641d2682b170190-be06ef2eb1a2807fc4c599b8cd1ada02.txt @@ -7,19 +7,13 @@ options: {strict_locals: true} @ DocumentNode (location: (1:0)-(2:0)) └── children: (2 items) ├── @ ERBStrictLocalsNode (location: (1:0)-(1:31)) - │ ├── errors: (7 errors) + │ ├── errors: (6 errors) │ │ ├── @ RubyParseError (location: (1:19)-(1:20)) │ │ │ ├── message: "array_term: unexpected ','; expected a `]` to close the array" │ │ │ ├── error_message: "unexpected ','; expected a `]` to close the array" │ │ │ ├── diagnostic_id: "array_term" │ │ │ └── level: "syntax" │ │ │ - │ │ ├── @ RubyParseError (location: (1:18)-(1:19)) - │ │ │ ├── message: "parameter_wild_loose_comma: unexpected `,` in parameters" - │ │ │ ├── error_message: "unexpected `,` in parameters" - │ │ │ ├── diagnostic_id: "parameter_wild_loose_comma" - │ │ │ └── level: "syntax" - │ │ │ │ │ ├── @ RubyParseError (location: (1:19)-(1:20)) │ │ │ ├── message: "def_params_term_paren: unexpected ','; expected a `)` to close the parameters" │ │ │ ├── error_message: "unexpected ','; expected a `)` to close the parameters" diff --git a/test/snapshots/parser/erb_openers_test/test_0009_a_configured_tag_is_left_out_of_the_prism_program_102be0a51c570ab94f1ec4ef062b1412-003059dd935a24b8eea1cbb1b54f231d.txt b/test/snapshots/parser/erb_openers_test/test_0009_a_configured_tag_is_left_out_of_the_prism_program_102be0a51c570ab94f1ec4ef062b1412-003059dd935a24b8eea1cbb1b54f231d.txt index 222d6231d..69621c688 100644 --- a/test/snapshots/parser/erb_openers_test/test_0009_a_configured_tag_is_left_out_of_the_prism_program_102be0a51c570ab94f1ec4ef062b1412-003059dd935a24b8eea1cbb1b54f231d.txt +++ b/test/snapshots/parser/erb_openers_test/test_0009_a_configured_tag_is_left_out_of_the_prism_program_102be0a51c570ab94f1ec4ef062b1412-003059dd935a24b8eea1cbb1b54f231d.txt @@ -42,4 +42,9 @@ options: {erb_openers: ["graphql"], prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "name" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/erb_openers_test/test_0010_a_tag_is_in_the_prism_program_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/erb_openers_test/test_0010_a_tag_is_in_the_prism_program_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-0af561a0c6dea91d159fd88b7a3988aa.txt index 332ee3df4..a834a4cf1 100644 --- a/test/snapshots/parser/erb_openers_test/test_0010_a_tag_is_in_the_prism_program_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/erb_openers_test/test_0010_a_tag_is_in_the_prism_program_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -60,31 +60,53 @@ options: {prism_program: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: - │ │ │ └── @ BlockNode (location: (1:25)-(1:31)) - │ │ │ ├── locals: [] - │ │ │ ├── parameters: ∅ - │ │ │ ├── body: - │ │ │ │ └── @ StatementsNode (location: (1:27)-(1:29)) - │ │ │ │ └── body: (1 item) - │ │ │ │ └── @ CallNode (location: (1:27)-(1:29)) - │ │ │ │ ├── receiver: ∅ - │ │ │ │ ├── call_operator_loc: ∅ - │ │ │ │ ├── name: :id - │ │ │ │ ├── message_loc: (1:27)-(1:29) - │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ ├── arguments: ∅ - │ │ │ │ ├── closing_loc: ∅ - │ │ │ │ ├── equal_loc: ∅ - │ │ │ │ └── block: ∅ - │ │ │ ├── opening_loc: (1:25)-(1:26) - │ │ │ └── closing_loc: (1:30)-(1:31) + │ │ │ ├── block: + │ │ │ │ └── @ BlockNode (location: (1:25)-(1:31)) + │ │ │ │ ├── locals: [] + │ │ │ │ ├── parameters: ∅ + │ │ │ │ ├── body: + │ │ │ │ │ └── @ StatementsNode (location: (1:27)-(1:29)) + │ │ │ │ │ └── body: (1 item) + │ │ │ │ │ └── @ CallNode (location: (1:27)-(1:29)) + │ │ │ │ │ ├── receiver: ∅ + │ │ │ │ │ ├── call_operator_loc: ∅ + │ │ │ │ │ ├── name: :id + │ │ │ │ │ ├── message_loc: (1:27)-(1:29) + │ │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ │ ├── arguments: ∅ + │ │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ │ ├── block: ∅ + │ │ │ │ │ ├── call_operator: ∅ + │ │ │ │ │ ├── message: "id" + │ │ │ │ │ ├── opening: ∅ + │ │ │ │ │ ├── closing: ∅ + │ │ │ │ │ └── equal: ∅ + │ │ │ │ ├── opening_loc: (1:25)-(1:26) + │ │ │ │ ├── closing_loc: (1:30)-(1:31) + │ │ │ │ ├── opening: "{" + │ │ │ │ └── closing: "}" + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "Products" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "query" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "graphql" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ └── @ CallNode (location: (2:4)-(2:8)) ├── receiver: ∅ ├── call_operator_loc: ∅ @@ -94,4 +116,9 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "name" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/erb_openers_test/test_0011_a_configured_tag_gets_no_prism_node_102be0a51c570ab94f1ec4ef062b1412-a3a1f10b5bd7b0ac57caf801765569a7.txt b/test/snapshots/parser/erb_openers_test/test_0011_a_configured_tag_gets_no_prism_node_102be0a51c570ab94f1ec4ef062b1412-a3a1f10b5bd7b0ac57caf801765569a7.txt index 0d2b7d0c2..19f912848 100644 --- a/test/snapshots/parser/erb_openers_test/test_0011_a_configured_tag_gets_no_prism_node_102be0a51c570ab94f1ec4ef062b1412-a3a1f10b5bd7b0ac57caf801765569a7.txt +++ b/test/snapshots/parser/erb_openers_test/test_0011_a_configured_tag_gets_no_prism_node_102be0a51c570ab94f1ec4ef062b1412-a3a1f10b5bd7b0ac57caf801765569a7.txt @@ -33,7 +33,12 @@ options: {erb_openers: ["graphql"], prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── @ HTMLTextNode (location: (2:11)-(3:0)) └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/erb_openers_test/test_0012_a_tag_gets_a_prism_node_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/erb_openers_test/test_0012_a_tag_gets_a_prism_node_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-4f327c88bdb6320c9643a72adbf55b3f.txt index 3c3040db7..9fc2abdb7 100644 --- a/test/snapshots/parser/erb_openers_test/test_0012_a_tag_gets_a_prism_node_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/erb_openers_test/test_0012_a_tag_gets_a_prism_node_when_its_opener_is_not_configured_102be0a51c570ab94f1ec4ef062b1412-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -41,31 +41,53 @@ options: {prism_nodes: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: - │ │ │ └── @ BlockNode (location: (1:25)-(1:31)) - │ │ │ ├── locals: [] - │ │ │ ├── parameters: ∅ - │ │ │ ├── body: - │ │ │ │ └── @ StatementsNode (location: (1:27)-(1:29)) - │ │ │ │ └── body: (1 item) - │ │ │ │ └── @ CallNode (location: (1:27)-(1:29)) - │ │ │ │ ├── receiver: ∅ - │ │ │ │ ├── call_operator_loc: ∅ - │ │ │ │ ├── name: :id - │ │ │ │ ├── message_loc: (1:27)-(1:29) - │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ ├── arguments: ∅ - │ │ │ │ ├── closing_loc: ∅ - │ │ │ │ ├── equal_loc: ∅ - │ │ │ │ └── block: ∅ - │ │ │ ├── opening_loc: (1:25)-(1:26) - │ │ │ └── closing_loc: (1:30)-(1:31) + │ │ │ ├── block: + │ │ │ │ └── @ BlockNode (location: (1:25)-(1:31)) + │ │ │ │ ├── locals: [] + │ │ │ │ ├── parameters: ∅ + │ │ │ │ ├── body: + │ │ │ │ │ └── @ StatementsNode (location: (1:27)-(1:29)) + │ │ │ │ │ └── body: (1 item) + │ │ │ │ │ └── @ CallNode (location: (1:27)-(1:29)) + │ │ │ │ │ ├── receiver: ∅ + │ │ │ │ │ ├── call_operator_loc: ∅ + │ │ │ │ │ ├── name: :id + │ │ │ │ │ ├── message_loc: (1:27)-(1:29) + │ │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ │ ├── arguments: ∅ + │ │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ │ ├── block: ∅ + │ │ │ │ │ ├── call_operator: ∅ + │ │ │ │ │ ├── message: "id" + │ │ │ │ │ ├── opening: ∅ + │ │ │ │ │ ├── closing: ∅ + │ │ │ │ │ └── equal: ∅ + │ │ │ │ ├── opening_loc: (1:25)-(1:26) + │ │ │ │ ├── closing_loc: (1:30)-(1:31) + │ │ │ │ ├── opening: "{" + │ │ │ │ └── closing: "}" + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "Products" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "query" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "graphql" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── @ HTMLTextNode (location: (1:34)-(2:0)) │ └── content: "\n" @@ -86,7 +108,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── @ HTMLTextNode (location: (2:11)-(3:0)) └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/erb_openers_test/test_0013_a_configured_tag_gets_no_nested_prism_nodes_102be0a51c570ab94f1ec4ef062b1412-0cffaea49c6f77b9a084769c1d358883.txt b/test/snapshots/parser/erb_openers_test/test_0013_a_configured_tag_gets_no_nested_prism_nodes_102be0a51c570ab94f1ec4ef062b1412-0cffaea49c6f77b9a084769c1d358883.txt index d71015c12..f4bc3829c 100644 --- a/test/snapshots/parser/erb_openers_test/test_0013_a_configured_tag_gets_no_nested_prism_nodes_102be0a51c570ab94f1ec4ef062b1412-0cffaea49c6f77b9a084769c1d358883.txt +++ b/test/snapshots/parser/erb_openers_test/test_0013_a_configured_tag_gets_no_nested_prism_nodes_102be0a51c570ab94f1ec4ef062b1412-0cffaea49c6f77b9a084769c1d358883.txt @@ -33,7 +33,12 @@ options: {erb_openers: ["graphql"], prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── @ HTMLTextNode (location: (2:11)-(3:0)) └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 529fa929f..1e90d8c17 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -16,4 +16,7 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── opening_loc: (1:4)-(1:5) ├── content_loc: (1:5)-(1:10) ├── closing_loc: (1:10)-(1:11) - └── unescaped: "hello" \ No newline at end of file + ├── unescaped: "hello" + ├── opening: "\"" + ├── content: "hello" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 3e483ec99..7e9240577 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -23,7 +23,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "user" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :name ├── message_loc: (1:9)-(1:13) @@ -31,4 +36,9 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "name" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-e79bb61ffe77cd2ab8e991dc1764c41e.txt index cf6d74e48..650cbbb48 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -25,7 +25,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "user" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :posts │ ├── message_loc: (1:9)-(1:14) @@ -33,7 +38,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "posts" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:14)-(1:15) ├── name: :count ├── message_loc: (1:15)-(1:20) @@ -41,4 +51,9 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "count" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-e79bb61ffe77cd2ab8e991dc1764c41e.txt index cdec57cc1..255caf1e6 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -25,7 +25,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:12)-(1:13) │ │ ├── content_loc: (1:13)-(1:17) │ │ ├── closing_loc: (1:17)-(1:18) - │ │ └── unescaped: "Home" + │ │ ├── unescaped: "Home" + │ │ ├── opening: "\"" + │ │ ├── content: "Home" + │ │ └── closing: "\"" │ └── @ CallNode (location: (1:20)-(1:29)) │ ├── receiver: ∅ │ ├── call_operator_loc: ∅ @@ -35,7 +38,17 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "root_path" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "link_to" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-e79bb61ffe77cd2ab8e991dc1764c41e.txt index cf1850fee..a951c0800 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -24,7 +24,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "admin?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: (1:11)-(1:12) ├── statements: │ └── @ StatementsNode (location: (1:13)-(1:18)) @@ -33,7 +38,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:13)-(1:14) │ ├── content_loc: (1:14)-(1:17) │ ├── closing_loc: (1:17)-(1:18) - │ └── unescaped: "Yes" + │ ├── unescaped: "Yes" + │ ├── opening: "\"" + │ ├── content: "Yes" + │ └── closing: "\"" ├── subsequent: │ └── @ ElseNode (location: (1:19)-(1:25)) │ ├── else_keyword_loc: (1:19)-(1:20) @@ -44,6 +52,14 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:21)-(1:22) │ │ ├── content_loc: (1:22)-(1:24) │ │ ├── closing_loc: (1:24)-(1:25) - │ │ └── unescaped: "No" - │ └── end_keyword_loc: ∅ - └── end_keyword_loc: ∅ \ No newline at end of file + │ │ ├── unescaped: "No" + │ │ ├── opening: "\"" + │ │ ├── content: "No" + │ │ └── closing: "\"" + │ ├── end_keyword_loc: ∅ + │ ├── else_keyword: ":" + │ └── end_keyword: ∅ + ├── end_keyword_loc: ∅ + ├── if_keyword: ∅ + ├── then_keyword: "?" + └── end_keyword: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-e79bb61ffe77cd2ab8e991dc1764c41e.txt index e0722f185..532df47cd 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -19,7 +19,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: ∅ │ │ ├── content_loc: (1:5)-(1:11) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "hello " + │ │ ├── unescaped: "hello " + │ │ ├── opening: ∅ + │ │ ├── content: "hello " + │ │ └── closing: ∅ │ └── @ EmbeddedStatementsNode (location: (1:11)-(1:18)) │ ├── opening_loc: (1:11)-(1:13) │ ├── statements: @@ -34,6 +37,15 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── closing_loc: (1:17)-(1:18) - └── closing_loc: (1:18)-(1:19) \ No newline at end of file + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── closing_loc: (1:17)-(1:18) + │ ├── opening: "\#{" + │ └── closing: "}" + ├── closing_loc: (1:18)-(1:19) + ├── opening: "\"" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0008_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0008_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-e79bb61ffe77cd2ab8e991dc1764c41e.txt index a3a7053d6..8e6c94e89 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0008_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0008_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -19,4 +19,5 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── value: │ └── @ IntegerNode (location: (1:7)-(1:8)) │ └── value: 1 - └── operator_loc: (1:5)-(1:6) \ No newline at end of file + ├── operator_loc: (1:5)-(1:6) + └── operator: "=" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0009_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0009_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 819429fa0..6e7c7489e 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0009_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0009_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -27,16 +27,28 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── key: │ │ └── @ SymbolNode (location: (1:10)-(1:18)) │ │ ├── opening_loc: ∅ - │ │ ├── value_loc: (1:10)-(1:17) + │ │ ├── content_loc: (1:10)-(1:17) │ │ ├── closing_loc: (1:17)-(1:18) - │ │ └── unescaped: "partial" + │ │ ├── unescaped: "partial" + │ │ ├── opening: ∅ + │ │ ├── content: "partial" + │ │ └── closing: ":" │ ├── value: │ │ └── @ StringNode (location: (1:19)-(1:27)) │ │ ├── opening_loc: (1:19)-(1:20) │ │ ├── content_loc: (1:20)-(1:26) │ │ ├── closing_loc: (1:26)-(1:27) - │ │ └── unescaped: "header" - │ └── operator_loc: ∅ + │ │ ├── unescaped: "header" + │ │ ├── opening: "\"" + │ │ ├── content: "header" + │ │ └── closing: "\"" + │ ├── operator_loc: ∅ + │ └── operator: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "render" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0010_if_statement_4670130f794a227341991a25a1b7e654-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0010_if_statement_4670130f794a227341991a25a1b7e654-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 2cff0b445..d39426f17 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0010_if_statement_4670130f794a227341991a25a1b7e654-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0010_if_statement_4670130f794a227341991a25a1b7e654-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -23,9 +23,15 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:17)-(1:18) │ │ ├── content_loc: (1:18)-(1:21) │ │ ├── closing_loc: (1:21)-(1:22) - │ │ └── unescaped: "yes" + │ │ ├── unescaped: "yes" + │ │ ├── opening: "\"" + │ │ ├── content: "yes" + │ │ └── closing: "\"" │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:28)-(1:31) + │ ├── end_keyword_loc: (1:28)-(1:31) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:13)-(1:25)) │ ├── tag_opening: "<%=" (location: (1:13)-(1:16)) @@ -38,7 +44,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:17)-(1:18) │ ├── content_loc: (1:18)-(1:21) │ ├── closing_loc: (1:21)-(1:22) - │ └── unescaped: "yes" + │ ├── unescaped: "yes" + │ ├── opening: "\"" + │ ├── content: "yes" + │ └── closing: "\"" │ ├── subsequent: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0011_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0011_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-e79bb61ffe77cd2ab8e991dc1764c41e.txt index b78311019..d4fbb342d 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0011_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0011_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -23,7 +23,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "admin?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: │ │ └── @ StatementsNode (location: (1:19)-(1:26)) @@ -32,7 +37,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:19)-(1:20) │ │ ├── content_loc: (1:20)-(1:25) │ │ ├── closing_loc: (1:25)-(1:26) - │ │ └── unescaped: "admin" + │ │ ├── unescaped: "admin" + │ │ ├── opening: "\"" + │ │ ├── content: "admin" + │ │ └── closing: "\"" │ ├── subsequent: │ │ └── @ ElseNode (location: (1:32)-(1:58)) │ │ ├── else_keyword_loc: (1:32)-(1:36) @@ -43,9 +51,17 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── opening_loc: (1:43)-(1:44) │ │ │ ├── content_loc: (1:44)-(1:48) │ │ │ ├── closing_loc: (1:48)-(1:49) - │ │ │ └── unescaped: "user" - │ │ └── end_keyword_loc: (1:55)-(1:58) - │ └── end_keyword_loc: (1:55)-(1:58) + │ │ │ ├── unescaped: "user" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "user" + │ │ │ └── closing: "\"" + │ │ ├── end_keyword_loc: (1:55)-(1:58) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:55)-(1:58) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:15)-(1:29)) │ ├── tag_opening: "<%=" (location: (1:15)-(1:18)) @@ -58,7 +74,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:19)-(1:20) │ ├── content_loc: (1:20)-(1:25) │ ├── closing_loc: (1:25)-(1:26) - │ └── unescaped: "admin" + │ ├── unescaped: "admin" + │ ├── opening: "\"" + │ ├── content: "admin" + │ └── closing: "\"" │ ├── subsequent: │ └── @ ERBElseNode (location: (1:29)-(1:52)) @@ -77,7 +96,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:43)-(1:44) │ ├── content_loc: (1:44)-(1:48) │ ├── closing_loc: (1:48)-(1:49) - │ └── unescaped: "user" + │ ├── unescaped: "user" + │ ├── opening: "\"" + │ ├── content: "user" + │ └── closing: "\"" │ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0012_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0012_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 792f21d0f..13db9845c 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0012_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0012_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -23,7 +23,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "a?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: @@ -39,16 +44,29 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "b?" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: ∅ │ │ ├── subsequent: │ │ │ └── @ ElseNode (location: (1:30)-(1:44)) │ │ │ ├── else_keyword_loc: (1:30)-(1:34) │ │ │ ├── statements: ∅ - │ │ │ └── end_keyword_loc: (1:41)-(1:44) - │ │ └── end_keyword_loc: (1:41)-(1:44) - │ └── end_keyword_loc: (1:41)-(1:44) + │ │ │ ├── end_keyword_loc: (1:41)-(1:44) + │ │ │ ├── else_keyword: "else" + │ │ │ └── end_keyword: "end" + │ │ ├── end_keyword_loc: (1:41)-(1:44) + │ │ ├── if_keyword: "elsif" + │ │ ├── then_keyword: ∅ + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:41)-(1:44) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ HTMLTextNode (location: (1:11)-(1:12)) │ └── content: "A" diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0013_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0013_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 9c740abc6..0a4fb9d92 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0013_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0013_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -25,7 +25,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "user" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── call_operator_loc: (1:10)-(1:11) │ │ ├── name: :admin? │ │ ├── message_loc: (1:11)-(1:17) @@ -33,7 +38,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "admin?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: │ │ └── @ StatementsNode (location: (1:24)-(1:33)) @@ -49,7 +59,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "user" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── call_operator_loc: (1:28)-(1:29) │ │ ├── name: :name │ │ ├── message_loc: (1:29)-(1:33) @@ -57,9 +72,17 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:39)-(1:42) + │ ├── end_keyword_loc: (1:39)-(1:42) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:36)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) @@ -79,7 +102,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "user" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:28)-(1:29) │ ├── name: :name │ ├── message_loc: (1:29)-(1:33) @@ -87,7 +115,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── subsequent: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 9d1fb8634..ccec0f76f 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -12,7 +12,7 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── then_keyword: ∅ ├── prism_node: │ └── @ UnlessNode (location: (1:3)-(1:40)) - │ ├── keyword_loc: (1:3)-(1:9) + │ ├── unless_keyword_loc: (1:3)-(1:9) │ ├── predicate: │ │ └── @ CallNode (location: (1:10)-(1:17)) │ │ ├── receiver: ∅ @@ -23,7 +23,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "hidden?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: │ │ └── @ StatementsNode (location: (1:24)-(1:31)) @@ -37,9 +42,17 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "content" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── else_clause: ∅ - │ └── end_keyword_loc: (1:37)-(1:40) + │ ├── end_keyword_loc: (1:37)-(1:40) + │ ├── unless_keyword: "unless" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:34)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) @@ -57,7 +70,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "content" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── else_clause: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 60801c551..29c1ac9c6 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -12,7 +12,7 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── then_keyword: ∅ ├── prism_node: │ └── @ UnlessNode (location: (1:3)-(1:70)) - │ ├── keyword_loc: (1:3)-(1:9) + │ ├── unless_keyword_loc: (1:3)-(1:9) │ ├── predicate: │ │ └── @ CallNode (location: (1:10)-(1:16)) │ │ ├── receiver: ∅ @@ -23,7 +23,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "admin?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: │ │ └── @ StatementsNode (location: (1:23)-(1:35)) @@ -32,7 +37,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:23)-(1:24) │ │ ├── content_loc: (1:24)-(1:34) │ │ ├── closing_loc: (1:34)-(1:35) - │ │ └── unescaped: "restricted" + │ │ ├── unescaped: "restricted" + │ │ ├── opening: "\"" + │ │ ├── content: "restricted" + │ │ └── closing: "\"" │ ├── else_clause: │ │ └── @ ElseNode (location: (1:41)-(1:70)) │ │ ├── else_keyword_loc: (1:41)-(1:45) @@ -43,9 +51,17 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── opening_loc: (1:52)-(1:53) │ │ │ ├── content_loc: (1:53)-(1:60) │ │ │ ├── closing_loc: (1:60)-(1:61) - │ │ │ └── unescaped: "welcome" - │ │ └── end_keyword_loc: (1:67)-(1:70) - │ └── end_keyword_loc: (1:67)-(1:70) + │ │ │ ├── unescaped: "welcome" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "welcome" + │ │ │ └── closing: "\"" + │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:67)-(1:70) + │ ├── unless_keyword: "unless" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:19)-(1:38)) │ ├── tag_opening: "<%=" (location: (1:19)-(1:22)) @@ -58,7 +74,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:23)-(1:24) │ ├── content_loc: (1:24)-(1:34) │ ├── closing_loc: (1:34)-(1:35) - │ └── unescaped: "restricted" + │ ├── unescaped: "restricted" + │ ├── opening: "\"" + │ ├── content: "restricted" + │ └── closing: "\"" │ ├── else_clause: │ └── @ ERBElseNode (location: (1:38)-(1:64)) @@ -77,7 +96,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:52)-(1:53) │ ├── content_loc: (1:53)-(1:60) │ ├── closing_loc: (1:60)-(1:61) - │ └── unescaped: "welcome" + │ ├── unescaped: "welcome" + │ ├── opening: "\"" + │ ├── content: "welcome" + │ └── closing: "\"" │ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 7c7a657eb..1e46ce77b 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each │ ├── message_loc: (1:9)-(1:13) @@ -29,34 +34,43 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:14)-(1:43)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:17)-(1:18) - │ │ └── closing_loc: (1:22)-(1:23) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:30)-(1:34)) - │ │ └── body: (1 item) - │ │ └── @ LocalVariableReadNode (location: (1:30)-(1:34)) - │ │ ├── name: :item - │ │ └── depth: 0 - │ ├── opening_loc: (1:14)-(1:16) - │ └── closing_loc: (1:40)-(1:43) + │ ├── block: + │ │ └── @ BlockNode (location: (1:14)-(1:43)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:17)-(1:18) + │ │ │ ├── closing_loc: (1:22)-(1:23) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:30)-(1:34)) + │ │ │ └── body: (1 item) + │ │ │ └── @ LocalVariableReadNode (location: (1:30)-(1:34)) + │ │ │ ├── name: :item + │ │ │ └── depth: 0 + │ │ ├── opening_loc: (1:14)-(1:16) + │ │ ├── closing_loc: (1:40)-(1:43) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:26)-(1:37)) │ ├── tag_opening: "<%=" (location: (1:26)-(1:29)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-e79bb61ffe77cd2ab8e991dc1764c41e.txt index bd7b434b0..59a97bdc3 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each_with_index │ ├── message_loc: (1:9)-(1:24) @@ -29,37 +34,46 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:25)-(1:61)) - │ ├── locals: (2 items) - │ │ ├── :item - │ │ └── :index - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:28)-(1:41)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:29)-(1:40)) - │ │ │ ├── requireds: (2 items) - │ │ │ │ ├── @ RequiredParameterNode (location: (1:29)-(1:33)) - │ │ │ │ │ └── name: :item - │ │ │ │ └── @ RequiredParameterNode (location: (1:35)-(1:40)) - │ │ │ │ └── name: :index - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:28)-(1:29) - │ │ └── closing_loc: (1:40)-(1:41) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:48)-(1:52)) - │ │ └── body: (1 item) - │ │ └── @ LocalVariableReadNode (location: (1:48)-(1:52)) - │ │ ├── name: :item - │ │ └── depth: 0 - │ ├── opening_loc: (1:25)-(1:27) - │ └── closing_loc: (1:58)-(1:61) + │ ├── block: + │ │ └── @ BlockNode (location: (1:25)-(1:61)) + │ │ ├── locals: (2 items) + │ │ │ ├── :item + │ │ │ └── :index + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:28)-(1:41)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:29)-(1:40)) + │ │ │ │ ├── requireds: (2 items) + │ │ │ │ │ ├── @ RequiredParameterNode (location: (1:29)-(1:33)) + │ │ │ │ │ │ └── name: :item + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:35)-(1:40)) + │ │ │ │ │ └── name: :index + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:28)-(1:29) + │ │ │ ├── closing_loc: (1:40)-(1:41) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:48)-(1:52)) + │ │ │ └── body: (1 item) + │ │ │ └── @ LocalVariableReadNode (location: (1:48)-(1:52)) + │ │ │ ├── name: :item + │ │ │ └── depth: 0 + │ │ ├── opening_loc: (1:25)-(1:27) + │ │ ├── closing_loc: (1:58)-(1:61) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each_with_index" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:44)-(1:55)) │ ├── tag_opening: "<%=" (location: (1:44)-(1:47)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-e79bb61ffe77cd2ab8e991dc1764c41e.txt index ea7a09d9a..27a543ae9 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :map │ ├── message_loc: (1:9)-(1:12) @@ -29,44 +34,58 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:13)-(1:47)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:16)-(1:22)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:17)-(1:21)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:17)-(1:21)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:16)-(1:17) - │ │ └── closing_loc: (1:21)-(1:22) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:29)-(1:38)) - │ │ └── body: (1 item) - │ │ └── @ CallNode (location: (1:29)-(1:38)) - │ │ ├── receiver: - │ │ │ └── @ LocalVariableReadNode (location: (1:29)-(1:33)) - │ │ │ ├── name: :item - │ │ │ └── depth: 0 - │ │ ├── call_operator_loc: (1:33)-(1:34) - │ │ ├── name: :name - │ │ ├── message_loc: (1:34)-(1:38) - │ │ ├── opening_loc: ∅ - │ │ ├── arguments: ∅ - │ │ ├── closing_loc: ∅ - │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ ├── opening_loc: (1:13)-(1:15) - │ └── closing_loc: (1:44)-(1:47) + │ ├── block: + │ │ └── @ BlockNode (location: (1:13)-(1:47)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:16)-(1:22)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:17)-(1:21)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:17)-(1:21)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:16)-(1:17) + │ │ │ ├── closing_loc: (1:21)-(1:22) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:29)-(1:38)) + │ │ │ └── body: (1 item) + │ │ │ └── @ CallNode (location: (1:29)-(1:38)) + │ │ │ ├── receiver: + │ │ │ │ └── @ LocalVariableReadNode (location: (1:29)-(1:33)) + │ │ │ │ ├── name: :item + │ │ │ │ └── depth: 0 + │ │ │ ├── call_operator_loc: (1:33)-(1:34) + │ │ │ ├── name: :name + │ │ │ ├── message_loc: (1:34)-(1:38) + │ │ │ ├── opening_loc: ∅ + │ │ │ ├── arguments: ∅ + │ │ │ ├── closing_loc: ∅ + │ │ │ ├── equal_loc: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "name" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ + │ │ ├── opening_loc: (1:13)-(1:15) + │ │ ├── closing_loc: (1:44)-(1:47) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "map" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:25)-(1:41)) │ ├── tag_opening: "<%=" (location: (1:25)-(1:28)) @@ -87,7 +106,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── block_arguments: (1 item) │ └── @ RubyParameterNode (location: (1:17)-(1:21)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 553cb6aa0..bb9553c15 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -21,34 +21,43 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:11)-(1:34)) - │ ├── locals: (1 item) - │ │ └── :i - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:14)-(1:17)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:15)-(1:16)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:15)-(1:16)) - │ │ │ │ └── name: :i - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:14)-(1:15) - │ │ └── closing_loc: (1:16)-(1:17) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:24)-(1:25)) - │ │ └── body: (1 item) - │ │ └── @ LocalVariableReadNode (location: (1:24)-(1:25)) - │ │ ├── name: :i - │ │ └── depth: 0 - │ ├── opening_loc: (1:11)-(1:13) - │ └── closing_loc: (1:31)-(1:34) + │ ├── block: + │ │ └── @ BlockNode (location: (1:11)-(1:34)) + │ │ ├── locals: (1 item) + │ │ │ └── :i + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:14)-(1:17)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:15)-(1:16)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:15)-(1:16)) + │ │ │ │ │ └── name: :i + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:14)-(1:15) + │ │ │ ├── closing_loc: (1:16)-(1:17) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:24)-(1:25)) + │ │ │ └── body: (1 item) + │ │ │ └── @ LocalVariableReadNode (location: (1:24)-(1:25)) + │ │ │ ├── name: :i + │ │ │ └── depth: 0 + │ │ ├── opening_loc: (1:11)-(1:13) + │ │ ├── closing_loc: (1:31)-(1:34) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "times" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:28)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 7c72c843b..981c25b1d 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -11,9 +11,9 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── tag_closing: "%>" (location: (1:18)-(1:20)) ├── prism_node: │ └── @ WhileNode (location: (1:3)-(1:39)) - │ ├── keyword_loc: (1:3)-(1:8) + │ ├── while_keyword_loc: (1:3)-(1:8) │ ├── do_keyword_loc: ∅ - │ ├── closing_loc: (1:36)-(1:39) + │ ├── end_keyword_loc: (1:36)-(1:39) │ ├── predicate: │ │ └── @ CallNode (location: (1:9)-(1:17)) │ │ ├── receiver: ∅ @@ -24,20 +24,33 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── statements: - │ └── @ StatementsNode (location: (1:24)-(1:30)) - │ └── body: (1 item) - │ └── @ CallNode (location: (1:24)-(1:30)) - │ ├── receiver: ∅ - │ ├── call_operator_loc: ∅ - │ ├── name: :status - │ ├── message_loc: (1:24)-(1:30) - │ ├── opening_loc: ∅ - │ ├── arguments: ∅ - │ ├── closing_loc: ∅ - │ ├── equal_loc: ∅ - │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "running?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── statements: + │ │ └── @ StatementsNode (location: (1:24)-(1:30)) + │ │ └── body: (1 item) + │ │ └── @ CallNode (location: (1:24)-(1:30)) + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :status + │ │ ├── message_loc: (1:24)-(1:30) + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── equal_loc: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "status" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── while_keyword: "while" + │ ├── do_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:33)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) @@ -55,7 +68,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "status" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── end_node: └── @ ERBEndNode (location: (1:33)-(1:42)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-e79bb61ffe77cd2ab8e991dc1764c41e.txt index df50f445c..ba51313f7 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -11,9 +11,9 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── tag_closing: "%>" (location: (1:15)-(1:17)) ├── prism_node: │ └── @ UntilNode (location: (1:3)-(1:38)) - │ ├── keyword_loc: (1:3)-(1:8) + │ ├── until_keyword_loc: (1:3)-(1:8) │ ├── do_keyword_loc: ∅ - │ ├── closing_loc: (1:35)-(1:38) + │ ├── end_keyword_loc: (1:35)-(1:38) │ ├── predicate: │ │ └── @ CallNode (location: (1:9)-(1:14)) │ │ ├── receiver: ∅ @@ -24,20 +24,33 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── statements: - │ └── @ StatementsNode (location: (1:21)-(1:29)) - │ └── body: (1 item) - │ └── @ CallNode (location: (1:21)-(1:29)) - │ ├── receiver: ∅ - │ ├── call_operator_loc: ∅ - │ ├── name: :progress - │ ├── message_loc: (1:21)-(1:29) - │ ├── opening_loc: ∅ - │ ├── arguments: ∅ - │ ├── closing_loc: ∅ - │ ├── equal_loc: ∅ - │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "done?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── statements: + │ │ └── @ StatementsNode (location: (1:21)-(1:29)) + │ │ └── body: (1 item) + │ │ └── @ CallNode (location: (1:21)-(1:29)) + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :progress + │ │ ├── message_loc: (1:21)-(1:29) + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── equal_loc: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "progress" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── until_keyword: "until" + │ ├── do_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:17)-(1:32)) │ ├── tag_opening: "<%=" (location: (1:17)-(1:20)) @@ -55,7 +68,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "progress" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── end_node: └── @ ERBEndNode (location: (1:32)-(1:41)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 29ffec70d..bf8efd025 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -25,7 +25,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── statements: │ │ └── @ StatementsNode (location: (1:27)-(1:31)) │ │ └── body: (1 item) @@ -35,7 +40,11 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── for_keyword_loc: (1:3)-(1:6) │ ├── in_keyword_loc: (1:12)-(1:14) │ ├── do_keyword_loc: ∅ - │ └── end_keyword_loc: (1:37)-(1:40) + │ ├── end_keyword_loc: (1:37)-(1:40) + │ ├── for_keyword: "for" + │ ├── in_keyword: "in" + │ ├── do_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:23)-(1:34)) │ ├── tag_opening: "<%=" (location: (1:23)-(1:26)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 4b62a5606..078ea7a11 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -22,45 +22,68 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "role" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── conditions: (2 items) │ │ ├── @ WhenNode (location: (1:18)-(1:44)) - │ │ │ ├── keyword_loc: (1:18)-(1:22) + │ │ │ ├── when_keyword_loc: (1:18)-(1:22) │ │ │ ├── conditions: (1 item) │ │ │ │ └── @ StringNode (location: (1:23)-(1:30)) │ │ │ │ ├── opening_loc: (1:23)-(1:24) │ │ │ │ ├── content_loc: (1:24)-(1:29) │ │ │ │ ├── closing_loc: (1:29)-(1:30) - │ │ │ │ └── unescaped: "admin" + │ │ │ │ ├── unescaped: "admin" + │ │ │ │ ├── opening: "\"" + │ │ │ │ ├── content: "admin" + │ │ │ │ └── closing: "\"" │ │ │ ├── then_keyword_loc: ∅ - │ │ │ └── statements: - │ │ │ └── @ StatementsNode (location: (1:37)-(1:44)) - │ │ │ └── body: (1 item) - │ │ │ └── @ StringNode (location: (1:37)-(1:44)) - │ │ │ ├── opening_loc: (1:37)-(1:38) - │ │ │ ├── content_loc: (1:38)-(1:43) - │ │ │ ├── closing_loc: (1:43)-(1:44) - │ │ │ └── unescaped: "Admin" + │ │ │ ├── statements: + │ │ │ │ └── @ StatementsNode (location: (1:37)-(1:44)) + │ │ │ │ └── body: (1 item) + │ │ │ │ └── @ StringNode (location: (1:37)-(1:44)) + │ │ │ │ ├── opening_loc: (1:37)-(1:38) + │ │ │ │ ├── content_loc: (1:38)-(1:43) + │ │ │ │ ├── closing_loc: (1:43)-(1:44) + │ │ │ │ ├── unescaped: "Admin" + │ │ │ │ ├── opening: "\"" + │ │ │ │ ├── content: "Admin" + │ │ │ │ └── closing: "\"" + │ │ │ ├── when_keyword: "when" + │ │ │ └── then_keyword: ∅ │ │ └── @ WhenNode (location: (1:50)-(1:74)) - │ │ ├── keyword_loc: (1:50)-(1:54) + │ │ ├── when_keyword_loc: (1:50)-(1:54) │ │ ├── conditions: (1 item) │ │ │ └── @ StringNode (location: (1:55)-(1:61)) │ │ │ ├── opening_loc: (1:55)-(1:56) │ │ │ ├── content_loc: (1:56)-(1:60) │ │ │ ├── closing_loc: (1:60)-(1:61) - │ │ │ └── unescaped: "user" + │ │ │ ├── unescaped: "user" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "user" + │ │ │ └── closing: "\"" │ │ ├── then_keyword_loc: ∅ - │ │ └── statements: - │ │ └── @ StatementsNode (location: (1:68)-(1:74)) - │ │ └── body: (1 item) - │ │ └── @ StringNode (location: (1:68)-(1:74)) - │ │ ├── opening_loc: (1:68)-(1:69) - │ │ ├── content_loc: (1:69)-(1:73) - │ │ ├── closing_loc: (1:73)-(1:74) - │ │ └── unescaped: "User" + │ │ ├── statements: + │ │ │ └── @ StatementsNode (location: (1:68)-(1:74)) + │ │ │ └── body: (1 item) + │ │ │ └── @ StringNode (location: (1:68)-(1:74)) + │ │ │ ├── opening_loc: (1:68)-(1:69) + │ │ │ ├── content_loc: (1:69)-(1:73) + │ │ │ ├── closing_loc: (1:73)-(1:74) + │ │ │ ├── unescaped: "User" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "User" + │ │ │ └── closing: "\"" + │ │ ├── when_keyword: "when" + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── case_keyword_loc: (1:3)-(1:7) - │ └── end_keyword_loc: (1:80)-(1:83) + │ ├── end_keyword_loc: (1:80)-(1:83) + │ ├── case_keyword: "case" + │ └── end_keyword: "end" ├── conditions: (2 items) │ ├── @ ERBWhenNode (location: (1:15)-(1:33)) │ │ ├── tag_opening: "<%" (location: (1:15)-(1:17)) @@ -79,7 +102,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:37)-(1:38) │ │ ├── content_loc: (1:38)-(1:43) │ │ ├── closing_loc: (1:43)-(1:44) - │ │ └── unescaped: "Admin" + │ │ ├── unescaped: "Admin" + │ │ ├── opening: "\"" + │ │ ├── content: "Admin" + │ │ └── closing: "\"" │ │ │ │ │ └── @ ERBWhenNode (location: (1:47)-(1:64)) @@ -99,7 +125,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── opening_loc: (1:68)-(1:69) │ ├── content_loc: (1:69)-(1:73) │ ├── closing_loc: (1:73)-(1:74) - │ └── unescaped: "User" + │ ├── unescaped: "User" + │ ├── opening: "\"" + │ ├── content: "User" + │ └── closing: "\"" │ │ ├── else_clause: ∅ diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 1cd27de56..e8914fbf8 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -22,35 +22,54 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "status" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── conditions: (2 items) │ │ ├── @ WhenNode (location: (1:20)-(1:32)) - │ │ │ ├── keyword_loc: (1:20)-(1:24) + │ │ │ ├── when_keyword_loc: (1:20)-(1:24) │ │ │ ├── conditions: (1 item) │ │ │ │ └── @ SymbolNode (location: (1:25)-(1:32)) │ │ │ │ ├── opening_loc: (1:25)-(1:26) - │ │ │ │ ├── value_loc: (1:26)-(1:32) + │ │ │ │ ├── content_loc: (1:26)-(1:32) │ │ │ │ ├── closing_loc: ∅ - │ │ │ │ └── unescaped: "active" + │ │ │ │ ├── unescaped: "active" + │ │ │ │ ├── opening: ":" + │ │ │ │ ├── content: "active" + │ │ │ │ └── closing: ∅ │ │ │ ├── then_keyword_loc: ∅ - │ │ │ └── statements: ∅ + │ │ │ ├── statements: ∅ + │ │ │ ├── when_keyword: "when" + │ │ │ └── then_keyword: ∅ │ │ └── @ WhenNode (location: (1:44)-(1:58)) - │ │ ├── keyword_loc: (1:44)-(1:48) + │ │ ├── when_keyword_loc: (1:44)-(1:48) │ │ ├── conditions: (1 item) │ │ │ └── @ SymbolNode (location: (1:49)-(1:58)) │ │ │ ├── opening_loc: (1:49)-(1:50) - │ │ │ ├── value_loc: (1:50)-(1:58) + │ │ │ ├── content_loc: (1:50)-(1:58) │ │ │ ├── closing_loc: ∅ - │ │ │ └── unescaped: "inactive" + │ │ │ ├── unescaped: "inactive" + │ │ │ ├── opening: ":" + │ │ │ ├── content: "inactive" + │ │ │ └── closing: ∅ │ │ ├── then_keyword_loc: ∅ - │ │ └── statements: ∅ + │ │ ├── statements: ∅ + │ │ ├── when_keyword: "when" + │ │ └── then_keyword: ∅ │ ├── else_clause: │ │ └── @ ElseNode (location: (1:72)-(1:92)) │ │ ├── else_keyword_loc: (1:72)-(1:76) │ │ ├── statements: ∅ - │ │ └── end_keyword_loc: (1:89)-(1:92) + │ │ ├── end_keyword_loc: (1:89)-(1:92) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" │ ├── case_keyword_loc: (1:3)-(1:7) - │ └── end_keyword_loc: (1:89)-(1:92) + │ ├── end_keyword_loc: (1:89)-(1:92) + │ ├── case_keyword: "case" + │ └── end_keyword: "end" ├── conditions: (2 items) │ ├── @ ERBWhenNode (location: (1:17)-(1:35)) │ │ ├── tag_opening: "<%" (location: (1:17)-(1:19)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 10d83c522..9132e5060 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -22,7 +22,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "data" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── conditions: (1 item) │ │ └── @ InNode (location: (1:18)-(1:41)) │ │ ├── pattern: @@ -33,30 +38,40 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ │ ├── key: │ │ │ │ │ └── @ SymbolNode (location: (1:23)-(1:28)) │ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ │ ├── value_loc: (1:23)-(1:27) + │ │ │ │ │ ├── content_loc: (1:23)-(1:27) │ │ │ │ │ ├── closing_loc: (1:27)-(1:28) - │ │ │ │ │ └── unescaped: "name" + │ │ │ │ │ ├── unescaped: "name" + │ │ │ │ │ ├── opening: ∅ + │ │ │ │ │ ├── content: "name" + │ │ │ │ │ └── closing: ":" │ │ │ │ ├── value: │ │ │ │ │ └── @ ImplicitNode (location: (1:23)-(1:27)) │ │ │ │ │ └── value: │ │ │ │ │ └── @ LocalVariableTargetNode (location: (1:23)-(1:27)) │ │ │ │ │ ├── name: :name │ │ │ │ │ └── depth: 0 - │ │ │ │ └── operator_loc: ∅ + │ │ │ │ ├── operator_loc: ∅ + │ │ │ │ └── operator: ∅ │ │ │ ├── rest: ∅ │ │ │ ├── opening_loc: (1:21)-(1:22) - │ │ │ └── closing_loc: (1:29)-(1:30) + │ │ │ ├── closing_loc: (1:29)-(1:30) + │ │ │ ├── opening: "{" + │ │ │ └── closing: "}" │ │ ├── statements: │ │ │ └── @ StatementsNode (location: (1:37)-(1:41)) │ │ │ └── body: (1 item) │ │ │ └── @ LocalVariableReadNode (location: (1:37)-(1:41)) │ │ │ ├── name: :name │ │ │ └── depth: 0 - │ │ ├── in_loc: (1:18)-(1:20) - │ │ └── then_loc: ∅ + │ │ ├── in_keyword_loc: (1:18)-(1:20) + │ │ ├── then_keyword_loc: ∅ + │ │ ├── in_keyword: "in" + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── case_keyword_loc: (1:3)-(1:7) - │ └── end_keyword_loc: (1:47)-(1:50) + │ ├── end_keyword_loc: (1:47)-(1:50) + │ ├── case_keyword: "case" + │ └── end_keyword: "end" ├── conditions: (1 item) │ └── @ ERBInNode (location: (1:15)-(1:33)) │ ├── tag_opening: "<%" (location: (1:15)-(1:17)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-e79bb61ffe77cd2ab8e991dc1764c41e.txt index fcb2a7737..8bd272ebd 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -24,7 +24,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "dangerous_call" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── rescue_clause: │ │ └── @ RescueNode (location: (1:35)-(1:55)) │ │ ├── keyword_loc: (1:35)-(1:41) @@ -39,11 +44,19 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── opening_loc: (1:48)-(1:49) │ │ │ ├── content_loc: (1:49)-(1:54) │ │ │ ├── closing_loc: (1:54)-(1:55) - │ │ │ └── unescaped: "error" - │ │ └── subsequent: ∅ + │ │ │ ├── unescaped: "error" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "error" + │ │ │ └── closing: "\"" + │ │ ├── subsequent: ∅ + │ │ ├── keyword: "rescue" + │ │ ├── operator: ∅ + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── ensure_clause: ∅ - │ └── end_keyword_loc: (1:61)-(1:64) + │ ├── end_keyword_loc: (1:61)-(1:64) + │ ├── begin_keyword: "begin" + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:11)-(1:32)) │ ├── tag_opening: "<%=" (location: (1:11)-(1:14)) @@ -61,7 +74,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "dangerous_call" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── rescue_clause: │ └── @ ERBRescueNode (location: (1:32)-(1:58)) @@ -80,7 +98,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── opening_loc: (1:48)-(1:49) │ │ ├── content_loc: (1:49)-(1:54) │ │ ├── closing_loc: (1:54)-(1:55) - │ │ └── unescaped: "error" + │ │ ├── unescaped: "error" + │ │ ├── opening: "\"" + │ │ ├── content: "error" + │ │ └── closing: "\"" │ │ │ └── subsequent: ∅ │ diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 23b27d37c..9c97f7e2e 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -24,7 +24,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "risky" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── rescue_clause: │ │ └── @ RescueNode (location: (1:26)-(1:53)) │ │ ├── keyword_loc: (1:26)-(1:32) @@ -50,8 +55,16 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ - │ │ └── subsequent: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "message" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ + │ │ ├── subsequent: ∅ + │ │ ├── keyword: "rescue" + │ │ ├── operator: "=>" + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── ensure_clause: │ │ └── @ EnsureNode (location: (1:59)-(1:88)) @@ -68,9 +81,18 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ - │ │ └── end_keyword_loc: (1:85)-(1:88) - │ └── end_keyword_loc: (1:85)-(1:88) + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "cleanup" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ + │ │ ├── end_keyword_loc: (1:85)-(1:88) + │ │ ├── ensure_keyword: "ensure" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:85)-(1:88) + │ ├── begin_keyword: "begin" + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:11)-(1:23)) │ ├── tag_opening: "<%=" (location: (1:11)-(1:14)) @@ -88,7 +110,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "risky" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── rescue_clause: │ └── @ ERBRescueNode (location: (1:23)-(1:56)) @@ -115,7 +142,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "message" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ │ │ └── subsequent: ∅ │ @@ -142,7 +174,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "cleanup" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-e79bb61ffe77cd2ab8e991dc1764c41e.txt index cd1abd05a..40e5244dd 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each │ ├── message_loc: (1:9)-(1:13) @@ -29,66 +34,88 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:14)-(1:79)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:17)-(1:18) - │ │ └── closing_loc: (1:22)-(1:23) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:29)-(1:70)) - │ │ └── body: (1 item) - │ │ └── @ IfNode (location: (1:29)-(1:70)) - │ │ ├── if_keyword_loc: (1:29)-(1:31) - │ │ ├── predicate: - │ │ │ └── @ CallNode (location: (1:32)-(1:45)) - │ │ │ ├── receiver: - │ │ │ │ └── @ LocalVariableReadNode (location: (1:32)-(1:36)) - │ │ │ │ ├── name: :item - │ │ │ │ └── depth: 0 - │ │ │ ├── call_operator_loc: (1:36)-(1:37) - │ │ │ ├── name: :visible? - │ │ │ ├── message_loc: (1:37)-(1:45) - │ │ │ ├── opening_loc: ∅ - │ │ │ ├── arguments: ∅ - │ │ │ ├── closing_loc: ∅ - │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ - │ │ ├── then_keyword_loc: ∅ - │ │ ├── statements: - │ │ │ └── @ StatementsNode (location: (1:52)-(1:61)) - │ │ │ └── body: (1 item) - │ │ │ └── @ CallNode (location: (1:52)-(1:61)) - │ │ │ ├── receiver: - │ │ │ │ └── @ LocalVariableReadNode (location: (1:52)-(1:56)) - │ │ │ │ ├── name: :item - │ │ │ │ └── depth: 0 - │ │ │ ├── call_operator_loc: (1:56)-(1:57) - │ │ │ ├── name: :name - │ │ │ ├── message_loc: (1:57)-(1:61) - │ │ │ ├── opening_loc: ∅ - │ │ │ ├── arguments: ∅ - │ │ │ ├── closing_loc: ∅ - │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ - │ │ ├── subsequent: ∅ - │ │ └── end_keyword_loc: (1:67)-(1:70) - │ ├── opening_loc: (1:14)-(1:16) - │ └── closing_loc: (1:76)-(1:79) + │ ├── block: + │ │ └── @ BlockNode (location: (1:14)-(1:79)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:17)-(1:18) + │ │ │ ├── closing_loc: (1:22)-(1:23) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:29)-(1:70)) + │ │ │ └── body: (1 item) + │ │ │ └── @ IfNode (location: (1:29)-(1:70)) + │ │ │ ├── if_keyword_loc: (1:29)-(1:31) + │ │ │ ├── predicate: + │ │ │ │ └── @ CallNode (location: (1:32)-(1:45)) + │ │ │ │ ├── receiver: + │ │ │ │ │ └── @ LocalVariableReadNode (location: (1:32)-(1:36)) + │ │ │ │ │ ├── name: :item + │ │ │ │ │ └── depth: 0 + │ │ │ │ ├── call_operator_loc: (1:36)-(1:37) + │ │ │ │ ├── name: :visible? + │ │ │ │ ├── message_loc: (1:37)-(1:45) + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ ├── block: ∅ + │ │ │ │ ├── call_operator: "." + │ │ │ │ ├── message: "visible?" + │ │ │ │ ├── opening: ∅ + │ │ │ │ ├── closing: ∅ + │ │ │ │ └── equal: ∅ + │ │ │ ├── then_keyword_loc: ∅ + │ │ │ ├── statements: + │ │ │ │ └── @ StatementsNode (location: (1:52)-(1:61)) + │ │ │ │ └── body: (1 item) + │ │ │ │ └── @ CallNode (location: (1:52)-(1:61)) + │ │ │ │ ├── receiver: + │ │ │ │ │ └── @ LocalVariableReadNode (location: (1:52)-(1:56)) + │ │ │ │ │ ├── name: :item + │ │ │ │ │ └── depth: 0 + │ │ │ │ ├── call_operator_loc: (1:56)-(1:57) + │ │ │ │ ├── name: :name + │ │ │ │ ├── message_loc: (1:57)-(1:61) + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ ├── block: ∅ + │ │ │ │ ├── call_operator: "." + │ │ │ │ ├── message: "name" + │ │ │ │ ├── opening: ∅ + │ │ │ │ ├── closing: ∅ + │ │ │ │ └── equal: ∅ + │ │ │ ├── subsequent: ∅ + │ │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ │ ├── if_keyword: "if" + │ │ │ ├── then_keyword: ∅ + │ │ │ └── end_keyword: "end" + │ │ ├── opening_loc: (1:14)-(1:16) + │ │ ├── closing_loc: (1:76)-(1:79) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBIfNode (location: (1:26)-(1:73)) │ ├── tag_opening: "<%" (location: (1:26)-(1:28)) @@ -111,7 +138,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "visible?" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: │ │ │ └── @ StatementsNode (location: (1:52)-(1:61)) @@ -128,9 +160,17 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "name" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── subsequent: ∅ - │ │ └── end_keyword_loc: (1:67)-(1:70) + │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ ├── if_keyword: "if" + │ │ ├── then_keyword: ∅ + │ │ └── end_keyword: "end" │ ├── statements: (1 item) │ │ └── @ ERBContentNode (location: (1:48)-(1:64)) │ │ ├── tag_opening: "<%=" (location: (1:48)-(1:51)) @@ -151,7 +191,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ │ │ ├── subsequent: ∅ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-e79bb61ffe77cd2ab8e991dc1764c41e.txt index d3a25448d..1e66f3915 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -41,7 +41,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "css_class" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ │ │ │ ├── close_quote: """ (location: (1:28)-(1:29)) │ │ └── quoted: true @@ -67,7 +72,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "content" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── close_tag: │ └── @ HTMLCloseTagNode (location: (1:44)-(1:50)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0030_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0030_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-e79bb61ffe77cd2ab8e991dc1764c41e.txt index bee4e2b41..ba3bdd2b2 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0030_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0030_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -23,7 +23,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "show?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: │ │ └── @ StatementsNode (location: (1:18)-(1:31)) @@ -36,12 +41,21 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ │ └── arguments: (1 item) │ │ │ └── @ SymbolNode (location: (1:24)-(1:31)) │ │ │ ├── opening_loc: (1:24)-(1:25) - │ │ │ ├── value_loc: (1:25)-(1:31) + │ │ │ ├── content_loc: (1:25)-(1:31) │ │ │ ├── closing_loc: ∅ - │ │ │ └── unescaped: "header" - │ │ └── rparen_loc: ∅ + │ │ │ ├── unescaped: "header" + │ │ │ ├── opening: ":" + │ │ │ ├── content: "header" + │ │ │ └── closing: ∅ + │ │ ├── rparen_loc: ∅ + │ │ ├── keyword: "yield" + │ │ ├── lparen: ∅ + │ │ └── rparen: ∅ │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:37)-(1:40) + │ ├── end_keyword_loc: (1:37)-(1:40) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBYieldNode (location: (1:14)-(1:34)) │ ├── tag_opening: "<%=" (location: (1:14)-(1:17)) @@ -56,10 +70,16 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ └── arguments: (1 item) │ │ └── @ SymbolNode (location: (1:24)-(1:31)) │ │ ├── opening_loc: (1:24)-(1:25) - │ │ ├── value_loc: (1:25)-(1:31) + │ │ ├── content_loc: (1:25)-(1:31) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "header" - │ └── rparen_loc: ∅ + │ │ ├── unescaped: "header" + │ │ ├── opening: ":" + │ │ ├── content: "header" + │ │ └── closing: ∅ + │ ├── rparen_loc: ∅ + │ ├── keyword: "yield" + │ ├── lparen: ∅ + │ └── rparen: ∅ │ ├── subsequent: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0031_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0031_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 3a7877b96..babac4280 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0031_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0031_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each │ ├── message_loc: (1:9)-(1:13) @@ -29,41 +34,53 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:14)-(1:49)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:17)-(1:18) - │ │ └── closing_loc: (1:22)-(1:23) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:30)-(1:40)) - │ │ └── body: (1 item) - │ │ └── @ YieldNode (location: (1:30)-(1:40)) - │ │ ├── keyword_loc: (1:30)-(1:35) - │ │ ├── lparen_loc: ∅ - │ │ ├── arguments: - │ │ │ └── @ ArgumentsNode (location: (1:36)-(1:40)) - │ │ │ └── arguments: (1 item) - │ │ │ └── @ LocalVariableReadNode (location: (1:36)-(1:40)) - │ │ │ ├── name: :item - │ │ │ └── depth: 0 - │ │ └── rparen_loc: ∅ - │ ├── opening_loc: (1:14)-(1:16) - │ └── closing_loc: (1:46)-(1:49) + │ ├── block: + │ │ └── @ BlockNode (location: (1:14)-(1:49)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:17)-(1:18) + │ │ │ ├── closing_loc: (1:22)-(1:23) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:30)-(1:40)) + │ │ │ └── body: (1 item) + │ │ │ └── @ YieldNode (location: (1:30)-(1:40)) + │ │ │ ├── keyword_loc: (1:30)-(1:35) + │ │ │ ├── lparen_loc: ∅ + │ │ │ ├── arguments: + │ │ │ │ └── @ ArgumentsNode (location: (1:36)-(1:40)) + │ │ │ │ └── arguments: (1 item) + │ │ │ │ └── @ LocalVariableReadNode (location: (1:36)-(1:40)) + │ │ │ │ ├── name: :item + │ │ │ │ └── depth: 0 + │ │ │ ├── rparen_loc: ∅ + │ │ │ ├── keyword: "yield" + │ │ │ ├── lparen: ∅ + │ │ │ └── rparen: ∅ + │ │ ├── opening_loc: (1:14)-(1:16) + │ │ ├── closing_loc: (1:46)-(1:49) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBYieldNode (location: (1:26)-(1:43)) │ ├── tag_opening: "<%=" (location: (1:26)-(1:29)) @@ -79,7 +96,10 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ │ └── @ LocalVariableReadNode (location: (1:36)-(1:40)) │ │ ├── name: :item │ │ └── depth: 0 - │ └── rparen_loc: ∅ + │ ├── rparen_loc: ∅ + │ ├── keyword: "yield" + │ ├── lparen: ∅ + │ └── rparen: ∅ │ ├── block_arguments: (1 item) │ └── @ RubyParameterNode (location: (1:18)-(1:22)) diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0032_yield_1564254a88399098a10aea8889a5b2a8-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0032_yield_1564254a88399098a10aea8889a5b2a8-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 1f2447996..dd0351bbc 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0032_yield_1564254a88399098a10aea8889a5b2a8-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0032_yield_1564254a88399098a10aea8889a5b2a8-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -14,4 +14,7 @@ options: {prism_nodes: true, prism_nodes_deep: true} ├── keyword_loc: (1:4)-(1:9) ├── lparen_loc: ∅ ├── arguments: ∅ - └── rparen_loc: ∅ \ No newline at end of file + ├── rparen_loc: ∅ + ├── keyword: "yield" + ├── lparen: ∅ + └── rparen: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0033_yield_with_arguments_20df759643e04c69893d23024fd03df8-e79bb61ffe77cd2ab8e991dc1764c41e.txt b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0033_yield_with_arguments_20df759643e04c69893d23024fd03df8-e79bb61ffe77cd2ab8e991dc1764c41e.txt index 36fde9f5b..13242653e 100644 --- a/test/snapshots/parser/prism/prism_nodes_deep_test/test_0033_yield_with_arguments_20df759643e04c69893d23024fd03df8-e79bb61ffe77cd2ab8e991dc1764c41e.txt +++ b/test/snapshots/parser/prism/prism_nodes_deep_test/test_0033_yield_with_arguments_20df759643e04c69893d23024fd03df8-e79bb61ffe77cd2ab8e991dc1764c41e.txt @@ -18,9 +18,12 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ └── arguments: (2 items) │ ├── @ SymbolNode (location: (1:10)-(1:17)) │ │ ├── opening_loc: (1:10)-(1:11) - │ │ ├── value_loc: (1:11)-(1:17) + │ │ ├── content_loc: (1:11)-(1:17) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "header" + │ │ ├── unescaped: "header" + │ │ ├── opening: ":" + │ │ ├── content: "header" + │ │ └── closing: ∅ │ └── @ CallNode (location: (1:19)-(1:23)) │ ├── receiver: ∅ │ ├── call_operator_loc: ∅ @@ -30,5 +33,13 @@ options: {prism_nodes: true, prism_nodes_deep: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ - └── rparen_loc: ∅ \ No newline at end of file + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "user" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ + ├── rparen_loc: ∅ + ├── keyword: "yield" + ├── lparen: ∅ + └── rparen: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-4f327c88bdb6320c9643a72adbf55b3f.txt index 7eada5045..a76da3f97 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -16,4 +16,7 @@ options: {prism_nodes: true} ├── opening_loc: (1:4)-(1:5) ├── content_loc: (1:5)-(1:10) ├── closing_loc: (1:10)-(1:11) - └── unescaped: "hello" \ No newline at end of file + ├── unescaped: "hello" + ├── opening: "\"" + ├── content: "hello" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0002_expression_tag_with_String_779e950a9d5beda8e271fd36ad2c3d51-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0002_expression_tag_with_String_779e950a9d5beda8e271fd36ad2c3d51-4f327c88bdb6320c9643a72adbf55b3f.txt index f474d2cae..9129ededd 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0002_expression_tag_with_String_779e950a9d5beda8e271fd36ad2c3d51-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0002_expression_tag_with_String_779e950a9d5beda8e271fd36ad2c3d51-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -16,4 +16,7 @@ options: {prism_nodes: true} ├── opening_loc: (1:4)-(1:5) ├── content_loc: (1:5)-(1:11) ├── closing_loc: (1:11)-(1:12) - └── unescaped: "String" \ No newline at end of file + ├── unescaped: "String" + ├── opening: "\"" + ├── content: "String" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0003_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0003_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-4f327c88bdb6320c9643a72adbf55b3f.txt index 2990e10fd..080217936 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0003_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0003_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -23,7 +23,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "user" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :name ├── message_loc: (1:9)-(1:13) @@ -31,4 +36,9 @@ options: {prism_nodes: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "name" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0005_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0005_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-4f327c88bdb6320c9643a72adbf55b3f.txt index 361c1cc75..65c591167 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0005_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0005_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -25,7 +25,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "user" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :posts │ ├── message_loc: (1:9)-(1:14) @@ -33,7 +38,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "posts" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:14)-(1:15) ├── name: :count ├── message_loc: (1:15)-(1:20) @@ -41,4 +51,9 @@ options: {prism_nodes: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "count" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0006_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0006_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-4f327c88bdb6320c9643a72adbf55b3f.txt index a8a4ed7ec..3350e4a99 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0006_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0006_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -25,7 +25,10 @@ options: {prism_nodes: true} │ │ ├── opening_loc: (1:12)-(1:13) │ │ ├── content_loc: (1:13)-(1:17) │ │ ├── closing_loc: (1:17)-(1:18) - │ │ └── unescaped: "Home" + │ │ ├── unescaped: "Home" + │ │ ├── opening: "\"" + │ │ ├── content: "Home" + │ │ └── closing: "\"" │ └── @ CallNode (location: (1:20)-(1:29)) │ ├── receiver: ∅ │ ├── call_operator_loc: ∅ @@ -35,7 +38,17 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "root_path" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "link_to" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0007_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0007_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-4f327c88bdb6320c9643a72adbf55b3f.txt index ddf044af1..a4abd7236 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0007_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0007_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -24,7 +24,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "admin?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: (1:11)-(1:12) ├── statements: │ └── @ StatementsNode (location: (1:13)-(1:18)) @@ -33,7 +38,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:13)-(1:14) │ ├── content_loc: (1:14)-(1:17) │ ├── closing_loc: (1:17)-(1:18) - │ └── unescaped: "Yes" + │ ├── unescaped: "Yes" + │ ├── opening: "\"" + │ ├── content: "Yes" + │ └── closing: "\"" ├── subsequent: │ └── @ ElseNode (location: (1:19)-(1:25)) │ ├── else_keyword_loc: (1:19)-(1:20) @@ -44,6 +52,14 @@ options: {prism_nodes: true} │ │ ├── opening_loc: (1:21)-(1:22) │ │ ├── content_loc: (1:22)-(1:24) │ │ ├── closing_loc: (1:24)-(1:25) - │ │ └── unescaped: "No" - │ └── end_keyword_loc: ∅ - └── end_keyword_loc: ∅ \ No newline at end of file + │ │ ├── unescaped: "No" + │ │ ├── opening: "\"" + │ │ ├── content: "No" + │ │ └── closing: "\"" + │ ├── end_keyword_loc: ∅ + │ ├── else_keyword: ":" + │ └── end_keyword: ∅ + ├── end_keyword_loc: ∅ + ├── if_keyword: ∅ + ├── then_keyword: "?" + └── end_keyword: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0008_expression_tag_with_arithmetic_45933f07c353c3e1be297397df336b76-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0008_expression_tag_with_arithmetic_45933f07c353c3e1be297397df336b76-4f327c88bdb6320c9643a72adbf55b3f.txt index 750f458eb..5fdbfa1ef 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0008_expression_tag_with_arithmetic_45933f07c353c3e1be297397df336b76-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0008_expression_tag_with_arithmetic_45933f07c353c3e1be297397df336b76-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -27,4 +27,9 @@ options: {prism_nodes: true} │ └── value: 2 ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "+" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0009_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0009_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-4f327c88bdb6320c9643a72adbf55b3f.txt index 6056f85ba..29c8e5b89 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0009_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0009_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -19,7 +19,10 @@ options: {prism_nodes: true} │ │ ├── opening_loc: ∅ │ │ ├── content_loc: (1:5)-(1:11) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "hello " + │ │ ├── unescaped: "hello " + │ │ ├── opening: ∅ + │ │ ├── content: "hello " + │ │ └── closing: ∅ │ └── @ EmbeddedStatementsNode (location: (1:11)-(1:18)) │ ├── opening_loc: (1:11)-(1:13) │ ├── statements: @@ -34,6 +37,15 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── closing_loc: (1:17)-(1:18) - └── closing_loc: (1:18)-(1:19) \ No newline at end of file + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── closing_loc: (1:17)-(1:18) + │ ├── opening: "\#{" + │ └── closing: "}" + ├── closing_loc: (1:18)-(1:19) + ├── opening: "\"" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0010_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0010_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-4f327c88bdb6320c9643a72adbf55b3f.txt index d25e00b64..1bf7c057e 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0010_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0010_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -19,4 +19,5 @@ options: {prism_nodes: true} ├── value: │ └── @ IntegerNode (location: (1:7)-(1:8)) │ └── value: 1 - └── operator_loc: (1:5)-(1:6) \ No newline at end of file + ├── operator_loc: (1:5)-(1:6) + └── operator: "=" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0011_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0011_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-4f327c88bdb6320c9643a72adbf55b3f.txt index bc2d82ae0..6d5bf0427 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0011_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0011_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -27,16 +27,28 @@ options: {prism_nodes: true} │ ├── key: │ │ └── @ SymbolNode (location: (1:10)-(1:18)) │ │ ├── opening_loc: ∅ - │ │ ├── value_loc: (1:10)-(1:17) + │ │ ├── content_loc: (1:10)-(1:17) │ │ ├── closing_loc: (1:17)-(1:18) - │ │ └── unescaped: "partial" + │ │ ├── unescaped: "partial" + │ │ ├── opening: ∅ + │ │ ├── content: "partial" + │ │ └── closing: ":" │ ├── value: │ │ └── @ StringNode (location: (1:19)-(1:27)) │ │ ├── opening_loc: (1:19)-(1:20) │ │ ├── content_loc: (1:20)-(1:26) │ │ ├── closing_loc: (1:26)-(1:27) - │ │ └── unescaped: "header" - │ └── operator_loc: ∅ + │ │ ├── unescaped: "header" + │ │ ├── opening: "\"" + │ │ ├── content: "header" + │ │ └── closing: "\"" + │ ├── operator_loc: ∅ + │ └── operator: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "render" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0012_if_statement_4670130f794a227341991a25a1b7e654-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0012_if_statement_4670130f794a227341991a25a1b7e654-4f327c88bdb6320c9643a72adbf55b3f.txt index cf780981b..41409099a 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0012_if_statement_4670130f794a227341991a25a1b7e654-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0012_if_statement_4670130f794a227341991a25a1b7e654-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -18,7 +18,10 @@ options: {prism_nodes: true} │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:28)-(1:31) + │ ├── end_keyword_loc: (1:28)-(1:31) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:13)-(1:25)) │ ├── tag_opening: "<%=" (location: (1:13)-(1:16)) @@ -31,7 +34,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:17)-(1:18) │ ├── content_loc: (1:18)-(1:21) │ ├── closing_loc: (1:21)-(1:22) - │ └── unescaped: "yes" + │ ├── unescaped: "yes" + │ ├── opening: "\"" + │ ├── content: "yes" + │ └── closing: "\"" │ ├── subsequent: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0013_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0013_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-4f327c88bdb6320c9643a72adbf55b3f.txt index 983168e81..570cb288a 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0013_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0013_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -23,15 +23,25 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "admin?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: │ │ └── @ ElseNode (location: (1:32)-(1:58)) │ │ ├── else_keyword_loc: (1:32)-(1:36) │ │ ├── statements: ∅ - │ │ └── end_keyword_loc: (1:55)-(1:58) - │ └── end_keyword_loc: (1:55)-(1:58) + │ │ ├── end_keyword_loc: (1:55)-(1:58) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:55)-(1:58) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:15)-(1:29)) │ ├── tag_opening: "<%=" (location: (1:15)-(1:18)) @@ -44,7 +54,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:19)-(1:20) │ ├── content_loc: (1:20)-(1:25) │ ├── closing_loc: (1:25)-(1:26) - │ └── unescaped: "admin" + │ ├── unescaped: "admin" + │ ├── opening: "\"" + │ ├── content: "admin" + │ └── closing: "\"" │ ├── subsequent: │ └── @ ERBElseNode (location: (1:29)-(1:52)) @@ -63,7 +76,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:43)-(1:44) │ ├── content_loc: (1:44)-(1:48) │ ├── closing_loc: (1:48)-(1:49) - │ └── unescaped: "user" + │ ├── unescaped: "user" + │ ├── opening: "\"" + │ ├── content: "user" + │ └── closing: "\"" │ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0014_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0014_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-4f327c88bdb6320c9643a72adbf55b3f.txt index 46ba7ada2..25597d244 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0014_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0014_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -23,7 +23,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "a?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: @@ -39,16 +44,29 @@ options: {prism_nodes: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "b?" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: ∅ │ │ ├── subsequent: │ │ │ └── @ ElseNode (location: (1:30)-(1:44)) │ │ │ ├── else_keyword_loc: (1:30)-(1:34) │ │ │ ├── statements: ∅ - │ │ │ └── end_keyword_loc: (1:41)-(1:44) - │ │ └── end_keyword_loc: (1:41)-(1:44) - │ └── end_keyword_loc: (1:41)-(1:44) + │ │ │ ├── end_keyword_loc: (1:41)-(1:44) + │ │ │ ├── else_keyword: "else" + │ │ │ └── end_keyword: "end" + │ │ ├── end_keyword_loc: (1:41)-(1:44) + │ │ ├── if_keyword: "elsif" + │ │ ├── then_keyword: ∅ + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:41)-(1:44) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ HTMLTextNode (location: (1:11)-(1:12)) │ └── content: "A" diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0015_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0015_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-4f327c88bdb6320c9643a72adbf55b3f.txt index a928140d7..f16aab7e7 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0015_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0015_if_with_predicate_method_2ea6a14556b04f577cbb15a729cec892-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -25,7 +25,12 @@ options: {prism_nodes: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "user" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── call_operator_loc: (1:10)-(1:11) │ │ ├── name: :admin? │ │ ├── message_loc: (1:11)-(1:17) @@ -33,11 +38,19 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "admin?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:39)-(1:42) + │ ├── end_keyword_loc: (1:39)-(1:42) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:36)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) @@ -57,7 +70,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "user" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:28)-(1:29) │ ├── name: :name │ ├── message_loc: (1:29)-(1:33) @@ -65,7 +83,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── subsequent: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0016_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0016_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-4f327c88bdb6320c9643a72adbf55b3f.txt index 48441535a..f36bdc04d 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0016_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0016_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -12,7 +12,7 @@ options: {prism_nodes: true} ├── then_keyword: ∅ ├── prism_node: │ └── @ UnlessNode (location: (1:3)-(1:40)) - │ ├── keyword_loc: (1:3)-(1:9) + │ ├── unless_keyword_loc: (1:3)-(1:9) │ ├── predicate: │ │ └── @ CallNode (location: (1:10)-(1:17)) │ │ ├── receiver: ∅ @@ -23,11 +23,19 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "hidden?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── else_clause: ∅ - │ └── end_keyword_loc: (1:37)-(1:40) + │ ├── end_keyword_loc: (1:37)-(1:40) + │ ├── unless_keyword: "unless" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:34)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) @@ -45,7 +53,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "content" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── else_clause: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0017_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0017_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-4f327c88bdb6320c9643a72adbf55b3f.txt index 2296be2f9..7796080da 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0017_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0017_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -12,7 +12,7 @@ options: {prism_nodes: true} ├── then_keyword: ∅ ├── prism_node: │ └── @ UnlessNode (location: (1:3)-(1:70)) - │ ├── keyword_loc: (1:3)-(1:9) + │ ├── unless_keyword_loc: (1:3)-(1:9) │ ├── predicate: │ │ └── @ CallNode (location: (1:10)-(1:16)) │ │ ├── receiver: ∅ @@ -23,15 +23,25 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "admin?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── else_clause: │ │ └── @ ElseNode (location: (1:41)-(1:70)) │ │ ├── else_keyword_loc: (1:41)-(1:45) │ │ ├── statements: ∅ - │ │ └── end_keyword_loc: (1:67)-(1:70) - │ └── end_keyword_loc: (1:67)-(1:70) + │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:67)-(1:70) + │ ├── unless_keyword: "unless" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:19)-(1:38)) │ ├── tag_opening: "<%=" (location: (1:19)-(1:22)) @@ -44,7 +54,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:23)-(1:24) │ ├── content_loc: (1:24)-(1:34) │ ├── closing_loc: (1:34)-(1:35) - │ └── unescaped: "restricted" + │ ├── unescaped: "restricted" + │ ├── opening: "\"" + │ ├── content: "restricted" + │ └── closing: "\"" │ ├── else_clause: │ └── @ ERBElseNode (location: (1:38)-(1:64)) @@ -63,7 +76,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:52)-(1:53) │ ├── content_loc: (1:53)-(1:60) │ ├── closing_loc: (1:60)-(1:61) - │ └── unescaped: "welcome" + │ ├── unescaped: "welcome" + │ ├── opening: "\"" + │ ├── content: "welcome" + │ └── closing: "\"" │ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0018_each_block_5a778ee67ef1535beff509800d30f540-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0018_each_block_5a778ee67ef1535beff509800d30f540-4f327c88bdb6320c9643a72adbf55b3f.txt index 8b544eae5..3dbb4cbf6 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0018_each_block_5a778ee67ef1535beff509800d30f540-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0018_each_block_5a778ee67ef1535beff509800d30f540-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each │ ├── message_loc: (1:9)-(1:13) @@ -29,29 +34,38 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:14)-(1:43)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:17)-(1:18) - │ │ └── closing_loc: (1:22)-(1:23) - │ ├── body: ∅ - │ ├── opening_loc: (1:14)-(1:16) - │ └── closing_loc: (1:40)-(1:43) + │ ├── block: + │ │ └── @ BlockNode (location: (1:14)-(1:43)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:17)-(1:18) + │ │ │ ├── closing_loc: (1:22)-(1:23) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: ∅ + │ │ ├── opening_loc: (1:14)-(1:16) + │ │ ├── closing_loc: (1:40)-(1:43) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:26)-(1:37)) │ ├── tag_opening: "<%=" (location: (1:26)-(1:29)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0019_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0019_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-4f327c88bdb6320c9643a72adbf55b3f.txt index 5f7fc5259..34954921f 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0019_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0019_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each_with_index │ ├── message_loc: (1:9)-(1:24) @@ -29,32 +34,41 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:25)-(1:61)) - │ ├── locals: (2 items) - │ │ ├── :item - │ │ └── :index - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:28)-(1:41)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:29)-(1:40)) - │ │ │ ├── requireds: (2 items) - │ │ │ │ ├── @ RequiredParameterNode (location: (1:29)-(1:33)) - │ │ │ │ │ └── name: :item - │ │ │ │ └── @ RequiredParameterNode (location: (1:35)-(1:40)) - │ │ │ │ └── name: :index - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:28)-(1:29) - │ │ └── closing_loc: (1:40)-(1:41) - │ ├── body: ∅ - │ ├── opening_loc: (1:25)-(1:27) - │ └── closing_loc: (1:58)-(1:61) + │ ├── block: + │ │ └── @ BlockNode (location: (1:25)-(1:61)) + │ │ ├── locals: (2 items) + │ │ │ ├── :item + │ │ │ └── :index + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:28)-(1:41)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:29)-(1:40)) + │ │ │ │ ├── requireds: (2 items) + │ │ │ │ │ ├── @ RequiredParameterNode (location: (1:29)-(1:33)) + │ │ │ │ │ │ └── name: :item + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:35)-(1:40)) + │ │ │ │ │ └── name: :index + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:28)-(1:29) + │ │ │ ├── closing_loc: (1:40)-(1:41) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: ∅ + │ │ ├── opening_loc: (1:25)-(1:27) + │ │ ├── closing_loc: (1:58)-(1:61) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each_with_index" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:44)-(1:55)) │ ├── tag_opening: "<%=" (location: (1:44)-(1:47)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0020_map_block_63f0ea87d37776c9a4061d49991dfc24-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0020_map_block_63f0ea87d37776c9a4061d49991dfc24-4f327c88bdb6320c9643a72adbf55b3f.txt index ea76adcfb..7751b96ab 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0020_map_block_63f0ea87d37776c9a4061d49991dfc24-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0020_map_block_63f0ea87d37776c9a4061d49991dfc24-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :map │ ├── message_loc: (1:9)-(1:12) @@ -29,29 +34,38 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:13)-(1:47)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:16)-(1:22)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:17)-(1:21)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:17)-(1:21)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:16)-(1:17) - │ │ └── closing_loc: (1:21)-(1:22) - │ ├── body: ∅ - │ ├── opening_loc: (1:13)-(1:15) - │ └── closing_loc: (1:44)-(1:47) + │ ├── block: + │ │ └── @ BlockNode (location: (1:13)-(1:47)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:16)-(1:22)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:17)-(1:21)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:17)-(1:21)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:16)-(1:17) + │ │ │ ├── closing_loc: (1:21)-(1:22) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: ∅ + │ │ ├── opening_loc: (1:13)-(1:15) + │ │ ├── closing_loc: (1:44)-(1:47) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "map" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:25)-(1:41)) │ ├── tag_opening: "<%=" (location: (1:25)-(1:28)) @@ -72,7 +86,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "name" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── block_arguments: (1 item) │ └── @ RubyParameterNode (location: (1:17)-(1:21)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0021_times_block_eff9a7d84dd2d4278289689e08ff361c-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0021_times_block_eff9a7d84dd2d4278289689e08ff361c-4f327c88bdb6320c9643a72adbf55b3f.txt index 1018cfddc..9ada9d7eb 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0021_times_block_eff9a7d84dd2d4278289689e08ff361c-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0021_times_block_eff9a7d84dd2d4278289689e08ff361c-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,29 +21,38 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:11)-(1:34)) - │ ├── locals: (1 item) - │ │ └── :i - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:14)-(1:17)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:15)-(1:16)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:15)-(1:16)) - │ │ │ │ └── name: :i - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:14)-(1:15) - │ │ └── closing_loc: (1:16)-(1:17) - │ ├── body: ∅ - │ ├── opening_loc: (1:11)-(1:13) - │ └── closing_loc: (1:31)-(1:34) + │ ├── block: + │ │ └── @ BlockNode (location: (1:11)-(1:34)) + │ │ ├── locals: (1 item) + │ │ │ └── :i + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:14)-(1:17)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:15)-(1:16)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:15)-(1:16)) + │ │ │ │ │ └── name: :i + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:14)-(1:15) + │ │ │ ├── closing_loc: (1:16)-(1:17) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: ∅ + │ │ ├── opening_loc: (1:11)-(1:13) + │ │ ├── closing_loc: (1:31)-(1:34) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "times" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:28)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0022_while_loop_316bfac13320a30adea0c3f0c2d8487f-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0022_while_loop_316bfac13320a30adea0c3f0c2d8487f-4f327c88bdb6320c9643a72adbf55b3f.txt index cfe043409..4624b91ae 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0022_while_loop_316bfac13320a30adea0c3f0c2d8487f-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0022_while_loop_316bfac13320a30adea0c3f0c2d8487f-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -11,9 +11,9 @@ options: {prism_nodes: true} ├── tag_closing: "%>" (location: (1:18)-(1:20)) ├── prism_node: │ └── @ WhileNode (location: (1:3)-(1:39)) - │ ├── keyword_loc: (1:3)-(1:8) + │ ├── while_keyword_loc: (1:3)-(1:8) │ ├── do_keyword_loc: ∅ - │ ├── closing_loc: (1:36)-(1:39) + │ ├── end_keyword_loc: (1:36)-(1:39) │ ├── predicate: │ │ └── @ CallNode (location: (1:9)-(1:17)) │ │ ├── receiver: ∅ @@ -24,8 +24,16 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── statements: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "running?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── statements: ∅ + │ ├── while_keyword: "while" + │ ├── do_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:20)-(1:33)) │ ├── tag_opening: "<%=" (location: (1:20)-(1:23)) @@ -43,7 +51,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "status" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── end_node: └── @ ERBEndNode (location: (1:33)-(1:42)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0023_until_loop_0749dafecd752ebf473439e0aed82839-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0023_until_loop_0749dafecd752ebf473439e0aed82839-4f327c88bdb6320c9643a72adbf55b3f.txt index 9c3bde474..905fcce62 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0023_until_loop_0749dafecd752ebf473439e0aed82839-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0023_until_loop_0749dafecd752ebf473439e0aed82839-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -11,9 +11,9 @@ options: {prism_nodes: true} ├── tag_closing: "%>" (location: (1:15)-(1:17)) ├── prism_node: │ └── @ UntilNode (location: (1:3)-(1:38)) - │ ├── keyword_loc: (1:3)-(1:8) + │ ├── until_keyword_loc: (1:3)-(1:8) │ ├── do_keyword_loc: ∅ - │ ├── closing_loc: (1:35)-(1:38) + │ ├── end_keyword_loc: (1:35)-(1:38) │ ├── predicate: │ │ └── @ CallNode (location: (1:9)-(1:14)) │ │ ├── receiver: ∅ @@ -24,8 +24,16 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── statements: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "done?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── statements: ∅ + │ ├── until_keyword: "until" + │ ├── do_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:17)-(1:32)) │ ├── tag_opening: "<%=" (location: (1:17)-(1:20)) @@ -43,7 +51,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "progress" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ └── end_node: └── @ ERBEndNode (location: (1:32)-(1:41)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0024_for_loop_47be8823810057a1054aa82d2a1ed9a9-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0024_for_loop_47be8823810057a1054aa82d2a1ed9a9-4f327c88bdb6320c9643a72adbf55b3f.txt index 3e05df168..880f23177 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0024_for_loop_47be8823810057a1054aa82d2a1ed9a9-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0024_for_loop_47be8823810057a1054aa82d2a1ed9a9-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -25,12 +25,21 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── statements: ∅ │ ├── for_keyword_loc: (1:3)-(1:6) │ ├── in_keyword_loc: (1:12)-(1:14) │ ├── do_keyword_loc: ∅ - │ └── end_keyword_loc: (1:37)-(1:40) + │ ├── end_keyword_loc: (1:37)-(1:40) + │ ├── for_keyword: "for" + │ ├── in_keyword: "in" + │ ├── do_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:23)-(1:34)) │ ├── tag_opening: "<%=" (location: (1:23)-(1:26)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0025_case_when_42736e7ede24cdf8d921a1efe7042d39-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0025_case_when_42736e7ede24cdf8d921a1efe7042d39-4f327c88bdb6320c9643a72adbf55b3f.txt index e472db909..52fa44334 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0025_case_when_42736e7ede24cdf8d921a1efe7042d39-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0025_case_when_42736e7ede24cdf8d921a1efe7042d39-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -22,31 +22,48 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "role" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── conditions: (2 items) │ │ ├── @ WhenNode (location: (1:18)-(1:30)) - │ │ │ ├── keyword_loc: (1:18)-(1:22) + │ │ │ ├── when_keyword_loc: (1:18)-(1:22) │ │ │ ├── conditions: (1 item) │ │ │ │ └── @ StringNode (location: (1:23)-(1:30)) │ │ │ │ ├── opening_loc: (1:23)-(1:24) │ │ │ │ ├── content_loc: (1:24)-(1:29) │ │ │ │ ├── closing_loc: (1:29)-(1:30) - │ │ │ │ └── unescaped: "admin" + │ │ │ │ ├── unescaped: "admin" + │ │ │ │ ├── opening: "\"" + │ │ │ │ ├── content: "admin" + │ │ │ │ └── closing: "\"" │ │ │ ├── then_keyword_loc: ∅ - │ │ │ └── statements: ∅ + │ │ │ ├── statements: ∅ + │ │ │ ├── when_keyword: "when" + │ │ │ └── then_keyword: ∅ │ │ └── @ WhenNode (location: (1:50)-(1:61)) - │ │ ├── keyword_loc: (1:50)-(1:54) + │ │ ├── when_keyword_loc: (1:50)-(1:54) │ │ ├── conditions: (1 item) │ │ │ └── @ StringNode (location: (1:55)-(1:61)) │ │ │ ├── opening_loc: (1:55)-(1:56) │ │ │ ├── content_loc: (1:56)-(1:60) │ │ │ ├── closing_loc: (1:60)-(1:61) - │ │ │ └── unescaped: "user" + │ │ │ ├── unescaped: "user" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "user" + │ │ │ └── closing: "\"" │ │ ├── then_keyword_loc: ∅ - │ │ └── statements: ∅ + │ │ ├── statements: ∅ + │ │ ├── when_keyword: "when" + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── case_keyword_loc: (1:3)-(1:7) - │ └── end_keyword_loc: (1:80)-(1:83) + │ ├── end_keyword_loc: (1:80)-(1:83) + │ ├── case_keyword: "case" + │ └── end_keyword: "end" ├── conditions: (2 items) │ ├── @ ERBWhenNode (location: (1:15)-(1:33)) │ │ ├── tag_opening: "<%" (location: (1:15)-(1:17)) @@ -65,7 +82,10 @@ options: {prism_nodes: true} │ │ ├── opening_loc: (1:37)-(1:38) │ │ ├── content_loc: (1:38)-(1:43) │ │ ├── closing_loc: (1:43)-(1:44) - │ │ └── unescaped: "Admin" + │ │ ├── unescaped: "Admin" + │ │ ├── opening: "\"" + │ │ ├── content: "Admin" + │ │ └── closing: "\"" │ │ │ │ │ └── @ ERBWhenNode (location: (1:47)-(1:64)) @@ -85,7 +105,10 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:68)-(1:69) │ ├── content_loc: (1:69)-(1:73) │ ├── closing_loc: (1:73)-(1:74) - │ └── unescaped: "User" + │ ├── unescaped: "User" + │ ├── opening: "\"" + │ ├── content: "User" + │ └── closing: "\"" │ │ ├── else_clause: ∅ diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0026_case_when_else_953565c8c118844b420bebe8d4e6f716-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0026_case_when_else_953565c8c118844b420bebe8d4e6f716-4f327c88bdb6320c9643a72adbf55b3f.txt index b5f03985b..bf561f5ec 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0026_case_when_else_953565c8c118844b420bebe8d4e6f716-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0026_case_when_else_953565c8c118844b420bebe8d4e6f716-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -22,35 +22,54 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "status" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── conditions: (2 items) │ │ ├── @ WhenNode (location: (1:20)-(1:32)) - │ │ │ ├── keyword_loc: (1:20)-(1:24) + │ │ │ ├── when_keyword_loc: (1:20)-(1:24) │ │ │ ├── conditions: (1 item) │ │ │ │ └── @ SymbolNode (location: (1:25)-(1:32)) │ │ │ │ ├── opening_loc: (1:25)-(1:26) - │ │ │ │ ├── value_loc: (1:26)-(1:32) + │ │ │ │ ├── content_loc: (1:26)-(1:32) │ │ │ │ ├── closing_loc: ∅ - │ │ │ │ └── unescaped: "active" + │ │ │ │ ├── unescaped: "active" + │ │ │ │ ├── opening: ":" + │ │ │ │ ├── content: "active" + │ │ │ │ └── closing: ∅ │ │ │ ├── then_keyword_loc: ∅ - │ │ │ └── statements: ∅ + │ │ │ ├── statements: ∅ + │ │ │ ├── when_keyword: "when" + │ │ │ └── then_keyword: ∅ │ │ └── @ WhenNode (location: (1:44)-(1:58)) - │ │ ├── keyword_loc: (1:44)-(1:48) + │ │ ├── when_keyword_loc: (1:44)-(1:48) │ │ ├── conditions: (1 item) │ │ │ └── @ SymbolNode (location: (1:49)-(1:58)) │ │ │ ├── opening_loc: (1:49)-(1:50) - │ │ │ ├── value_loc: (1:50)-(1:58) + │ │ │ ├── content_loc: (1:50)-(1:58) │ │ │ ├── closing_loc: ∅ - │ │ │ └── unescaped: "inactive" + │ │ │ ├── unescaped: "inactive" + │ │ │ ├── opening: ":" + │ │ │ ├── content: "inactive" + │ │ │ └── closing: ∅ │ │ ├── then_keyword_loc: ∅ - │ │ └── statements: ∅ + │ │ ├── statements: ∅ + │ │ ├── when_keyword: "when" + │ │ └── then_keyword: ∅ │ ├── else_clause: │ │ └── @ ElseNode (location: (1:72)-(1:92)) │ │ ├── else_keyword_loc: (1:72)-(1:76) │ │ ├── statements: ∅ - │ │ └── end_keyword_loc: (1:89)-(1:92) + │ │ ├── end_keyword_loc: (1:89)-(1:92) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" │ ├── case_keyword_loc: (1:3)-(1:7) - │ └── end_keyword_loc: (1:89)-(1:92) + │ ├── end_keyword_loc: (1:89)-(1:92) + │ ├── case_keyword: "case" + │ └── end_keyword: "end" ├── conditions: (2 items) │ ├── @ ERBWhenNode (location: (1:17)-(1:35)) │ │ ├── tag_opening: "<%" (location: (1:17)-(1:19)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0027_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0027_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-4f327c88bdb6320c9643a72adbf55b3f.txt index 518079967..b19b1ddd3 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0027_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0027_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -22,7 +22,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "data" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── conditions: (1 item) │ │ └── @ InNode (location: (1:18)-(1:30)) │ │ ├── pattern: @@ -33,25 +38,35 @@ options: {prism_nodes: true} │ │ │ │ ├── key: │ │ │ │ │ └── @ SymbolNode (location: (1:23)-(1:28)) │ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ │ ├── value_loc: (1:23)-(1:27) + │ │ │ │ │ ├── content_loc: (1:23)-(1:27) │ │ │ │ │ ├── closing_loc: (1:27)-(1:28) - │ │ │ │ │ └── unescaped: "name" + │ │ │ │ │ ├── unescaped: "name" + │ │ │ │ │ ├── opening: ∅ + │ │ │ │ │ ├── content: "name" + │ │ │ │ │ └── closing: ":" │ │ │ │ ├── value: │ │ │ │ │ └── @ ImplicitNode (location: (1:23)-(1:27)) │ │ │ │ │ └── value: │ │ │ │ │ └── @ LocalVariableTargetNode (location: (1:23)-(1:27)) │ │ │ │ │ ├── name: :name │ │ │ │ │ └── depth: 0 - │ │ │ │ └── operator_loc: ∅ + │ │ │ │ ├── operator_loc: ∅ + │ │ │ │ └── operator: ∅ │ │ │ ├── rest: ∅ │ │ │ ├── opening_loc: (1:21)-(1:22) - │ │ │ └── closing_loc: (1:29)-(1:30) + │ │ │ ├── closing_loc: (1:29)-(1:30) + │ │ │ ├── opening: "{" + │ │ │ └── closing: "}" │ │ ├── statements: ∅ - │ │ ├── in_loc: (1:18)-(1:20) - │ │ └── then_loc: ∅ + │ │ ├── in_keyword_loc: (1:18)-(1:20) + │ │ ├── then_keyword_loc: ∅ + │ │ ├── in_keyword: "in" + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── case_keyword_loc: (1:3)-(1:7) - │ └── end_keyword_loc: (1:47)-(1:50) + │ ├── end_keyword_loc: (1:47)-(1:50) + │ ├── case_keyword: "case" + │ └── end_keyword: "end" ├── conditions: (1 item) │ └── @ ERBInNode (location: (1:15)-(1:33)) │ ├── tag_opening: "<%" (location: (1:15)-(1:17)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0028_begin_rescue_df4f24aebbe892defa838eb3f66814a4-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0028_begin_rescue_df4f24aebbe892defa838eb3f66814a4-4f327c88bdb6320c9643a72adbf55b3f.txt index 2c11872ba..bcbf7fc3f 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0028_begin_rescue_df4f24aebbe892defa838eb3f66814a4-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0028_begin_rescue_df4f24aebbe892defa838eb3f66814a4-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,10 +21,15 @@ options: {prism_nodes: true} │ │ ├── reference: ∅ │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: ∅ - │ │ └── subsequent: ∅ + │ │ ├── subsequent: ∅ + │ │ ├── keyword: "rescue" + │ │ ├── operator: ∅ + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── ensure_clause: ∅ - │ └── end_keyword_loc: (1:61)-(1:64) + │ ├── end_keyword_loc: (1:61)-(1:64) + │ ├── begin_keyword: "begin" + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:11)-(1:32)) │ ├── tag_opening: "<%=" (location: (1:11)-(1:14)) @@ -42,7 +47,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "dangerous_call" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── rescue_clause: │ └── @ ERBRescueNode (location: (1:32)-(1:58)) @@ -61,7 +71,10 @@ options: {prism_nodes: true} │ │ ├── opening_loc: (1:48)-(1:49) │ │ ├── content_loc: (1:49)-(1:54) │ │ ├── closing_loc: (1:54)-(1:55) - │ │ └── unescaped: "error" + │ │ ├── unescaped: "error" + │ │ ├── opening: "\"" + │ │ ├── content: "error" + │ │ └── closing: "\"" │ │ │ └── subsequent: ∅ │ diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0029_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0029_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-4f327c88bdb6320c9643a72adbf55b3f.txt index cd4700fa9..b304e9200 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0029_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0029_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -24,14 +24,21 @@ options: {prism_nodes: true} │ │ │ └── depth: 0 │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: ∅ - │ │ └── subsequent: ∅ + │ │ ├── subsequent: ∅ + │ │ ├── keyword: "rescue" + │ │ ├── operator: "=>" + │ │ └── then_keyword: ∅ │ ├── else_clause: ∅ │ ├── ensure_clause: │ │ └── @ EnsureNode (location: (1:59)-(1:88)) │ │ ├── ensure_keyword_loc: (1:59)-(1:65) │ │ ├── statements: ∅ - │ │ └── end_keyword_loc: (1:85)-(1:88) - │ └── end_keyword_loc: (1:85)-(1:88) + │ │ ├── end_keyword_loc: (1:85)-(1:88) + │ │ ├── ensure_keyword: "ensure" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:85)-(1:88) + │ ├── begin_keyword: "begin" + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBContentNode (location: (1:11)-(1:23)) │ ├── tag_opening: "<%=" (location: (1:11)-(1:14)) @@ -49,7 +56,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "risky" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── rescue_clause: │ └── @ ERBRescueNode (location: (1:23)-(1:56)) @@ -76,7 +88,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "message" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ │ │ └── subsequent: ∅ │ @@ -103,7 +120,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "cleanup" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0030_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0030_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-4f327c88bdb6320c9643a72adbf55b3f.txt index 9bbc7ba8d..854de54d8 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0030_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0030_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each │ ├── message_loc: (1:9)-(1:13) @@ -29,51 +34,68 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:14)-(1:79)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:17)-(1:18) - │ │ └── closing_loc: (1:22)-(1:23) - │ ├── body: - │ │ └── @ StatementsNode (location: (1:29)-(1:70)) - │ │ └── body: (1 item) - │ │ └── @ IfNode (location: (1:29)-(1:70)) - │ │ ├── if_keyword_loc: (1:29)-(1:31) - │ │ ├── predicate: - │ │ │ └── @ CallNode (location: (1:32)-(1:45)) - │ │ │ ├── receiver: - │ │ │ │ └── @ LocalVariableReadNode (location: (1:32)-(1:36)) - │ │ │ │ ├── name: :item - │ │ │ │ └── depth: 0 - │ │ │ ├── call_operator_loc: (1:36)-(1:37) - │ │ │ ├── name: :visible? - │ │ │ ├── message_loc: (1:37)-(1:45) - │ │ │ ├── opening_loc: ∅ - │ │ │ ├── arguments: ∅ - │ │ │ ├── closing_loc: ∅ - │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ - │ │ ├── then_keyword_loc: ∅ - │ │ ├── statements: ∅ - │ │ ├── subsequent: ∅ - │ │ └── end_keyword_loc: (1:67)-(1:70) - │ ├── opening_loc: (1:14)-(1:16) - │ └── closing_loc: (1:76)-(1:79) + │ ├── block: + │ │ └── @ BlockNode (location: (1:14)-(1:79)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:17)-(1:18) + │ │ │ ├── closing_loc: (1:22)-(1:23) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: + │ │ │ └── @ StatementsNode (location: (1:29)-(1:70)) + │ │ │ └── body: (1 item) + │ │ │ └── @ IfNode (location: (1:29)-(1:70)) + │ │ │ ├── if_keyword_loc: (1:29)-(1:31) + │ │ │ ├── predicate: + │ │ │ │ └── @ CallNode (location: (1:32)-(1:45)) + │ │ │ │ ├── receiver: + │ │ │ │ │ └── @ LocalVariableReadNode (location: (1:32)-(1:36)) + │ │ │ │ │ ├── name: :item + │ │ │ │ │ └── depth: 0 + │ │ │ │ ├── call_operator_loc: (1:36)-(1:37) + │ │ │ │ ├── name: :visible? + │ │ │ │ ├── message_loc: (1:37)-(1:45) + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ ├── block: ∅ + │ │ │ │ ├── call_operator: "." + │ │ │ │ ├── message: "visible?" + │ │ │ │ ├── opening: ∅ + │ │ │ │ ├── closing: ∅ + │ │ │ │ └── equal: ∅ + │ │ │ ├── then_keyword_loc: ∅ + │ │ │ ├── statements: ∅ + │ │ │ ├── subsequent: ∅ + │ │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ │ ├── if_keyword: "if" + │ │ │ ├── then_keyword: ∅ + │ │ │ └── end_keyword: "end" + │ │ ├── opening_loc: (1:14)-(1:16) + │ │ ├── closing_loc: (1:76)-(1:79) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBIfNode (location: (1:26)-(1:73)) │ ├── tag_opening: "<%" (location: (1:26)-(1:28)) @@ -96,11 +118,19 @@ options: {prism_nodes: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "visible?" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: ∅ │ │ ├── subsequent: ∅ - │ │ └── end_keyword_loc: (1:67)-(1:70) + │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ ├── if_keyword: "if" + │ │ ├── then_keyword: ∅ + │ │ └── end_keyword: "end" │ ├── statements: (1 item) │ │ └── @ ERBContentNode (location: (1:48)-(1:64)) │ │ ├── tag_opening: "<%=" (location: (1:48)-(1:51)) @@ -121,7 +151,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ │ │ ├── subsequent: ∅ │ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0031_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0031_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-4f327c88bdb6320c9643a72adbf55b3f.txt index 248286fba..cff27741d 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0031_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0031_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -41,7 +41,12 @@ options: {prism_nodes: true} │ │ │ ├── arguments: ∅ │ │ │ ├── closing_loc: ∅ │ │ │ ├── equal_loc: ∅ - │ │ │ └── block: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: ∅ + │ │ │ ├── message: "css_class" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ │ │ │ │ │ ├── close_quote: """ (location: (1:28)-(1:29)) │ │ └── quoted: true @@ -67,7 +72,12 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "content" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ │ ├── close_tag: │ └── @ HTMLCloseTagNode (location: (1:44)-(1:50)) diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0032_lambda_block_be3e20bc22dc97f13594380fdef6da84-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0032_lambda_block_be3e20bc22dc97f13594380fdef6da84-4f327c88bdb6320c9643a72adbf55b3f.txt index 586823cee..ebd3308d2 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0032_lambda_block_be3e20bc22dc97f13594380fdef6da84-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0032_lambda_block_be3e20bc22dc97f13594380fdef6da84-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -20,14 +20,20 @@ options: {prism_nodes: true} │ ├── opening_loc: (1:7)-(1:8) │ ├── closing_loc: (1:17)-(1:18) │ ├── parameters: ∅ - │ └── body: - │ └── @ StatementsNode (location: (1:9)-(1:16)) - │ └── body: (1 item) - │ └── @ StringNode (location: (1:9)-(1:16)) - │ ├── opening_loc: (1:9)-(1:10) - │ ├── content_loc: (1:10)-(1:15) - │ ├── closing_loc: (1:15)-(1:16) - │ └── unescaped: "hello" + │ ├── body: + │ │ └── @ StatementsNode (location: (1:9)-(1:16)) + │ │ └── body: (1 item) + │ │ └── @ StringNode (location: (1:9)-(1:16)) + │ │ ├── opening_loc: (1:9)-(1:10) + │ │ ├── content_loc: (1:10)-(1:15) + │ │ ├── closing_loc: (1:15)-(1:16) + │ │ ├── unescaped: "hello" + │ │ ├── opening: "\"" + │ │ ├── content: "hello" + │ │ └── closing: "\"" + │ ├── operator: "->" + │ ├── opening: "{" + │ └── closing: "}" ├── call_operator_loc: (1:18)-(1:19) ├── name: :call ├── message_loc: (1:19)-(1:23) @@ -35,4 +41,9 @@ options: {prism_nodes: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "call" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0033_Prism_structural_locations_use_one-based_lines_9c0eaf42f55b271f9b8dfe2a03eedf97-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0033_Prism_structural_locations_use_one-based_lines_9c0eaf42f55b271f9b8dfe2a03eedf97-4f327c88bdb6320c9643a72adbf55b3f.txt index 96b50090d..9e927ba77 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0033_Prism_structural_locations_use_one-based_lines_9c0eaf42f55b271f9b8dfe2a03eedf97-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0033_Prism_structural_locations_use_one-based_lines_9c0eaf42f55b271f9b8dfe2a03eedf97-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,7 +21,10 @@ options: {prism_nodes: true} │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: ∅ - │ └── end_keyword_loc: (3:3)-(3:6) + │ ├── end_keyword_loc: (3:3)-(3:6) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (3 items) │ ├── @ HTMLTextNode (location: (1:13)-(2:0)) │ │ └── content: "\n" diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0035_yield_1564254a88399098a10aea8889a5b2a8-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0035_yield_1564254a88399098a10aea8889a5b2a8-4f327c88bdb6320c9643a72adbf55b3f.txt index 8b2ec5a99..91d9706d4 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0035_yield_1564254a88399098a10aea8889a5b2a8-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0035_yield_1564254a88399098a10aea8889a5b2a8-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -14,4 +14,7 @@ options: {prism_nodes: true} ├── keyword_loc: (1:4)-(1:9) ├── lparen_loc: ∅ ├── arguments: ∅ - └── rparen_loc: ∅ \ No newline at end of file + ├── rparen_loc: ∅ + ├── keyword: "yield" + ├── lparen: ∅ + └── rparen: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0036_yield_with_arguments_20df759643e04c69893d23024fd03df8-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0036_yield_with_arguments_20df759643e04c69893d23024fd03df8-4f327c88bdb6320c9643a72adbf55b3f.txt index a58e17c65..5a1662588 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0036_yield_with_arguments_20df759643e04c69893d23024fd03df8-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0036_yield_with_arguments_20df759643e04c69893d23024fd03df8-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -18,9 +18,12 @@ options: {prism_nodes: true} │ └── arguments: (2 items) │ ├── @ SymbolNode (location: (1:10)-(1:17)) │ │ ├── opening_loc: (1:10)-(1:11) - │ │ ├── value_loc: (1:11)-(1:17) + │ │ ├── content_loc: (1:11)-(1:17) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "header" + │ │ ├── unescaped: "header" + │ │ ├── opening: ":" + │ │ ├── content: "header" + │ │ └── closing: ∅ │ └── @ CallNode (location: (1:19)-(1:23)) │ ├── receiver: ∅ │ ├── call_operator_loc: ∅ @@ -30,5 +33,13 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ - └── rparen_loc: ∅ \ No newline at end of file + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "user" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ + ├── rparen_loc: ∅ + ├── keyword: "yield" + ├── lparen: ∅ + └── rparen: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0037_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0037_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-4f327c88bdb6320c9643a72adbf55b3f.txt index 6078f4cdf..a8190d4e3 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0037_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0037_yield_inside_if_4cd6a6ffb4ba9fb0eccb20460a7a7aa8-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -23,11 +23,19 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "show?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:37)-(1:40) + │ ├── end_keyword_loc: (1:37)-(1:40) + │ ├── if_keyword: "if" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" ├── statements: (1 item) │ └── @ ERBYieldNode (location: (1:14)-(1:34)) │ ├── tag_opening: "<%=" (location: (1:14)-(1:17)) @@ -42,10 +50,16 @@ options: {prism_nodes: true} │ │ └── arguments: (1 item) │ │ └── @ SymbolNode (location: (1:24)-(1:31)) │ │ ├── opening_loc: (1:24)-(1:25) - │ │ ├── value_loc: (1:25)-(1:31) + │ │ ├── content_loc: (1:25)-(1:31) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "header" - │ └── rparen_loc: ∅ + │ │ ├── unescaped: "header" + │ │ ├── opening: ":" + │ │ ├── content: "header" + │ │ └── closing: ∅ + │ ├── rparen_loc: ∅ + │ ├── keyword: "yield" + │ ├── lparen: ∅ + │ └── rparen: ∅ │ ├── subsequent: ∅ └── end_node: diff --git a/test/snapshots/parser/prism/prism_nodes_test/test_0038_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-4f327c88bdb6320c9643a72adbf55b3f.txt b/test/snapshots/parser/prism/prism_nodes_test/test_0038_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-4f327c88bdb6320c9643a72adbf55b3f.txt index 1d63de6f7..cd324947d 100644 --- a/test/snapshots/parser/prism/prism_nodes_test/test_0038_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-4f327c88bdb6320c9643a72adbf55b3f.txt +++ b/test/snapshots/parser/prism/prism_nodes_test/test_0038_yield_inside_block_27a348b375fdc30c3f2f55ab574c9e47-4f327c88bdb6320c9643a72adbf55b3f.txt @@ -21,7 +21,12 @@ options: {prism_nodes: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "items" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :each │ ├── message_loc: (1:9)-(1:13) @@ -29,29 +34,38 @@ options: {prism_nodes: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: - │ └── @ BlockNode (location: (1:14)-(1:49)) - │ ├── locals: (1 item) - │ │ └── :item - │ ├── parameters: - │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ │ ├── parameters: - │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ │ ├── requireds: (1 item) - │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ │ └── name: :item - │ │ │ ├── optionals: [] - │ │ │ ├── rest: ∅ - │ │ │ ├── posts: [] - │ │ │ ├── keywords: [] - │ │ │ ├── keyword_rest: ∅ - │ │ │ └── block: ∅ - │ │ ├── locals: [] - │ │ ├── opening_loc: (1:17)-(1:18) - │ │ └── closing_loc: (1:22)-(1:23) - │ ├── body: ∅ - │ ├── opening_loc: (1:14)-(1:16) - │ └── closing_loc: (1:46)-(1:49) + │ ├── block: + │ │ └── @ BlockNode (location: (1:14)-(1:49)) + │ │ ├── locals: (1 item) + │ │ │ └── :item + │ │ ├── parameters: + │ │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ │ ├── parameters: + │ │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ │ ├── requireds: (1 item) + │ │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ │ └── name: :item + │ │ │ │ ├── optionals: [] + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: [] + │ │ │ │ ├── keywords: [] + │ │ │ │ ├── keyword_rest: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── locals: [] + │ │ │ ├── opening_loc: (1:17)-(1:18) + │ │ │ ├── closing_loc: (1:22)-(1:23) + │ │ │ ├── opening: "|" + │ │ │ └── closing: "|" + │ │ ├── body: ∅ + │ │ ├── opening_loc: (1:14)-(1:16) + │ │ ├── closing_loc: (1:46)-(1:49) + │ │ ├── opening: "do" + │ │ └── closing: "end" + │ ├── call_operator: "." + │ ├── message: "each" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── body: (1 item) │ └── @ ERBYieldNode (location: (1:26)-(1:43)) │ ├── tag_opening: "<%=" (location: (1:26)-(1:29)) @@ -67,7 +81,10 @@ options: {prism_nodes: true} │ │ └── @ LocalVariableReadNode (location: (1:36)-(1:40)) │ │ ├── name: :item │ │ └── depth: 0 - │ └── rparen_loc: ∅ + │ ├── rparen_loc: ∅ + │ ├── keyword: "yield" + │ ├── lparen: ∅ + │ └── rparen: ∅ │ ├── block_arguments: (1 item) │ └── @ RubyParameterNode (location: (1:18)-(1:22)) diff --git a/test/snapshots/parser/prism/prism_program_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-0af561a0c6dea91d159fd88b7a3988aa.txt index 309325e33..13b781da3 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0001_expression_tag_with_string_75d33ee779925ae6c8a23f8d82a1bc69-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -22,4 +22,7 @@ options: {prism_program: true} ├── opening_loc: (1:4)-(1:5) ├── content_loc: (1:5)-(1:10) ├── closing_loc: (1:10)-(1:11) - └── unescaped: "hello" \ No newline at end of file + ├── unescaped: "hello" + ├── opening: "\"" + ├── content: "hello" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-0af561a0c6dea91d159fd88b7a3988aa.txt index c3c647999..4941d7826 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0002_expression_tag_with_method_call_097ddbf7b62f7127ef77685a3938d003-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -29,7 +29,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "user" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :name ├── message_loc: (1:9)-(1:13) @@ -37,4 +42,9 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "name" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-0af561a0c6dea91d159fd88b7a3988aa.txt index c86e4b213..fd7ae80da 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0004_expression_tag_with_chained_method_call_f263b445fced98d5bf8ba80a6ee5d1b8-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -31,7 +31,12 @@ options: {prism_program: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "user" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── call_operator_loc: (1:8)-(1:9) │ ├── name: :posts │ ├── message_loc: (1:9)-(1:14) @@ -39,7 +44,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: "." + │ ├── message: "posts" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:14)-(1:15) ├── name: :count ├── message_loc: (1:15)-(1:20) @@ -47,4 +57,9 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: "." + ├── message: "count" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-0af561a0c6dea91d159fd88b7a3988aa.txt index 0f3bffe7b..24514d67e 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0005_expression_tag_with_method_call_and_arguments_e68887f68f9e99f8c04ec0950009653f-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -31,7 +31,10 @@ options: {prism_program: true} │ │ ├── opening_loc: (1:12)-(1:13) │ │ ├── content_loc: (1:13)-(1:17) │ │ ├── closing_loc: (1:17)-(1:18) - │ │ └── unescaped: "Home" + │ │ ├── unescaped: "Home" + │ │ ├── opening: "\"" + │ │ ├── content: "Home" + │ │ └── closing: "\"" │ └── @ CallNode (location: (1:20)-(1:29)) │ ├── receiver: ∅ │ ├── call_operator_loc: ∅ @@ -41,7 +44,17 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "root_path" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "link_to" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-0af561a0c6dea91d159fd88b7a3988aa.txt index 0e455fcd7..59af1c122 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0006_expression_tag_with_ternary_e02b2475f3d0e02be7ec03e0aba33c7b-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -30,7 +30,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "admin?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: (1:11)-(1:12) ├── statements: │ └── @ StatementsNode (location: (1:13)-(1:18)) @@ -39,7 +44,10 @@ options: {prism_program: true} │ ├── opening_loc: (1:13)-(1:14) │ ├── content_loc: (1:14)-(1:17) │ ├── closing_loc: (1:17)-(1:18) - │ └── unescaped: "Yes" + │ ├── unescaped: "Yes" + │ ├── opening: "\"" + │ ├── content: "Yes" + │ └── closing: "\"" ├── subsequent: │ └── @ ElseNode (location: (1:19)-(1:25)) │ ├── else_keyword_loc: (1:19)-(1:20) @@ -50,6 +58,14 @@ options: {prism_program: true} │ │ ├── opening_loc: (1:21)-(1:22) │ │ ├── content_loc: (1:22)-(1:24) │ │ ├── closing_loc: (1:24)-(1:25) - │ │ └── unescaped: "No" - │ └── end_keyword_loc: ∅ - └── end_keyword_loc: ∅ \ No newline at end of file + │ │ ├── unescaped: "No" + │ │ ├── opening: "\"" + │ │ ├── content: "No" + │ │ └── closing: "\"" + │ ├── end_keyword_loc: ∅ + │ ├── else_keyword: ":" + │ └── end_keyword: ∅ + ├── end_keyword_loc: ∅ + ├── if_keyword: ∅ + ├── then_keyword: "?" + └── end_keyword: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-0af561a0c6dea91d159fd88b7a3988aa.txt index ef3a9d601..b99c3dedf 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0007_expression_tag_with_string_interpolation_8aa2072f7ed66fb75b5e661774c17f5e-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -25,7 +25,10 @@ options: {prism_program: true} │ │ ├── opening_loc: ∅ │ │ ├── content_loc: (1:5)-(1:11) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "hello " + │ │ ├── unescaped: "hello " + │ │ ├── opening: ∅ + │ │ ├── content: "hello " + │ │ └── closing: ∅ │ └── @ EmbeddedStatementsNode (location: (1:11)-(1:18)) │ ├── opening_loc: (1:11)-(1:13) │ ├── statements: @@ -40,6 +43,15 @@ options: {prism_program: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── closing_loc: (1:17)-(1:18) - └── closing_loc: (1:18)-(1:19) \ No newline at end of file + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── closing_loc: (1:17)-(1:18) + │ ├── opening: "\#{" + │ └── closing: "}" + ├── closing_loc: (1:18)-(1:19) + ├── opening: "\"" + └── closing: "\"" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0008_multiple_expressions_a3ebccfe794c406e6ef805c817febfc3-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0008_multiple_expressions_a3ebccfe794c406e6ef805c817febfc3-0af561a0c6dea91d159fd88b7a3988aa.txt index 93ea024ca..6b3552cb5 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0008_multiple_expressions_a3ebccfe794c406e6ef805c817febfc3-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0008_multiple_expressions_a3ebccfe794c406e6ef805c817febfc3-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -34,7 +34,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "first" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ └── @ CallNode (location: (1:16)-(1:22)) ├── receiver: ∅ ├── call_operator_loc: ∅ @@ -44,4 +49,9 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "second" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0009_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0009_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-0af561a0c6dea91d159fd88b7a3988aa.txt index a493fcede..bcbc5cae8 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0009_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0009_non-output_tag_with_assignment_6e00aefb01b4439f8133cf1425d2db06-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -26,4 +26,5 @@ options: {prism_program: true} ├── value: │ └── @ IntegerNode (location: (1:7)-(1:8)) │ └── value: 1 - └── operator_loc: (1:5)-(1:6) \ No newline at end of file + ├── operator_loc: (1:5)-(1:6) + └── operator: "=" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0010_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0010_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-0af561a0c6dea91d159fd88b7a3988aa.txt index 448a9a6fa..1a72a1720 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0010_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0010_non-output_tag_with_method_call_ed25741ab36410710f338e9f6c01115c-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -33,16 +33,28 @@ options: {prism_program: true} │ ├── key: │ │ └── @ SymbolNode (location: (1:10)-(1:18)) │ │ ├── opening_loc: ∅ - │ │ ├── value_loc: (1:10)-(1:17) + │ │ ├── content_loc: (1:10)-(1:17) │ │ ├── closing_loc: (1:17)-(1:18) - │ │ └── unescaped: "partial" + │ │ ├── unescaped: "partial" + │ │ ├── opening: ∅ + │ │ ├── content: "partial" + │ │ └── closing: ":" │ ├── value: │ │ └── @ StringNode (location: (1:19)-(1:27)) │ │ ├── opening_loc: (1:19)-(1:20) │ │ ├── content_loc: (1:20)-(1:26) │ │ ├── closing_loc: (1:26)-(1:27) - │ │ └── unescaped: "header" - │ └── operator_loc: ∅ + │ │ ├── unescaped: "header" + │ │ ├── opening: "\"" + │ │ ├── content: "header" + │ │ └── closing: "\"" + │ ├── operator_loc: ∅ + │ └── operator: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "render" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0011_if_statement_4670130f794a227341991a25a1b7e654-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0011_if_statement_4670130f794a227341991a25a1b7e654-0af561a0c6dea91d159fd88b7a3988aa.txt index 5f1b7e774..f81cb76ed 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0011_if_statement_4670130f794a227341991a25a1b7e654-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0011_if_statement_4670130f794a227341991a25a1b7e654-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -44,6 +44,12 @@ options: {prism_program: true} │ ├── opening_loc: (1:17)-(1:18) │ ├── content_loc: (1:18)-(1:21) │ ├── closing_loc: (1:21)-(1:22) - │ └── unescaped: "yes" + │ ├── unescaped: "yes" + │ ├── opening: "\"" + │ ├── content: "yes" + │ └── closing: "\"" ├── subsequent: ∅ - └── end_keyword_loc: (1:28)-(1:31) \ No newline at end of file + ├── end_keyword_loc: (1:28)-(1:31) + ├── if_keyword: "if" + ├── then_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0012_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0012_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-0af561a0c6dea91d159fd88b7a3988aa.txt index 4752fa9be..76fb87458 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0012_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0012_if_else_statement_24d85ee3956f68a4337fc2e6211c89b3-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -57,7 +57,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "admin?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: ∅ ├── statements: │ └── @ StatementsNode (location: (1:19)-(1:26)) @@ -66,7 +71,10 @@ options: {prism_program: true} │ ├── opening_loc: (1:19)-(1:20) │ ├── content_loc: (1:20)-(1:25) │ ├── closing_loc: (1:25)-(1:26) - │ └── unescaped: "admin" + │ ├── unescaped: "admin" + │ ├── opening: "\"" + │ ├── content: "admin" + │ └── closing: "\"" ├── subsequent: │ └── @ ElseNode (location: (1:32)-(1:58)) │ ├── else_keyword_loc: (1:32)-(1:36) @@ -77,6 +85,14 @@ options: {prism_program: true} │ │ ├── opening_loc: (1:43)-(1:44) │ │ ├── content_loc: (1:44)-(1:48) │ │ ├── closing_loc: (1:48)-(1:49) - │ │ └── unescaped: "user" - │ └── end_keyword_loc: (1:55)-(1:58) - └── end_keyword_loc: (1:55)-(1:58) \ No newline at end of file + │ │ ├── unescaped: "user" + │ │ ├── opening: "\"" + │ │ ├── content: "user" + │ │ └── closing: "\"" + │ ├── end_keyword_loc: (1:55)-(1:58) + │ ├── else_keyword: "else" + │ └── end_keyword: "end" + ├── end_keyword_loc: (1:55)-(1:58) + ├── if_keyword: "if" + ├── then_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0013_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0013_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-0af561a0c6dea91d159fd88b7a3988aa.txt index 1f8572cbe..19158bd2e 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0013_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0013_if_elsif_else_statement_4295317a9df1ca62b954255d3b6b8d43-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -61,7 +61,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "a?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: ∅ ├── statements: ∅ ├── subsequent: @@ -77,13 +82,26 @@ options: {prism_program: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "b?" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: ∅ │ ├── subsequent: │ │ └── @ ElseNode (location: (1:30)-(1:44)) │ │ ├── else_keyword_loc: (1:30)-(1:34) │ │ ├── statements: ∅ - │ │ └── end_keyword_loc: (1:41)-(1:44) - │ └── end_keyword_loc: (1:41)-(1:44) - └── end_keyword_loc: (1:41)-(1:44) \ No newline at end of file + │ │ ├── end_keyword_loc: (1:41)-(1:44) + │ │ ├── else_keyword: "else" + │ │ └── end_keyword: "end" + │ ├── end_keyword_loc: (1:41)-(1:44) + │ ├── if_keyword: "elsif" + │ ├── then_keyword: ∅ + │ └── end_keyword: "end" + ├── end_keyword_loc: (1:41)-(1:44) + ├── if_keyword: "if" + ├── then_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-0af561a0c6dea91d159fd88b7a3988aa.txt index ab02c26fb..34cc0b413 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0014_unless_statement_2ea545251e1a9ea50245d36aad7c3a96-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -33,7 +33,7 @@ options: {prism_program: true} └── @ StatementsNode (location: (1:3)-(1:40)) └── body: (1 item) └── @ UnlessNode (location: (1:3)-(1:40)) - ├── keyword_loc: (1:3)-(1:9) + ├── unless_keyword_loc: (1:3)-(1:9) ├── predicate: │ └── @ CallNode (location: (1:10)-(1:17)) │ ├── receiver: ∅ @@ -44,7 +44,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "hidden?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: ∅ ├── statements: │ └── @ StatementsNode (location: (1:24)-(1:31)) @@ -58,6 +63,14 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "content" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── else_clause: ∅ - └── end_keyword_loc: (1:37)-(1:40) \ No newline at end of file + ├── end_keyword_loc: (1:37)-(1:40) + ├── unless_keyword: "unless" + ├── then_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-0af561a0c6dea91d159fd88b7a3988aa.txt index ba7591a74..2327d1e7a 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0015_unless_else_statement_2918e3e0a219b40854b5e720ce8a194b-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -46,7 +46,7 @@ options: {prism_program: true} └── @ StatementsNode (location: (1:3)-(1:70)) └── body: (1 item) └── @ UnlessNode (location: (1:3)-(1:70)) - ├── keyword_loc: (1:3)-(1:9) + ├── unless_keyword_loc: (1:3)-(1:9) ├── predicate: │ └── @ CallNode (location: (1:10)-(1:16)) │ ├── receiver: ∅ @@ -57,7 +57,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "admin?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── then_keyword_loc: ∅ ├── statements: │ └── @ StatementsNode (location: (1:23)-(1:35)) @@ -66,7 +71,10 @@ options: {prism_program: true} │ ├── opening_loc: (1:23)-(1:24) │ ├── content_loc: (1:24)-(1:34) │ ├── closing_loc: (1:34)-(1:35) - │ └── unescaped: "restricted" + │ ├── unescaped: "restricted" + │ ├── opening: "\"" + │ ├── content: "restricted" + │ └── closing: "\"" ├── else_clause: │ └── @ ElseNode (location: (1:41)-(1:70)) │ ├── else_keyword_loc: (1:41)-(1:45) @@ -77,6 +85,14 @@ options: {prism_program: true} │ │ ├── opening_loc: (1:52)-(1:53) │ │ ├── content_loc: (1:53)-(1:60) │ │ ├── closing_loc: (1:60)-(1:61) - │ │ └── unescaped: "welcome" - │ └── end_keyword_loc: (1:67)-(1:70) - └── end_keyword_loc: (1:67)-(1:70) \ No newline at end of file + │ │ ├── unescaped: "welcome" + │ │ ├── opening: "\"" + │ │ ├── content: "welcome" + │ │ └── closing: "\"" + │ ├── end_keyword_loc: (1:67)-(1:70) + │ ├── else_keyword: "else" + │ └── end_keyword: "end" + ├── end_keyword_loc: (1:67)-(1:70) + ├── unless_keyword: "unless" + ├── then_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-0af561a0c6dea91d159fd88b7a3988aa.txt index 14ccad6af..ce9ca6aaa 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0016_each_block_5a778ee67ef1535beff509800d30f540-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -51,7 +51,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "items" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :each ├── message_loc: (1:9)-(1:13) @@ -59,31 +64,40 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: - └── @ BlockNode (location: (1:14)-(1:43)) - ├── locals: (1 item) - │ └── :item - ├── parameters: - │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ ├── parameters: - │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ ├── requireds: (1 item) - │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ └── name: :item - │ │ ├── optionals: [] - │ │ ├── rest: ∅ - │ │ ├── posts: [] - │ │ ├── keywords: [] - │ │ ├── keyword_rest: ∅ - │ │ └── block: ∅ - │ ├── locals: [] - │ ├── opening_loc: (1:17)-(1:18) - │ └── closing_loc: (1:22)-(1:23) - ├── body: - │ └── @ StatementsNode (location: (1:30)-(1:34)) - │ └── body: (1 item) - │ └── @ LocalVariableReadNode (location: (1:30)-(1:34)) - │ ├── name: :item - │ └── depth: 0 - ├── opening_loc: (1:14)-(1:16) - └── closing_loc: (1:40)-(1:43) \ No newline at end of file + ├── block: + │ └── @ BlockNode (location: (1:14)-(1:43)) + │ ├── locals: (1 item) + │ │ └── :item + │ ├── parameters: + │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ ├── parameters: + │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ ├── requireds: (1 item) + │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ └── name: :item + │ │ │ ├── optionals: [] + │ │ │ ├── rest: ∅ + │ │ │ ├── posts: [] + │ │ │ ├── keywords: [] + │ │ │ ├── keyword_rest: ∅ + │ │ │ └── block: ∅ + │ │ ├── locals: [] + │ │ ├── opening_loc: (1:17)-(1:18) + │ │ ├── closing_loc: (1:22)-(1:23) + │ │ ├── opening: "|" + │ │ └── closing: "|" + │ ├── body: + │ │ └── @ StatementsNode (location: (1:30)-(1:34)) + │ │ └── body: (1 item) + │ │ └── @ LocalVariableReadNode (location: (1:30)-(1:34)) + │ │ ├── name: :item + │ │ └── depth: 0 + │ ├── opening_loc: (1:14)-(1:16) + │ ├── closing_loc: (1:40)-(1:43) + │ ├── opening: "do" + │ └── closing: "end" + ├── call_operator: "." + ├── message: "each" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-0af561a0c6dea91d159fd88b7a3988aa.txt index 93b5b13ee..3e7215346 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0017_each_with_index_block_89cd8abe206f1b944b052cb07b124fe3-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -57,7 +57,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "items" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :each_with_index ├── message_loc: (1:9)-(1:24) @@ -65,34 +70,43 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: - └── @ BlockNode (location: (1:25)-(1:61)) - ├── locals: (2 items) - │ ├── :item - │ └── :index - ├── parameters: - │ └── @ BlockParametersNode (location: (1:28)-(1:41)) - │ ├── parameters: - │ │ └── @ ParametersNode (location: (1:29)-(1:40)) - │ │ ├── requireds: (2 items) - │ │ │ ├── @ RequiredParameterNode (location: (1:29)-(1:33)) - │ │ │ │ └── name: :item - │ │ │ └── @ RequiredParameterNode (location: (1:35)-(1:40)) - │ │ │ └── name: :index - │ │ ├── optionals: [] - │ │ ├── rest: ∅ - │ │ ├── posts: [] - │ │ ├── keywords: [] - │ │ ├── keyword_rest: ∅ - │ │ └── block: ∅ - │ ├── locals: [] - │ ├── opening_loc: (1:28)-(1:29) - │ └── closing_loc: (1:40)-(1:41) - ├── body: - │ └── @ StatementsNode (location: (1:48)-(1:52)) - │ └── body: (1 item) - │ └── @ LocalVariableReadNode (location: (1:48)-(1:52)) - │ ├── name: :item - │ └── depth: 0 - ├── opening_loc: (1:25)-(1:27) - └── closing_loc: (1:58)-(1:61) \ No newline at end of file + ├── block: + │ └── @ BlockNode (location: (1:25)-(1:61)) + │ ├── locals: (2 items) + │ │ ├── :item + │ │ └── :index + │ ├── parameters: + │ │ └── @ BlockParametersNode (location: (1:28)-(1:41)) + │ │ ├── parameters: + │ │ │ └── @ ParametersNode (location: (1:29)-(1:40)) + │ │ │ ├── requireds: (2 items) + │ │ │ │ ├── @ RequiredParameterNode (location: (1:29)-(1:33)) + │ │ │ │ │ └── name: :item + │ │ │ │ └── @ RequiredParameterNode (location: (1:35)-(1:40)) + │ │ │ │ └── name: :index + │ │ │ ├── optionals: [] + │ │ │ ├── rest: ∅ + │ │ │ ├── posts: [] + │ │ │ ├── keywords: [] + │ │ │ ├── keyword_rest: ∅ + │ │ │ └── block: ∅ + │ │ ├── locals: [] + │ │ ├── opening_loc: (1:28)-(1:29) + │ │ ├── closing_loc: (1:40)-(1:41) + │ │ ├── opening: "|" + │ │ └── closing: "|" + │ ├── body: + │ │ └── @ StatementsNode (location: (1:48)-(1:52)) + │ │ └── body: (1 item) + │ │ └── @ LocalVariableReadNode (location: (1:48)-(1:52)) + │ │ ├── name: :item + │ │ └── depth: 0 + │ ├── opening_loc: (1:25)-(1:27) + │ ├── closing_loc: (1:58)-(1:61) + │ ├── opening: "do" + │ └── closing: "end" + ├── call_operator: "." + ├── message: "each_with_index" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-0af561a0c6dea91d159fd88b7a3988aa.txt index ebfd44fe4..c4938b60e 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0018_map_block_63f0ea87d37776c9a4061d49991dfc24-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -51,7 +51,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "items" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :map ├── message_loc: (1:9)-(1:12) @@ -59,41 +64,55 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: - └── @ BlockNode (location: (1:13)-(1:47)) - ├── locals: (1 item) - │ └── :item - ├── parameters: - │ └── @ BlockParametersNode (location: (1:16)-(1:22)) - │ ├── parameters: - │ │ └── @ ParametersNode (location: (1:17)-(1:21)) - │ │ ├── requireds: (1 item) - │ │ │ └── @ RequiredParameterNode (location: (1:17)-(1:21)) - │ │ │ └── name: :item - │ │ ├── optionals: [] - │ │ ├── rest: ∅ - │ │ ├── posts: [] - │ │ ├── keywords: [] - │ │ ├── keyword_rest: ∅ - │ │ └── block: ∅ - │ ├── locals: [] - │ ├── opening_loc: (1:16)-(1:17) - │ └── closing_loc: (1:21)-(1:22) - ├── body: - │ └── @ StatementsNode (location: (1:29)-(1:38)) - │ └── body: (1 item) - │ └── @ CallNode (location: (1:29)-(1:38)) - │ ├── receiver: - │ │ └── @ LocalVariableReadNode (location: (1:29)-(1:33)) - │ │ ├── name: :item - │ │ └── depth: 0 - │ ├── call_operator_loc: (1:33)-(1:34) - │ ├── name: :name - │ ├── message_loc: (1:34)-(1:38) - │ ├── opening_loc: ∅ - │ ├── arguments: ∅ - │ ├── closing_loc: ∅ - │ ├── equal_loc: ∅ - │ └── block: ∅ - ├── opening_loc: (1:13)-(1:15) - └── closing_loc: (1:44)-(1:47) \ No newline at end of file + ├── block: + │ └── @ BlockNode (location: (1:13)-(1:47)) + │ ├── locals: (1 item) + │ │ └── :item + │ ├── parameters: + │ │ └── @ BlockParametersNode (location: (1:16)-(1:22)) + │ │ ├── parameters: + │ │ │ └── @ ParametersNode (location: (1:17)-(1:21)) + │ │ │ ├── requireds: (1 item) + │ │ │ │ └── @ RequiredParameterNode (location: (1:17)-(1:21)) + │ │ │ │ └── name: :item + │ │ │ ├── optionals: [] + │ │ │ ├── rest: ∅ + │ │ │ ├── posts: [] + │ │ │ ├── keywords: [] + │ │ │ ├── keyword_rest: ∅ + │ │ │ └── block: ∅ + │ │ ├── locals: [] + │ │ ├── opening_loc: (1:16)-(1:17) + │ │ ├── closing_loc: (1:21)-(1:22) + │ │ ├── opening: "|" + │ │ └── closing: "|" + │ ├── body: + │ │ └── @ StatementsNode (location: (1:29)-(1:38)) + │ │ └── body: (1 item) + │ │ └── @ CallNode (location: (1:29)-(1:38)) + │ │ ├── receiver: + │ │ │ └── @ LocalVariableReadNode (location: (1:29)-(1:33)) + │ │ │ ├── name: :item + │ │ │ └── depth: 0 + │ │ ├── call_operator_loc: (1:33)-(1:34) + │ │ ├── name: :name + │ │ ├── message_loc: (1:34)-(1:38) + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── equal_loc: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "name" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── opening_loc: (1:13)-(1:15) + │ ├── closing_loc: (1:44)-(1:47) + │ ├── opening: "do" + │ └── closing: "end" + ├── call_operator: "." + ├── message: "map" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-0af561a0c6dea91d159fd88b7a3988aa.txt index 7ce74a971..e872fd01b 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0019_times_block_eff9a7d84dd2d4278289689e08ff361c-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -51,31 +51,40 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: - └── @ BlockNode (location: (1:11)-(1:34)) - ├── locals: (1 item) - │ └── :i - ├── parameters: - │ └── @ BlockParametersNode (location: (1:14)-(1:17)) - │ ├── parameters: - │ │ └── @ ParametersNode (location: (1:15)-(1:16)) - │ │ ├── requireds: (1 item) - │ │ │ └── @ RequiredParameterNode (location: (1:15)-(1:16)) - │ │ │ └── name: :i - │ │ ├── optionals: [] - │ │ ├── rest: ∅ - │ │ ├── posts: [] - │ │ ├── keywords: [] - │ │ ├── keyword_rest: ∅ - │ │ └── block: ∅ - │ ├── locals: [] - │ ├── opening_loc: (1:14)-(1:15) - │ └── closing_loc: (1:16)-(1:17) - ├── body: - │ └── @ StatementsNode (location: (1:24)-(1:25)) - │ └── body: (1 item) - │ └── @ LocalVariableReadNode (location: (1:24)-(1:25)) - │ ├── name: :i - │ └── depth: 0 - ├── opening_loc: (1:11)-(1:13) - └── closing_loc: (1:31)-(1:34) \ No newline at end of file + ├── block: + │ └── @ BlockNode (location: (1:11)-(1:34)) + │ ├── locals: (1 item) + │ │ └── :i + │ ├── parameters: + │ │ └── @ BlockParametersNode (location: (1:14)-(1:17)) + │ │ ├── parameters: + │ │ │ └── @ ParametersNode (location: (1:15)-(1:16)) + │ │ │ ├── requireds: (1 item) + │ │ │ │ └── @ RequiredParameterNode (location: (1:15)-(1:16)) + │ │ │ │ └── name: :i + │ │ │ ├── optionals: [] + │ │ │ ├── rest: ∅ + │ │ │ ├── posts: [] + │ │ │ ├── keywords: [] + │ │ │ ├── keyword_rest: ∅ + │ │ │ └── block: ∅ + │ │ ├── locals: [] + │ │ ├── opening_loc: (1:14)-(1:15) + │ │ ├── closing_loc: (1:16)-(1:17) + │ │ ├── opening: "|" + │ │ └── closing: "|" + │ ├── body: + │ │ └── @ StatementsNode (location: (1:24)-(1:25)) + │ │ └── body: (1 item) + │ │ └── @ LocalVariableReadNode (location: (1:24)-(1:25)) + │ │ ├── name: :i + │ │ └── depth: 0 + │ ├── opening_loc: (1:11)-(1:13) + │ ├── closing_loc: (1:31)-(1:34) + │ ├── opening: "do" + │ └── closing: "end" + ├── call_operator: "." + ├── message: "times" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-0af561a0c6dea91d159fd88b7a3988aa.txt index 83e76788f..33537ed4d 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0020_while_loop_316bfac13320a30adea0c3f0c2d8487f-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -31,9 +31,9 @@ options: {prism_program: true} └── @ StatementsNode (location: (1:3)-(1:39)) └── body: (1 item) └── @ WhileNode (location: (1:3)-(1:39)) - ├── keyword_loc: (1:3)-(1:8) + ├── while_keyword_loc: (1:3)-(1:8) ├── do_keyword_loc: ∅ - ├── closing_loc: (1:36)-(1:39) + ├── end_keyword_loc: (1:36)-(1:39) ├── predicate: │ └── @ CallNode (location: (1:9)-(1:17)) │ ├── receiver: ∅ @@ -44,17 +44,30 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ - └── statements: - └── @ StatementsNode (location: (1:24)-(1:30)) - └── body: (1 item) - └── @ CallNode (location: (1:24)-(1:30)) - ├── receiver: ∅ - ├── call_operator_loc: ∅ - ├── name: :status - ├── message_loc: (1:24)-(1:30) - ├── opening_loc: ∅ - ├── arguments: ∅ - ├── closing_loc: ∅ - ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "running?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ + ├── statements: + │ └── @ StatementsNode (location: (1:24)-(1:30)) + │ └── body: (1 item) + │ └── @ CallNode (location: (1:24)-(1:30)) + │ ├── receiver: ∅ + │ ├── call_operator_loc: ∅ + │ ├── name: :status + │ ├── message_loc: (1:24)-(1:30) + │ ├── opening_loc: ∅ + │ ├── arguments: ∅ + │ ├── closing_loc: ∅ + │ ├── equal_loc: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "status" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ + ├── while_keyword: "while" + ├── do_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-0af561a0c6dea91d159fd88b7a3988aa.txt index 00a1a35cd..f6cbd4f33 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0021_until_loop_0749dafecd752ebf473439e0aed82839-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -31,9 +31,9 @@ options: {prism_program: true} └── @ StatementsNode (location: (1:3)-(1:38)) └── body: (1 item) └── @ UntilNode (location: (1:3)-(1:38)) - ├── keyword_loc: (1:3)-(1:8) + ├── until_keyword_loc: (1:3)-(1:8) ├── do_keyword_loc: ∅ - ├── closing_loc: (1:35)-(1:38) + ├── end_keyword_loc: (1:35)-(1:38) ├── predicate: │ └── @ CallNode (location: (1:9)-(1:14)) │ ├── receiver: ∅ @@ -44,17 +44,30 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ - └── statements: - └── @ StatementsNode (location: (1:21)-(1:29)) - └── body: (1 item) - └── @ CallNode (location: (1:21)-(1:29)) - ├── receiver: ∅ - ├── call_operator_loc: ∅ - ├── name: :progress - ├── message_loc: (1:21)-(1:29) - ├── opening_loc: ∅ - ├── arguments: ∅ - ├── closing_loc: ∅ - ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "done?" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ + ├── statements: + │ └── @ StatementsNode (location: (1:21)-(1:29)) + │ └── body: (1 item) + │ └── @ CallNode (location: (1:21)-(1:29)) + │ ├── receiver: ∅ + │ ├── call_operator_loc: ∅ + │ ├── name: :progress + │ ├── message_loc: (1:21)-(1:29) + │ ├── opening_loc: ∅ + │ ├── arguments: ∅ + │ ├── closing_loc: ∅ + │ ├── equal_loc: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "progress" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ + ├── until_keyword: "until" + ├── do_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-0af561a0c6dea91d159fd88b7a3988aa.txt index 773f03628..92a6b0d2f 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0022_for_loop_47be8823810057a1054aa82d2a1ed9a9-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -46,7 +46,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "items" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── statements: │ └── @ StatementsNode (location: (1:27)-(1:31)) │ └── body: (1 item) @@ -56,4 +61,8 @@ options: {prism_program: true} ├── for_keyword_loc: (1:3)-(1:6) ├── in_keyword_loc: (1:12)-(1:14) ├── do_keyword_loc: ∅ - └── end_keyword_loc: (1:37)-(1:40) \ No newline at end of file + ├── end_keyword_loc: (1:37)-(1:40) + ├── for_keyword: "for" + ├── in_keyword: "in" + ├── do_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-0af561a0c6dea91d159fd88b7a3988aa.txt index cb03263b8..3894d5432 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0023_case_when_42736e7ede24cdf8d921a1efe7042d39-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -64,42 +64,65 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "role" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── conditions: (2 items) │ ├── @ WhenNode (location: (1:18)-(1:44)) - │ │ ├── keyword_loc: (1:18)-(1:22) + │ │ ├── when_keyword_loc: (1:18)-(1:22) │ │ ├── conditions: (1 item) │ │ │ └── @ StringNode (location: (1:23)-(1:30)) │ │ │ ├── opening_loc: (1:23)-(1:24) │ │ │ ├── content_loc: (1:24)-(1:29) │ │ │ ├── closing_loc: (1:29)-(1:30) - │ │ │ └── unescaped: "admin" + │ │ │ ├── unescaped: "admin" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "admin" + │ │ │ └── closing: "\"" │ │ ├── then_keyword_loc: ∅ - │ │ └── statements: - │ │ └── @ StatementsNode (location: (1:37)-(1:44)) - │ │ └── body: (1 item) - │ │ └── @ StringNode (location: (1:37)-(1:44)) - │ │ ├── opening_loc: (1:37)-(1:38) - │ │ ├── content_loc: (1:38)-(1:43) - │ │ ├── closing_loc: (1:43)-(1:44) - │ │ └── unescaped: "Admin" + │ │ ├── statements: + │ │ │ └── @ StatementsNode (location: (1:37)-(1:44)) + │ │ │ └── body: (1 item) + │ │ │ └── @ StringNode (location: (1:37)-(1:44)) + │ │ │ ├── opening_loc: (1:37)-(1:38) + │ │ │ ├── content_loc: (1:38)-(1:43) + │ │ │ ├── closing_loc: (1:43)-(1:44) + │ │ │ ├── unescaped: "Admin" + │ │ │ ├── opening: "\"" + │ │ │ ├── content: "Admin" + │ │ │ └── closing: "\"" + │ │ ├── when_keyword: "when" + │ │ └── then_keyword: ∅ │ └── @ WhenNode (location: (1:50)-(1:74)) - │ ├── keyword_loc: (1:50)-(1:54) + │ ├── when_keyword_loc: (1:50)-(1:54) │ ├── conditions: (1 item) │ │ └── @ StringNode (location: (1:55)-(1:61)) │ │ ├── opening_loc: (1:55)-(1:56) │ │ ├── content_loc: (1:56)-(1:60) │ │ ├── closing_loc: (1:60)-(1:61) - │ │ └── unescaped: "user" + │ │ ├── unescaped: "user" + │ │ ├── opening: "\"" + │ │ ├── content: "user" + │ │ └── closing: "\"" │ ├── then_keyword_loc: ∅ - │ └── statements: - │ └── @ StatementsNode (location: (1:68)-(1:74)) - │ └── body: (1 item) - │ └── @ StringNode (location: (1:68)-(1:74)) - │ ├── opening_loc: (1:68)-(1:69) - │ ├── content_loc: (1:69)-(1:73) - │ ├── closing_loc: (1:73)-(1:74) - │ └── unescaped: "User" + │ ├── statements: + │ │ └── @ StatementsNode (location: (1:68)-(1:74)) + │ │ └── body: (1 item) + │ │ └── @ StringNode (location: (1:68)-(1:74)) + │ │ ├── opening_loc: (1:68)-(1:69) + │ │ ├── content_loc: (1:69)-(1:73) + │ │ ├── closing_loc: (1:73)-(1:74) + │ │ ├── unescaped: "User" + │ │ ├── opening: "\"" + │ │ ├── content: "User" + │ │ └── closing: "\"" + │ ├── when_keyword: "when" + │ └── then_keyword: ∅ ├── else_clause: ∅ ├── case_keyword_loc: (1:3)-(1:7) - └── end_keyword_loc: (1:80)-(1:83) \ No newline at end of file + ├── end_keyword_loc: (1:80)-(1:83) + ├── case_keyword: "case" + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-0af561a0c6dea91d159fd88b7a3988aa.txt index 4d7fb5ca1..901245b93 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0024_case_when_else_953565c8c118844b420bebe8d4e6f716-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -65,32 +65,51 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "status" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── conditions: (2 items) │ ├── @ WhenNode (location: (1:20)-(1:32)) - │ │ ├── keyword_loc: (1:20)-(1:24) + │ │ ├── when_keyword_loc: (1:20)-(1:24) │ │ ├── conditions: (1 item) │ │ │ └── @ SymbolNode (location: (1:25)-(1:32)) │ │ │ ├── opening_loc: (1:25)-(1:26) - │ │ │ ├── value_loc: (1:26)-(1:32) + │ │ │ ├── content_loc: (1:26)-(1:32) │ │ │ ├── closing_loc: ∅ - │ │ │ └── unescaped: "active" + │ │ │ ├── unescaped: "active" + │ │ │ ├── opening: ":" + │ │ │ ├── content: "active" + │ │ │ └── closing: ∅ │ │ ├── then_keyword_loc: ∅ - │ │ └── statements: ∅ + │ │ ├── statements: ∅ + │ │ ├── when_keyword: "when" + │ │ └── then_keyword: ∅ │ └── @ WhenNode (location: (1:44)-(1:58)) - │ ├── keyword_loc: (1:44)-(1:48) + │ ├── when_keyword_loc: (1:44)-(1:48) │ ├── conditions: (1 item) │ │ └── @ SymbolNode (location: (1:49)-(1:58)) │ │ ├── opening_loc: (1:49)-(1:50) - │ │ ├── value_loc: (1:50)-(1:58) + │ │ ├── content_loc: (1:50)-(1:58) │ │ ├── closing_loc: ∅ - │ │ └── unescaped: "inactive" + │ │ ├── unescaped: "inactive" + │ │ ├── opening: ":" + │ │ ├── content: "inactive" + │ │ └── closing: ∅ │ ├── then_keyword_loc: ∅ - │ └── statements: ∅ + │ ├── statements: ∅ + │ ├── when_keyword: "when" + │ └── then_keyword: ∅ ├── else_clause: │ └── @ ElseNode (location: (1:72)-(1:92)) │ ├── else_keyword_loc: (1:72)-(1:76) │ ├── statements: ∅ - │ └── end_keyword_loc: (1:89)-(1:92) + │ ├── end_keyword_loc: (1:89)-(1:92) + │ ├── else_keyword: "else" + │ └── end_keyword: "end" ├── case_keyword_loc: (1:3)-(1:7) - └── end_keyword_loc: (1:89)-(1:92) \ No newline at end of file + ├── end_keyword_loc: (1:89)-(1:92) + ├── case_keyword: "case" + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-0af561a0c6dea91d159fd88b7a3988aa.txt index 9512d1e1f..d6cadff89 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0025_case_in_pattern_matching_7e9f30c2157d57cdef2a3ae79a4d7343-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -51,7 +51,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "data" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── conditions: (1 item) │ └── @ InNode (location: (1:18)-(1:41)) │ ├── pattern: @@ -62,27 +67,37 @@ options: {prism_program: true} │ │ │ ├── key: │ │ │ │ └── @ SymbolNode (location: (1:23)-(1:28)) │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ ├── value_loc: (1:23)-(1:27) + │ │ │ │ ├── content_loc: (1:23)-(1:27) │ │ │ │ ├── closing_loc: (1:27)-(1:28) - │ │ │ │ └── unescaped: "name" + │ │ │ │ ├── unescaped: "name" + │ │ │ │ ├── opening: ∅ + │ │ │ │ ├── content: "name" + │ │ │ │ └── closing: ":" │ │ │ ├── value: │ │ │ │ └── @ ImplicitNode (location: (1:23)-(1:27)) │ │ │ │ └── value: │ │ │ │ └── @ LocalVariableTargetNode (location: (1:23)-(1:27)) │ │ │ │ ├── name: :name │ │ │ │ └── depth: 0 - │ │ │ └── operator_loc: ∅ + │ │ │ ├── operator_loc: ∅ + │ │ │ └── operator: ∅ │ │ ├── rest: ∅ │ │ ├── opening_loc: (1:21)-(1:22) - │ │ └── closing_loc: (1:29)-(1:30) + │ │ ├── closing_loc: (1:29)-(1:30) + │ │ ├── opening: "{" + │ │ └── closing: "}" │ ├── statements: │ │ └── @ StatementsNode (location: (1:37)-(1:41)) │ │ └── body: (1 item) │ │ └── @ LocalVariableReadNode (location: (1:37)-(1:41)) │ │ ├── name: :name │ │ └── depth: 0 - │ ├── in_loc: (1:18)-(1:20) - │ └── then_loc: ∅ + │ ├── in_keyword_loc: (1:18)-(1:20) + │ ├── then_keyword_loc: ∅ + │ ├── in_keyword: "in" + │ └── then_keyword: ∅ ├── else_clause: ∅ ├── case_keyword_loc: (1:3)-(1:7) - └── end_keyword_loc: (1:47)-(1:50) \ No newline at end of file + ├── end_keyword_loc: (1:47)-(1:50) + ├── case_keyword: "case" + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-0af561a0c6dea91d159fd88b7a3988aa.txt index 48cd5feae..a0013a082 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0026_begin_rescue_df4f24aebbe892defa838eb3f66814a4-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -61,7 +61,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "dangerous_call" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── rescue_clause: │ └── @ RescueNode (location: (1:35)-(1:55)) │ ├── keyword_loc: (1:35)-(1:41) @@ -76,8 +81,16 @@ options: {prism_program: true} │ │ ├── opening_loc: (1:48)-(1:49) │ │ ├── content_loc: (1:49)-(1:54) │ │ ├── closing_loc: (1:54)-(1:55) - │ │ └── unescaped: "error" - │ └── subsequent: ∅ + │ │ ├── unescaped: "error" + │ │ ├── opening: "\"" + │ │ ├── content: "error" + │ │ └── closing: "\"" + │ ├── subsequent: ∅ + │ ├── keyword: "rescue" + │ ├── operator: ∅ + │ └── then_keyword: ∅ ├── else_clause: ∅ ├── ensure_clause: ∅ - └── end_keyword_loc: (1:61)-(1:64) \ No newline at end of file + ├── end_keyword_loc: (1:61)-(1:64) + ├── begin_keyword: "begin" + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-0af561a0c6dea91d159fd88b7a3988aa.txt index 43dfe9100..4ac89706d 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0027_begin_rescue_ensure_1b2421996b45845394c648f1ac384d9b-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -75,7 +75,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "risky" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── rescue_clause: │ └── @ RescueNode (location: (1:26)-(1:53)) │ ├── keyword_loc: (1:26)-(1:32) @@ -101,8 +106,16 @@ options: {prism_program: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── subsequent: ∅ + │ │ ├── block: ∅ + │ │ ├── call_operator: "." + │ │ ├── message: "message" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── subsequent: ∅ + │ ├── keyword: "rescue" + │ ├── operator: "=>" + │ └── then_keyword: ∅ ├── else_clause: ∅ ├── ensure_clause: │ └── @ EnsureNode (location: (1:59)-(1:88)) @@ -119,6 +132,15 @@ options: {prism_program: true} │ │ ├── arguments: ∅ │ │ ├── closing_loc: ∅ │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ └── end_keyword_loc: (1:85)-(1:88) - └── end_keyword_loc: (1:85)-(1:88) \ No newline at end of file + │ │ ├── block: ∅ + │ │ ├── call_operator: ∅ + │ │ ├── message: "cleanup" + │ │ ├── opening: ∅ + │ │ ├── closing: ∅ + │ │ └── equal: ∅ + │ ├── end_keyword_loc: (1:85)-(1:88) + │ ├── ensure_keyword: "ensure" + │ └── end_keyword: "end" + ├── end_keyword_loc: (1:85)-(1:88) + ├── begin_keyword: "begin" + └── end_keyword: "end" \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-0af561a0c6dea91d159fd88b7a3988aa.txt index fa1a0c530..b13cad2ab 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0028_nested_if_inside_each_14eb53491aa7f9c5de33ff7db6af498f-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -65,7 +65,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "items" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ ├── call_operator_loc: (1:8)-(1:9) ├── name: :each ├── message_loc: (1:9)-(1:13) @@ -73,63 +78,85 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: - └── @ BlockNode (location: (1:14)-(1:79)) - ├── locals: (1 item) - │ └── :item - ├── parameters: - │ └── @ BlockParametersNode (location: (1:17)-(1:23)) - │ ├── parameters: - │ │ └── @ ParametersNode (location: (1:18)-(1:22)) - │ │ ├── requireds: (1 item) - │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) - │ │ │ └── name: :item - │ │ ├── optionals: [] - │ │ ├── rest: ∅ - │ │ ├── posts: [] - │ │ ├── keywords: [] - │ │ ├── keyword_rest: ∅ - │ │ └── block: ∅ - │ ├── locals: [] - │ ├── opening_loc: (1:17)-(1:18) - │ └── closing_loc: (1:22)-(1:23) - ├── body: - │ └── @ StatementsNode (location: (1:29)-(1:70)) - │ └── body: (1 item) - │ └── @ IfNode (location: (1:29)-(1:70)) - │ ├── if_keyword_loc: (1:29)-(1:31) - │ ├── predicate: - │ │ └── @ CallNode (location: (1:32)-(1:45)) - │ │ ├── receiver: - │ │ │ └── @ LocalVariableReadNode (location: (1:32)-(1:36)) - │ │ │ ├── name: :item - │ │ │ └── depth: 0 - │ │ ├── call_operator_loc: (1:36)-(1:37) - │ │ ├── name: :visible? - │ │ ├── message_loc: (1:37)-(1:45) - │ │ ├── opening_loc: ∅ - │ │ ├── arguments: ∅ - │ │ ├── closing_loc: ∅ - │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ ├── then_keyword_loc: ∅ - │ ├── statements: - │ │ └── @ StatementsNode (location: (1:52)-(1:61)) - │ │ └── body: (1 item) - │ │ └── @ CallNode (location: (1:52)-(1:61)) - │ │ ├── receiver: - │ │ │ └── @ LocalVariableReadNode (location: (1:52)-(1:56)) - │ │ │ ├── name: :item - │ │ │ └── depth: 0 - │ │ ├── call_operator_loc: (1:56)-(1:57) - │ │ ├── name: :name - │ │ ├── message_loc: (1:57)-(1:61) - │ │ ├── opening_loc: ∅ - │ │ ├── arguments: ∅ - │ │ ├── closing_loc: ∅ - │ │ ├── equal_loc: ∅ - │ │ └── block: ∅ - │ ├── subsequent: ∅ - │ └── end_keyword_loc: (1:67)-(1:70) - ├── opening_loc: (1:14)-(1:16) - └── closing_loc: (1:76)-(1:79) \ No newline at end of file + ├── block: + │ └── @ BlockNode (location: (1:14)-(1:79)) + │ ├── locals: (1 item) + │ │ └── :item + │ ├── parameters: + │ │ └── @ BlockParametersNode (location: (1:17)-(1:23)) + │ │ ├── parameters: + │ │ │ └── @ ParametersNode (location: (1:18)-(1:22)) + │ │ │ ├── requireds: (1 item) + │ │ │ │ └── @ RequiredParameterNode (location: (1:18)-(1:22)) + │ │ │ │ └── name: :item + │ │ │ ├── optionals: [] + │ │ │ ├── rest: ∅ + │ │ │ ├── posts: [] + │ │ │ ├── keywords: [] + │ │ │ ├── keyword_rest: ∅ + │ │ │ └── block: ∅ + │ │ ├── locals: [] + │ │ ├── opening_loc: (1:17)-(1:18) + │ │ ├── closing_loc: (1:22)-(1:23) + │ │ ├── opening: "|" + │ │ └── closing: "|" + │ ├── body: + │ │ └── @ StatementsNode (location: (1:29)-(1:70)) + │ │ └── body: (1 item) + │ │ └── @ IfNode (location: (1:29)-(1:70)) + │ │ ├── if_keyword_loc: (1:29)-(1:31) + │ │ ├── predicate: + │ │ │ └── @ CallNode (location: (1:32)-(1:45)) + │ │ │ ├── receiver: + │ │ │ │ └── @ LocalVariableReadNode (location: (1:32)-(1:36)) + │ │ │ │ ├── name: :item + │ │ │ │ └── depth: 0 + │ │ │ ├── call_operator_loc: (1:36)-(1:37) + │ │ │ ├── name: :visible? + │ │ │ ├── message_loc: (1:37)-(1:45) + │ │ │ ├── opening_loc: ∅ + │ │ │ ├── arguments: ∅ + │ │ │ ├── closing_loc: ∅ + │ │ │ ├── equal_loc: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "visible?" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ + │ │ ├── then_keyword_loc: ∅ + │ │ ├── statements: + │ │ │ └── @ StatementsNode (location: (1:52)-(1:61)) + │ │ │ └── body: (1 item) + │ │ │ └── @ CallNode (location: (1:52)-(1:61)) + │ │ │ ├── receiver: + │ │ │ │ └── @ LocalVariableReadNode (location: (1:52)-(1:56)) + │ │ │ │ ├── name: :item + │ │ │ │ └── depth: 0 + │ │ │ ├── call_operator_loc: (1:56)-(1:57) + │ │ │ ├── name: :name + │ │ │ ├── message_loc: (1:57)-(1:61) + │ │ │ ├── opening_loc: ∅ + │ │ │ ├── arguments: ∅ + │ │ │ ├── closing_loc: ∅ + │ │ │ ├── equal_loc: ∅ + │ │ │ ├── block: ∅ + │ │ │ ├── call_operator: "." + │ │ │ ├── message: "name" + │ │ │ ├── opening: ∅ + │ │ │ ├── closing: ∅ + │ │ │ └── equal: ∅ + │ │ ├── subsequent: ∅ + │ │ ├── end_keyword_loc: (1:67)-(1:70) + │ │ ├── if_keyword: "if" + │ │ ├── then_keyword: ∅ + │ │ └── end_keyword: "end" + │ ├── opening_loc: (1:14)-(1:16) + │ ├── closing_loc: (1:76)-(1:79) + │ ├── opening: "do" + │ └── closing: "end" + ├── call_operator: "." + ├── message: "each" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-0af561a0c6dea91d159fd88b7a3988aa.txt b/test/snapshots/parser/prism/prism_program_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-0af561a0c6dea91d159fd88b7a3988aa.txt index d7f5bc97a..8e45a9030 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-0af561a0c6dea91d159fd88b7a3988aa.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0029_expression_inside_HTML_5b5dd1f7a0f0dbb5866f800df961244b-0af561a0c6dea91d159fd88b7a3988aa.txt @@ -72,7 +72,12 @@ options: {prism_program: true} │ ├── arguments: ∅ │ ├── closing_loc: ∅ │ ├── equal_loc: ∅ - │ └── block: ∅ + │ ├── block: ∅ + │ ├── call_operator: ∅ + │ ├── message: "css_class" + │ ├── opening: ∅ + │ ├── closing: ∅ + │ └── equal: ∅ └── @ CallNode (location: (1:34)-(1:41)) ├── receiver: ∅ ├── call_operator_loc: ∅ @@ -82,4 +87,9 @@ options: {prism_program: true} ├── arguments: ∅ ├── closing_loc: ∅ ├── equal_loc: ∅ - └── block: ∅ \ No newline at end of file + ├── block: ∅ + ├── call_operator: ∅ + ├── message: "content" + ├── opening: ∅ + ├── closing: ∅ + └── equal: ∅ \ No newline at end of file diff --git a/test/snapshots/parser/prism/prism_program_test/test_0030_prism_nodes_and_prism_program_combined_if_statement_4670130f794a227341991a25a1b7e654-1f424d525118cb2d26233fc0ed8459a3.txt b/test/snapshots/parser/prism/prism_program_test/test_0030_prism_nodes_and_prism_program_combined_if_statement_4670130f794a227341991a25a1b7e654-1f424d525118cb2d26233fc0ed8459a3.txt index 0bef0df0c..4e227c85c 100644 --- a/test/snapshots/parser/prism/prism_program_test/test_0030_prism_nodes_and_prism_program_combined_if_statement_4670130f794a227341991a25a1b7e654-1f424d525118cb2d26233fc0ed8459a3.txt +++ b/test/snapshots/parser/prism/prism_program_test/test_0030_prism_nodes_and_prism_program_combined_if_statement_4670130f794a227341991a25a1b7e654-1f424d525118cb2d26233fc0ed8459a3.txt @@ -18,7 +18,10 @@ options: {prism_nodes: true, prism_program: true} │ │ ├── then_keyword_loc: ∅ │ │ ├── statements: ∅ │ │ ├── subsequent: ∅ -│ │ └── end_keyword_loc: (1:28)-(1:31) +│ │ ├── end_keyword_loc: (1:28)-(1:31) +│ │ ├── if_keyword: "if" +│ │ ├── then_keyword: ∅ +│ │ └── end_keyword: "end" │ ├── statements: (1 item) │ │ └── @ ERBContentNode (location: (1:13)-(1:25)) │ │ ├── tag_opening: "<%=" (location: (1:13)-(1:16)) @@ -31,7 +34,10 @@ options: {prism_nodes: true, prism_program: true} │ │ ├── opening_loc: (1:17)-(1:18) │ │ ├── content_loc: (1:18)-(1:21) │ │ ├── closing_loc: (1:21)-(1:22) -│ │ └── unescaped: "yes" +│ │ ├── unescaped: "yes" +│ │ ├── opening: "\"" +│ │ ├── content: "yes" +│ │ └── closing: "\"" │ │ │ ├── subsequent: ∅ │ └── end_node: @@ -59,6 +65,12 @@ options: {prism_nodes: true, prism_program: true} │ ├── opening_loc: (1:17)-(1:18) │ ├── content_loc: (1:18)-(1:21) │ ├── closing_loc: (1:21)-(1:22) - │ └── unescaped: "yes" + │ ├── unescaped: "yes" + │ ├── opening: "\"" + │ ├── content: "yes" + │ └── closing: "\"" ├── subsequent: ∅ - └── end_keyword_loc: (1:28)-(1:31) \ No newline at end of file + ├── end_keyword_loc: (1:28)-(1:31) + ├── if_keyword: "if" + ├── then_keyword: ∅ + └── end_keyword: "end" \ No newline at end of file diff --git a/wasm/Makefile b/wasm/Makefile index 7467a3d19..f8f196218 100644 --- a/wasm/Makefile +++ b/wasm/Makefile @@ -11,21 +11,18 @@ C_SOURCES = $(filter-out ../src/main.c ../src/ruby_parser.c, $(shell find ../src PRISM_PATH = $(shell cd .. && bundle show prism) PRISM_MAIN_SOURCES = $(wildcard $(PRISM_PATH)/src/*.c) -PRISM_UTIL_SOURCES = $(wildcard $(PRISM_PATH)/src/util/*.c) -ALL_C_SOURCES = $(C_SOURCES) $(PRISM_MAIN_SOURCES) $(PRISM_UTIL_SOURCES) +ALL_C_SOURCES = $(C_SOURCES) $(PRISM_MAIN_SOURCES) OBJ_DIR = obj C_OBJECTS = $(patsubst ../src/%.c,$(OBJ_DIR)/herb/%.o,$(C_SOURCES)) CPP_OBJECTS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(CPP_SOURCES)) PRISM_MAIN_OBJECTS = $(patsubst $(PRISM_PATH)/src/%.c,$(OBJ_DIR)/prism/%.o,$(PRISM_MAIN_SOURCES)) -PRISM_UTIL_OBJECTS = $(patsubst $(PRISM_PATH)/src/util/%.c,$(OBJ_DIR)/prism/util/%.o,$(PRISM_UTIL_SOURCES)) -ALL_OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS) $(PRISM_MAIN_OBJECTS) $(PRISM_UTIL_OBJECTS) +ALL_OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS) $(PRISM_MAIN_OBJECTS) INCLUDE_DIR = ../include PRISM_INCLUDE = $(PRISM_PATH)/include PRISM_SRC = $(PRISM_PATH)/src -PRISM_UTIL = $(PRISM_PATH)/src/util PRISM_EXCLUDE_FLAGS = -DPRISM_EXCLUDE_PRETTYPRINT -DPRISM_EXCLUDE_JSON -DPRISM_EXCLUDE_PACK HERB_EXCLUDE_FLAGS = -DHERB_EXCLUDE_PRETTYPRINT @@ -33,7 +30,7 @@ HERB_ARENA_FLAGS = '-DHB_ALLOCATOR_DEFAULT_ARENA_SIZE=KB(16)' OPT_FLAGS = -Oz -g0 -flto -fdata-sections -ffunction-sections -CFLAGS = -I$(INCLUDE_DIR) -I$(PRISM_INCLUDE) -I$(PRISM_SRC) -I$(PRISM_UTIL) -DPRISM_STATIC=1 -DPRISM_EXPORT_SYMBOLS=static $(PRISM_EXCLUDE_FLAGS) $(HERB_EXCLUDE_FLAGS) $(HERB_ARENA_FLAGS) $(OPT_FLAGS) +CFLAGS = -I$(INCLUDE_DIR) -I$(PRISM_INCLUDE) -I$(PRISM_SRC) -DPRISM_STATIC=1 -DPRISM_EXPORT_SYMBOLS=static $(PRISM_EXCLUDE_FLAGS) $(HERB_EXCLUDE_FLAGS) $(HERB_ARENA_FLAGS) $(OPT_FLAGS) WASM_FLAGS = -s WASM=1 \ -s SINGLE_FILE=1 \ -s EXPORT_ES6=1 \ @@ -48,7 +45,7 @@ all: $(BROWSER_WASM_OUTPUT) $(NODE_WASM_OUTPUT) $(OBJ_DIR): mkdir -p $(OBJ_DIR)/herb - mkdir -p $(OBJ_DIR)/prism/util + mkdir -p $(OBJ_DIR)/prism $(OBJ_DIR)/herb/%.o: ../src/%.c | $(OBJ_DIR) @mkdir -p $(@D) @@ -62,10 +59,6 @@ $(OBJ_DIR)/prism/%.o: $(PRISM_PATH)/src/%.c | $(OBJ_DIR) @mkdir -p $(@D) emcc -c $< -o $@ $(CFLAGS) -$(OBJ_DIR)/prism/util/%.o: $(PRISM_PATH)/src/util/%.c | $(OBJ_DIR) - @mkdir -p $(@D) - emcc -c $< -o $@ $(CFLAGS) - $(BROWSER_WASM_OUTPUT): $(ALL_OBJECTS) mkdir -p $(BROWSER_BUILD_DIR) em++ $(ALL_OBJECTS) $(CFLAGS) $(WASM_FLAGS) -s ENVIRONMENT='web' -o $(BROWSER_WASM_OUTPUT) diff --git a/wasm/herb-wasm.cpp b/wasm/herb-wasm.cpp index 0656b5f70..d89121939 100644 --- a/wasm/herb-wasm.cpp +++ b/wasm/herb-wasm.cpp @@ -188,17 +188,17 @@ val Herb_parse_ruby(const std::string& source) { if (!parse_result) { return val::null(); } - pm_buffer_t buffer = { 0 }; - pm_serialize(&parse_result->parser, parse_result->root, &buffer); + pm_buffer_t* buffer = pm_buffer_new(); + pm_serialize(parse_result->parser, parse_result->root, buffer); val result = val::null(); - if (buffer.length > 0) { - result = val(typed_memory_view(buffer.length, (const uint8_t*) buffer.value)); + if (pm_buffer_length(buffer) > 0) { + result = val(typed_memory_view(pm_buffer_length(buffer), (const uint8_t*) pm_buffer_value(buffer))); result = val::global("Uint8Array").new_(result); } - pm_buffer_free(&buffer); + pm_buffer_free(buffer); herb_free_ruby_parse_result(parse_result); return result; diff --git a/yarn.lock b/yarn.lock index 4a7e2f87c..b43861619 100644 --- a/yarn.lock +++ b/yarn.lock @@ -897,10 +897,10 @@ resolved "https://registry.yarnpkg.com/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz#e3fcee093fbb5ce765e1ad088ff4de2889f6f9be" integrity sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw== -"@ruby/prism@^1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@ruby/prism/-/prism-1.9.0.tgz#064f599caf2288e8f0738875abbdd4bc4755df95" - integrity sha512-/j+JfP1eA0nCjx6c/8L6K/ENErmsqc6RMAba8rKYNz4RadrT7AW20u4WrjpWYWzdlk6k1YWHxoW9OS68w02+Vw== +"@ruby/prism@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@ruby/prism/-/prism-2.0.0.tgz#3ac014617360879f5df43fa66d10fb58a9ff35ef" + integrity sha512-jEPf56svf7nwFRZ3T+3Dgvfy2RJJSwGk3kEviVEHA6HueR0NT6apbh0YdisqEYducwvzZU/3tZAjgYpqrYzLuw== "@shikijs/core@4.5.0": version "4.5.0"