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
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
- #The array of completion results.(arrayofcompletionresults.) ⇒ Object readonly
- #The number of completion results.(numberofcompletionresults.) ⇒ Object readonly
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.
33 34 35 36 37 38 |
# File 'lib/ffi/clang/code_completion.rb', line 33 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
#results ⇒ Object (readonly)
Returns the value of attribute results.
28 29 30 |
# File 'lib/ffi/clang/code_completion.rb', line 28 def results @results end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
25 26 27 |
# File 'lib/ffi/clang/code_completion.rb', line 25 def size @size end |
#The array of completion results.(arrayofcompletionresults.) ⇒ Object (readonly)
28 |
# File 'lib/ffi/clang/code_completion.rb', line 28 attr_reader :results |
#The number of completion results.(numberofcompletionresults.) ⇒ Object (readonly)
25 |
# File 'lib/ffi/clang/code_completion.rb', line 25 attr_reader :size |
Class Method Details
.release(pointer) ⇒ Object
Release the completion results pointer.
42 43 44 45 |
# File 'lib/ffi/clang/code_completion.rb', line 42 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.
91 92 93 94 |
# File 'lib/ffi/clang/code_completion.rb', line 91 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.
85 86 87 |
# File 'lib/ffi/clang/code_completion.rb', line 85 def container_usr Lib.extract_string Lib.get_code_complete_get_container_usr(@code_complete_results) end |
#contexts ⇒ Object
Get the completion contexts.
79 80 81 |
# File 'lib/ffi/clang/code_completion.rb', line 79 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.
65 66 67 |
# File 'lib/ffi/clang/code_completion.rb', line 65 def diagnostic(i) Diagnostic.new(@translation_unit, Lib.get_code_complete_get_diagnostic(@code_complete_results, i)) end |
#diagnostics ⇒ Object
Get all diagnostics.
71 72 73 74 75 |
# File 'lib/ffi/clang/code_completion.rb', line 71 def diagnostics num_diagnostics.times.map {|i| Diagnostic.new(@translation_unit, Lib.get_code_complete_get_diagnostic(@code_complete_results, i)) } end |
#each(&block) ⇒ Object
Iterate over each completion result.
50 51 52 53 54 |
# File 'lib/ffi/clang/code_completion.rb', line 50 def each(&block) @results.each do |token| block.call(token) end end |
#incomplete? ⇒ Boolean
Check if the results are incomplete.
98 99 100 101 102 |
# File 'lib/ffi/clang/code_completion.rb', line 98 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.
118 119 120 |
# File 'lib/ffi/clang/code_completion.rb', line 118 def inspect @results.inspect end |
#num_diagnostics ⇒ Object
Get the number of diagnostics.
58 59 60 |
# File 'lib/ffi/clang/code_completion.rb', line 58 def num_diagnostics Lib.get_code_complete_get_num_diagnostics(@code_complete_results) end |
#objc_selector ⇒ Object
Get the Objective-C selector.
106 107 108 |
# File 'lib/ffi/clang/code_completion.rb', line 106 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.
111 112 113 114 |
# File 'lib/ffi/clang/code_completion.rb', line 111 def sort! Lib.sort_code_completion_results(@code_complete_results[:results], @code_complete_results[:num]) initialize_results end |