Procházet zdrojové kódy

[display] refactor

* merge display_field_kind and IdentifierType
* rename IdentifierType to CompletionKind
* rename some CompletionKind variants
* make genjson not depend on common
* move JSON files to its own package
* support "textDocument/completion"
Simon Krajewski před 7 roky
rodič
revize
d388791029

+ 1 - 1
Makefile

@@ -29,7 +29,7 @@ STATICLINK?=0
 # Configuration
 
 # Modules in these directories should only depend on modules that are in directories to the left
-HAXE_DIRECTORIES=core syntax context codegen codegen/gencommon generators optimization filters macro macro/eval typing compiler
+HAXE_DIRECTORIES=core core/json syntax context codegen codegen/gencommon generators optimization filters macro macro/eval typing compiler
 EXTLIB_LIBS=extlib-leftovers extc neko javalib swflib ttflib ilib objsize pcre ziplib
 OCAML_LIBS=unix str threads dynlink
 OPAM_LIBS=sedlex xml-light extlib rope ptmap sha

+ 56 - 32
src/compiler/displayOutput.ml

@@ -2,6 +2,7 @@ open Globals
 open Common
 open Timer
 open DisplayTypes.DisplayMode
+open DisplayTypes.CompletionKind
 open Type
 open Display
 open DisplayTypes
@@ -39,18 +40,34 @@ let print_keywords () =
 let print_fields fields =
 	let b = Buffer.create 0 in
 	Buffer.add_string b "<list>\n";
-	List.iter (fun (n,k,d) ->
-		let s_kind, t = match k with
-			| FKVar t -> "var", s_type (print_context()) t
-			| FKMethod t -> "method", s_type (print_context()) t
-			| FKType t -> "type", s_type (print_context()) t
-			| FKPackage -> "package", ""
-			| FKModule -> "type", ""
-			| FKMetadata -> "metadata", ""
-			| FKTimer s -> "timer", s
-		in
-		Buffer.add_string b (Printf.sprintf "<i n=\"%s\" k=\"%s\"><t>%s</t><d>%s</d></i>\n" n s_kind (htmlescape t) (htmlescape d))
-	) (List.sort (fun (a,ak,_) (b,bk,_) -> compare (display_field_kind_index ak,a) (display_field_kind_index bk,b)) fields);
+	let convert k = match k with
+		| ITClassMember cf | ITClassStatic cf | ITEnumAbstractField(_,cf) ->
+			let kind = match cf.cf_kind with
+				| Method _ -> "method"
+				| Var _ -> "var"
+			in
+			kind,cf.cf_name,s_type (print_context()) cf.cf_type,cf.cf_doc
+		| ITEnumField(en,ef) ->
+			let kind = match follow ef.ef_type with
+				| TFun _ -> "method"
+				| _ -> "var"
+			in
+			kind,ef.ef_name,s_type (print_context()) ef.ef_type,ef.ef_doc
+		| ITType(mt,_) ->
+			let infos = t_infos mt in
+			"type",snd infos.mt_path,s_type_path infos.mt_path,infos.mt_doc
+		| ITPackage s -> "package",s,"",None
+		| ITModule s -> "type",s,"",None
+		| ITMetadata(s,doc) -> "metadata",s,"",doc
+		| ITTimer(name,value) -> "timer",name,"",Some value
+		| ITGlobal _ | ITLiteral _ | ITLocal _ -> assert false
+	in
+	let fields = List.sort (fun k1 k2 -> compare (legacy_sort k1) (legacy_sort k2)) fields in
+	let fields = List.map convert fields in
+	List.iter (fun(k,n,t,d) ->
+		let d = match d with None -> "" | Some d -> d in
+		Buffer.add_string b (Printf.sprintf "<i n=\"%s\" k=\"%s\"><t>%s</t><d>%s</d></i>\n" n k (htmlescape t) (htmlescape d))
+	) fields;
 	Buffer.add_string b "</list>\n";
 	Buffer.contents b
 
