class Declaration
Represents a declaration event reported during indexing.
Definitions
attr_reader :cursor, :location, :entity, :semantic_container, :lexical_container, :declaration_container, :flags
Signature
-
attribute
r cursor
-
returns
Cursor The declaration cursor.
-
returns
-
attribute
r location
-
returns
ExpansionLocation The declaration location.
-
returns
-
attribute
r entity
-
returns
Entity | Nil The declared entity.
-
returns
-
attribute
r semantic_container
-
returns
Container | Nil The semantic container.
-
returns
-
attribute
r lexical_container
-
returns
Container | Nil The lexical container.
-
returns
-
attribute
r declaration_container
-
returns
Container | Nil The declaration container if this declaration is also a container.
-
returns
-
attribute
r flags
-
returns
Array(Symbol) The declaration flags.
-
returns
def initialize(info, translation_unit)
Build a declaration wrapper from low-level info.
Signature
-
parameter
infoLib::CXIdxDeclInfo The low-level declaration info.
-
parameter
translation_unitTranslationUnit | Nil The translation unit for derived wrappers.
Implementation
def initialize(info, translation_unit)
@cursor = Cursor.new(info[:cursor], translation_unit)
@location = ExpansionLocation.new(Lib.index_loc_get_source_location(info[:loc]))
@entity = self.class.entity_from_pointer(info[:entity_info], translation_unit)
@semantic_container = self.class.container_from_pointer(info[:semantic_container], translation_unit)
@lexical_container = self.class.container_from_pointer(info[:lexical_container], translation_unit)
@declaration_container = self.class.container_from_pointer(info[:decl_as_container], translation_unit)
@redeclaration = info[:is_redeclaration] != 0
@definition = info[:is_definition] != 0
@container = info[:is_container] != 0
@implicit = info[:is_implicit] != 0
@flags = Lib.opts_from(Lib::IdxDeclInfoFlags, info[:flags])
end
def redeclaration?
Check if this declaration is a redeclaration.
Signature
-
returns
Boolean True if this is a redeclaration.
Implementation
def redeclaration?
@redeclaration
end
def definition?
Check if this declaration is a definition.
Signature
-
returns
Boolean True if this declaration is a definition.
Implementation
def definition?
@definition
end
def container?
Check if this declaration is itself a container.
Signature
-
returns
Boolean True if this declaration introduces a container.
Implementation
def container?
@container
end
def implicit?
Check if this declaration was implicit.
Signature
-
returns
Boolean True if the declaration was implicit.
Implementation
def implicit?
@implicit
end
def self.entity_from_pointer(pointer, translation_unit)
- private
Signature
- private
Implementation
def self.entity_from_pointer(pointer, translation_unit)
return nil if pointer.null?
Entity.new(Lib::CXIdxEntityInfo.new(pointer), translation_unit)
end
def self.container_from_pointer(pointer, translation_unit)
- private
Signature
- private
Implementation
def self.container_from_pointer(pointer, translation_unit)
return nil if pointer.null?
Container.new(Lib::CXIdxContainerInfo.new(pointer), translation_unit)
end