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

Result#type and Result#prefix #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions lib/repl_type_completor/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def initialize(analyze_result, binding, source_file)
@source_file = source_file
end

def type
@analyze_result[0]
end

def prefix
@analyze_result[1]
end

def completion_candidates
verbose, $VERBOSE = $VERBOSE, nil
candidates = case @analyze_result
Expand Down
2 changes: 2 additions & 0 deletions sig/repl_type_completor.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module ReplTypeCompletor
VERSION: String

class Result
def type: () -> Symbol
def prefix: () -> String
def completion_candidates: () -> Array[String]
def doc_namespace: (String) -> String?
end
Expand Down
3 changes: 3 additions & 0 deletions test/repl_type_completor/test_repl_type_completor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def test_method_block_sym
end

def test_symbol
result = ReplTypeCompletor.analyze(':symbol_prefix', binding: binding)
assert_equal :symbol, result.type
assert_equal 'symbol_prefix', result.prefix
prefix = ':test_com'
sym = :test_completion_symbol
assert_completion(prefix, include: sym.inspect.delete_prefix(prefix))
Expand Down