@@ -71,33 +88,36 @@ let print_toplevel il =
 		end
 	in
 	List.iter (fun id -> match id with
-		| IdentifierType.ITLocal v ->
+		| ITLocal v ->
 			if check_ident v.v_name then Buffer.add_string b (Printf.sprintf "<i k=\"local\" t=\"%s\">%s</i>\n" (s_type v.v_type) v.v_name);
-		| IdentifierType.ITMember cf ->
+		| ITClassMember cf ->
 			if check_ident cf.cf_name then Buffer.add_string b (Printf.sprintf "<i k=\"member\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
-		| IdentifierType.ITStatic cf ->
+		| ITClassStatic cf ->
 			if check_ident cf.cf_name then Buffer.add_string b (Printf.sprintf "<i k=\"static\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
-		| IdentifierType.ITEnum(en,ef) ->
+		| ITEnumField(en,ef) ->
 			if check_ident ef.ef_name then Buffer.add_string b (Printf.sprintf "<i k=\"enum\" t=\"%s\"%s>%s</i>\n" (s_type ef.ef_type) (s_doc ef.ef_doc) ef.ef_name);
-		| IdentifierType.ITEnumAbstract(a,cf) ->
+		| ITEnumAbstractField(a,cf) ->
 			if check_ident cf.cf_name then Buffer.add_string b (Printf.sprintf "<i k=\"enumabstract\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
-		| IdentifierType.ITGlobal(mt,s,t) ->
+		| ITGlobal(mt,s,t) ->
 			if check_ident s then Buffer.add_string b (Printf.sprintf "<i k=\"global\" p=\"%s\" t=\"%s\">%s</i>\n" (s_type_path (t_infos mt).mt_path) (s_type t) s);
-		| IdentifierType.ITType(mt,rm) ->
+		| ITType(mt,rm) ->
 			let infos = t_infos mt in
 			let import,name = match rm with
-				| IdentifierType.RMOtherModule path ->
+				| RMOtherModule path ->
 					let label_path = if path = infos.mt_path then path else (fst path @ [snd path],snd infos.mt_path) in
 					Printf.sprintf " import=\"%s\"" (s_type_path path),s_type_path label_path
 				| _ -> "",(snd infos.mt_path)
 			in
 			Buffer.add_string b (Printf.sprintf "<i k=\"type\" p=\"%s\"%s%s>%s</i>\n" (s_type_path infos.mt_path) import ("") name);
-		| IdentifierType.ITPackage s ->
+		| ITPackage s ->
 			Buffer.add_string b (Printf.sprintf "<i k=\"package\">%s</i>\n" s)
-		| IdentifierType.ITLiteral s ->
+		| ITLiteral s ->
 			Buffer.add_string b (Printf.sprintf "<i k=\"literal\">%s</i>\n" s)
-		| IdentifierType.ITTimer s ->
+		| ITTimer(s,_) ->
 			Buffer.add_string b (Printf.sprintf "<i k=\"timer\">%s</i>\n" s)
+		| ITMetadata _ | ITModule _ ->
+			(* compat: don't add *)
+			()
 	) il;
 	Buffer.add_string b "</il>";
 	Buffer.contents b
@@ -344,8 +364,8 @@ module TypePathHandler = struct
 		if packs = [] && modules = [] then
 			(abort ("No classes found in " ^ String.concat "." p) null_pos)
 		else
-			let packs = List.map (fun n -> n,Display.FKPackage,"") packs in
-			let modules = List.map (fun n -> n,Display.FKModule,"") modules in
+			let packs = List.map (fun n -> ITPackage n) packs in
+			let modules = List.map (fun n -> ITModule n) modules in
 			Some (packs @ modules)
 
 	(** raise field completion listing module sub-types and static fields *)
@@ -385,14 +405,11 @@ module TypePathHandler = struct
 					[]
 				else
 					List.map (fun t ->
-						let infos = t_infos t in
-						(snd infos.mt_path), Display.FKModule, (Option.default "" infos.mt_doc)
+						ITType(t,RMOtherModule m.m_path)
 					) public_types
 			in
 			let make_field_doc cf =
-				cf.cf_name,
-				(match cf.cf_kind with Method _ -> Display.FKMethod cf.cf_type | Var _ -> Display.FKVar cf.cf_type),
-				(match cf.cf_doc with Some s -> s | None -> "")
+				ITClassStatic cf
 			in
 			let fields = match !statics with
 				| None -> types
@@ -808,5 +825,12 @@ let print_type com t p doc = match com.json_out with
 	| Some(f,_) -> f (JObject [
 		"documentation",jopt jstring doc;
 		"range",generate_pos_as_range p;
-		"type",generate_type (create_context com) t;
-	])
+		"type",generate_type (create_context ()) t;
+	])
+
+let print_fields com fields = match com.json_out with
+	| None ->
+		print_fields fields
+	| Some(f,_) ->
+		let j = List.map (CompletionKind.to_json (Genjson.create_context ())) fields in
+		f (jarray j)

+ 7 - 8
src/compiler/main.ml

@@ -855,7 +855,7 @@ try
 			| Some file ->
 				Common.log com ("Generating json : " ^ file);
 				Path.mkdir_from_path file;
-				Genjson.generate com file
+				Genjson.generate com.types file
 		end;
 		if not !no_output then generate tctx ext !xml_out !interp !swf_header;
 	end;
@@ -903,17 +903,16 @@ with
 	| Display.DisplayPackage pack ->
 		raise (DisplayOutput.Completion (String.concat "." pack))
 	| Display.DisplayFields fields ->
-		let fields = List.map (
-			fun (name,kind,doc) -> name, kind, (Option.default "" doc)
-		) fields in
 		let fields =
 			if !measure_times then begin
 				Timer.close_times();
-				(List.map (fun (name,value) -> ("@TIME " ^ name, Display.FKTimer value, "")) (DisplayOutput.get_timer_fields !start_time)) @ fields
+				(List.map (fun (name,value) ->
+					DisplayTypes.CompletionKind.ITTimer("@TIME " ^ name,value)
+				) (DisplayOutput.get_timer_fields !start_time)) @ fields
 			end else
 				fields
 		in
-		raise (DisplayOutput.Completion (DisplayOutput.print_fields fields))
+		raise (DisplayOutput.Completion (DisplayOutput.print_fields ctx.com fields))
 	| Display.DisplayType (t,p,doc) ->
 		let doc = match doc with Some _ -> doc | None -> DisplayOutput.find_doc t in
 		raise (DisplayOutput.Completion (DisplayOutput.print_type ctx.com t p doc))
@@ -928,7 +927,7 @@ with
 		let il =
 			if !measure_times then begin
 				Timer.close_times();
-				(List.map (fun (name,value) -> DisplayTypes.IdentifierType.ITTimer ("@TIME " ^ name ^ ": " ^ value)) (DisplayOutput.get_timer_fields !start_time)) @ il
+				(List.map (fun (name,value) -> DisplayTypes.CompletionKind.ITTimer ("@TIME " ^ name,value)) (DisplayOutput.get_timer_fields !start_time)) @ il
 			end else
 				il
 		in
@@ -944,7 +943,7 @@ with
 				error ctx msg p;
 				None
 		in
-		Option.may (fun fields -> raise (DisplayOutput.Completion (DisplayOutput.print_fields fields))) fields
+		Option.may (fun fields -> raise (DisplayOutput.Completion (DisplayOutput.print_fields ctx.com fields))) fields
 	| Display.ModuleSymbols s | Display.Diagnostics s | Display.Statistics s | Display.Metadata s ->
 		raise (DisplayOutput.Completion s)
 	| EvalExceptions.Sys_exit i | Hlinterp.Sys_exit i ->

+ 1 - 1
src/context/common.ml

@@ -110,7 +110,7 @@ type shared_display_information = {
 }
 
 type display_information = {
-	mutable unresolved_identifiers : (string * pos * (string * DisplayTypes.IdentifierType.t) list) list;
+	mutable unresolved_identifiers : (string * pos * (string * DisplayTypes.CompletionKind.t) list) list;
 	mutable interface_field_implementations : (tclass * tclass_field * tclass * tclass_field option) list;
 }
 

+ 6 - 21
src/context/display.ml

@@ -1,28 +1,11 @@
 open Ast
 open Common
 open DisplayTypes.DisplayMode
+open DisplayTypes.CompletionKind
 open Type
 open Typecore
 open Globals
 
-type display_field_kind =
-	| FKVar of t
-	| FKMethod of t
-	| FKType of t
-	| FKModule
-	| FKPackage
-	| FKMetadata
-	| FKTimer of string
-
-let display_field_kind_index = function
-	| FKVar _ -> 0
-	| FKMethod _ -> 1
-	| FKType _ -> 2
-	| FKModule -> 3
-	| FKPackage -> 4
-	| FKMetadata -> 5
-	| FKTimer _ -> 6
-
 let reference_position = ref null_pos
 
 exception Diagnostics of string
@@ -32,8 +15,8 @@ exception Metadata of string
 exception DisplaySignatures of (tsignature * documentation) list * int
 exception DisplayType of t * pos * string option
 exception DisplayPosition of pos list
-exception DisplayFields of (string * display_field_kind * documentation) list
-exception DisplayToplevel of DisplayTypes.IdentifierType.t list
+exception DisplayFields of DisplayTypes.CompletionKind.t list
+exception DisplayToplevel of DisplayTypes.CompletionKind.t list
 exception DisplayPackage of string list
 
 let is_display_file file =
@@ -215,7 +198,9 @@ module DisplayEmitter = struct
 			end
 		| DMDefault ->
 			let all,_ = Meta.get_documentation_list() in
-			let all = List.map (fun (s,doc) -> (s,FKMetadata,Some doc)) all in
+			let all = List.map (fun (s,doc) ->
+				ITMetadata(s,Some doc)
+			) all in
 			raise (DisplayFields all)
 		| _ ->
 			()

+ 5 - 6
src/context/displayFields.ml

@@ -21,14 +21,12 @@ open Globals
 open Error
 open Typecore
 open Type
+open DisplayTypes.CompletionKind
 
 let get_submodule_fields ctx path =
 	let m = Hashtbl.find ctx.g.modules path in
 	let tl = List.filter (fun t -> path <> (t_infos t).mt_path && not (t_infos t).mt_private) m.m_types in
-	let tl = List.map (fun mt ->
-		let infos = t_infos mt in
-		(snd infos.mt_path),Display.FKType (type_of_module_type mt),infos.mt_doc
-	) tl in
+	let tl = List.map (fun mt -> ITType(mt,RMOtherModule m.m_path)) tl in
 	tl
 
 let collect ctx e_ast e dk with_type p =
@@ -183,10 +181,11 @@ let collect ctx e_ast e dk with_type p =
 			fields
 	in
 	let fields = PMap.fold (fun f acc -> if Meta.has Meta.NoCompletion f.cf_meta then acc else f :: acc) fields [] in
+	let open Display in
 	let get_field acc f =
 		List.fold_left (fun acc f ->
-			let kind = match f.cf_kind with Method _ -> Display.FKMethod f.cf_type | Var _ -> Display.FKVar f.cf_type in
-			if f.cf_public then (f.cf_name,kind,f.cf_doc) :: acc else acc
+			if not f.cf_public then acc
+			else (ITClassMember f) :: acc
 		) acc (f :: f.cf_overloads)
 	in
 	let fields = List.fold_left get_field [] fields in

+ 10 - 4
src/context/displayJson.ml

@@ -17,6 +17,7 @@ let get_capabilities () =
 	JObject [
 		"definitionProvider",JBool true;
 		"hoverProvider",JBool true;
+		"completionProvider",JBool true;
 	]
 
 let parse_input com input =
@@ -48,10 +49,11 @@ let parse_input com input =
 			| JInt i -> i
 			| _ -> raise_haxe_json_error id (BadParamType(name,"Int"))
 		in
-		(* let get_bool_param name = match get_param name with
+		let get_bool_param name = match get_param name with
 			| JBool b -> b
 			| _ -> raise_haxe_json_error id (BadParamType(name,"Bool"))
 		in
+		(*
 		let opt_param name f =
 			if not (List.mem_assoc name params) then None
 			else Some (f name)
@@ -62,9 +64,10 @@ let parse_input com input =
 			Common.define_value com Define.Display "1";
 			Parser.use_doc := true;
 		in
-		let read_display_file () =
+		let read_display_file was_auto_triggered =
 			let file = get_string_param "file" in
 			let pos = get_int_param "offset" in
+			Parser.was_auto_triggered := was_auto_triggered;
 			Parser.resume_display := {
 				pfile = Path.unique_full_path file;
 				pmin = pos;
@@ -76,13 +79,16 @@ let parse_input com input =
 				raise (DisplayOutput.Completion (f_result (JObject [
 					"capabilities",get_capabilities()
 				])))
+			| "textDocument/completion" ->
+				read_display_file (get_bool_param "wasAutoTriggered");
+				enable_display DMDefault;
 			| "textDocument/definition" ->
 				Common.define com Define.NoCOpt;
-				read_display_file();
+				read_display_file false;
 				enable_display DMDefinition;
 			| "textDocument/hover" ->
 				Common.define com Define.NoCOpt;
-				read_display_file();
+				read_display_file false;
 				enable_display DMHover;
 			| _ -> raise_method_not_found id name
 		end;

+ 6 - 6
src/context/displayToplevel.ml

@@ -20,7 +20,7 @@ open Ast
 open Common
 open Type
 open Typecore
-open DisplayTypes.IdentifierType
+open DisplayTypes.CompletionKind
 
 let explore_class_paths ctx class_paths recusive f_pack f_module f_type =
 	let rec loop dir pack =
@@ -73,7 +73,7 @@ let collect ctx only_types =
 		if ctx.curfun <> FunStatic then begin
 			let rec loop c =
 				List.iter (fun cf ->
-					if not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITMember cf)
+					if not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITClassMember cf)
 				) c.cl_ordered_fields;
 				match c.cl_super with
 					| None ->
@@ -87,7 +87,7 @@ let collect ctx only_types =
 
 		(* statics *)
 		List.iter (fun cf ->
-			if not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITStatic cf)
+			if not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITClassStatic cf)
 		) ctx.curclass.cl_ordered_statics;
 
 		(* enum constructors *)
@@ -95,7 +95,7 @@ let collect ctx only_types =
 			match t with
 			| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
 				List.iter (fun cf ->
-					if (Meta.has Meta.Enum cf.cf_meta) && not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITEnumAbstract(a,cf));
+					if (Meta.has Meta.Enum cf.cf_meta) && not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITEnumAbstractField(a,cf));
 				) c.cl_ordered_statics
 			| TClassDecl _ | TAbstractDecl _ ->
 				()
