class Result
Represents a single code completion result.
Definitions
def initialize(result, owner = nil, index = nil)
Initialize a completion result.
Signature
-
parameter
resultLib::CXCompletionResult The completion result structure.
-
parameter
ownerResults | Nil The owning Results object (prevents GC of the parent allocation).
-
parameter
indexInteger | Nil The index of this result in the parent.
Implementation
def initialize(result, owner = nil, index = nil)
@result = result
@owner = owner
@index = index
end
def kind
Get the kind of completion.
Signature
-
returns
Symbol The completion kind.
Implementation
def kind
@result[:kind]
end
def string
Get the completion string.
Signature
-
returns
CodeCompletion::String The completion string.
Implementation
def string
CodeCompletion::String.new @result[:string]
end
def num_fix_its
Get the number of fix-its required before this completion can be applied.
Signature
-
returns
Integer The number of fix-its.
Implementation
def num_fix_its
return 0 unless @owner
Lib.get_completion_num_fix_its(@owner.code_complete_results, @index)
end
def fix_its
Get all fix-its for this completion result.
Signature
-
returns
Array(FixIt) The fix-its.
Implementation
def fix_its
num_fix_its.times.map do |i|
range_ptr = MemoryPointer.new(Lib::CXSourceRange, 1)
text = Lib.extract_string(Lib.get_completion_fix_it(@owner.code_complete_results, @index, i, range_ptr))
range = SourceRange.new(Lib::CXSourceRange.new(range_ptr))
FixIt.new(text, range)
end
end
def inspect
Get a string representation of this result.
Signature
-
returns
String The result as a string.
Implementation
def inspect
"<#{kind.inspect} = #{string.inspect}>"
end