Commit graph

8 commits

Author SHA1 Message Date
Schneems
226cfda306 [ruby/syntax_suggest] Fix missing line break due to puts logic
In #225 it was reported that the output looks incorrect:

```
$ cat /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
def x.y.z
end
$ ruby /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
/tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb: --> /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
expected a delimiter to close the parametersunexpected '.', ignoring it
> 1  def x.y.z
> 2  end
```

Specifically:

```
expected a delimiter to close the parametersunexpected '.', ignoring it
```

However this does not show up when executing the debug executable:

```
$ bin/bundle exec exe/syntax_suggest /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
--> /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb

expected a delimiter to close the parameters
unexpected '.', ignoring it

> 1  def x.y.z
> 2  end
```

This is because `exe/syntax_suggest` uses STDOUT.puts while calling `ruby` with the filename uses a fake IO object represented by MiniStringIO. This class was incorrectly not adding a newline to the end of the print.

The fix was to move the class to it's own file where it can be tested and then fix the behavior.

close https://github.com/ruby/syntax_suggest/pull/225

d2ecd94a3b

Co-authored-by: Andy Yong <andyywz@gmail.com>
2024-11-15 01:31:26 +00:00
Nobuyoshi Nakada
ae71bbbc44 [ruby/syntax_suggest] [DOC] Fix method name
08a9afb64f
2023-06-28 16:34:53 +09:00
Yusuke Endoh
d511e6960f [ruby/syntax_suggest] The annotation must end with a new line
syntax_suggest did not work great when there is no new line at the end
of the input file.

Input:
```
def foo
end
end # No newline at end of file
```

Previous output:
```
$ ruby test.rb
test.rb: --> test.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
> 1  def foo
> 2  end
> 3  end # No newline at end of filetest.rb:3: syntax error, unexpected `end' (SyntaxError)
end # No newline at end of file
^~~
```

Note that "test.rb:3: ..." is appended to the last line of the
annotation.

This change makes sure that the annotation ends with a new line.

New output:
```
$ ruby test.rb
test.rb: --> test.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
> 1  def foo
> 2  end
> 3  end # No newline at end of file
test.rb:3: syntax error, unexpected `end' (SyntaxError)
end # No newline at end of file
^~~
```

db4cf9147d
2023-04-06 15:45:30 +09:00
Nobuyoshi Nakada
06e30df408 [ruby/syntax_suggest] Hide internal document and detail of Kernel monkey patching
https://bugs.ruby-lang.org/issues/19285

25ca82f8f9
2023-01-27 11:31:10 +09:00
Hiroshi SHIBATA
0677bbe3ff Merge syntax_suggest master
Pick from daee74dcb0
2022-12-09 16:36:22 +09:00
schneems
85a1c67a65 [ruby/syntax_suggest] Add temp support for 3.2.0-preview{3,2,1}
This SyntaxError#path feature only exists in Ruby HEAD. Until it is released in a preview I want to continue to support existing releases of 3.2.0 (and also so CI will continue to work, as it still uses a preview version to execute tests).

9862032465
2022-12-02 09:36:40 +09:00
Hiroshi SHIBATA
652e2d8f5d [ruby/syntax_suggest] No longer need PathnameFromMessage with SyntaxError#path.
https://bugs.ruby-lang.org/issues/19138

  Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

8e1e7b3298
2022-12-02 09:36:39 +09:00
schneems
490af8dbdb Sync SyntaxSuggest
```
$ tool/sync_default_gems.rb syntax_suggest
```
2022-08-19 10:02:24 +09:00