|
@@ -93,7 +93,9 @@ export function renderMenu (command, ref_object, dom_object, function_obj, size_
|
|
|
if (ref_object.content || ref_object.function_called) {
|
|
|
if (ref_object.content) {
|
|
|
// Verificar se a variável ainda existe:
|
|
|
- if (isVarInProgram(ref_object.content, function_obj)) {
|
|
|
+ var variable_fun = isVarInProgram(ref_object.content, function_obj);
|
|
|
+ if (variable_fun) {
|
|
|
+ ref_object.content = variable_fun;
|
|
|
renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
|
|
|
} else {
|
|
|
if (ref_object.content && ref_object.content.type) {
|
|
@@ -105,7 +107,9 @@ export function renderMenu (command, ref_object, dom_object, function_obj, size_
|
|
|
}
|
|
|
} else if (ref_object.function_called) {
|
|
|
// Verificar se a função ainda existe:
|
|
|
- if (isFunctionInProgram(ref_object.function_called)) {
|
|
|
+ var ret_function = isFunctionInProgram(ref_object.function_called);
|
|
|
+ if (ret_function) {
|
|
|
+ ref_object.function_called = ret_function;
|
|
|
renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
|
|
|
} else {
|
|
|
ref_object.content = null;
|
|
@@ -141,14 +145,28 @@ function appendSelectText (ref_object, menu_var_or_value) {
|
|
|
}
|
|
|
|
|
|
function isFunctionInProgram (function_called_obj) {
|
|
|
- if (window.program_obj.functions) {
|
|
|
- for (var i = 0; i < window.program_obj.functions.length; i++) {
|
|
|
- if (window.program_obj.functions[i] == function_called_obj) {
|
|
|
- return true;
|
|
|
+ if (function_called_obj.name) {
|
|
|
+ if (window.program_obj.functions) {
|
|
|
+ for (var i = 0; i < window.program_obj.functions.length; i++) {
|
|
|
+ if (window.program_obj.functions[i] == function_called_obj) {
|
|
|
+ return window.program_obj.functions[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var i = 0; i < window.program_obj.functions.length; i++) {
|
|
|
+ if (window.program_obj.functions[i].name == function_called_obj.name) {
|
|
|
+ return window.program_obj.functions[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (function_called_obj.identifier) {
|
|
|
+ for (var i = 0; i < window.system_functions.length; i++) {
|
|
|
+ if (window.system_functions[i].identifier == function_called_obj.identifier) {
|
|
|
+ return window.system_functions[i];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
function isVarInProgram (var_obj, function_obj) {
|
|
@@ -156,7 +174,7 @@ function isVarInProgram (var_obj, function_obj) {
|
|
|
if (function_obj.variables_list) {
|
|
|
for (var i = 0; i < function_obj.variables_list.length; i++) {
|
|
|
if (function_obj.variables_list[i] == var_obj) {
|
|
|
- return true;
|
|
|
+ return function_obj.variables_list[i];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -164,7 +182,7 @@ function isVarInProgram (var_obj, function_obj) {
|
|
|
if (function_obj.parameters_list) {
|
|
|
for (var i = 0; i < function_obj.parameters_list.length; i++) {
|
|
|
if (function_obj.parameters_list[i] == var_obj) {
|
|
|
- return true;
|
|
|
+ return function_obj.parameters_list[i];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -172,11 +190,37 @@ function isVarInProgram (var_obj, function_obj) {
|
|
|
if (window.program_obj.globals) {
|
|
|
for (var i = 0; i < window.program_obj.globals.length; i++) {
|
|
|
if (window.program_obj.globals[i] == var_obj) {
|
|
|
- return true;
|
|
|
+ return window.program_obj.globals[i];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
+ // If not found, verify if the reference was lost
|
|
|
+ if (var_obj) {
|
|
|
+ if (function_obj.variables_list) {
|
|
|
+ for (var i = 0; i < function_obj.variables_list.length; i++) {
|
|
|
+ if (function_obj.variables_list[i].name == var_obj.name) {
|
|
|
+ return function_obj.variables_list[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (function_obj.parameters_list) {
|
|
|
+ for (var i = 0; i < function_obj.parameters_list.length; i++) {
|
|
|
+ if (function_obj.parameters_list[i].name == var_obj.name) {
|
|
|
+ return function_obj.parameters_list[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (window.program_obj.globals) {
|
|
|
+ for (var i = 0; i < window.program_obj.globals.length; i++) {
|
|
|
+ if (window.program_obj.globals[i].name == var_obj.name) {
|
|
|
+ return window.program_obj.globals[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
export function refreshMenu (menu_var_or_value_dom) {
|
|
@@ -213,8 +257,10 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
|
|
|
|
|
|
if (variable_obj.content || variable_obj.function_called) {
|
|
|
// Verificar se a variável ainda existe:
|
|
|
- if (isVarInProgram(variable_obj.content, function_obj)) {
|
|
|
-
|
|
|
+ var var_fun = isVarInProgram(variable_obj.content, function_obj);
|
|
|
+
|
|
|
+ if (var_fun) {
|
|
|
+ variable_obj.content = var_fun;
|
|
|
} else {
|
|
|
if (variable_obj.content && variable_obj.content.type) {
|
|
|
variable_obj.content = null;
|
|
@@ -661,6 +707,7 @@ function addVariablesToMenu (function_obj, menu_var_or_value, ref_object, expres
|
|
|
|
|
|
var sub_menu = menu_var_or_value.find('.menu_only_vars');
|
|
|
sub_menu.text('');
|
|
|
+ var is_there = false;
|
|
|
|
|
|
if (window.program_obj.globals) {
|
|
|
|
|
@@ -669,6 +716,7 @@ function addVariablesToMenu (function_obj, menu_var_or_value, ref_object, expres
|
|
|
var temp = $('<div class="item" data-option="'+VAR_OR_VALUE_TYPES.only_variable+'">' + window.program_obj.globals[i].name + ' </div>');
|
|
|
temp.data('variable_reference', window.program_obj.globals[i]);
|
|
|
sub_menu.append(temp);
|
|
|
+ is_there = true;
|
|
|
}
|
|
|
} else {
|
|
|
for (var i = 0; i < window.program_obj.globals.length; i++) {
|
|
@@ -676,6 +724,7 @@ function addVariablesToMenu (function_obj, menu_var_or_value, ref_object, expres
|
|
|
var temp = $('<div class="item" data-option="'+VAR_OR_VALUE_TYPES.only_variable+'">' + window.program_obj.globals[i].name + ' </div>');
|
|
|
temp.data('variable_reference', window.program_obj.globals[i]);
|
|
|
sub_menu.append(temp);
|
|
|
+ is_there = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -686,6 +735,7 @@ function addVariablesToMenu (function_obj, menu_var_or_value, ref_object, expres
|
|
|
var temp = $('<div class="item" data-option="'+VAR_OR_VALUE_TYPES.only_variable+'">' + function_obj.parameters_list[i].name + ' </div>');
|
|
|
temp.data('variable_reference', function_obj.parameters_list[i]);
|
|
|
sub_menu.append(temp);
|
|
|
+ is_there = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -694,8 +744,13 @@ function addVariablesToMenu (function_obj, menu_var_or_value, ref_object, expres
|
|
|
var temp = $('<div class="item" data-option="'+VAR_OR_VALUE_TYPES.only_variable+'">' + function_obj.variables_list[i].name + ' </div>');
|
|
|
temp.data('variable_reference', function_obj.variables_list[i]);
|
|
|
sub_menu.append(temp);
|
|
|
+ is_there = true;
|
|
|
}
|
|
|
}
|
|
|
+ if (!is_there) {
|
|
|
+ sub_menu.append($('<div class="header">'+LocalizedStrings.getUI('text_none_variable')+'</div>'));
|
|
|
+ sub_menu.append($('<div class="item disabled">'+LocalizedStrings.getUI('text_none_variable_instruction')+'</div>'));
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|