@@ -106,7 +106,7 @@ let collect ctx only_types =
 				end
 			| TEnumDecl e ->
 				PMap.iter (fun _ ef ->
-					add (ITEnum(e,ef))
+					add (ITEnumField(e,ef))
 				) e.e_constrs;
 		in
 		List.iter enum_ctors ctx.m.curmod.m_types;
@@ -212,7 +212,7 @@ let collect ctx only_types =
 let handle_unresolved_identifier ctx i p only_types =
 	let l = collect ctx only_types in
 	let cl = List.map (fun it ->
-		let s = DisplayTypes.IdentifierType.get_name it in
+		let s = DisplayTypes.CompletionKind.get_name it in
 		(s,it),StringError.levenshtein i s
 	) l in
 	let cl = List.sort (fun (_,c1) (_,c2) -> compare c1 c2) cl in

+ 65 - 9
src/context/displayTypes.ml

@@ -2,6 +2,8 @@ open Globals
 open Path
 open Ast
 open Type
+open Json
+open Genjson
 
 module SymbolKind = struct
 	type t =
@@ -61,7 +63,7 @@ module DiagnosticsSeverity = struct
 		| Hint -> 4
 end
 
-module IdentifierType = struct
+module CompletionKind = struct
 	type resolution_mode =
 		| RMLocalModule
 		| RMImport
