Browse Source

added "new" completion
hidden private static fields from display
fixed bug when accessing uppercase super method

Nicolas Cannasse 18 years ago
parent
commit
38f12ce4f7
5 changed files with 34 additions and 11 deletions
  1. 1 0
      ast.ml
  2. 2 0
      doc/CHANGES.txt
  3. 12 7
      main.ml
  4. 5 1
      parser.ml
  5. 14 3
      typer.ml

+ 1 - 0
ast.ml

@@ -194,6 +194,7 @@ and expr_def =
 	| EThrow of expr
 	| ECast of expr * type_path option
 	| EDisplay of expr
+	| EDisplayNew of type_path_normal
 
 and expr = expr_def * pos
 

+ 2 - 0
doc/CHANGES.txt

@@ -11,6 +11,8 @@
 	fixed tar support in neko.zip.File
 	ide completion support using --display
 	give access to neko.net.Host ip (as Int32)
+	fixed bug when calling super.UpperCaseMethod()
+	hide additional flash Array methods
 
 2007-01-28: 1.11
 	changed StringBuf.add implementation

+ 12 - 7
main.ml

@@ -70,12 +70,12 @@ let report msg p =
 	warn msg p;
 	do_exit()
 
+let htmlescape s =
+	let s = String.concat "&lt;" (ExtString.String.nsplit s "<") in
+	let s = String.concat "&gt;" (ExtString.String.nsplit s ">") in
+	s
+
 let report_list l =
-	let htmlescape s =
-		let s = String.concat "&lt;" (ExtString.String.nsplit s "<") in
-		let s = String.concat "&gt;" (ExtString.String.nsplit s ">") in
-		s
-	in
 	prerr_endline "<list>";
 	List.iter (fun (n,t,d) ->
 		prerr_endline (Printf.sprintf "<i n=\"%s\"><t>%s</t><d>%s</d></i>" n (htmlescape t) (htmlescape d));
@@ -436,10 +436,15 @@ with
 		(match Type.follow t with
 		| Type.TAnon a ->
 			report_list (PMap.fold (fun f acc ->
-				(f.Type.cf_name,Type.s_type ctx f.Type.cf_type,match f.Type.cf_doc with None -> "" | Some d -> d) :: acc
+				if not f.Type.cf_public then
+					acc
+				else
+					(f.Type.cf_name,Type.s_type ctx f.Type.cf_type,match f.Type.cf_doc with None -> "" | Some d -> d) :: acc
 			) a.Type.a_fields []);
 		| _ ->
-			prerr_string (Type.s_type ctx t));
+			prerr_endline "<type>";
+			prerr_endline (htmlescape (Type.s_type ctx t));
+			prerr_endline "</type>");
 		exit 0;
 	| Parser.TypePath p ->
 		let packs, classes = read_type_path p (!Plugin.class_path) in

+ 5 - 1
parser.ml

@@ -499,7 +499,11 @@ and expr = parser
 		| [< e = expr; s >] -> expr_next (ECast (e,None),punion p1 (pos e)) s
 		| [< >] -> serror())
 	| [< '(Kwd Throw,p); e = expr >] -> (EThrow e,p)
-	| [< '(Kwd New,p1); t = parse_type_path_normal; '(POpen,_); al = psep Comma expr; '(PClose,p2); s >] -> expr_next (ENew (t,al),punion p1 p2) s
+	| [< '(Kwd New,p1); t = parse_type_path_normal; '(POpen,p); s >] ->
+		if is_resuming p then display (EDisplayNew t,punion p1 p);
+		(match s with parser
+		| [< al = psep Comma expr; '(PClose,p2); s >] -> expr_next (ENew (t,al),punion p1 p2) s
+		| [< >] -> serror())
 	| [< '(POpen,p1); e = expr; '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s
 	| [< '(BkOpen,p1); l = parse_array_decl; '(BkClose,p2); s >] -> expr_next (EArrayDecl l, punion p1 p2) s
 	| [< '(Kwd Function,p1); '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; e = expr; s >] ->

+ 14 - 3
typer.ml

@@ -1887,7 +1887,9 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		) in
 		mk (TCall (mk (TConst TSuper) t sp,el)) (t_void ctx) p
 	| ECall (e,el) ->
-		(match e with EField ((EConst (Ident "super"),_),_) , _ -> ctx.super_call <- true | _ -> ());
+		(match e with 
+		| EField ((EConst (Ident "super"),_),_) , _ | EType ((EConst (Ident "super"),_),_) , _ -> ctx.super_call <- true
+		| _ -> ());
 		let e = type_expr ctx e in
 		let el , t = (match follow e.etype with
 		| TFun (args,r) ->
@@ -1910,7 +1912,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		mk (TCall (e,el)) t p
 	| ENew (t,el) ->
 		let t = load_normal_type ctx t p true in
-		let el, c , params , t = (match follow t with
+		let el, c , params = (match follow t with
 		| TInst (c,params) ->
 			let name = (match c.cl_path with [], name -> name | x :: _ , _ -> x) in
 			if PMap.mem name ctx.locals then error ("Local variable " ^ name ^ " is preventing usage of this class here") p;
@@ -1922,7 +1924,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			| _ ->
 				error "Constructor is not a function" p
 			) in
-			el , c , params , t
+			el , c , params
 		| _ ->
 			error (s_type (print_context()) t ^ " cannot be constructed") p
 		) in
@@ -2013,6 +2015,15 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			| t -> t
 		) in
 		raise (Display t)
+	| EDisplayNew t ->
+		let t = load_normal_type ctx t p true in
+		(match follow t with
+		| TInst (c,params) ->
+			let f = (match c.cl_constructor with Some f -> f | None -> error (s_type_path c.cl_path ^ " does not have a constructor") p) in
+			let t = apply_params c.cl_types params (field_type f) in
+			raise (Display t)
+		| _ -> 
+			error "Not a class" p)
 
 and type_function ctx t static constr f p =
 	let locals = save_locals ctx in