Types
numbat.types
Element
Wrapper class for sourcetrail 'element' table:
The 'element' table is used in sourcetrail to be able to easily manage other elements of others tables. Since all higher level element are referencing an element in the 'element' table it's possible to remove any element by removing the correct entry in the 'element' table.
Create a new Element object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
ElementComponentType
Internal class that represent an ElementComponent type inside the sourcetrail database. This type is used to indicate that an element component is ambiguous.
ElementComponent
Wrapper class for sourcetrail element_component table:
CREATE TABLE element_component(
id INTEGER,
element_id INTEGER,
type INTEGER,
data TEXT,
PRIMARY KEY(id),
FOREIGN KEY(element_id) REFERENCES element(id) ON DELETE CASCADE
)
This table is not commonly used, it only contains indication about the ambiguity of another element such as an edge or a node.
Create a new ElementComponent object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
elem_id
|
int
|
The id of the referenced element |
0
|
type_
|
ElementComponentType
|
The type of the ElementComponent |
NONE
|
data
|
str
|
Additional data (optional) |
''
|
EdgeType
Internal class that represent an Edge type inside the sourcetrail database. This type define the relationship between the nodes.
Edge
Wrapper class for sourcetrail edge table:
CREATE TABLE edge(
id INTEGER NOT NULL,
type INTEGER NOT NULL,
source_node_id INTEGER NOT NULL,
target_node_id INTEGER NOT NULL,
color TEXT,
hover_display TEXT,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES element(id) ON DELETE CASCADE,
FOREIGN KEY(source_node_id) REFERENCES node(id) ON DELETE CASCADE,
FOREIGN KEY(target_node_id) REFERENCES node(id) ON DELETE CASCADE
)
The 'edge' table is used to define relation between element of the 'node' table. For example, it can be used to indicate that a field is a member of a class or a function foo is calling another function bar.
Create a new Edge object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
type_
|
EdgeType
|
The type of the Edge |
UNDEFINED
|
src
|
int
|
The id of the source element |
0
|
dst
|
int
|
The id of the destination element |
0
|
hover_display
|
str
|
The display text when hovering over the Edge |
''
|
NodeType
Internal class that represent an Edge type inside the sourcetrail database. This type define the type of the node in the database.
Node
Wrapper class for sourcetrail node table:
CREATE TABLE node(
id INTEGER NOT NULL,
type INTEGER NOT NULL,
serialized_name TEXT,
color TEXT,
hover_display TEXT,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES element(id) ON DELETE CASCADE
)
The 'node' table is the main table of the sourcetrail database. It allows to store elements such as function, class, package, etc. However, this table is weirdly implemented as the field 'serialized_name' contains another type called NameHierarchy with a custom serialization format.
The NameHierarchy describe a relationship between node elements, for example, a class 'A' with a member 'b' will result in two entries in the database:
id1 | NODE_CLASS | '. A s p'
id2 | NODE_FIELD | '. A s p m b s p'
The above example shows that the 'serialized_name' of the member 'b' (id2) hold some information about his parent 'A' (id1).
Create a new Node object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
type_
|
NodeType
|
The type of the Node |
NODE_TYPE
|
name
|
str
|
The serialized name of the Node |
''
|
hover_display
|
str
|
The display text when hovering over the Node |
''
|
NodeDisplay
Represent how Sourcetrail's internal node types are displayed.
The 'node_type' table is used to store how each type of node is displayed.
Create a new NodeDisplay object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
NodeType
|
The internal id according to the NodeType enum |
required |
graph_display
|
str
|
The display text in the Sourcetrail graph |
required |
hover_display
|
str
|
The display text when hovering over a node |
required |
SymbolType
Internal class that represent a Symbol type inside the sourcetrail database. This type define the symbol type in the database.
Symbol
Wrapper class for sourcetrail symbol table:
CREATE TABLE symbol(
id INTEGER NOT NULL,
definition_kind INTEGER NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE
)
The 'symbol' table is used to add additional information on elements such as node.
Create a new Symbol object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
definition
|
SymbolType
|
The type of the Symbol |
NONE
|
File
Wrapper class for sourcetrail file table:
CREATE TABLE file(
id INTEGER NOT NULL,
path TEXT,
language TEXT,
modification_time TEXT,
indexed INTEGER,
complete INTEGER,
line_count INTEGER,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE
)
The 'file' table hold the information about the different source file that have been parsed by sourcetrail. Each one of them contains an id that will be reference by the element of the 'filecontent' table.
Create a new File object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
path
|
str
|
The path to the source file |
''
|
language
|
str
|
The language of the source file. |
''
|
modification_time
|
str
|
The time of the last modification of the source file |
''
|
indexed
|
int
|
A indication to tell if the file was indexed or not (0 or 1) |
0
|
complete
|
int
|
A indicate to tell if the indexing is complete or not (0 or 1) |
0
|
line_count
|
int
|
The number of line in the source file |
0
|
FileContent
Wrapper class for sourcetrail filecontent table:
CREATE TABLE filecontent(
id INTEGER,
content TEXT,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES file(id)ON DELETE CASCADE ON UPDATE CASCADE
)
The 'filecontent' table holds the content of the different source file. Because the id field of the filecontent is a primary key (unique element) a filecontent should contain the entire content of a file.
Create a new FileContent object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
content
|
str
|
The content of the source file. |
''
|
NodeFile
Wrapper class for node_file table
CREATE TABLE node_file(
file_id INTEGER,
file_name TEXT,
display_content INTEGER,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE
)
The 'node_file' table contains the paths to all files that have been copied to the project folder, and the node they are associated to.
Create a new NodeFile object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_id
|
int
|
id of the copied file |
required |
file_name
|
str
|
path to the copy |
required |
display_content
|
bool
|
whether the file content should be displayed or not |
required |
LocalSymbol
Wrapper class for sourcetrail local_symbol table:
CREATE TABLE local_symbol(
id INTEGER NOT NULL,
name TEXT,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES element(id) ON DELETE CASCADE
)
The 'local_symbol' table holds reference to nodes that represent elements such as variables only used locally. For example, the following code snippet:
While result in 3 different nodes, two of them (a and b) with have an entry in the 'local_symbol' table. The content of this table is not essential to the application but can provide a better level of detail to the user when browsing code in Sourcetrail UI.
Create a new LocalSymbol object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
name
|
str
|
The name of local symbol |
''
|
SourceLocationType
Internal class that represent a SymbolLocation type inside the sourcetrail database. This type define the symbol location type in the database and can be used to indicate indexing errors.
SourceLocation
SourceLocation(
id_=0, file_node_id=0, start_line=0, start_column=0, end_line=0, end_column=0, type_=UNSOLVED
)
Wrapper class for sourcetrail source_location table:
CREATE TABLE source_location(
id INTEGER NOT NULL,
file_node_id INTEGER,
start_line INTEGER,
start_column INTEGER,
end_line INTEGER,
end_column INTEGER,
type INTEGER,
PRIMARY KEY(id),
FOREIGN KEY(file_node_id) REFERENCES node(id) ON DELETE CASCADE
)
The table 'source_location' contain some entries indicating where the corresponding node element (the ones that are referenced by the id) are located in the source tree.
Create a new SourceLocation object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
file_node_id
|
int
|
The id of the file element corresponding to this content. |
0
|
start_line
|
int
|
The line at which the element starts. |
0
|
start_column
|
int
|
The column at which the element starts. |
0
|
end_line
|
int
|
The line at which the element ends. |
0
|
end_column
|
int
|
The line at which the element ends. |
0
|
type_
|
SourceLocationType
|
The type of the source location. |
UNSOLVED
|
Occurrence
Wrapper class for sourcetrail occurrence table:
CREATE TABLE occurrence(
element_id INTEGER NOT NULL,
source_location_id INTEGER NOT NULL,
PRIMARY KEY(element_id, source_location_id),
FOREIGN KEY(element_id) REFERENCES element(id) ON DELETE CASCADE,
FOREIGN KEY(source_location_id) REFERENCES source_location(id)
ON DELETE CASCADE
)
The table 'occurrence' allow to link the elements define in the 'source_location' table and the ones define in the 'node' table.
Create a new Occurrence object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elem_id
|
int
|
The id of the element referenced by this occurrence |
0
|
source_location_id
|
int
|
The id of the source location referenced by this occurrence |
0
|
ComponentAccessType
Internal class that represent a ComponentAccess type inside the sourcetrail database. This type define the type of ComponentAccess in the database and can be used to add extra information regarding the visibility of elements (in the "Object-Oriented" sens)
ComponentAccess
Wrapper class for sourcetrail component_access table:
CREATE TABLE component_access(
node_id INTEGER NOT NULL,
type INTEGER NOT NULL,
PRIMARY KEY(node_id),
FOREIGN KEY(node_id) REFERENCES node(id) ON DELETE CASCADE
)
The table 'component_access' allow to add information on the type of visibility of element in the 'node' table. For example, a java class that is set to public will have an entry in this table.
Create a new ComponentAccess object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_id
|
int
|
The id of the element |
0
|
type_
|
ComponentAccessType
|
The type of the ComponentAccess |
NONE
|
Error
Wrapper class for sourcetrail error table:
CREATE TABLE error(
id INTEGER NOT NULL,
message TEXT,
fatal INTEGER NOT NULL,
indexed INTEGER NOT NULL,
translation_unit TEXT,
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES element(id) ON DELETE CASCADE
)
The table 'error' holds the different error message produced during the parsing of the source files and are displayed in the UI.
Create a new Error object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
int
|
The id of the element |
0
|
message
|
str
|
The description of the error |
''
|
fatal
|
int
|
Indicate if this error is fatal or not (0 or 1) |
0
|
indexed
|
int
|
Indicate if this error occurs while indexing (0 or 1) |
0
|
translation_unit
|
str
|
Indicate in which translation unit the error occurs |
''
|
NameElement
This class is a basic component of the serialized_name field of the node table. This type does not represent directly a type in the database.
Create a new NameElement object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix
|
str
|
The prefix of the element |
None
|
name
|
str
|
The name of the element |
None
|
postfix
|
str
|
The postfix of the element |
None
|
get_prefix
Return the prefix of this element
Returns:
Type | Description |
---|---|
str
|
The prefix of the element |
get_name
Return the name of this element
Returns:
Type | Description |
---|---|
str
|
The name of the element |
get_postfix
Return the postfix of this element
Returns:
Type | Description |
---|---|
str
|
The postfix of the element |
set_prefix
Set the prefix of this element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix
|
str
|
The new prefix of the element |
required |
Returns:
Type | Description |
---|---|
None
|
None |
set_name
Set the name of this element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The new name of the element |
required |
Returns:
Type | Description |
---|---|
None
|
None |
NameHierarchy
This class represent the hierarchy relationship between nodes. This type does not represent directly a type in the database and is stored in the 'serialized_name' field of the 'node' table.
Create a new NameHierarchy object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delimiter
|
str
|
The delimiter of for this NameHierarchy, must be one of the NAME_DELIMITERS |
required |
elements
|
list[NameElement]
|
A list of NameElement representing the hierarchy of this element |
required |
Returns:
Type | Description |
---|---|
None |
extend
Utility method that adds a new element to a hierarchy
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
NameElement
|
The new element to add |
required |
serialize_range
Utility method that return a part of the serialized name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start
|
int
|
the starting position of the elements |
required |
end
|
int
|
the ending position of the elements |
required |
Returns:
Type | Description |
---|---|
str
|
The serialized name |
serialize_name
Utility method that return the full serialized name
Returns:
Type | Description |
---|---|
str
|
The serialized name |
size
Return the size of the NameHierarchy object.
Returns:
Type | Description |
---|---|
int
|
The size of the NameHierarchy |
deserialize_name
staticmethod
Utility method that return prefix, name and suffix from a serialized name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
serialized_name
|
str
|
A string that should start by one of the following: - NAME_DELIMITER_FILE - NAME_DELIMITER_CXX - NAME_DELIMITER_JAVA - NAME_DELIMITER_UNKNOWN And then be followed by at least 3 elements separated by the delimiter "DELIMITER". |
required |
Returns:
Type | Description |
---|---|
NameHierarchy
|
The NameHierarchy corresponding to the deserialize_name |