@@ -72,26 +74,80 @@ module IdentifierType = struct
 
 	type t =
 		| ITLocal of tvar
-		| ITMember of tclass_field
-		| ITStatic of tclass_field
-		| ITEnum of tenum * tenum_field
-		| ITEnumAbstract of tabstract * tclass_field
+		| ITClassMember of tclass_field
+		| ITClassStatic of tclass_field
+		| ITEnumField of tenum * tenum_field
+		| ITEnumAbstractField of tabstract * tclass_field
 		| ITGlobal of module_type * string * Type.t
 		| ITType of module_type * resolution_mode
 		| ITPackage of string
+		| ITModule of string
 		| ITLiteral of string
-		| ITTimer of string
+		| ITTimer of string * string
+		| ITMetadata of string * documentation
+
+	let legacy_sort = function
+		| ITClassMember cf | ITClassStatic cf | ITEnumAbstractField(_,cf) ->
+			begin match cf.cf_kind with
+			| Var _ -> 0,cf.cf_name
+			| Method _ -> 1,cf.cf_name
+			end
+		| ITEnumField(_,ef) ->
+			begin match follow ef.ef_type with
+			| TFun _ -> 1,ef.ef_name
+			| _ -> 0,ef.ef_name
+			end
+		| ITType(mt,_) ->
+			2,(snd (t_infos mt).mt_path)
+		| ITModule s -> 3,s
+		| ITPackage s -> 4,s
+		| ITMetadata(s,_) -> 5,s
+		| ITTimer(s,_) -> 6,s
+		| ITLocal v -> 7,v.v_name
+		| ITGlobal(_,s,_) -> 8,s
+		| ITLiteral s -> 9,s
 
 	let get_name = function
 		| ITLocal v -> v.v_name
