From 46cb2898c31f482b14e2e09506ad067db89c50e6 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Thu, 10 Sep 2020 13:57:27 +0800 Subject: [PATCH 1/2] Partially address #4624 (allow names like 404.ml); better handling emacs backup files --- jscomp/bsb/bsb_db_util.ml | 11 +++++++++++ jscomp/ext/ext_filename.ml | 1 + 2 files changed, 12 insertions(+) diff --git a/jscomp/bsb/bsb_db_util.ml b/jscomp/bsb/bsb_db_util.ml index 8c84845a24b..5b3b857b5a4 100644 --- a/jscomp/bsb/bsb_db_util.ml +++ b/jscomp/bsb/bsb_db_util.ml @@ -71,12 +71,23 @@ let check (x : module_info) let warning_unused_file : _ format = "@{IGNORED@}: file %s under %s is ignored because it can't be turned into a valid module name. \n\ The build system transforms a file name into a module name by upper-casing the first letter@." +(* TODO: add a link for more explanations *) + +let is_editor_temporary_files basename = + Ext_string.starts_with basename ".#" +(* + Example: .#hi.ml + Note for other files like ~, .swp + it does not pass the suffix rules +*) let add_basename ~(dir:string) (map : t) ?(error_on_invalid_suffix) basename : t = + if is_editor_temporary_files basename then map + else let info = ref Bsb_db.Impl in let syntax_kind = ref Bsb_db.Ml in let invalid_suffix = ref false in diff --git a/jscomp/ext/ext_filename.ml b/jscomp/ext/ext_filename.ml index 37afc62b328..c01eb358bfc 100644 --- a/jscomp/ext/ext_filename.ml +++ b/jscomp/ext/ext_filename.ml @@ -144,6 +144,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower From 41cb0f4e2bf12c205066f5d6425e04ae36d5e3cf Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Thu, 10 Sep 2020 13:57:33 +0800 Subject: [PATCH 2/2] snapshot --- lib/4.06.1/bsb.ml | 12 ++++++++++++ lib/4.06.1/bsb_helper.ml | 1 + lib/4.06.1/unstable/all_ounit_tests.ml | 1 + lib/4.06.1/unstable/bspack.ml | 1 + lib/4.06.1/unstable/js_compiler.ml | 1 + lib/4.06.1/unstable/js_refmt_compiler.ml | 1 + lib/4.06.1/whole_compiler.ml | 1 + 7 files changed, 18 insertions(+) diff --git a/lib/4.06.1/bsb.ml b/lib/4.06.1/bsb.ml index efcba0b4969..327565e2b80 100644 --- a/lib/4.06.1/bsb.ml +++ b/lib/4.06.1/bsb.ml @@ -6763,6 +6763,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower @@ -10450,12 +10451,23 @@ let check (x : module_info) let warning_unused_file : _ format = "@{IGNORED@}: file %s under %s is ignored because it can't be turned into a valid module name. \n\ The build system transforms a file name into a module name by upper-casing the first letter@." +(* TODO: add a link for more explanations *) + +let is_editor_temporary_files basename = + Ext_string.starts_with basename ".#" +(* + Example: .#hi.ml + Note for other files like ~, .swp + it does not pass the suffix rules +*) let add_basename ~(dir:string) (map : t) ?(error_on_invalid_suffix) basename : t = + if is_editor_temporary_files basename then map + else let info = ref Bsb_db.Impl in let syntax_kind = ref Bsb_db.Ml in let invalid_suffix = ref false in diff --git a/lib/4.06.1/bsb_helper.ml b/lib/4.06.1/bsb_helper.ml index 5fe65073334..1579eaf38ef 100644 --- a/lib/4.06.1/bsb_helper.ml +++ b/lib/4.06.1/bsb_helper.ml @@ -2133,6 +2133,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower diff --git a/lib/4.06.1/unstable/all_ounit_tests.ml b/lib/4.06.1/unstable/all_ounit_tests.ml index fcf70a770bc..d4580c7ed0e 100644 --- a/lib/4.06.1/unstable/all_ounit_tests.ml +++ b/lib/4.06.1/unstable/all_ounit_tests.ml @@ -16284,6 +16284,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower diff --git a/lib/4.06.1/unstable/bspack.ml b/lib/4.06.1/unstable/bspack.ml index aa2b54abb38..78c12c77798 100644 --- a/lib/4.06.1/unstable/bspack.ml +++ b/lib/4.06.1/unstable/bspack.ml @@ -10275,6 +10275,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 5cbc1c4355f..974c14466ac 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -69437,6 +69437,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower diff --git a/lib/4.06.1/unstable/js_refmt_compiler.ml b/lib/4.06.1/unstable/js_refmt_compiler.ml index f05ad253900..5a23e244dba 100644 --- a/lib/4.06.1/unstable/js_refmt_compiler.ml +++ b/lib/4.06.1/unstable/js_refmt_compiler.ml @@ -69437,6 +69437,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index 3931dad422a..3060c0e1a9e 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -294987,6 +294987,7 @@ let valid_module_name name len = Upper else Invalid | 'a' .. 'z' + | '0' .. '9' -> if valid_module_name_aux name 1 len then Lower