Explorar el Código

allow "using" completion on functions
make difference between ( and . completion

Nicolas Cannasse hace 15 años
padre
commit
97c61f6ab8
Se han modificado 3 ficheros con 13 adiciones y 7 borrados
  1. 1 1
      ast.ml
  2. 3 3
      parser.ml
  3. 9 3
      typer.ml

+ 1 - 1
ast.ml

@@ -189,7 +189,7 @@ and expr_def =
 	| EUntyped of expr
 	| EThrow of expr
 	| ECast of expr * type_path option
-	| EDisplay of expr
+	| EDisplay of expr * bool
 	| EDisplayNew of type_path_normal
 	| ETernary of expr * expr * expr
 

+ 3 - 3
parser.ml

@@ -587,18 +587,18 @@ and expr = parser
 
 and expr_next e1 = parser
 	| [< '(Dot,p); s >] ->
-		if is_resuming p then display (EDisplay e1,p);
+		if is_resuming p then display (EDisplay (e1,false),p);
 		(match s with parser
 		| [< '(Const (Ident f),p2) when p.pmax = p2.pmin; s >] -> expr_next (EField (e1,f) , punion (pos e1) p2) s
 		| [< '(Const (Type t),p2) when p.pmax = p2.pmin; s >] -> expr_next (EType (e1,t) , punion (pos e1) p2) s
-		| [< '(Binop OpOr,p2) when do_resume() >] -> display (EDisplay e1,p)
+		| [< '(Binop OpOr,p2) when do_resume() >] -> display (EDisplay (e1,false),p) (* help for debug display mode *)
 		| [< >] ->
 			(* turn an integer followed by a dot into a float *)
 			match e1 with
 			| (EConst (Int v),p2) when p2.pmax = p.pmin -> expr_next (EConst (Float (v ^ ".")),punion p p2) s
 			| _ -> serror())
 	| [< '(POpen,p1); s >] ->
-		if is_resuming p1 then display (EDisplay e1,p1);
+		if is_resuming p1 then display (EDisplay (e1,true),p1);
 		(match s with parser
 		| [< params = parse_call_params e1; '(PClose,p2); s >] -> expr_next (ECall (e1,params) , punion (pos e1) p2) s
 		| [< >] -> serror())

+ 9 - 3
typer.ml

@@ -91,6 +91,7 @@ let classify t =
 	| TInst ({ cl_path = ([],"Float") },[]) -> KFloat
 	| TInst ({ cl_path = ([],"String") },[]) -> KString
 	| TInst ({ cl_kind = KTypeParameter; cl_implements = [{ cl_path = ([],"Float")},[]] },[]) -> KParam t
+	| TInst ({ cl_kind = KTypeParameter; cl_implements = [{ cl_path = ([],"Int")},[]] },[]) -> KParam t
 	| TMono r when !r = None -> KUnk
 	| TDynamic _ -> KDyn
 	| _ -> KOther
@@ -1456,7 +1457,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			error "Cast type must be a class or an enum" p
 		) in
 		mk (TCast (type_expr ctx e,Some texpr)) t p
-	| EDisplay e ->
+	| EDisplay (e,iscall) ->
 		let old = ctx.in_display in
 		ctx.in_display <- true;
 		let e = (try type_expr ctx e with Error (Unknown_ident n,_) -> raise (Parser.TypePath ([n],None))) in
@@ -1511,8 +1512,13 @@ and type_expr ctx ?(need_val=true) (e,p) =
 				!acc
 		in	
 		let use_methods = loop PMap.empty ctx.local_using in
-		let t = (if PMap.is_empty use_methods then t else match follow t with
-			| TFun _ -> t (* don't provide use methods for functions *)
+		let t = (if iscall then
+			match follow t with
+			| TFun _ -> t
+			| _ -> t_dynamic
+		else if PMap.is_empty use_methods then
+			t
+		else match follow t with
 			| TAnon a -> TAnon { a_fields = PMap.fold (fun f acc -> PMap.add f.cf_name f acc) a.a_fields use_methods; a_status = ref Closed; }
 			| _ -> TAnon { a_fields = use_methods; a_status = ref Closed }
 		) in