Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescue Exception, ignore warning in completion doc_namespace #777

Merged
merged 1 commit into from
Nov 22, 2023
Merged
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
12 changes: 9 additions & 3 deletions lib/irb/type_completion/completor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def inspect
end

def completion_candidates(preposing, target, _postposing, bind:)
@preposing = preposing
verbose, $VERBOSE = $VERBOSE, nil
@preposing = preposing
code = "#{preposing}#{target}"
@result = analyze code, bind
name, candidates = candidates_from_result(@result)
Expand All @@ -36,15 +36,15 @@ def completion_candidates(preposing, target, _postposing, bind:)
candidates.map(&:to_s).select { !_1.match?(all_symbols_pattern) && _1.start_with?(name) }.uniq.sort.map do
target + _1[name.size..]
end
rescue SyntaxError, StandardError => e
Completor.last_completion_error = e
rescue Exception => e
handle_error(e)
[]
ensure
$VERBOSE = verbose
end

def doc_namespace(preposing, matched, postposing, bind:)
verbose, $VERBOSE = $VERBOSE, nil
name = matched[/[a-zA-Z_0-9]*[!?=]?\z/]
method_doc = -> type do
type = type.types.find { _1.all_methods.include? name.to_sym }
Expand Down Expand Up @@ -102,6 +102,11 @@ def doc_namespace(preposing, matched, postposing, bind:)
end
else
end
rescue Exception => e
handle_error(e)
nil
ensure
$VERBOSE = verbose
end

def candidates_from_result(result)
Expand Down Expand Up @@ -229,6 +234,7 @@ def find_target(node, position)
end

def handle_error(e)
Completor.last_completion_error = e
end
end
end
Expand Down