-		| ITMember cf | ITStatic cf | ITEnumAbstract(_,cf) -> cf.cf_name
-		| ITEnum(_,ef) -> ef.ef_name
+		| ITClassMember cf | ITClassStatic cf | ITEnumAbstractField(_,cf) -> cf.cf_name
+		| ITEnumField(_,ef) -> ef.ef_name
 		| ITGlobal(_,s,_) -> s
 		| ITType(mt,_) -> snd (t_infos mt).mt_path
 		| ITPackage s -> s
+		| ITModule s -> s
 		| ITLiteral s -> s
-		| ITTimer s -> s
+		| ITTimer(s,_) -> s
+		| ITMetadata(s,_) -> s
 
+	let to_json ctx ck =
+		let kind,data = match ck with
+			| ITLocal v -> "Local",generate_tvar ctx v
+			| ITClassMember cf -> "Member",generate_class_field ctx cf
+			| ITClassStatic cf -> "Static",generate_class_field ctx cf
+			| ITEnumField(_,ef) -> "EnumField",generate_enum_field ctx ef
+			| ITEnumAbstractField(_,cf) -> "EnumAbstractField",generate_class_field ctx cf
+			| ITGlobal(mt,s,t) -> "Global",jobject [
+				"modulePath",generate_path (t_infos mt).mt_path;
+				"name",jstring s;
+				"type",generate_type ctx t
+			]
+			| ITType(mt,rm) -> "Type",jobject [
+				"modulePath",generate_path (t_infos mt).mt_path;
+				"resolutionMode",jtodo;
+			]
+			| ITPackage s -> "Package",jstring s
+			| ITModule s -> "Module",jstring s
+			| ITLiteral s -> "Literal",jstring s
+			| ITTimer(s,value) -> "Timer",jobject [
+				"name",jstring s;
+				"value",jstring value;
+			]
+			| ITMetadata(s,doc) -> "Metadata",jobject [
+				"name",jstring s;
+				"doc",jopt jstring doc;
+			]
+		in
+		generate_adt ctx None kind (Some data)
 end
 
 module DisplayMode = struct

