Просмотр исходного кода

next batch of display fixes

closes #5622
closes #5624
closes #5629
Simon Krajewski 9 лет назад
Родитель
Сommit
0ce0b5ebd9
5 измененных файлов с 13 добавлено и 5 удалено
  1. 1 1
      src/display/display.ml
  2. 2 0
      src/main.ml
  3. 2 1
      src/typing/common.ml
  4. 4 3
      src/typing/typeload.ml
  5. 4 0
      src/typing/typer.ml

+ 1 - 1
src/display/display.ml

@@ -237,7 +237,7 @@ module DocumentSymbols = struct
 		l
 
 	let print_module_symbols com symbols filter =
-		let regex = Option.map Str.regexp filter in
+		let regex = Option.map Str.regexp_case_fold filter in
 		let reported = Hashtbl.create 0 in
 		let add si =
 			if Hashtbl.mem reported si.pos then false

+ 2 - 0
src/main.ml

@@ -1816,6 +1816,8 @@ with
 				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) ->
 				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) ->
+				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) ->
 				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) ->

+ 2 - 1
src/typing/common.ml

@@ -218,13 +218,14 @@ module IdentifierType = struct
 		| ITMember of tclass * tclass_field
 		| ITStatic of tclass * tclass_field
 		| ITEnum of tenum * tenum_field
+		| ITEnumAbstract of tabstract * tclass_field
 		| ITGlobal of module_type * string * Type.t
 		| ITType of module_type
 		| ITPackage of string
 
 	let get_name = function
 		| ITLocal v -> v.v_name
-		| ITMember(_,cf) | ITStatic(_,cf) -> cf.cf_name
+		| ITMember(_,cf) | ITStatic(_,cf) | ITEnumAbstract(_,cf) -> cf.cf_name
 		| ITEnum(_,ef) -> ef.ef_name
 		| ITGlobal(_,s,_) -> s
 		| ITType mt -> snd (t_infos mt).mt_path

+ 4 - 3
src/typing/typeload.ml

@@ -1085,11 +1085,12 @@ let is_generic_parameter ctx c =
 	with Not_found ->
 		false
 
-let type_function_arg_value ctx t c =
+let type_function_arg_value ctx t c do_display =
 	match c with
 		| None -> None
 		| Some e ->
 			let p = pos e in
+			let e = if do_display then Display.process_expr ctx.com e else e in
 			let e = ctx.g.do_optimize ctx (type_expr ctx e (WithType t)) in
 			unify ctx e.etype t p;
 			let rec loop e = match e.eexpr with
@@ -1312,7 +1313,7 @@ let add_constructor ctx c force_constructor p =
 					match follow cfsup.cf_type with
 					| TFun (args,_) ->
 						List.map (fun (n,o,t) ->
-							let def = try type_function_arg_value ctx t (Some (PMap.find n values)) with Not_found -> if o then Some TNull else None in
+							let def = try type_function_arg_value ctx t (Some (PMap.find n values)) false with Not_found -> if o then Some TNull else None in
 							map_arg (alloc_var n (if o then ctx.t.tnull t else t) p,def) (* TODO: var pos *)
 						) args
 					| _ -> assert false
@@ -1613,7 +1614,7 @@ let type_function ctx args ret fmode f do_display p =
 	let locals = save_locals ctx in
 	let fargs = List.map2 (fun (n,c,t) ((_,pn),_,m,_,_) ->
 		if n.[0] = '$' then error "Function argument names starting with a dollar are not allowed" p;
-		let c = type_function_arg_value ctx t c in
+		let c = type_function_arg_value ctx t c do_display in
 		let v,c = add_local ctx n t pn, c in
 		v.v_meta <- m;
 		if do_display && Display.is_display_position pn then

+ 4 - 0
src/typing/typer.ml

@@ -432,6 +432,10 @@ module ToplevelCollecter = struct
 		(* enum constructors *)
 		let rec enum_ctors t =
 			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) then DynArray.add acc (ITEnumAbstract(a,cf));
+				) c.cl_ordered_statics
 			| TClassDecl _ | TAbstractDecl _ ->
 				()
 			| TTypeDecl t ->