desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'The category number for this diagnostic.'
| @property
def category_number(self):
| return conf.lib.clang_getDiagnosticCategory(self)
|
'The string name of the category for this diagnostic.'
| @property
def category_name(self):
| return conf.lib.clang_getDiagnosticCategoryName(self.category_number)
|
'The command-line option that enables this diagnostic.'
| @property
def option(self):
| return conf.lib.clang_getDiagnosticOption(self, None)
|
'The command-line option that disables this diagnostic.'
| @property
def disable_option(self):
| disable = _CXString()
conf.lib.clang_getDiagnosticOption(self, byref(disable))
return conf.lib.clang_getCString(disable)
|
'Helper method to return all tokens in an extent.
This functionality is needed multiple places in this module. We define
it here because it seems like a logical place.'
| @staticmethod
def get_tokens(tu, extent):
| tokens_memory = POINTER(Token)()
tokens_count = c_uint()
conf.lib.clang_tokenize(tu, extent, byref(tokens_memory), byref(tokens_count))
count = int(tokens_count.value)
if (count < 1):
return
tokens_array = cast(tokens_memory, POINTER((Token * count))).contents
token_group = TokenGrou... |
'Create a new TokenKind instance from a numeric value and a name.'
| def __init__(self, value, name):
| self.value = value
self.name = name
|
'Obtain a registered TokenKind instance from its value.'
| @staticmethod
def from_value(value):
| result = TokenKind._value_map.get(value, None)
if (result is None):
raise ValueError(('Unknown TokenKind: %d' % value))
return result
|
'Register a new TokenKind enumeration.
This should only be called at module load time by code within this
package.'
| @staticmethod
def register(value, name):
| if (value in TokenKind._value_map):
raise ValueError(('TokenKind already registered: %d' % value))
kind = TokenKind(value, name)
TokenKind._value_map[value] = kind
setattr(TokenKind, name, kind)
|
'Get the enumeration name of this cursor kind.'
| @property
def name(self):
| if (self._name_map is None):
self._name_map = {}
for (key, value) in CursorKind.__dict__.items():
if isinstance(value, CursorKind):
self._name_map[value] = key
return self._name_map[self]
|
'Return all CursorKind enumeration instances.'
| @staticmethod
def get_all_kinds():
| return [_f for _f in CursorKind._kinds if _f]
|
'Test if this is a declaration kind.'
| def is_declaration(self):
| return conf.lib.clang_isDeclaration(self)
|
'Test if this is a reference kind.'
| def is_reference(self):
| return conf.lib.clang_isReference(self)
|
'Test if this is an expression kind.'
| def is_expression(self):
| return conf.lib.clang_isExpression(self)
|
'Test if this is a statement kind.'
| def is_statement(self):
| return conf.lib.clang_isStatement(self)
|
'Test if this is an attribute kind.'
| def is_attribute(self):
| return conf.lib.clang_isAttribute(self)
|
'Test if this is an invalid kind.'
| def is_invalid(self):
| return conf.lib.clang_isInvalid(self)
|
'Test if this is a translation unit kind.'
| def is_translation_unit(self):
| return conf.lib.clang_isTranslationUnit(self)
|
'Test if this is a preprocessing kind.'
| def is_preprocessing(self):
| return conf.lib.clang_isPreprocessing(self)
|
'Test if this is an unexposed kind.'
| def is_unexposed(self):
| return conf.lib.clang_isUnexposed(self)
|
'Returns true if the declaration pointed at by the cursor is also a
definition of that entity.'
| def is_definition(self):
| return conf.lib.clang_isCursorDefinition(self)
|
'Returns True if the cursor refers to a C++ member function or member
function template that is declared \'static\'.'
| def is_static_method(self):
| return conf.lib.clang_CXXMethod_isStatic(self)
|
'If the cursor is a reference to a declaration or a declaration of
some entity, return a cursor that points to the definition of that
entity.'
| def get_definition(self):
| return conf.lib.clang_getCursorDefinition(self)
|
'Return the Unified Symbol Resultion (USR) for the entity referenced
by the given cursor (or None).
A Unified Symbol Resolution (USR) is a string that identifies a
particular entity (function, class, variable, etc.) within a
program. USRs can be compared across translation units to determine,
e.g., when references in o... | def get_usr(self):
| return conf.lib.clang_getCursorUSR(self)
|
'Return the kind of this cursor.'
| @property
def kind(self):
| return CursorKind.from_id(self._kind_id)
|
'Return the spelling of the entity pointed at by the cursor.'
| @property
def spelling(self):
| if (not self.kind.is_declaration()):
return None
if (not hasattr(self, '_spelling')):
self._spelling = conf.lib.clang_getCursorSpelling(self)
return self._spelling
|
'Return the display name for the entity referenced by this cursor.
The display name contains extra information that helps identify the cursor,
such as the parameters of a function or template or the arguments of a
class template specialization.'
| @property
def displayname(self):
| if (not hasattr(self, '_displayname')):
self._displayname = conf.lib.clang_getCursorDisplayName(self)
return self._displayname
|
'Return the source location (the starting character) of the entity
pointed at by the cursor.'
| @property
def location(self):
| if (not hasattr(self, '_loc')):
self._loc = conf.lib.clang_getCursorLocation(self)
return self._loc
|
'Return the source range (the range of text) occupied by the entity
pointed at by the cursor.'
| @property
def extent(self):
| if (not hasattr(self, '_extent')):
self._extent = conf.lib.clang_getCursorExtent(self)
return self._extent
|
'Retrieve the Type (if any) of the entity pointed at by the cursor.'
| @property
def type(self):
| if (not hasattr(self, '_type')):
self._type = conf.lib.clang_getCursorType(self)
return self._type
|
'Return the canonical Cursor corresponding to this Cursor.
The canonical cursor is the cursor which is representative for the
underlying entity. For example, if you have multiple forward
declarations for the same class, the canonical cursor for the forward
declarations will be identical.'
| @property
def canonical(self):
| if (not hasattr(self, '_canonical')):
self._canonical = conf.lib.clang_getCanonicalCursor(self)
return self._canonical
|
'Retrieve the Type of the result for this Cursor.'
| @property
def result_type(self):
| if (not hasattr(self, '_result_type')):
self._result_type = conf.lib.clang_getResultType(self.type)
return self._result_type
|
'Return the underlying type of a typedef declaration.
Returns a Type for the typedef this cursor is a declaration for. If
the current cursor is not a typedef, this raises.'
| @property
def underlying_typedef_type(self):
| if (not hasattr(self, '_underlying_type')):
assert self.kind.is_declaration()
self._underlying_type = conf.lib.clang_getTypedefDeclUnderlyingType(self)
return self._underlying_type
|
'Return the integer type of an enum declaration.
Returns a Type corresponding to an integer. If the cursor is not for an
enum, this raises.'
| @property
def enum_type(self):
| if (not hasattr(self, '_enum_type')):
assert (self.kind == CursorKind.ENUM_DECL)
self._enum_type = conf.lib.clang_getEnumDeclIntegerType(self)
return self._enum_type
|
'Return the value of an enum constant.'
| @property
def enum_value(self):
| if (not hasattr(self, '_enum_value')):
assert (self.kind == CursorKind.ENUM_CONSTANT_DECL)
underlying_type = self.type
if (underlying_type.kind == TypeKind.ENUM):
underlying_type = underlying_type.get_declaration().enum_type
if (underlying_type.kind in (TypeKind.CHAR_U, T... |
'Return the Objective-C type encoding as a str.'
| @property
def objc_type_encoding(self):
| if (not hasattr(self, '_objc_type_encoding')):
self._objc_type_encoding = conf.lib.clang_getDeclObjCTypeEncoding(self)
return self._objc_type_encoding
|
'Returns a hash of the cursor as an int.'
| @property
def hash(self):
| if (not hasattr(self, '_hash')):
self._hash = conf.lib.clang_hashCursor(self)
return self._hash
|
'Return the semantic parent for this cursor.'
| @property
def semantic_parent(self):
| if (not hasattr(self, '_semantic_parent')):
self._semantic_parent = conf.lib.clang_getCursorSemanticParent(self)
return self._semantic_parent
|
'Return the lexical parent for this cursor.'
| @property
def lexical_parent(self):
| if (not hasattr(self, '_lexical_parent')):
self._lexical_parent = conf.lib.clang_getCursorLexicalParent(self)
return self._lexical_parent
|
'Returns the TranslationUnit to which this Cursor belongs.'
| @property
def translation_unit(self):
| return self._tu
|
'For a cursor that is a reference, returns a cursor
representing the entity that it references.'
| @property
def referenced(self):
| if (not hasattr(self, '_referenced')):
self._referenced = conf.lib.clang_getCursorReferenced(self)
return self._referenced
|
'Return an iterator for accessing the arguments of this cursor.'
| def get_arguments(self):
| num_args = conf.lib.clang_Cursor_getNumArguments(self)
for i in range(0, num_args):
(yield conf.lib.clang_Cursor_getArgument(self, i))
|
'Return an iterator for accessing the children of this cursor.'
| def get_children(self):
| def visitor(child, parent, children):
assert (child != conf.lib.clang_getNullCursor())
child._tu = self._tu
children.append(child)
return 1
children = []
conf.lib.clang_visitChildren(self, callbacks['cursor_visit'](visitor), children)
return iter(children)
|
'Obtain Token instances formulating that compose this Cursor.
This is a generator for Token instances. It returns all tokens which
occupy the extent this cursor occupies.'
| def get_tokens(self):
| return TokenGroup.get_tokens(self._tu, self.extent)
|
'Get the enumeration name of this cursor kind.'
| @property
def name(self):
| if (self._name_map is None):
self._name_map = {}
for (key, value) in TypeKind.__dict__.items():
if isinstance(value, TypeKind):
self._name_map[value] = key
return self._name_map[self]
|
'Retrieve the spelling of this TypeKind.'
| @property
def spelling(self):
| return conf.lib.clang_getTypeKindSpelling(self.value)
|
'Return the kind of this type.'
| @property
def kind(self):
| return TypeKind.from_id(self._kind_id)
|
'Retrieve a container for the non-variadic arguments for this type.
The returned object is iterable and indexable. Each item in the
container is a Type instance.'
| def argument_types(self):
| class ArgumentsIterator(collections.Sequence, ):
def __init__(self, parent):
self.parent = parent
self.length = None
def __len__(self):
if (self.length is None):
self.length = conf.lib.clang_getNumArgTypes(self.parent)
return self.lengt... |
'Retrieve the Type of elements within this Type.
If accessed on a type that is not an array, complex, or vector type, an
exception will be raised.'
| @property
def element_type(self):
| result = conf.lib.clang_getElementType(self)
if (result.kind == TypeKind.INVALID):
raise Exception('Element type not available on this type.')
return result
|
'Retrieve the number of elements in this type.
Returns an int.
If the Type is not an array or vector, this raises.'
| @property
def element_count(self):
| result = conf.lib.clang_getNumElements(self)
if (result < 0):
raise Exception('Type does not have elements.')
return result
|
'The TranslationUnit to which this Type is associated.'
| @property
def translation_unit(self):
| return self._tu
|
'Return the canonical type for a Type.
Clang\'s type system explicitly models typedefs and all the
ways a specific type can be represented. The canonical type
is the underlying type with all the "sugar" removed. For
example, if \'T\' is a typedef for \'int\', the canonical type for
\'T\' would be \'int\'.'
| def get_canonical(self):
| return conf.lib.clang_getCanonicalType(self)
|
'Determine whether a Type has the "const" qualifier set.
This does not look through typedefs that may have added "const"
at a different level.'
| def is_const_qualified(self):
| return conf.lib.clang_isConstQualifiedType(self)
|
'Determine whether a Type has the "volatile" qualifier set.
This does not look through typedefs that may have added "volatile"
at a different level.'
| def is_volatile_qualified(self):
| return conf.lib.clang_isVolatileQualifiedType(self)
|
'Determine whether a Type has the "restrict" qualifier set.
This does not look through typedefs that may have added "restrict" at
a different level.'
| def is_restrict_qualified(self):
| return conf.lib.clang_isRestrictQualifiedType(self)
|
'Determine whether this function Type is a variadic function type.'
| def is_function_variadic(self):
| assert (self.kind == TypeKind.FUNCTIONPROTO)
return conf.lib.clang_isFunctionTypeVariadic(self)
|
'Determine whether this Type represents plain old data (POD).'
| def is_pod(self):
| return conf.lib.clang_isPODType(self)
|
'For pointer types, returns the type of the pointee.'
| def get_pointee(self):
| return conf.lib.clang_getPointeeType(self)
|
'Return the cursor for the declaration of the given type.'
| def get_declaration(self):
| return conf.lib.clang_getTypeDeclaration(self)
|
'Retrieve the result type associated with a function type.'
| def get_result(self):
| return conf.lib.clang_getResultType(self)
|
'Retrieve the type of the elements of the array type.'
| def get_array_element_type(self):
| return conf.lib.clang_getArrayElementType(self)
|
'Retrieve the size of the constant array.'
| def get_array_size(self):
| return conf.lib.clang_getArraySize(self)
|
'Create a new Index.
Parameters:
excludeDecls -- Exclude local declarations from translation units.'
| @staticmethod
def create(excludeDecls=False):
| return Index(conf.lib.clang_createIndex(excludeDecls, 0))
|
'Load a TranslationUnit from the given AST file.'
| def read(self, path):
| return TranslationUnit.from_ast(path, self)
|
'Load the translation unit from the given source code file by running
clang and generating the AST before loading. Additional command line
parameters can be passed to clang via the args parameter.
In-memory contents for files can be provided by passing a list of pairs
to as unsaved_files, the first item should be the f... | def parse(self, path, args=None, unsaved_files=None, options=0):
| return TranslationUnit.from_source(path, args, unsaved_files, options, self)
|
'Create a TranslationUnit by parsing source.
This is capable of processing source code both from files on the
filesystem as well as in-memory contents.
Command-line arguments that would be passed to clang are specified as
a list via args. These can be used to specify include paths, warnings,
etc. e.g. ["-Wall", "-I/pat... | @classmethod
def from_source(cls, filename, args=None, unsaved_files=None, options=0, index=None):
| if (args is None):
args = []
else:
args = list(args)
args.append('-fno-color-diagnostics')
if (unsaved_files is None):
unsaved_files = []
if (index is None):
index = Index.create()
args_array = None
if (len(args) > 0):
args_array = (c_char_p * len(args... |
'Create a TranslationUnit instance from a saved AST file.
A previously-saved AST file (provided with -emit-ast or
TranslationUnit.save()) is loaded from the filename specified.
If the file cannot be loaded, a TranslationUnitLoadError will be
raised.
index is optional and is the Index instance to use. If not provided,
a... | @classmethod
def from_ast_file(cls, filename, index=None):
| if (index is None):
index = Index.create()
ptr = conf.lib.clang_createTranslationUnit(index, filename)
if (not ptr):
raise TranslationUnitLoadError(filename)
return cls(ptr=ptr, index=index)
|
'Create a TranslationUnit instance.
TranslationUnits should be created using one of the from_* @classmethod
functions above. __init__ is only called internally.'
| def __init__(self, ptr, index):
| assert isinstance(index, Index)
ClangObject.__init__(self, ptr)
|
'Retrieve the cursor that represents the given translation unit.'
| @property
def cursor(self):
| return conf.lib.clang_getTranslationUnitCursor(self)
|
'Get the original translation unit source file name.'
| @property
def spelling(self):
| return conf.lib.clang_getTranslationUnitSpelling(self)
|
'Return an iterable sequence of FileInclusion objects that describe the
sequence of inclusions in a translation unit. The first object in
this sequence is always the input file. Note that this method will not
recursively iterate over header files included through precompiled
headers.'
| def get_includes(self):
| def visitor(fobj, lptr, depth, includes):
if (depth > 0):
loc = lptr.contents
includes.append(FileInclusion(loc.file, File(fobj), loc, depth))
includes = []
conf.lib.clang_getInclusions(self, callbacks['translation_unit_includes'](visitor), includes)
return iter(includes)... |
'Obtain a File from this translation unit.'
| def get_file(self, filename):
| return File.from_name(self, filename)
|
'Obtain a SourceLocation for a file in this translation unit.
The position can be specified by passing:
- Integer file offset. Initial file offset is 0.
- 2-tuple of (line number, column number). Initial file position is
(0, 0)'
| def get_location(self, filename, position):
| f = self.get_file(filename)
if isinstance(position, int):
return SourceLocation.from_offset(self, f, position)
return SourceLocation.from_position(self, f, position[0], position[1])
|
'Obtain a SourceRange from this translation unit.
The bounds of the SourceRange must ultimately be defined by a start and
end SourceLocation. For the locations argument, you can pass:
- 2 SourceLocation instances in a 2-tuple or list.
- 2 int file offsets via a 2-tuple or list.
- 2 2-tuple or lists of (line, column) pa... | def get_extent(self, filename, locations):
| f = self.get_file(filename)
if (len(locations) < 2):
raise Exception('Must pass object with at least 2 elements')
(start_location, end_location) = locations
if hasattr(start_location, '__len__'):
start_location = SourceLocation.from_position(self, f, start_location[0... |
'Return an iterable (and indexable) object containing the diagnostics.'
| @property
def diagnostics(self):
| class DiagIterator:
def __init__(self, tu):
self.tu = tu
def __len__(self):
return int(conf.lib.clang_getNumDiagnostics(self.tu))
def __getitem__(self, key):
diag = conf.lib.clang_getDiagnostic(self.tu, key)
if (not diag):
raise... |
'Reparse an already parsed translation unit.
In-memory contents for files can be provided by passing a list of pairs
as unsaved_files, the first items should be the filenames to be mapped
and the second should be the contents to be substituted for the
file. The contents may be passed as strings or file objects.'
| def reparse(self, unsaved_files=None, options=0):
| if (unsaved_files is None):
unsaved_files = []
unsaved_files_array = 0
if len(unsaved_files):
unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))()
for (i, (name, value)) in enumerate(unsaved_files):
if (not isinstance(value, str)):
value = value.r... |
'Saves the TranslationUnit to a file.
This is equivalent to passing -emit-ast to the clang frontend. The
saved file can be loaded back into a TranslationUnit. Or, if it
corresponds to a header, it can be used as a pre-compiled header file.
If an error occurs while saving, a TranslationUnitSaveError is raised.
If the er... | def save(self, filename):
| options = conf.lib.clang_defaultSaveOptions(self)
result = int(conf.lib.clang_saveTranslationUnit(self, filename, options))
if (result != 0):
raise TranslationUnitSaveError(result, 'Error saving TranslationUnit.')
|
'Code complete in this translation unit.
In-memory contents for files can be provided by passing a list of pairs
as unsaved_files, the first items should be the filenames to be mapped
and the second should be the contents to be substituted for the
file. The contents may be passed as strings or file objects.'
| def codeComplete(self, path, line, column, unsaved_files=None, include_macros=False, include_code_patterns=False, include_brief_comments=False):
| options = 0
if include_macros:
options += 1
if include_code_patterns:
options += 2
if include_brief_comments:
options += 4
if (unsaved_files is None):
unsaved_files = []
unsaved_files_array = 0
if len(unsaved_files):
unsaved_files_array = (_CXUnsavedFi... |
'Obtain tokens in this translation unit.
This is a generator for Token instances. The caller specifies a range
of source code to obtain tokens for. The range can be specified as a
2-tuple of SourceLocation or as a SourceRange. If both are defined,
behavior is undefined.'
| def get_tokens(self, locations=None, extent=None):
| if (locations is not None):
extent = SourceRange(start=locations[0], end=locations[1])
return TokenGroup.get_tokens(self, extent)
|
'Retrieve a file handle within the given translation unit.'
| @staticmethod
def from_name(translation_unit, file_name):
| return File(conf.lib.clang_getFile(translation_unit, encode(file_name)))
|
'Return the complete file and path name of the file.'
| @property
def name(self):
| return conf.lib.clang_getCString(conf.lib.clang_getFileName(self))
|
'Return the last modification time of the file.'
| @property
def time(self):
| return conf.lib.clang_getFileTime(self)
|
'True if the included file is the input file.'
| @property
def is_input_file(self):
| return (self.depth == 0)
|
'Get the working directory for this CompileCommand'
| @property
def directory(self):
| return conf.lib.clang_CompileCommand_getDirectory(self.cmd)
|
'Get an iterable object providing each argument in the
command line for the compiler invocation as a _CXString.
Invariant : the first argument is the compiler executable'
| @property
def arguments(self):
| length = conf.lib.clang_CompileCommand_getNumArgs(self.cmd)
for i in range(length):
(yield conf.lib.clang_CompileCommand_getArg(self.cmd, i))
|
'Builds a CompilationDatabase from the database found in buildDir'
| @staticmethod
def fromDirectory(buildDir):
| errorCode = c_uint()
try:
cdb = conf.lib.clang_CompilationDatabase_fromDirectory(encode(buildDir), byref(errorCode))
except CompilationDatabaseError as e:
raise CompilationDatabaseError(int(errorCode.value), 'CompilationDatabase loading failed')
return cdb
|
'Get an iterable object providing all the CompileCommands available to
build filename. Returns None if filename is not found in the database.'
| def getCompileCommands(self, filename):
| return conf.lib.clang_CompilationDatabase_getCompileCommands(self, encode(filename))
|
'The spelling of this token.
This is the textual representation of the token in source.'
| @property
def spelling(self):
| return conf.lib.clang_getTokenSpelling(self._tu, self)
|
'Obtain the TokenKind of the current token.'
| @property
def kind(self):
| return TokenKind.from_value(conf.lib.clang_getTokenKind(self))
|
'The SourceLocation this Token occurs at.'
| @property
def location(self):
| return conf.lib.clang_getTokenLocation(self._tu, self)
|
'The SourceRange this Token occupies.'
| @property
def extent(self):
| return conf.lib.clang_getTokenExtent(self._tu, self)
|
'The Cursor this Token corresponds to.'
| @property
def cursor(self):
| cursor = Cursor()
conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))
return cursor
|
'Set the path in which to search for libclang'
| @staticmethod
def set_library_path(path):
| if Config.loaded:
raise Exception('library path must be set before before using any other functionalities in libclang.')
Config.library_path = path
|
'Set the exact location of libclang'
| @staticmethod
def set_library_file(filename):
| if Config.loaded:
raise Exception('library file must be set before before using any other functionalities in libclang.')
Config.library_file = filename
|
'Perform compatibility check when loading libclang
The python bindings are only tested and evaluated with the version of
libclang they are provided with. To ensure correct behavior a (limited)
compatibility check is performed when loading the bindings. This check
will throw an exception, as soon as it fails.
In case th... | @staticmethod
def set_compatibility_check(check_status):
| if Config.loaded:
raise Exception('compatibility_check must be set before before using any other functionalities in libclang.')
Config.compatibility_check = check_status
|
'The tex root of the analysis'
| def tex_root(self):
| return self._tex_root
|
'The folder in which the file is seen by the latex compiler.
This is usually the folder of the tex root, but can change if
the import package is used.
Use this instead of the tex root path to implement functions
like the \input command completion.'
| def tex_base_path(self, file_path):
| file_path = os.path.normpath(file_path)
try:
base_path = self._import_base_paths[file_path]
except KeyError:
(base_path, _) = os.path.split(self._tex_root)
return base_path
|
'The content of the file without comments (a string)'
| def content(self, file_name):
| if (file_name not in self._content):
raise FileNotAnalyzed(file_name)
return self._content[file_name]
|
'The raw unprocessed content of the file (a string)'
| def raw_content(self, file_name):
| if (file_name not in self._raw_content):
raise FileNotAnalyzed(file_name)
return self._raw_content[file_name]
|
'Returns a rowcol function for the file with the same behavior as the
view.rowcol function from the sublime api'
| def rowcol(self, file_name):
| return make_rowcol(self.raw_content(file_name))
|
'Returns a list with copies of each command entry in the document
Arguments:
flags -- flags to filter the commands, which should for a be used over
over filtering the commands on your own (optimization/caching).
Possible flags are:
NO_BEGIN_END_COMMANDS - removes all begind and end commands
i.e.: exclude \begin{} and \... | def commands(self, flags=DEFAULT_FLAGS):
| return self._commands(flags)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.