FFI::ClangSourceFFIClangIndexActionIncludedFile

class IncludedFile

Represents an include directive encountered during indexing.

Definitions

attr_reader :filename, :file, :location

Signature

attribute r

filename

returns String

The file name as written in the include directive.

attribute r

file

returns File | Nil

The resolved included file.

attribute r

location

returns ExpansionLocation

The location of the include directive.

def initialize(info, translation_unit)

Build an include wrapper from a libclang include info pointer.

Signature

parameter info Lib::CXIdxIncludedFileInfo

The low-level include info.

parameter translation_unit TranslationUnit | Nil

The translation unit for derived wrappers.

Implementation

def initialize(info, translation_unit)
	@filename = Entity.string_from_pointer(info[:filename])
	@file = self.class.file_from_pointer(info[:file], translation_unit)
	@location = ExpansionLocation.new(Lib.index_loc_get_source_location(info[:hash_loc]))
	@import = info[:is_import] != 0
	@angled = info[:is_angled] != 0
	@module_import = info[:is_module_import] != 0
end

def import?

Check if the directive was an import.

Signature

returns Boolean

True if the directive was an import.

Implementation

def import?
	@import
end

def angled?

Check if the include used angle brackets.

Signature

returns Boolean

True if the include used angle brackets.

Implementation

def angled?
	@angled
end

def module_import?

Check if the include was converted into a module import by clang.

Signature

returns Boolean

True if the include became a module import.

Implementation

def module_import?
	@module_import
end

def self.file_from_pointer(pointer, translation_unit)

  • private

Signature

private

Implementation

def self.file_from_pointer(pointer, translation_unit)
	return nil if pointer.null?
	
	FFI::Clang::File.new(pointer, translation_unit)
end