Class: FFI::Clang::CodeCompletion::Results

Inherits:
AutoPointer
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi/clang/code_completion.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code_complete_results, translation_unit) ⇒ Results

Returns a new instance of Results.



23
24
25
26
27
28
# File 'lib/ffi/clang/code_completion.rb', line 23

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

#resultsObject (readonly)

Returns the value of attribute results.



21
22
23
# File 'lib/ffi/clang/code_completion.rb', line 21

def results
  @results
end

#sizeObject (readonly)

Returns the value of attribute size.



20
21
22
# File 'lib/ffi/clang/code_completion.rb', line 20

def size
  @size
end

Class Method Details

.release(pointer) ⇒ Object



30
31
32
33
# File 'lib/ffi/clang/code_completion.rb', line 30

def self.release(pointer)
      results = Lib::CXCodeCompleteResults.new(pointer)
	Lib.dispose_code_complete_results(results)
end

Instance Method Details

#container_kindObject



63
64
65
66
# File 'lib/ffi/clang/code_completion.rb', line 63

def container_kind
	is_incomplete = MemoryPointer.new :uint
	Lib.get_code_complete_get_container_kind(@code_complete_results, is_incomplete)
end

#container_usrObject



59
60
61
# File 'lib/ffi/clang/code_completion.rb', line 59

def container_usr
	Lib.extract_string Lib.get_code_complete_get_container_usr(@code_complete_results)
end

#contextsObject



55
56
57
# File 'lib/ffi/clang/code_completion.rb', line 55

def contexts
	Lib.opts_from Lib::CompletionContext, Lib.get_code_complete_get_contexts(@code_complete_results)
end

#diagnostic(i) ⇒ Object



45
46
47
# File 'lib/ffi/clang/code_completion.rb', line 45

def diagnostic(i)
	Diagnostic.new(@translation_unit, Lib.get_code_complete_get_diagnostic(@code_complete_results, i))
end

#diagnosticsObject



49
50
51
52
53
# File 'lib/ffi/clang/code_completion.rb', line 49

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



35
36
37
38
39
# File 'lib/ffi/clang/code_completion.rb', line 35

def each(&block)
	@results.each do |token|
		block.call(token)
	end
end

#incomplete?Boolean

Returns:

  • (Boolean)


68
69
70
71
72
# File 'lib/ffi/clang/code_completion.rb', line 68

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

#inspectObject



83
84
85
# File 'lib/ffi/clang/code_completion.rb', line 83

def inspect
	@results.inspect
end

#num_diagnosticsObject



41
42
43
# File 'lib/ffi/clang/code_completion.rb', line 41

def num_diagnostics
	Lib.get_code_complete_get_num_diagnostics(@code_complete_results)
end

#objc_selectorObject



74
75
76
# File 'lib/ffi/clang/code_completion.rb', line 74

def objc_selector
	Lib.extract_string Lib.get_code_complete_get_objc_selector(@code_complete_results)
end

#sort!Object



78
79
80
81
# File 'lib/ffi/clang/code_completion.rb', line 78

def sort!
	Lib.sort_code_completion_results(@code_complete_results[:results], @code_complete_results[:num])
	initialize_results
end