Browse Source

[display] respect `@:noCompletion` for toplevel (closes #6407)

Simon Krajewski 8 years ago
parent
commit
dcf4e8a4e7
2 changed files with 15 additions and 3 deletions
  1. 3 3
      src/display/display.ml
  2. 12 0
      tests/display/src/cases/Toplevel.hx

+ 3 - 3
src/display/display.ml

@@ -799,7 +799,7 @@ module ToplevelCollector = struct
 			if ctx.curfun <> FunStatic then begin
 				let rec loop c =
 					List.iter (fun cf ->
-						add (ITMember(ctx.curclass,cf))
+						if not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITMember(ctx.curclass,cf))
 					) c.cl_ordered_fields;
 					match c.cl_super with
 						| None ->
@@ -813,7 +813,7 @@ module ToplevelCollector = struct
 
 			(* statics *)
 			List.iter (fun cf ->
-				add (ITStatic(ctx.curclass,cf))
+				if not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITStatic(ctx.curclass,cf))
 			) ctx.curclass.cl_ordered_statics;
 
 			(* enum constructors *)
@@ -821,7 +821,7 @@ module ToplevelCollector = struct
 				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 add (ITEnumAbstract(a,cf));
+						if (Meta.has Meta.Enum cf.cf_meta) && not (Meta.has Meta.NoCompletion cf.cf_meta) then add (ITEnumAbstract(a,cf));
 					) c.cl_ordered_statics
 				| TClassDecl _ | TAbstractDecl _ ->
 					()

+ 12 - 0
tests/display/src/cases/Toplevel.hx

@@ -187,6 +187,18 @@ class Toplevel extends DisplayTestCase {
 		eq("local", toplevels[0].kind);
 	}
 
+	/**
+	class Main {
+		static function main() {
+			{-1-}
+		}
+		@:noCompletion static function test() { }
+	}
+	**/
+	function testIssue6407() {
+		eq(false, hasToplevel(toplevel(pos(1)), "static", "test"));
+	}
+
 	public static function hasToplevel(a:Array<ToplevelElement>, kind:String, name:String):Bool {
 		return a.exists(function(t) return t.kind == kind && t.name == name);
 	}