diff --git a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js index 765b5b112a6febfff550b84d16a11378c2e2c6de..138d97587ab28bacf482ffde41cedc402de5a7f5 100644 --- a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js +++ b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-EN.js @@ -152,6 +152,9 @@ list.push(default_sets[i]); } } + + // included sets + hintsSetsFromIncludedFiles(editor.options.files, editor, curWord, list); }else{ // get variables of function var previous_block = ""; @@ -197,6 +200,8 @@ } } } + // included enums + hintsEnumsFromIncludedFiles(editor.options.files, editor, curWord, list); // get functions var re_funs = new RegExp(FUNS.source, "g"); for (var dir = -1; dir <= 1; dir += 2) { @@ -211,6 +216,8 @@ } } } + // included functions + hintsFunctionsFromIncludedFiles(editor.options.files, editor, curWord, list); // add default functions var default_functions = hintWords.EN_functions(); for (var i = 0; i < default_functions.length; i++) { @@ -227,6 +234,95 @@ return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; }); + var INCLUIR = /include\s+([\w\_\d]+)/; + + function hintsFunctionsFromIncludedFiles(all_files, editor, curWord, list){ + var re_digits = new RegExp(/^\d+$/, "g"); + var includes = new RegExp(INCLUIR.source, "g"); + var content = editor.getValue(); + + var file; + while (file = includes.exec(content)) { + var files = all_files.archivos.filter( + function(a){ + return a.nombre === file[1]; + }); + for (var f = 0; f < files.length; f++){ + var seen = {}; + var m; + var re_funs = new RegExp(FUNS.source, "g"); + + var file_content = files[f].contenido; + + while (m = re_funs.exec(file_content)) { + if (!re_digits.exec(m[1]) && (!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { + seen[m[1]] = true; + list.push(m[1]); + } + } + } + } + } + + function hintsSetsFromIncludedFiles(all_files, editor, curWord, list){ + var re_digits = new RegExp(/^\d+$/, "g"); + var includes = new RegExp(INCLUIR.source, "g"); + var content = editor.getValue(); + + var file; + while (file = includes.exec(content)) { + var files = all_files.archivos.filter( + function(a){ + return a.nombre === file[1]; + }); + for (var f = 0; f < files.length; f++){ + var seen = {}; + var m; + var re_sets = new RegExp(SET.source, "g"); + + var file_content = files[f].contenido; + + while (m = re_sets.exec(file_content)) { + if (!re_digits.exec(m[1]) && (!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { + seen[m[1]] = true; + list.push(m[1]); + } + } + } + } + } + + function hintsEnumsFromIncludedFiles(all_files, editor, curWord, list){ + var re_digits = new RegExp(/^\d+$/, "g"); + var includes = new RegExp(INCLUIR.source, "g"); + var content = editor.getValue(); + + var file; + while (file = includes.exec(content)) { + var files = all_files.archivos.filter( + function(a){ + return a.nombre === file[1]; + }); + for (var f = 0; f < files.length; f++){ + var seen = {}; + var m; + var re_enums = new RegExp(ENUMS.source, "g"); + + var file_content = files[f].contenido; + + while (m = re_enums.exec(file_content)) { + var enums = m[1].replace(/\s/g,'').split(','); + for (var i = 0; i < enums.length; i++) { + if (!re_digits.exec(enums[i]) && (!curWord || enums[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, enums[i])) { + seen[enums[i]] = true; + list.push(enums[i]); + } + } + } + } + } + } + function normal(source, setState) { if (source.eatWhile(whiteCharRE)) { return null; diff --git a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js index 567e7e95fde114c399bce47ee91cb8c92334ea2b..2fbe7f747c8fcbcb364c341c077caaa16a2e0804 100755 --- a/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js +++ b/Frontend Angular 4/src/app/layout/matefun/codemirror/matefun-mode-ES.js @@ -149,6 +149,9 @@ list.push(default_sets[i]); } } + + // included sets + hintsSetsFromIncludedFiles(editor.options.files, editor, curWord, list); }else{ // get variables of function var previous_block = ""; @@ -194,6 +197,8 @@ } } } + // included enums + hintsEnumsFromIncludedFiles(editor.options.files, editor, curWord, list); // get functions var re_funs = new RegExp(FUNS.source, "g"); for (var dir = -1; dir <= 1; dir += 2) { @@ -208,6 +213,8 @@ } } } + // included functions + hintsFunctionsFromIncludedFiles(editor.options.files, editor, curWord, list); // add default functions var default_functions = hintWords.ES_functions(); for (var i = 0; i < default_functions.length; i++) { @@ -224,6 +231,95 @@ return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; }); + var INCLUIR = /incluir\s+([\w\_\d]+)/; + + function hintsFunctionsFromIncludedFiles(all_files, editor, curWord, list){ + var re_digits = new RegExp(/^\d+$/, "g"); + var includes = new RegExp(INCLUIR.source, "g"); + var content = editor.getValue(); + + var file; + while (file = includes.exec(content)) { + var files = all_files.archivos.filter( + function(a){ + return a.nombre === file[1]; + }); + for (var f = 0; f < files.length; f++){ + var seen = {}; + var m; + var re_funs = new RegExp(FUNS.source, "g"); + + var file_content = files[f].contenido; + + while (m = re_funs.exec(file_content)) { + if (!re_digits.exec(m[1]) && (!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { + seen[m[1]] = true; + list.push(m[1]); + } + } + } + } + } + + function hintsSetsFromIncludedFiles(all_files, editor, curWord, list){ + var re_digits = new RegExp(/^\d+$/, "g"); + var includes = new RegExp(INCLUIR.source, "g"); + var content = editor.getValue(); + + var file; + while (file = includes.exec(content)) { + var files = all_files.archivos.filter( + function(a){ + return a.nombre === file[1]; + }); + for (var f = 0; f < files.length; f++){ + var seen = {}; + var m; + var re_sets = new RegExp(SET.source, "g"); + + var file_content = files[f].contenido; + + while (m = re_sets.exec(file_content)) { + if (!re_digits.exec(m[1]) && (!curWord || m[1].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[1])) { + seen[m[1]] = true; + list.push(m[1]); + } + } + } + } + } + + function hintsEnumsFromIncludedFiles(all_files, editor, curWord, list){ + var re_digits = new RegExp(/^\d+$/, "g"); + var includes = new RegExp(INCLUIR.source, "g"); + var content = editor.getValue(); + + var file; + while (file = includes.exec(content)) { + var files = all_files.archivos.filter( + function(a){ + return a.nombre === file[1]; + }); + for (var f = 0; f < files.length; f++){ + var seen = {}; + var m; + var re_enums = new RegExp(ENUMS.source, "g"); + + var file_content = files[f].contenido; + + while (m = re_enums.exec(file_content)) { + var enums = m[1].replace(/\s/g,'').split(','); + for (var i = 0; i < enums.length; i++) { + if (!re_digits.exec(enums[i]) && (!curWord || enums[i].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, enums[i])) { + seen[enums[i]] = true; + list.push(enums[i]); + } + } + } + } + } + } + function normal(source, setState) { if (source.eatWhile(whiteCharRE)) { return null; diff --git a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts index 11361b7eef9cc96cf535076ade3ed40fef565354..d7ff4324c9aec5e5be6a66913fbc3001fbef99cd 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -103,7 +103,8 @@ export class MateFunComponent { hintOptions: { completeSingle: false, closeCharacters: /[^\d\w\_]/ - } + }, + files: null }; themes = ['3024-day', '3024-night', 'abcdef', 'ambiance-mobile', 'ambiance', 'base16-dark', 'base16-light', 'bespin', 'blackboard', 'cobalt', 'colorforth', 'dracula', 'duotone-dark', 'duotone-light', 'eclipse', 'elegant', 'erlang-dark', 'hopscotch', 'icecoder', 'isotope', 'lesser-dark', 'liquibyte', 'material', 'mbo', 'mdn-like', 'midnight', 'monokai', 'neat', 'neo', 'night', 'panda-syntax', 'paraiso-dark', 'paraiso-light', 'pastel-on-dark', 'railscasts', 'rubyblue', 'seti', 'solarized', 'the-matrix', 'tomorrow-night-bright', 'tomorrow-night-eighties', 'ttcn', 'twilight', 'vibrant-ink', 'xq-dark', 'xq-light', 'yeti', 'zenburn'] version: string = npm.version; @@ -447,8 +448,10 @@ export class MateFunComponent { archivoModificado(event){ if (this.hintsCheck && !event.ctrlKey && !event.altKey){ - if (/^[\w\_\d]$/.test(event.key) || event.key == 'Enter') + if (/^[\w\_\d]$/.test(event.key) || event.key == 'Enter'){ + this.codemirror.instance.options.files = this.archivosTree; this.codemirror.instance.showHint(event); + } if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){ this.modificado = true; }else{