FFI::ClangSourceFFIClangCodeCompletionString

class String

Represents a code completion string with chunks.

Definitions

def initialize(ptr)

Initialize a completion string.

Signature

parameter ptr FFI::Pointer

The completion string pointer.

Implementation

def initialize(ptr)
	@pointer = ptr
end

def chunk_kind(i)

Get the kind of a chunk.

Signature

parameter i Integer

The chunk index.

returns Symbol

The chunk kind.

Implementation

def chunk_kind(i)
	Lib.get_completion_chunk_kind(@pointer, i)
end

def chunk_text(i)

Get the text of a chunk.

Signature

parameter i Integer

The chunk index.

returns String

The chunk text.

Implementation

def chunk_text(i)
	Lib.extract_string Lib.get_completion_text(@pointer, i)
end

def chunk_completion(i)

Get the completion string of a chunk.

Signature

parameter i Integer

The chunk index.

returns CodeCompletion::String

The chunk's completion string.

Implementation

def chunk_completion(i)
	CodeCompletion::String.new Lib.get_completion_chunk_completion_string(@pointer, i)
end

def num_chunks

Get the number of chunks.

Signature

returns Integer

The number of chunks.

Implementation

def num_chunks
	Lib.get_num_completion_chunks(@pointer)
end

def chunks

Get all chunks as an array of hashes.

Signature

returns Array(Hash)

Array of chunk hashes with :kind, :text, and :completion keys.

Implementation

def chunks
	num_chunks.times.map {|i|
		{ kind: chunk_kind(i), text: chunk_text(i), completion: chunk_completion(i) }
	}
end

def priority

Get the priority of this completion.

Signature

returns Integer

The completion priority.

Implementation

def priority
	Lib.get_completion_priority(@pointer)
end

def availability

Get the availability of this completion.

Signature

returns Symbol

The completion availability.

Implementation

def availability
	Lib.get_completion_availability(@pointer)
end

def num_annotations

Get the number of annotations.

Signature

returns Integer

The number of annotations.

Implementation

def num_annotations
	Lib.get_completion_num_annotations(@pointer)
end

def annotation(i)

Get an annotation by index.

Signature

parameter i Integer

The annotation index.

returns String

The annotation text.

Implementation

def annotation(i)
	Lib.extract_string Lib.get_completion_annotation(@pointer, i)
end

def annotations

Get all annotations.

Signature

returns Array(String)

Array of annotation strings.

Implementation

def annotations
	num_annotations.times.map {|i|
		Lib.extract_string Lib.get_completion_annotation(@pointer, i)
	}
end

def parent

Get the parent context.

Signature

returns String

The parent context.

Implementation

def parent
	Lib.extract_string Lib.get_completion_parent(@pointer, nil)
end

def comment

Get the brief comment.

Signature

returns String

The brief comment.

Implementation

def comment
	Lib.extract_string Lib.get_completion_brief_comment(@pointer)
end

def inspect

Get a string representation of this completion string.

Signature

returns String

The chunks as a string.

Implementation

def inspect
	chunks.inspect
end