mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/code] Rename ScriptNode::Types to With/WithoutParentheses
Because some functions already have the parentheses in their name, so their type would have been Variable but it is clearer to give it the type WithoutParentheses. this is the case for nodes created from toolbox nodes.
This commit is contained in:
@@ -9,10 +9,10 @@ namespace Code {
|
||||
class ScriptNode {
|
||||
public:
|
||||
enum class Type : bool {
|
||||
Function,
|
||||
Variable
|
||||
WithoutParentheses,
|
||||
WithParentheses
|
||||
};
|
||||
ScriptNode(Type type = Type::Variable, const char * name = nullptr, int nameLength = -1, const char * nodeSourceName = nullptr, const char * description = nullptr) :
|
||||
ScriptNode(Type type = Type::WithoutParentheses, const char * name = nullptr, int nameLength = -1, const char * nodeSourceName = nullptr, const char * description = nullptr) :
|
||||
m_type(type),
|
||||
m_name(name),
|
||||
m_nodeSourceName(nodeSourceName),
|
||||
|
||||
@@ -29,7 +29,7 @@ void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) cons
|
||||
const KDCoordinate nodeNameY = rectHeightPerLine - k_verticalMargin / 2 - nameSize.height() ;
|
||||
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, KDColorBlack, backgroundColor, nodeNameLength);
|
||||
// If it is a function, draw the parentheses
|
||||
if (m_scriptNode->type() == ScriptNode::Type::Function) {
|
||||
if (m_scriptNode->type() == ScriptNode::Type::WithParentheses) {
|
||||
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, KDColorBlack, backgroundColor);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ KDSize ScriptNodeCell::ScriptNodeView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(300 /*TODO LEA*/, 2*k_topBottomMargin + m_scriptNode->description() == nullptr ? k_font->glyphSize().height() : k_font->glyphSize().height() * 2 + k_verticalMargin);
|
||||
#if 0
|
||||
KDSize nameLineSize = k_font->stringSize(m_scriptNode->name(), m_scriptNode->nameLength());
|
||||
if (m_scriptNode->type() == ScriptNode::Type::Function) {
|
||||
if (m_scriptNode->type() == ScriptNode::Type::WithParentheses) {
|
||||
nameLineSize = KDSize(nameLineSize.width() + k_font->stringSize(k_parentheses).width(), nameLineSize.height());
|
||||
}
|
||||
const char * sourceName = m_scriptNode->nodeSourceName();
|
||||
|
||||
@@ -323,7 +323,7 @@ bool VariableBoxController::selectLeaf(int rowIndex) {
|
||||
(void)cellType; // Silence warnings
|
||||
ScriptNode * selectedScriptNode = scriptNodeAtIndex(rowIndex - cumulatedOriginsCount); // Remove the number of subtitle cells from the index
|
||||
insertTextInCaller(selectedScriptNode->name() + m_shortenResultCharCount, selectedScriptNode->nameLength() - m_shortenResultCharCount);
|
||||
if (selectedScriptNode->type() == ScriptNode::Type::Function) {
|
||||
if (selectedScriptNode->type() == ScriptNode::Type::WithParentheses) {
|
||||
insertTextInCaller(ScriptNodeCell::k_parenthesesWithEmpty);
|
||||
}
|
||||
Container::activeApp()->dismissModalViewController();
|
||||
@@ -343,124 +343,124 @@ void VariableBoxController::loadBuiltinNodes(const char * textToAutocomplete, in
|
||||
//TODO LEA Prune these (check all are usable in our Python, but just comment those which aren't -> there might become usable later)
|
||||
//TODO LEA add matplotlib.pyplot
|
||||
static const struct { const char * name; ScriptNode::Type type; } builtinNames[] = {
|
||||
{"False", ScriptNode::Type::Variable},
|
||||
{"None", ScriptNode::Type::Variable},
|
||||
{"True", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR___import__), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_abs), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_all), ScriptNode::Type::Function},
|
||||
{"and", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_any), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_append), ScriptNode::Type::Function},
|
||||
{"as", ScriptNode::Type::Variable},
|
||||
//{qstr_str(MP_QSTR_ascii), ScriptNode::Type::Function},
|
||||
{"assert", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_bin), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_bool), ScriptNode::Type::Function},
|
||||
{"break", ScriptNode::Type::Variable},
|
||||
//{qstr_str(MP_QSTR_breakpoint), ScriptNode::Type::Function},
|
||||
//{qstr_str(MP_QSTR_bytearray), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_bytes), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_callable), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_chr), ScriptNode::Type::Function},
|
||||
{"class", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_classmethod), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_clear), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_cmath), ScriptNode::Type::Variable},
|
||||
//{qstr_str(MP_QSTR_compile), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_complex), ScriptNode::Type::Function},
|
||||
{"continue", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_count), ScriptNode::Type::Function},
|
||||
{"def", ScriptNode::Type::Variable},
|
||||
{"del", ScriptNode::Type::Variable},
|
||||
//{qstr_str(MP_QSTR_delattr), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_dict), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_dir), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_divmod), ScriptNode::Type::Function},
|
||||
{"elif", ScriptNode::Type::Variable},
|
||||
{"else", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_enumerate), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_eval), ScriptNode::Type::Function},
|
||||
{"except", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_exec), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_filter), ScriptNode::Type::Function},
|
||||
{"finally", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_float), ScriptNode::Type::Function},
|
||||
{"for", ScriptNode::Type::Variable},
|
||||
//{qstr_str(MP_QSTR_format), ScriptNode::Type::Function},
|
||||
{"from", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_frozenset), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_getattr), ScriptNode::Type::Function},
|
||||
{"global", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_globals), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_hasattr), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_hash), ScriptNode::Type::Function},
|
||||
//{qstr_str(MP_QSTR_help), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_hex), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_id), ScriptNode::Type::Function},
|
||||
{"if", ScriptNode::Type::Variable},
|
||||
{"import", ScriptNode::Type::Variable},
|
||||
{"in", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_index), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_input), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_insert), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_int), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_ion), ScriptNode::Type::Variable},
|
||||
{"is", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_isinstance), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_issubclass), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_iter), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_kandinsky), ScriptNode::Type::Variable},
|
||||
{"lambda", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_len), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_list), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_locals), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_map), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_math), ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_max), ScriptNode::Type::Function},
|
||||
//{qstr_str(MP_QSTR_memoryview), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_min), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_next), ScriptNode::Type::Function},
|
||||
{"nonlocal", ScriptNode::Type::Variable},
|
||||
{"not", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_object), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_oct), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_open), ScriptNode::Type::Function},
|
||||
{"or", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_ord), ScriptNode::Type::Function},
|
||||
{"pass", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_pow), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_pop), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_print), ScriptNode::Type::Function},
|
||||
//{qstr_str(MP_QSTR_property), ScriptNode::Type::Function},
|
||||
{"raise", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_random), ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_range), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_remove), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_repr), ScriptNode::Type::Function},
|
||||
{"return", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_reverse), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_reversed), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_round), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_set), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_setattr), ScriptNode::Type::Function},
|
||||
//{qstr_str(MP_QSTR_slice), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_sort), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_sorted), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_staticmethod), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_str), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_sum), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_super), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_time), ScriptNode::Type::Variable},
|
||||
{"try", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_tuple), ScriptNode::Type::Function},
|
||||
{qstr_str(MP_QSTR_turtle), ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_type), ScriptNode::Type::Function},
|
||||
//{qstr_str(MP_QSTR_vars), ScriptNode::Type::Function},
|
||||
{"while", ScriptNode::Type::Variable},
|
||||
{"with", ScriptNode::Type::Variable},
|
||||
{"yield", ScriptNode::Type::Variable},
|
||||
{qstr_str(MP_QSTR_zip), ScriptNode::Type::Function}
|
||||
{"False", ScriptNode::Type::WithoutParentheses},
|
||||
{"None", ScriptNode::Type::WithoutParentheses},
|
||||
{"True", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR___import__), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_abs), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_all), ScriptNode::Type::WithParentheses},
|
||||
{"and", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_any), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_append), ScriptNode::Type::WithParentheses},
|
||||
{"as", ScriptNode::Type::WithoutParentheses},
|
||||
//{qstr_str(MP_QSTR_ascii), ScriptNode::Type::WithParentheses},
|
||||
{"assert", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_bin), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_bool), ScriptNode::Type::WithParentheses},
|
||||
{"break", ScriptNode::Type::WithoutParentheses},
|
||||
//{qstr_str(MP_QSTR_breakpoint), ScriptNode::Type::WithParentheses},
|
||||
//{qstr_str(MP_QSTR_bytearray), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_bytes), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_callable), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_chr), ScriptNode::Type::WithParentheses},
|
||||
{"class", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_classmethod), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_clear), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_cmath), ScriptNode::Type::WithoutParentheses},
|
||||
//{qstr_str(MP_QSTR_compile), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_complex), ScriptNode::Type::WithParentheses},
|
||||
{"continue", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_count), ScriptNode::Type::WithParentheses},
|
||||
{"def", ScriptNode::Type::WithoutParentheses},
|
||||
{"del", ScriptNode::Type::WithoutParentheses},
|
||||
//{qstr_str(MP_QSTR_delattr), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_dict), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_dir), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_divmod), ScriptNode::Type::WithParentheses},
|
||||
{"elif", ScriptNode::Type::WithoutParentheses},
|
||||
{"else", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_enumerate), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_eval), ScriptNode::Type::WithParentheses},
|
||||
{"except", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_exec), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_filter), ScriptNode::Type::WithParentheses},
|
||||
{"finally", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_float), ScriptNode::Type::WithParentheses},
|
||||
{"for", ScriptNode::Type::WithoutParentheses},
|
||||
//{qstr_str(MP_QSTR_format), ScriptNode::Type::WithParentheses},
|
||||
{"from", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_frozenset), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_getattr), ScriptNode::Type::WithParentheses},
|
||||
{"global", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_globals), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_hasattr), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_hash), ScriptNode::Type::WithParentheses},
|
||||
//{qstr_str(MP_QSTR_help), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_hex), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_id), ScriptNode::Type::WithParentheses},
|
||||
{"if", ScriptNode::Type::WithoutParentheses},
|
||||
{"import", ScriptNode::Type::WithoutParentheses},
|
||||
{"in", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_index), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_input), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_insert), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_int), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_ion), ScriptNode::Type::WithoutParentheses},
|
||||
{"is", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_isinstance), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_issubclass), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_iter), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_kandinsky), ScriptNode::Type::WithoutParentheses},
|
||||
{"lambda", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_len), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_list), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_locals), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_map), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_math), ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_max), ScriptNode::Type::WithParentheses},
|
||||
//{qstr_str(MP_QSTR_memoryview), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_min), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_next), ScriptNode::Type::WithParentheses},
|
||||
{"nonlocal", ScriptNode::Type::WithoutParentheses},
|
||||
{"not", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_object), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_oct), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_open), ScriptNode::Type::WithParentheses},
|
||||
{"or", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_ord), ScriptNode::Type::WithParentheses},
|
||||
{"pass", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_pow), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_pop), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_print), ScriptNode::Type::WithParentheses},
|
||||
//{qstr_str(MP_QSTR_property), ScriptNode::Type::WithParentheses},
|
||||
{"raise", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_random), ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_range), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_remove), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_repr), ScriptNode::Type::WithParentheses},
|
||||
{"return", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_reverse), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_reversed), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_round), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_set), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_setattr), ScriptNode::Type::WithParentheses},
|
||||
//{qstr_str(MP_QSTR_slice), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_sort), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_sorted), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_staticmethod), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_str), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_sum), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_super), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_time), ScriptNode::Type::WithoutParentheses},
|
||||
{"try", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_tuple), ScriptNode::Type::WithParentheses},
|
||||
{qstr_str(MP_QSTR_turtle), ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_type), ScriptNode::Type::WithParentheses},
|
||||
//{qstr_str(MP_QSTR_vars), ScriptNode::Type::WithParentheses},
|
||||
{"while", ScriptNode::Type::WithoutParentheses},
|
||||
{"with", ScriptNode::Type::WithoutParentheses},
|
||||
{"yield", ScriptNode::Type::WithoutParentheses},
|
||||
{qstr_str(MP_QSTR_zip), ScriptNode::Type::WithParentheses}
|
||||
};
|
||||
assert(sizeof(builtinNames) / sizeof(builtinNames[0]) == k_totalBuiltinNodesCount);
|
||||
for (int i = 0; i < k_totalBuiltinNodesCount; i++) {
|
||||
@@ -565,7 +565,7 @@ void VariableBoxController::loadCurrentVariablesInScript(const char * scriptCont
|
||||
}
|
||||
}
|
||||
assert(strncmp(tokenInText, name, nameLength) == 0);
|
||||
addNode(defToken ? ScriptNode::Type::Function : ScriptNode::Type::Variable, NodeOrigin::CurrentScript, tokenInText, nameLength);
|
||||
addNode(defToken ? ScriptNode::Type::WithParentheses : ScriptNode::Type::WithoutParentheses, NodeOrigin::CurrentScript, tokenInText, nameLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ bool VariableBoxController::addNodesFromImportMaybe(mp_parse_node_struct_t * par
|
||||
if (MP_PARSE_NODE_IS_LEAF(child) && MP_PARSE_NODE_LEAF_KIND(child) == MP_PARSE_NODE_ID) {
|
||||
// Parsing something like "import math"
|
||||
const char * id = qstr_str(MP_PARSE_NODE_LEAF_ARG(child));
|
||||
checkAndAddNode(textToAutocomplete, textToAutocompleteLength, ScriptNode::Type::Variable, NodeOrigin::Importation, id, -1, "math", "desc" /*TODO LEA*/);
|
||||
checkAndAddNode(textToAutocomplete, textToAutocompleteLength, ScriptNode::Type::WithoutParentheses, NodeOrigin::Importation, id, -1, "math", "desc" /*TODO LEA*/);
|
||||
} else if (MP_PARSE_NODE_IS_STRUCT(child)) {
|
||||
// Parsing something like "from math import sin"
|
||||
addNodesFromImportMaybe((mp_parse_node_struct_t *)child, textToAutocomplete, textToAutocompleteLength);
|
||||
@@ -712,7 +712,7 @@ bool VariableBoxController::addNodesFromImportMaybe(mp_parse_node_struct_t * par
|
||||
assert(numberOfChildren > numberOfNodesToSkip);
|
||||
for (int i = 3; i < numberOfChildren; i++) {
|
||||
const char * name = I18n::translate((moduleChildren + i)->label());
|
||||
checkAndAddNode(textToAutocomplete, textToAutocompleteLength, ScriptNode::Type::Variable, NodeOrigin::Importation, name, -1, importationSourceName, I18n::translate((moduleChildren + i)->text()) /*TODO LEA text or label?*/);
|
||||
checkAndAddNode(textToAutocomplete, textToAutocompleteLength, ScriptNode::Type::WithoutParentheses, NodeOrigin::Importation, name, -1, importationSourceName, I18n::translate((moduleChildren + i)->text()) /*TODO LEA text or label?*/);
|
||||
}
|
||||
} else {
|
||||
// Try fetching the nodes from a script
|
||||
@@ -750,7 +750,7 @@ void VariableBoxController::addImportStruct(mp_parse_node_struct_t * pns, uint s
|
||||
if (name == nullptr) {
|
||||
return;
|
||||
}
|
||||
checkAndAddNode(textToAutocomplete, textToAutocompleteLength, structKind == PN_funcdef ? ScriptNode::Type::Function : ScriptNode::Type::Variable, NodeOrigin::Importation, name, -1, scriptName);
|
||||
checkAndAddNode(textToAutocomplete, textToAutocompleteLength, structKind == PN_funcdef ? ScriptNode::Type::WithParentheses : ScriptNode::Type::WithoutParentheses, NodeOrigin::Importation, name, -1, scriptName);
|
||||
}
|
||||
|
||||
void VariableBoxController::checkAndAddNode(const char * textToAutocomplete, int textToAutocompleteLength, ScriptNode::Type type, NodeOrigin origin, const char * nodeName, int nodeNameLength, const char * nodeSourceName, const char * description) {
|
||||
|
||||
Reference in New Issue
Block a user