Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## HEAD (unreleased)

- No longer supports EOL versions of Ruby.
- No longer supports EOL versions of Ruby. (https://github.com/ruby/syntax_suggest/pull/210)
- Handle Ruby 3.3 new eval source location format (https://github.com/ruby/syntax_suggest/pull/200).

## 1.1.0
Expand Down
52 changes: 34 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ GEM
ast (2.4.2)
benchmark-ips (2.9.2)
diff-lcs (1.4.4)
parallel (1.21.0)
parser (3.0.2.0)
json (2.7.0)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
rainbow (3.0.0)
racc
racc (1.7.3)
rainbow (3.1.1)
rake (12.3.3)
regexp_parser (2.1.1)
rexml (3.2.5)
regexp_parser (2.8.3)
rexml (3.2.6)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
Expand All @@ -29,27 +34,38 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.0)
rubocop (1.20.0)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.9.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.12.0)
parser (>= 3.0.1.1)
rubocop-performance (1.11.5)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-prof (1.4.3)
ruby-progressbar (1.11.0)
ruby-progressbar (1.13.0)
stackprof (0.2.16)
standard (1.3.0)
rubocop (= 1.20.0)
rubocop-performance (= 1.11.5)
unicode-display_width (2.1.0)
standard (1.32.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.57.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.1)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
unicode-display_width (2.5.0)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/code_frontier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def expand?

if ENV["SYNTAX_SUGGEST_DEBUG"]
puts "```"
puts @queue.peek.to_s
puts @queue.peek
puts "```"
puts " @frontier indent: #{frontier_indent}"
puts " @unvisited indent: #{unvisited_indent}"
Expand Down
4 changes: 2 additions & 2 deletions lib/syntax_suggest/code_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CodeSearch

def initialize(source, record_dir: DEFAULT_VALUE)
record_dir = if record_dir == DEFAULT_VALUE
ENV["SYNTAX_SUGGEST_RECORD_DIR"] || ENV["SYNTAX_SUGGEST_DEBUG"] ? "tmp" : nil
(ENV["SYNTAX_SUGGEST_RECORD_DIR"] || ENV["SYNTAX_SUGGEST_DEBUG"]) ? "tmp" : nil
else
record_dir
end
Expand Down Expand Up @@ -73,7 +73,7 @@ def record(block:, name: "record")
if ENV["SYNTAX_SUGGEST_DEBUG"]
puts "\n\n==== #{filename} ===="
puts "\n```#{block.starts_at}..#{block.ends_at}"
puts block.to_s
puts block
puts "```"
puts " block indent: #{block.current_indent}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/display_invalid_blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(code_lines:, blocks:, io: $stderr, filename: nil, terminal: DEFAU
@filename = filename
@code_lines = code_lines

@terminal = terminal == DEFAULT_VALUE ? io.isatty : terminal
@terminal = (terminal == DEFAULT_VALUE) ? io.isatty : terminal
end

def document_ok?
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/ruby_command_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module SyntaxSuggest
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
script.write <<~'EOM'
script.write <<~EOM
puts Kernel.private_methods
EOM

Expand Down Expand Up @@ -159,7 +159,7 @@ class Dog
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
script.write <<~'EOM'
script.write <<~EOM
$stderr = STDOUT
eval("def lol")
EOM
Expand All @@ -178,7 +178,7 @@ class Dog
Dir.mktmpdir do |dir|
tmpdir = Pathname(dir)
script = tmpdir.join("script.rb")
script.write <<~'EOM'
script.write <<~EOM
break
EOM

Expand Down
16 changes: 8 additions & 8 deletions spec/integration/syntax_suggest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module SyntaxSuggest
debug_display(io.string)
debug_display(benchmark)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
6 class SyntaxTree < Ripper
170 def self.parse(source)
174 end
Expand Down Expand Up @@ -54,7 +54,7 @@ module SyntaxSuggest
end

expect(io.string).to_not include("def ruby_install_binstub_path")
expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
> 1067 def add_yarn_binary
> 1068 return [] if yarn_preinstalled?
> 1069 |
Expand All @@ -72,7 +72,7 @@ module SyntaxSuggest
)
debug_display(io.string)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
1 Rails.application.routes.draw do
> 113 namespace :admin do
> 116 match "/foobar(*path)", via: :all, to: redirect { |_params, req|
Expand All @@ -91,7 +91,7 @@ module SyntaxSuggest
)
debug_display(io.string)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
1 describe "webmock tests" do
22 it "body" do
27 query = Cutlass::FunctionQuery.new(
Expand All @@ -113,7 +113,7 @@ module SyntaxSuggest
)
debug_display(io.string)

