Class: FFI::Clang::Diagnostic
- Inherits:
-
AutoPointer
- Object
- AutoPointer
- FFI::Clang::Diagnostic
- Defined in:
- lib/ffi/clang/diagnostic.rb
Class Method Summary collapse
Instance Method Summary collapse
- #category ⇒ Object
- #category_id ⇒ Object
- #children ⇒ Object
- #disable_option ⇒ Object
- #enable_option ⇒ Object
- #fixits ⇒ Object
- #format(opts = {}) ⇒ Object
-
#initialize(translation_unit, pointer) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #inspect ⇒ Object
- #location ⇒ Object
- #ranges ⇒ Object
- #severity ⇒ Object
- #spelling ⇒ Object
Constructor Details
#initialize(translation_unit, pointer) ⇒ Diagnostic
Returns a new instance of Diagnostic.
21 22 23 24 25 |
# File 'lib/ffi/clang/diagnostic.rb', line 21 def initialize(translation_unit, pointer) super pointer @translation_unit = translation_unit end |
Class Method Details
.default_display_opts ⇒ Object
17 18 19 |
# File 'lib/ffi/clang/diagnostic.rb', line 17 def self.default_display_opts Lib.opts_from(Lib::DiagnosticDisplayOptions, Lib.) end |
.release(pointer) ⇒ Object
27 28 29 |
# File 'lib/ffi/clang/diagnostic.rb', line 27 def self.release(pointer) Lib.dispose_diagnostic(pointer) end |
Instance Method Details
#category ⇒ Object
82 83 84 |
# File 'lib/ffi/clang/diagnostic.rb', line 82 def category Lib.extract_string Lib.get_diagnostic_category_text(self) end |
#category_id ⇒ Object
86 87 88 |
# File 'lib/ffi/clang/diagnostic.rb', line 86 def category_id Lib.get_diagnostic_category(self) end |
#children ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/ffi/clang/diagnostic.rb', line 64 def children diagnostic_set = Lib.get_child_diagnostics(self) num_diagnostics = Lib.get_num_diagnostics_in_set(diagnostic_set) num_diagnostics.times.map { |i| Diagnostic.new(@translation_unit, Lib.get_diagnostic_in_set(diagnostic_set, i)) } end |
#disable_option ⇒ Object
76 77 78 79 80 |
# File 'lib/ffi/clang/diagnostic.rb', line 76 def disable_option ptr = MemoryPointer.new Lib::CXString Lib.get_diagnostic_option(self, ptr) Lib.extract_string ptr end |
#enable_option ⇒ Object
72 73 74 |
# File 'lib/ffi/clang/diagnostic.rb', line 72 def enable_option Lib.extract_string Lib.get_diagnostic_option(self, nil) end |
#fixits ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/ffi/clang/diagnostic.rb', line 49 def fixits n = Lib.get_diagnostic_num_fix_its(self) n.times.map { |i| ptr = MemoryPointer.new Lib::CXSourceRange replace_text = Lib.extract_string(Lib.get_diagnostic_fix_it(self, i, ptr)) {text: replace_text, range: SourceRange.new(ptr)} } end |
#format(opts = {}) ⇒ Object
31 32 33 34 |
# File 'lib/ffi/clang/diagnostic.rb', line 31 def format(opts = {}) cxstring = Lib.format_diagnostic(self, display_opts(opts)) Lib.extract_string cxstring end |
#inspect ⇒ Object
90 91 92 |
# File 'lib/ffi/clang/diagnostic.rb', line 90 def inspect "#{self.location}: #{self.format}" end |
#location ⇒ Object
44 45 46 47 |
# File 'lib/ffi/clang/diagnostic.rb', line 44 def location sl = Lib.get_diagnostic_location(self) ExpansionLocation.new sl end |
#ranges ⇒ Object
58 59 60 61 62 |
# File 'lib/ffi/clang/diagnostic.rb', line 58 def ranges n = Lib.get_diagnostic_num_ranges(self) n.times.map {|i| SourceRange.new Lib.get_diagnostic_range(self, i)} end |
#severity ⇒ Object
36 37 38 |
# File 'lib/ffi/clang/diagnostic.rb', line 36 def severity Lib.get_diagnostic_severity self end |