Selaa lähdekoodia

rename CompilationServer to CompilationCache

Simon Krajewski 3 vuotta sitten
vanhempi
commit
7a2ef74655

+ 0 - 0
src/context/compilationServer.ml → src/compiler/compilationCache.ml


+ 1 - 1
src/compiler/compilationContext.ml

@@ -45,7 +45,7 @@ and compilation_context = {
 type server_accept = unit -> (bool * (bool -> string option) * (string -> unit) * (unit -> unit))
 
 type server_api = {
-	cache : CompilationServer.t;
+	cache : CompilationCache.t;
 	before_anything : compilation_context -> unit;
 	after_arg_parsing : compilation_context -> unit;
 	after_compilation : compilation_context -> unit;

+ 2 - 2
src/compiler/displayOutput.ml

@@ -3,7 +3,6 @@ open Ast
 open Common
 open Filename
 open CompilationContext
-open CompilationServer
 open Timer
 open DisplayTypes.DisplayMode
 open DisplayTypes.CompletionResultKind
@@ -412,11 +411,12 @@ let process_global_display_mode com tctx =
 		FindReferences.find_implementations tctx com
 	| DMModuleSymbols (Some "") -> ()
 	| DMModuleSymbols filter ->
+		let open CompilationCache in
 		let cs = com.cs in
 		let symbols =
 			let l = cs#get_context_files ((Define.get_signature com.defines) :: (match com.get_macros() with None -> [] | Some com -> [Define.get_signature com.defines])) in
 			List.fold_left (fun acc (file_key,cfile) ->
-				let file = cfile.CompilationServer.c_file_path in
+				let file = cfile.c_file_path in
 				if (filter <> None || DisplayPosition.display_position#is_in_file (com.file_keys#get file)) then
 					(file,DocumentSymbols.collect_module_symbols (Some (file,get_module_name_of_cfile file cfile)) (filter = None) (cfile.c_package,cfile.c_decls)) :: acc
 				else

+ 6 - 6
src/compiler/server.ml

@@ -2,7 +2,7 @@ open Printf
 open Globals
 open Ast
 open Common
-open CompilationServer
+open CompilationCache
 open Timer
 open Type
 open DisplayOutput
@@ -100,7 +100,7 @@ module ServerCompilationContext = struct
 		(* The list of changed directories per-signature *)
 		changed_directories : (Digest.t,cached_directory list) Hashtbl.t;
 		(* A reference to the compilation server instance *)
-		cs : CompilationServer.t;
+		cs : CompilationCache.t;
 		(* A list of class paths per-signature *)
 		class_paths : (Digest.t,string list) Hashtbl.t;
 		(* Increased for each typed module *)
@@ -119,7 +119,7 @@ module ServerCompilationContext = struct
 
 	let create verbose = {
 		verbose = verbose;
-		cs = new CompilationServer.cache;
+		cs = new CompilationCache.cache;
 		class_paths = Hashtbl.create 0;
 		changed_directories = Hashtbl.create 0;
 		compilation_step = 0;
@@ -255,10 +255,10 @@ let get_changed_directories sctx (ctx : Typecore.typer) =
 							if not (cs#has_directory sign dir) then begin
 								let time = stat dir in
 								ServerMessage.added_directory com "" dir;
-								cs#add_directory sign (CompilationServer.create_directory dir time)
+								cs#add_directory sign (CompilationCache.create_directory dir time)
 							end;
 						) sub_dirs;
-						(CompilationServer.create_directory dir.c_path time') :: acc
+						(CompilationCache.create_directory dir.c_path time') :: acc
 					end else
 						acc
 				with Unix.Unix_error _ ->
@@ -278,7 +278,7 @@ let get_changed_directories sctx (ctx : Typecore.typer) =
 				let add_dir path =
 					try
 						let time = stat path in
-						dirs := CompilationServer.create_directory path time :: !dirs
+						dirs := CompilationCache.create_directory path time :: !dirs
 					with Unix.Unix_error _ ->
 						()
 				in

+ 1 - 1
src/compiler/serverMessage.ml

@@ -1,6 +1,6 @@
 open Globals
 open Common
-open CompilationServer
+open CompilationCache
 open Type
 open Json
 

+ 4 - 4
src/compiler/tasks.ml

@@ -1,6 +1,6 @@
 
 open Type
-open CompilationServer
+open CompilationCache
 
 class gc_task (max_working_memory : float) (heap_size : float) = object(self)
 	inherit server_task ["gc"] 100
@@ -30,7 +30,7 @@ class gc_task (max_working_memory : float) (heap_size : float) = object(self)
 		ServerMessage.gc_stats (Timer.get_time() -. t0) stats do_compact new_space_overhead
 end
 
-class class_maintenance_task (cs : CompilationServer.t) (c : tclass) = object(self)
+class class_maintenance_task (cs : CompilationCache.t) (c : tclass) = object(self)
 	inherit server_task ["module maintenance"] 70
 
 	method private execute =
@@ -47,7 +47,7 @@ class class_maintenance_task (cs : CompilationServer.t) (c : tclass) = object(se
 		Option.may field c.cl_constructor;
 end
 
-class module_maintenance_task (cs : CompilationServer.t) (m : module_def) = object(self)
+class module_maintenance_task (cs : CompilationCache.t) (m : module_def) = object(self)
 	inherit server_task ["module maintenance"] 80
 
 	method private execute =
@@ -59,7 +59,7 @@ class module_maintenance_task (cs : CompilationServer.t) (m : module_def) = obje
 		) m.m_types
 end
 
-class server_exploration_task (cs : CompilationServer.t) = object(self)
+class server_exploration_task (cs : CompilationCache.t) = object(self)
 	inherit server_task ["server explore"] 90
 
 	method private execute =

+ 2 - 3
src/context/common.ml

@@ -18,7 +18,6 @@
  *)
 open Extlib_leftovers
 open Ast
-open CompilationServer
 open Type
 open Globals
 open Define
@@ -294,7 +293,7 @@ type report_mode =
 
 type context = {
 	mutable stage : compiler_stage;
-	mutable cache : context_cache option;
+	mutable cache : CompilationCache.context_cache option;
 	(* config *)
 	version : int;
 	args : string list;
@@ -353,7 +352,7 @@ type context = {
 	(* typing *)
 	mutable basic : basic_types;
 	memory_marker : float array;
-	cs : CompilationServer.t;
+	cs : CompilationCache.t;
 }
 
 exception Abort of string * pos

+ 0 - 1
src/context/commonCache.ml

@@ -1,6 +1,5 @@
 open Globals
 open Common
-open CompilationServer
 open Type
 
 let handle_native_lib com lib =

+ 4 - 3
src/context/display/diagnostics.ml

@@ -101,7 +101,8 @@ let prepare_field dctx com cf = match cf.cf_expr with
 		DeprecationCheck.run_on_expr ~force:true com e
 
 let collect_diagnostics dctx com =
-		List.iter (function
+	let open CompilationCache in
+	List.iter (function
 		| TClassDecl c when DiagnosticsPrinter.is_diagnostics_file com (com.file_keys#get c.cl_pos.pfile) ->
 			List.iter (prepare_field dctx com) c.cl_ordered_fields;
 			List.iter (prepare_field dctx com) c.cl_ordered_statics;
@@ -116,8 +117,8 @@ let collect_diagnostics dctx com =
 				ParserEntry.is_true (ParserEntry.eval defines e)
 			in
 			Hashtbl.iter (fun file_key cfile ->
-				if DisplayPosition.display_position#is_in_file (com.file_keys#get cfile.CompilationServer.c_file_path) then begin
-					let dead_blocks = cfile.CompilationServer.c_pdi.pd_dead_blocks in
+				if DisplayPosition.display_position#is_in_file (com.file_keys#get cfile.c_file_path) then begin
+					let dead_blocks = cfile.c_pdi.pd_dead_blocks in
 					let dead_blocks = List.filter (fun (_,e) -> not (is_true display_defines e)) dead_blocks in
 					try
 						let dead_blocks2 = Hashtbl.find dctx.dead_blocks file_key in

+ 2 - 2
src/context/display/displayJson.ml

@@ -44,7 +44,7 @@ let send_string j =
 let send_json json =
 	send_string (string_of_json json)
 
-class display_handler (jsonrpc : jsonrpc_handler) com (cs : CompilationServer.t) = object(self)
+class display_handler (jsonrpc : jsonrpc_handler) com (cs : CompilationCache.t) = object(self)
 	val cs = cs;
 
 	method get_cs = cs
@@ -82,7 +82,7 @@ type handler_context = {
 }
 
 let handler =
-	let open CompilationServer in
+	let open CompilationCache in
 	let h = Hashtbl.create 0 in
 	let l = [
 		"initialize", (fun hctx ->

+ 1 - 1
src/context/display/displayTexpr.ml

@@ -5,7 +5,7 @@ open Type
 open Typecore
 open DisplayPosition
 open CompletionItem
-open CompilationServer
+open CompilationCache
 open ClassFieldOrigin
 
 let find_field_by_position sc p =

+ 2 - 2
src/context/display/displayToplevel.ml

@@ -18,7 +18,7 @@
 *)
 open Ast
 open Common
-open CompilationServer
+open CompilationCache
 open Type
 open Typecore
 open CompletionItem
@@ -472,7 +472,7 @@ let collect ctx tk with_type sort =
 		| s :: sl -> add_package (List.rev sl,s)
 	in
 	List.iter (fun ((file_key,cfile),_) ->
-		let module_name = CompilationServer.get_module_name_of_cfile cfile.c_file_path cfile in
+		let module_name = CompilationCache.get_module_name_of_cfile cfile.c_file_path cfile in
 		let dot_path = s_type_path (cfile.c_package,module_name) in
 		(* In legacy mode we only show toplevel types. *)
 		if is_legacy_completion && cfile.c_package <> [] then begin

+ 0 - 1
src/context/display/findReferences.ml

@@ -4,7 +4,6 @@ open DisplayTypes
 open Common
 open Type
 open Typecore
-open CompilationServer
 open ImportHandling
 
 let find_possible_references tctx cs =

+ 2 - 1
src/context/display/syntaxExplorer.ml

@@ -160,13 +160,14 @@ let find_in_syntax symbols (pack,decls) =
 	) decls
 
 let explore_uncached_modules tctx cs symbols =
+	let open CompilationCache in
 	DisplayToplevel.init_or_update_server cs tctx.com ["display";"references"];
 	let cc = CommonCache.get_cache tctx.com in
 	let files = cc#get_files in
 	let modules = cc#get_modules in
 	let t = Timer.timer ["display";"references";"candidates"] in
 	let acc = Hashtbl.fold (fun file_key cfile acc ->
-		let module_name = CompilationServer.get_module_name_of_cfile cfile.CompilationServer.c_file_path cfile in
+		let module_name = get_module_name_of_cfile cfile.c_file_path cfile in
 		if Hashtbl.mem modules (cfile.c_package,module_name) then
 			acc
 		else try

+ 2 - 2
src/context/memory.ml

@@ -1,5 +1,5 @@
 open Globals
-open CompilationServer
+open CompilationCache
 open Common
 open Type
 open Genjson
@@ -93,7 +93,7 @@ let fmt_word f =
 let size v =
 	fmt_size (mem_size v)
 
-let get_memory_json (cs : CompilationServer.t) mreq =
+let get_memory_json (cs : CompilationCache.t) mreq =
 	begin match mreq with
 	| MCache ->
 		let old_gc = Gc.get() in

+ 4 - 3
src/typing/macroContext.ml

@@ -381,10 +381,11 @@ let make_macro_api ctx p =
 				| None -> ()
 				| Some(_,mctx) -> add mctx;
 			in
+			let open CompilationCache in
 			match Obj.magic i with
-			| CompilationServer.NormalContext -> add ctx
-			| CompilationServer.MacroContext -> add_macro ctx
-			| CompilationServer.NormalAndMacroContext -> add ctx; add_macro ctx;
+			| NormalContext -> add ctx
+			| MacroContext -> add_macro ctx
+			| NormalAndMacroContext -> add ctx; add_macro ctx;
 		);
 		MacroApi.decode_expr = Interp.decode_expr;
 		MacroApi.encode_expr = Interp.encode_expr;