Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/compiler/server/serverCache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,27 @@ let check_module sctx com m_path m_extra p =
with Not_found ->
true
in
let pack_path = match fst m_path with [] -> "" | pack -> String.concat "/" pack ^ "/" in
let contains hay needle =
let nl = String.length needle and hl = String.length hay in
let rec loop i = i + nl <= hl && (String.sub hay i nl = needle || loop (i + 1)) in
nl = 0 || loop 0
in
let dir_hosts_shadow c_path =
pack_path = ""
|| String.starts_with ~prefix:pack_path c_path
|| contains c_path ("/" ^ pack_path)
in
let check_module_shadowing paths m_path m_extra =
List.iter (fun dir ->
let file = (dir.c_path ^ (snd m_path)) ^ ".hx" in
if Sys.file_exists file then begin
let time = file_time file in
if time > m_extra.m_time then begin
ServerMessage.module_path_changed com "" (m_path,m_extra,time,file);
raise (Dirty (Shadowed file))
if dir_hosts_shadow dir.c_path then begin
let file = (dir.c_path ^ (snd m_path)) ^ ".hx" in
if Sys.file_exists file then begin
let time = file_time file in
if time > m_extra.m_time then begin
ServerMessage.module_path_changed com "" (m_path,m_extra,time,file);
raise (Dirty (Shadowed file))
end
end
end
) paths
Expand Down
Loading