summaryrefslogtreecommitdiff
path: root/lib/syntax_suggest
diff options
context:
space:
mode:
authorschneems <richard.schneeman+foo@gmail.com>2022-12-01 13:27:59 -0600
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-12-02 09:36:40 +0900
commit85a1c67a6550641e5de96cdbee1713be3f1e8882 (patch)
tree9f03d5a4cf1f35e64a2285f5590b060cabd9271d /lib/syntax_suggest
parent652e2d8f5d0e0210a4ef3cb541504433dbae57b3 (diff)
[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). https://github.com/ruby/syntax_suggest/commit/9862032465
Diffstat (limited to 'lib/syntax_suggest')
-rw-r--r--lib/syntax_suggest/core_ext.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/syntax_suggest/core_ext.rb b/lib/syntax_suggest/core_ext.rb
index 616a6ed983..59e13a149a 100644
--- a/lib/syntax_suggest/core_ext.rb
+++ b/lib/syntax_suggest/core_ext.rb
@@ -25,7 +25,16 @@ if SyntaxError.method_defined?(:detailed_message)
require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
message = super
- file = path
+
+ file = if respond_to?(:path)
+ path
+ elsif highlight
+ # This branch will be removed when the next Ruby 3.2 preview is released with
+ # support for SyntaxError#path
+ SyntaxSuggest::PathnameFromMessage.new(super(highlight: false, **kwargs)).call.name
+ else
+ SyntaxSuggest::PathnameFromMessage.new(message).call.name
+ end
if file
file = Pathname.new(file)