浏览代码

[display] skip generated local vars in toplevel completion (closes #3326)

Dan Korostelev 11 年之前
父节点
当前提交
ff7db98844
共有 3 个文件被更改,包括 6 次插入2 次删除
  1. 1 1
      filters.ml
  2. 3 0
      typecore.ml
  3. 2 1
      typer.ml

+ 1 - 1
filters.ml

@@ -649,7 +649,7 @@ let rename_local_vars com e =
 			| TAbstract ({a_path = [],"Void"},_) -> error "Arguments and variables of type Void are not allowed" p
 			| _ -> ());
 		(* chop escape char for all local variables generated *)
-		if String.unsafe_get v.v_name 0 = String.unsafe_get gen_local_prefix 0 then v.v_name <- "_g" ^ String.sub v.v_name 1 (String.length v.v_name - 1);
+		if is_gen_local v then v.v_name <- "_g" ^ String.sub v.v_name 1 (String.length v.v_name - 1);
 		let look_vars = (if not cfg.pf_captured_scope && v.v_capture then !all_vars else !vars) in
 		(try
 			let v2 = PMap.find v.v_name look_vars in

+ 3 - 0
typecore.ml

@@ -333,6 +333,9 @@ let gen_local ctx t =
 	in
 	add_local ctx (loop 0) t
 
+let is_gen_local v =
+	String.unsafe_get v.v_name 0 = String.unsafe_get gen_local_prefix 0
+
 let not_opened = ref Closed
 let mk_anon fl = TAnon { a_fields = fl; a_status = not_opened; }
 

+ 2 - 1
typer.ml

@@ -399,7 +399,8 @@ let collect_toplevel_identifiers ctx =
 
 	(* locals *)
 	PMap.iter (fun _ v ->
-		DynArray.add acc (ITLocal v)
+		if not (is_gen_local v) then
+			DynArray.add acc (ITLocal v)
 	) ctx.locals;
 
 	(* member vars *)