expect(io.string).to include(<<~'EOM')
expect(io.string).to include(<<~EOM)
5 module DerailedBenchmarks
6 class RequireTree
> 13 def initialize(name)
Expand Down Expand Up @@ -166,7 +166,7 @@ module SyntaxSuggest
end

it "ambiguous end" do
source = <<~'EOM'
source = <<~EOM
def call # 0
print "lol" # 1
end # one # 2
Expand All @@ -186,7 +186,7 @@ def call # 0
end

it "simple regression" do
source = <<~'EOM'
source = <<~EOM
class Dog
def bark
puts "woof"
Expand All @@ -206,7 +206,7 @@ def bark
end

it "empty else" do
source = <<~'EOM'
source = <<~EOM
class Foo
def foo
if cond?
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/around_block_scan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SyntaxSuggest
RSpec.describe AroundBlockScan do
it "continues scan from last location even if scan is false" do
source = <<~'EOM'
source = <<~EOM
print 'omg'
print 'lol'
print 'haha'
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/capture/before_after_keyword_ends_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SyntaxSuggest
RSpec.describe Capture::BeforeAfterKeywordEnds do
it "before after keyword ends" do
source = <<~'EOM'
source = <<~EOM
def nope
print 'not me'
end
Expand Down Expand Up @@ -36,7 +36,7 @@ def nada
).call
lines.sort!

expect(lines.join).to include(<<~'EOM')
expect(lines.join).to include(<<~EOM)
def lol
end
def yolo
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/capture/falling_indent_lines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SyntaxSuggest
RSpec.describe Capture::FallingIndentLines do
it "on_falling_indent" do
source = <<~'EOM'
source = <<~EOM
class OH
def lol
print 'lol
Expand Down Expand Up @@ -33,7 +33,7 @@ def yolo
end
lines.sort!

expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
class OH
def hello
end
Expand Down
28 changes: 14 additions & 14 deletions spec/unit/capture_code_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SyntaxSuggest
RSpec.describe CaptureCodeContext do
it "capture_before_after_kws two" do
source = <<~'EOM'
source = <<~EOM
class OH

def hello
Expand All @@ -23,15 +23,15 @@ def hai
code_lines: code_lines
)
display.capture_before_after_kws(block)
expect(display.sorted_lines.join).to eq(<<~'EOM'.indent(2))
expect(display.sorted_lines.join).to eq(<<~EOM.indent(2))
def hello
def hai
end
EOM
end

it "capture_before_after_kws" do
source = <<~'EOM'
source = <<~EOM
def sit
end

Expand All @@ -50,7 +50,7 @@ def eat
)

lines = display.capture_before_after_kws(block).sort
expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
def sit
end
def bark
Expand All @@ -60,7 +60,7 @@ def eat
end

it "handles ambiguous end" do
source = <<~'EOM'
source = <<~EOM
def call # 0
print "lol" # 1
end # one # 2
Expand All @@ -79,7 +79,7 @@ def call # 0

lines = lines.sort.map(&:original)

expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
def call # 0
end # one # 2
end # two # 3
Expand All @@ -106,15 +106,15 @@ def call # 0
lines = display.call

lines = lines.sort.map(&:original)
expect(lines.join).to include(<<~'EOM'.indent(2))
expect(lines.join).to include(<<~EOM.indent(2))
class Lookups
def format_requires
end
EOM
end

it "shows ends of captured block" do
source = <<~'EOM'
source = <<~EOM
class Dog
def bark
puts "woof"
Expand All @@ -132,15 +132,15 @@ def bark
code_lines: code_lines
)
lines = display.call.sort.map(&:original)
expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
class Dog
def bark
end
EOM
end

it "captures surrounding context on falling indent" do
source = <<~'EOM'
source = <<~EOM
class Blerg
end

Expand All @@ -164,7 +164,7 @@ class Zerg
code_lines: code_lines
)
lines = display.call.sort.map(&:original)
expect(lines.join).to eq(<<~'EOM')
expect(lines.join).to eq(<<~EOM)
class OH
def hello
it "foo" do
Expand All @@ -174,7 +174,7 @@ def hello
end

it "captures surrounding context on same indent" do
source = <<~'EOM'
source = <<~EOM
class Blerg
end
class OH
Expand All @@ -200,7 +200,7 @@ class Zerg

code_lines = CleanDocument.new(source: source).call.lines
block = CodeBlock.new(lines: code_lines[7..10])
expect(block.to_s).to eq(<<~'EOM'.indent(2))
expect(block.to_s).to eq(<<~EOM.indent(2))
def lol
end

Expand All @@ -217,7 +217,7 @@ def lol
lines: lines
).call

expect(out).to eq(<<~'EOM'.indent(2))
expect(out).to eq(<<~EOM.indent(2))
3 class OH
8 def lol
9 end
Expand Down
Loading