Class: FFI::Clang::CodeCompletion::Results
- Inherits:
-
AutoPointer
- Object
- AutoPointer
- FFI::Clang::CodeCompletion::Results
- Includes:
- Enumerable
- Defined in:
- lib/ffi/clang/code_completion.rb
Overview
Represents code completion results.
Instance Attribute Summary collapse
- #code_complete_results ⇒ Object readonly
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
-
.release(pointer) ⇒ Object
Release the completion results pointer.
Instance Method Summary collapse
-
#container_kind ⇒ Object
Get the kind of the container.
-
#container_usr ⇒ Object
Get the USR of the container.
-
#contexts ⇒ Object
Get the completion contexts.
-
#diagnostic(i) ⇒ Object
Get a diagnostic by index.
-
#diagnostics ⇒ Object
Get all diagnostics.
-
#each(&block) ⇒ Object
Iterate over each completion result.
-
#incomplete? ⇒ Boolean
Check if the results are incomplete.
-
#initialize(code_complete_results, translation_unit) ⇒ Results
constructor
Initialize code completion results.
-
#inspect ⇒ Object
Get a string representation of the results.
-
#num_diagnostics ⇒ Object
Get the number of diagnostics.
-
#objc_selector ⇒ Object
Get the Objective-C selector.
-
#sort! ⇒ Object
Sort the completion results in place.
Constructor Details
#initialize(code_complete_results, translation_unit) ⇒ Results
Initialize code completion results.
40 41 42 43 44 45 |
# File 'lib/ffi/clang/code_completion.rb', line 40 def initialize(code_complete_results, translation_unit) super code_complete_results.pointer @translation_unit = translation_unit @code_complete_results = code_complete_results initialize_results end |
Instance Attribute Details
#code_complete_results ⇒ Object (readonly)
35 36 37 |
# File 'lib/ffi/clang/code_completion.rb', line 35 def code_complete_results @code_complete_results end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
30 31 32 |
# File 'lib/ffi/clang/code_completion.rb', line 30 def results @results end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
26 27 28 |
# File 'lib/ffi/clang/code_completion.rb', line 26 def size @size end |
Class Method Details
.release(pointer) ⇒ Object
Release the completion results pointer.
49 50 51 52 |
# File 'lib/ffi/clang/code_completion.rb', line 49 def self.release(pointer) results = Lib::CXCodeCompleteResults.new(pointer) Lib.dispose_code_complete_results(results) end |
Instance Method Details
#container_kind ⇒ Object
Get the kind of the container.
99 100 101 102 |
# File 'lib/ffi/clang/code_completion.rb', line 99 def container_kind is_incomplete = MemoryPointer.new :uint Lib.get_code_complete_get_container_kind(@code_complete_results, is_incomplete) end |
#container_usr ⇒ Object
Get the USR of the container.
93 94 95 |
# File 'lib/ffi/clang/code_completion.rb', line 93 def container_usr Lib.extract_string Lib.get_code_complete_get_container_usr(@code_complete_results) end |
#contexts ⇒ Object
Get the completion contexts.
87 88 89 |
# File 'lib/ffi/clang/code_completion.rb', line 87 def contexts Lib.opts_from Lib::CompletionContext, Lib.get_code_complete_get_contexts(@code_complete_results) end |
#diagnostic(i) ⇒ Object
Get a diagnostic by index.
73 74 75 |
# File 'lib/ffi/clang/code_completion.rb', line 73 def diagnostic(i) Diagnostic.new(@translation_unit, Lib.get_code_complete_get_diagnostic(@code_complete_results, i)) end |
#diagnostics ⇒ Object
Get all diagnostics.
79 80 81 82 83 |
# File 'lib/ffi/clang/code_completion.rb', line 79 def diagnostics num_diagnostics.times.map do |i| Diagnostic.new(@translation_unit, Lib.get_code_complete_get_diagnostic(@code_complete_results, i)) end end |
#each(&block) ⇒ Object
Iterate over each completion result.
58 59 60 61 62 |
# File 'lib/ffi/clang/code_completion.rb', line 58 def each(&block) return to_enum(__method__) unless block_given? @results.each(&block) end |
#incomplete? ⇒ Boolean
Check if the results are incomplete.
106 107 108 109 110 |
# File 'lib/ffi/clang/code_completion.rb', line 106 def incomplete? is_incomplete = MemoryPointer.new :uint Lib.get_code_complete_get_container_kind(@code_complete_results, is_incomplete) is_incomplete.read_uint != 0 end |
#inspect ⇒ Object
Get a string representation of the results.
126 127 128 |
# File 'lib/ffi/clang/code_completion.rb', line 126 def inspect @results.inspect end |
#num_diagnostics ⇒ Object
Get the number of diagnostics.
66 67 68 |
# File 'lib/ffi/clang/code_completion.rb', line 66 def num_diagnostics Lib.get_code_complete_get_num_diagnostics(@code_complete_results) end |
#objc_selector ⇒ Object
Get the Objective-C selector.
114 115 116 |
# File 'lib/ffi/clang/code_completion.rb', line 114 def objc_selector Lib.extract_string Lib.get_code_complete_get_objc_selector(@code_complete_results) end |
#sort! ⇒ Object
Sort the completion results in place.
119 120 121 122 |
# File 'lib/ffi/clang/code_completion.rb', line 119 def sort! Lib.sort_code_completion_results(@code_complete_results[:results], @code_complete_results[:num]) initialize_results end |