Class: FFI::Clang::CodeCompletion::Result
- Inherits:
-
Object
- Object
- FFI::Clang::CodeCompletion::Result
- Defined in:
- lib/ffi/clang/code_completion.rb
Overview
Represents a single code completion result.
Instance Method Summary collapse
-
#fix_its ⇒ Object
Get all fix-its for this completion result.
-
#initialize(result, owner = nil, index = nil) ⇒ Result
constructor
Initialize a completion result.
-
#inspect ⇒ Object
Get a string representation of this result.
-
#kind ⇒ Object
Get the kind of completion.
-
#num_fix_its ⇒ Object
Get the number of fix-its required before this completion can be applied.
-
#string ⇒ Object
Get the completion string.
Constructor Details
#initialize(result, owner = nil, index = nil) ⇒ Result
Initialize a completion result.
151 152 153 154 155 |
# File 'lib/ffi/clang/code_completion.rb', line 151 def initialize(result, owner = nil, index = nil) @result = result @owner = owner @index = index end |
Instance Method Details
#fix_its ⇒ Object
Get all fix-its for this completion result.
179 180 181 182 183 184 185 186 |
# File 'lib/ffi/clang/code_completion.rb', line 179 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 |
#inspect ⇒ Object
Get a string representation of this result.
190 191 192 |
# File 'lib/ffi/clang/code_completion.rb', line 190 def inspect "<#{kind.inspect} = #{string.inspect}>" end |
#kind ⇒ Object
Get the kind of completion.
159 160 161 |
# File 'lib/ffi/clang/code_completion.rb', line 159 def kind @result[:kind] end |
#num_fix_its ⇒ Object
Get the number of fix-its required before this completion can be applied.
171 172 173 174 175 |
# File 'lib/ffi/clang/code_completion.rb', line 171 def num_fix_its return 0 unless @owner Lib.get_completion_num_fix_its(@owner.code_complete_results, @index) end |
#string ⇒ Object
Get the completion string.
165 166 167 |
# File 'lib/ffi/clang/code_completion.rb', line 165 def string CodeCompletion::String.new @result[:string] end |