diff --git a/src/CommandLineInterface.hx b/src/CommandLineInterface.hx index 3c186b6..5ac9b41 100644 --- a/src/CommandLineInterface.hx +++ b/src/CommandLineInterface.hx @@ -30,6 +30,12 @@ class CommandLineInterface { parser.load_processors_from_resources(); var results = parser.parse(code); + + if (results.length == 0) { + neko.Lib.print("Your code didn't have any tokens in it!"); + neko.Sys.exit(0); + } + var ignored_modules = parser.ignored_modules; var ignored_tokens_in_modules = parser.ignored_tokens_in_modules; diff --git a/src/JavaScriptTarget.hx b/src/JavaScriptTarget.hx index dd09869..129decb 100644 --- a/src/JavaScriptTarget.hx +++ b/src/JavaScriptTarget.hx @@ -94,177 +94,183 @@ class JavaScriptTarget { Display code version information. **/ static public function display_version_information() { - var version_info = new CodeVersionInformation(current_results, ignored_modules, ignored_tokens_in_modules); - - var output = "
Your code requires the following minimum PHP & PECL module versions:
"; - - var minimum = version_info.final_versions.get("minimum"); - - output += "
"; - - // module list - var all_modules_hash = new Hash(); - - for (module in minimum.keys()) { all_modules_hash.set(module, true); } - for (module in ignored_modules.keys()) { all_modules_hash.set(module, true); } - for (module in manually_ignored_modules.keys()) { all_modules_hash.set(module, true); } - - var all_modules = new Array(); - - for (module in all_modules_hash.keys()) { all_modules.push(module); } - - all_modules.sort(CodeVersionInformation.module_name_sorter); - + var output : String; var ignored_tokens = new Array(); var ignored_modules_array = new Array(); - for (module in manually_ignored_modules.keys()) { - if (manually_ignored_modules.get(module) == true) { - ignored_modules_array.push("@" + module); - } - } - output += ""; - output += ""; + if (current_results.length == 0) { + output = "
Your code doesn't have any tokens in it!
"; + } else { + var version_info = new CodeVersionInformation(current_results, ignored_modules, ignored_tokens_in_modules); - for (module in all_modules) { - var is_ignored = false; - var is_ignored_in_source = false; - var show_checkbox = true; - var is_checked = false; + output = "
Your code requires the following minimum PHP & PECL module versions:
"; - if (ignored_modules.exists(module) == true) { - is_ignored = true; - is_ignored_in_source = true; - show_checkbox = false; - } - if (manually_ignored_modules.get(module) == true) { - is_ignored = true; - is_checked = true; - } + var minimum = version_info.final_versions.get("minimum"); - output += ""; + output += ""; - if (show_checkbox && (module.toLowerCase() != "php")) { - output += ""; - } else { - output += ""; - } + // module list + var all_modules_hash = new Hash(); - if (is_ignored) { - if (is_ignored_in_source) { - output += ""; - } else { - output += ""; + for (module in minimum.keys()) { all_modules_hash.set(module, true); } + for (module in ignored_modules.keys()) { all_modules_hash.set(module, true); } + for (module in manually_ignored_modules.keys()) { all_modules_hash.set(module, true); } + + var all_modules = new Array(); + + for (module in all_modules_hash.keys()) { all_modules.push(module); } + + all_modules.sort(CodeVersionInformation.module_name_sorter); + + for (module in manually_ignored_modules.keys()) { + if (manually_ignored_modules.get(module) == true) { + ignored_modules_array.push("@" + module); } - } else { - if (minimum.exists(module)) { - output += ""; + } + + output += "
ModuleIgnore?Version
" + module + " (ignored in source)(ignored)" + minimum.get(module) + "
"; + output += ""; + + for (module in all_modules) { + var is_ignored = false; + var is_ignored_in_source = false; + var show_checkbox = true; + var is_checked = false; + + if (ignored_modules.exists(module) == true) { + is_ignored = true; + is_ignored_in_source = true; + show_checkbox = false; + } + if (manually_ignored_modules.get(module) == true) { + is_ignored = true; + is_checked = true; + } + + output += ""; + + if (show_checkbox && (module.toLowerCase() != "php")) { + output += ""; } else { output += ""; } - } - output += ""; - } - - output += "
ModuleIgnore?Version
" + module + " 
"; - - // maximum version info - var maximum = version_info.final_versions.get("maximum"); - var printed_message = false; - - for (module in maximum.keys()) { - if (!printed_message) { - output += "Your code also can't use PHP or PECL modules newer than:
    "; - printed_message = true; - } - output += ("
  • " + module + ": " + maximum.get(module) + "
  • "); - } - - if (printed_message) { output += "
"; } - - if (!version_info.is_valid()) { - output += "

This code may not run!

"; - } - - // tokens list - output += ""; - - output += ""; - - for (module in version_info.all_modules) { - var classes = ["filter"]; - if (show_only_modules.exists(module)) { - if (show_only_modules.get(module)) { - classes.push("is-filtering"); - } - } - - if (manually_ignored_modules.get(module) != true) { - output += ""; - } - } - - output += ""; - - var id_index = 0; - for (result in current_results) { - var ok_to_show = true; - var modules_check_out = true; - var any_visible_modules = false; - - if (!result.is_enabled) { ignored_tokens.push(result.token); } - - var max_versions = CodeVersionInformation.split_version_string(result.version); - - for (module in show_only_modules.keys()) { - if (show_only_modules.get(module)) { - ok_to_show = false; - if (!max_versions.exists(module)) { modules_check_out = false; } - } - } - - for (module in max_versions.keys()) { - if (ignored_modules.exists(module)) { - if (!ignored_modules.get(module)) { any_visible_modules = true; } + if (is_ignored) { + if (is_ignored_in_source) { + output += ""; + } else { + output += ""; + } } else { - any_visible_modules = true; - } - } - - if (modules_check_out) { ok_to_show = true; } - if (!any_visible_modules) { ok_to_show = false; } - - if (ok_to_show) { - var result_class = (result.is_enabled ? "enabled" : "disabled"); - var result_id = "result-" + id_index; - var enabled_id = "result-enabled-" + id_index; - output += ""; - - output += ""; - - output += ""; - - for (module in version_info.all_modules) { - if (manually_ignored_modules.get(module) != true) { - output += ""; + if (minimum.exists(module)) { + output += ""; + } else { + output += ""; } } output += ""; } - id_index++; - } - output += "
TokenIgnore?" + module + "
(ignored in source)(ignored)
" + result.token + ""; - if (max_versions.exists(module)) { - output += max_versions.get(module); - } else { - output += " "; - } - output += "" + minimum.get(module) + " 
"; - output += ""; + output += ""; + + // maximum version info + var maximum = version_info.final_versions.get("maximum"); + var printed_message = false; + + for (module in maximum.keys()) { + if (!printed_message) { + output += "Your code also can't use PHP or PECL modules newer than:
    "; + printed_message = true; + } + output += ("
  • " + module + ": " + maximum.get(module) + "
  • "); + } + + if (printed_message) { output += "
"; } + + if (!version_info.is_valid()) { + output += "

This code may not run!

"; + } + + // tokens list + output += ""; + + output += ""; + + for (module in version_info.all_modules) { + var classes = ["filter"]; + if (show_only_modules.exists(module)) { + if (show_only_modules.get(module)) { + classes.push("is-filtering"); + } + } + + if (manually_ignored_modules.get(module) != true) { + output += ""; + } + } + + output += ""; + + var id_index = 0; + for (result in current_results) { + var ok_to_show = true; + var modules_check_out = true; + var any_visible_modules = false; + + if (!result.is_enabled) { ignored_tokens.push(result.token); } + + var max_versions = CodeVersionInformation.split_version_string(result.version); + + for (module in show_only_modules.keys()) { + if (show_only_modules.get(module)) { + ok_to_show = false; + if (!max_versions.exists(module)) { modules_check_out = false; } + } + } + + for (module in max_versions.keys()) { + if (ignored_modules.exists(module)) { + if (!ignored_modules.get(module)) { any_visible_modules = true; } + } else { + any_visible_modules = true; + } + } + + if (modules_check_out) { ok_to_show = true; } + if (!any_visible_modules) { ok_to_show = false; } + + if (ok_to_show) { + var result_class = (result.is_enabled ? "enabled" : "disabled"); + var result_id = "result-" + id_index; + var enabled_id = "result-enabled-" + id_index; + output += ""; + + output += ""; + + output += ""; + + for (module in version_info.all_modules) { + if (manually_ignored_modules.get(module) != true) { + output += ""; + } + } + + output += ""; + } + id_index++; + } + output += "
TokenIgnore?" + module + "
" + result.token + ""; + if (max_versions.exists(module)) { + output += max_versions.get(module); + } else { + output += " "; + } + output += "
"; + + output += ""; + } // update the how-to-ignore information var permanent_ignore_div = js.Lib.document.getElementById("permanent-ignore");