diff --git a/lib/prism/node_find.rb b/lib/prism/node_find.rb index 46dd598c05..697ee430e8 100644 --- a/lib/prism/node_find.rb +++ b/lib/prism/node_find.rb @@ -15,7 +15,6 @@ module NodeFind # :nodoc: # Find the node for the given callable or backtrace location. #-- #: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable, bool rubyvm) -> Node? - #++ def self.find(callable, rubyvm) case callable when Proc @@ -50,7 +49,6 @@ class Find # Parse the given file path, returning a ParseResult or nil. #-- #: (String? file) -> ParseResult? - def parse_file(file) return unless file && File.readable?(file) result = Prism.parse_file(file) @@ -64,7 +62,6 @@ class RubyVMCallableFind < Find # Find the node for the given callable using the ISeq node_id. #-- #: (Method | UnboundMethod | Proc callable) -> Node? - def find(callable) return unless (source_location = callable.source_location) return unless (result = parse_file(source_location[0])) @@ -83,7 +80,6 @@ class RubyVMBacktraceLocationFind < Find # Find the node for the given backtrace location using node_id. #-- #: (Thread::Backtrace::Location location) -> Node? - def find(location) file = location.absolute_path || location.path return unless (result = parse_file(file)) @@ -101,7 +97,6 @@ class LineMethodFind < Find # Find the node for the given method by matching on name and line. #-- #: (Method | UnboundMethod callable) -> Node? - def find(callable) return unless (source_location = callable.source_location) return unless (result = parse_file(source_location[0])) @@ -128,7 +123,6 @@ class LineLambdaFind < Find # Find the node for the given lambda by matching on line. #-- #: (Proc callable) -> Node? - def find(callable) return unless (source_location = callable.source_location) return unless (result = parse_file(source_location[0])) @@ -154,7 +148,6 @@ class LineProcFind < Find # Find the node for the given proc by matching on line. #-- #: (Proc callable) -> Node? - def find(callable) return unless (source_location = callable.source_location) return unless (result = parse_file(source_location[0])) @@ -180,7 +173,6 @@ class LineBacktraceLocationFind < Find # Find the node for the given backtrace location by matching on line. #-- #: (Thread::Backtrace::Location location) -> Node? - def find(location) file = location.absolute_path || location.path return unless (result = parse_file(file)) diff --git a/rbi/generated/prism/node_find.rbi b/rbi/generated/prism/node_find.rbi index 9374a496c1..17afe9cc40 100644 --- a/rbi/generated/prism/node_find.rbi +++ b/rbi/generated/prism/node_find.rbi @@ -15,6 +15,7 @@ module Prism # Base class that handles parsing a file. class Find + # Parse the given file path, returning a ParseResult or nil. sig { params(file: ::T.nilable(String)).returns(::T.nilable(ParseResult)) } private def parse_file(file); end end @@ -22,6 +23,7 @@ module Prism # Finds the AST node for a Method, UnboundMethod, or Proc using the node_id # from the instruction sequence. class RubyVMCallableFind < Find + # Find the node for the given callable using the ISeq node_id. sig { params(callable: ::T.any(Method, UnboundMethod, Proc)).returns(::T.nilable(Node)) } def find(callable); end end @@ -29,6 +31,7 @@ module Prism # Finds the AST node for a Thread::Backtrace::Location using the node_id # from the backtrace location. class RubyVMBacktraceLocationFind < Find + # Find the node for the given backtrace location using node_id. sig { params(location: Thread::Backtrace::Location).returns(::T.nilable(Node)) } def find(location); end end @@ -36,6 +39,7 @@ module Prism # Finds the AST node for a Method or UnboundMethod using best-effort line # matching. Used on non-CRuby implementations. class LineMethodFind < Find + # Find the node for the given method by matching on name and line. sig { params(callable: ::T.any(Method, UnboundMethod)).returns(::T.nilable(Node)) } def find(callable); end end @@ -43,6 +47,7 @@ module Prism # Finds the AST node for a lambda using best-effort line matching. Used # on non-CRuby implementations. class LineLambdaFind < Find + # Find the node for the given lambda by matching on line. sig { params(callable: Proc).returns(::T.nilable(Node)) } def find(callable); end end @@ -50,6 +55,7 @@ module Prism # Finds the AST node for a non-lambda Proc using best-effort line # matching. Used on non-CRuby implementations. class LineProcFind < Find + # Find the node for the given proc by matching on line. sig { params(callable: Proc).returns(::T.nilable(Node)) } def find(callable); end end @@ -57,6 +63,7 @@ module Prism # Finds the AST node for a Thread::Backtrace::Location using best-effort # line matching. Used on non-CRuby implementations. class LineBacktraceLocationFind < Find + # Find the node for the given backtrace location by matching on line. sig { params(location: Thread::Backtrace::Location).returns(::T.nilable(Node)) } def find(location); end end diff --git a/sig/generated/prism/node_find.rbs b/sig/generated/prism/node_find.rbs index 3f8e4459d7..9924ff1452 100644 --- a/sig/generated/prism/node_find.rbs +++ b/sig/generated/prism/node_find.rbs @@ -18,6 +18,7 @@ module Prism class Find private + # Parse the given file path, returning a ParseResult or nil. # -- # : (String? file) -> ParseResult? def parse_file: (String? file) -> ParseResult? @@ -26,6 +27,7 @@ module Prism # Finds the AST node for a Method, UnboundMethod, or Proc using the node_id # from the instruction sequence. class RubyVMCallableFind < Find + # Find the node for the given callable using the ISeq node_id. # -- # : (Method | UnboundMethod | Proc callable) -> Node? def find: (Method | UnboundMethod | Proc callable) -> Node? @@ -34,6 +36,7 @@ module Prism # Finds the AST node for a Thread::Backtrace::Location using the node_id # from the backtrace location. class RubyVMBacktraceLocationFind < Find + # Find the node for the given backtrace location using node_id. # -- # : (Thread::Backtrace::Location location) -> Node? def find: (Thread::Backtrace::Location location) -> Node? @@ -42,6 +45,7 @@ module Prism # Finds the AST node for a Method or UnboundMethod using best-effort line # matching. Used on non-CRuby implementations. class LineMethodFind < Find + # Find the node for the given method by matching on name and line. # -- # : (Method | UnboundMethod callable) -> Node? def find: (Method | UnboundMethod callable) -> Node? @@ -50,6 +54,7 @@ module Prism # Finds the AST node for a lambda using best-effort line matching. Used # on non-CRuby implementations. class LineLambdaFind < Find + # Find the node for the given lambda by matching on line. # -- # : (Proc callable) -> Node? def find: (Proc callable) -> Node? @@ -58,6 +63,7 @@ module Prism # Finds the AST node for a non-lambda Proc using best-effort line # matching. Used on non-CRuby implementations. class LineProcFind < Find + # Find the node for the given proc by matching on line. # -- # : (Proc callable) -> Node? def find: (Proc callable) -> Node? @@ -66,6 +72,7 @@ module Prism # Finds the AST node for a Thread::Backtrace::Location using best-effort # line matching. Used on non-CRuby implementations. class LineBacktraceLocationFind < Find + # Find the node for the given backtrace location by matching on line. # -- # : (Thread::Backtrace::Location location) -> Node? def find: (Thread::Backtrace::Location location) -> Node?