+ 21 - 7
src/generators/genjson.ml → src/core/json/genjson.ml

@@ -1,11 +1,10 @@
 open Ast
 open Globals
-open Common
 open Type
 open Meta
 
 type context = {
-	com : Common.context;
+	todo : unit;
 }
 
 let jnull = Json.JNull
@@ -207,6 +206,21 @@ and generate_type_parameter ctx (s,t) =
 
 (* texpr *)
 
+and generate_tvar ctx v =
+	let generate_extra (params,eo) = jobject [
+		"params",jlist (generate_type_parameter ctx) params;
+		"expr",jopt (generate_texpr ctx) eo;
+	] in
+	jobject [
+		"id",jint v.v_id;
+		"name",jstring v.v_name;
+		"type",generate_type ctx v.v_type;
+		"capture",jbool v.v_capture;
+		"extra",jopt generate_extra v.v_extra;
+		"meta",generate_metadata ctx v.v_meta;
+		"pos",generate_pos ctx v.v_pos;
+	]
+
 and generate_texpr ctx e =
 	jtodo
 
@@ -377,14 +391,14 @@ let generate_module_type ctx mt =
 	let fields1 = ("kind",jstring kind) :: fields1 @ [("args",jobject fields2)] in
 	jobject fields1
 
-let create_context com = {
-	com = com;
+let create_context () = {
+	todo = ()
 }
 
-let generate com file =
+let generate types file =
 	let t = Timer.timer ["generate";"json";"construct"] in
-	let ctx = create_context com in
-	let json = jarray (List.map (generate_module_type ctx) com.types) in
+	let ctx = create_context () in
+	let json = jarray (List.map (generate_module_type ctx) types) in
 	t();
 	let t = Timer.timer ["generate";"json";"write"] in
 	let ch = open_out_bin file in

+ 0 - 0
src/core/json.ml → src/core/json/json.ml


+ 0 - 0
src/core/jsonRpc.ml → src/core/json/jsonRpc.ml


+ 0 - 0
src/core/jsonRpcSocket.ml → src/core/json/jsonRpcSocket.ml


+ 1 - 0
src/syntax/parser.ml

@@ -76,6 +76,7 @@ end
 
 let last_doc : (string * int) option ref = ref None
 let use_doc = ref false
+let was_auto_triggered = ref false
 let resume_display = ref null_pos
 let in_macro = ref false
 

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1296,7 +1296,7 @@ let init_class ctx c p context_init herits fields =
 		let open Display in
 		let l = PMap.fold (fun cf acc ->
 			if not (List.exists (fun cf' -> cf'.cf_name = cf.cf_name) c.cl_overrides) then
-				(IdentifierType.ITMember cf) :: acc
+				(IdentifierType.ITClassMember cf) :: acc
 			else acc
 		) fields [] in
 		raise (Display.DisplayToplevel l)

+ 1 - 1
src/typing/typerDisplay.ml

@@ -242,7 +242,7 @@ let handle_structure_display ctx e with_type =
 			| TAnon an ->
 				let fields = PMap.foldi (fun k cf acc ->
 					if Expr.field_mem_assoc k fl then acc
-					else ((k,Display.FKVar cf.cf_type,cf.cf_doc)) :: acc
+					else (DisplayTypes.CompletionKind.ITClassMember cf) :: acc
 				) an.a_fields [] in
 				fields
 			| _ -> fail()

+ 2 - 2
tests/misc/projects/Issue2263/import-completion.hxml.stderr

@@ -1,6 +1,6 @@
 <list>
 <i n="pubV" k="var"><t>Int</t><d></d></i>
 <i n="pubM" k="method"><t>Void -&gt; Void</t><d></d></i>
-<i n="MyModule" k="type"><t></t><d></d></i>
-<i n="OtherType" k="type"><t></t><d></d></i>
+<i n="MyModule" k="type"><t>MyModule</t><d></d></i>
+<i n="OtherType" k="type"><t>OtherType</t><d></d></i>
 </list>

+ 2 - 2
tests/misc/projects/Issue2263/type-completion.hxml.stderr

@@ -1,4 +1,4 @@
 <list>
-<i n="MyModule" k="type"><t></t><d></d></i>
-<i n="OtherType" k="type"><t></t><d></d></i>
+<i n="MyModule" k="type"><t>MyModule</t><d></d></i>
+<i n="OtherType" k="type"><t>OtherType</t><d></d></i>
 </list>

+ 2 - 2
tests/misc/projects/Issue3931/compile2.hxml.stderr

@@ -1,4 +1,4 @@
 <list>
-<i n="A" k="type"><t></t><d></d></i>
-<i n="C" k="type"><t></t><d></d></i>
+<i n="A" k="type"><t>pack.A</t><d></d></i>
+<i n="C" k="type"><t>pack.C</t><d></d></i>
 </list>