Browse Source

[display] don't show generated interface accessors in completion

see #9039
Simon Krajewski 6 years ago
parent
commit
3251a19e74
2 changed files with 25 additions and 1 deletions
  1. 1 1
      src/typing/typeloadFields.ml
  2. 24 0
      tests/server/src/DisplayTests.hx

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1284,7 +1284,7 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
 			| Not_found ->
 				if c.cl_interface then begin
 					let cf = mk_field m t p null_pos in
-					cf.cf_meta <- [Meta.CompilerGenerated,[],null_pos];
+					cf.cf_meta <- [Meta.CompilerGenerated,[],null_pos;Meta.NoCompletion,[],null_pos];
 					cf.cf_kind <- Method MethNormal;
 					c.cl_fields <- PMap.add cf.cf_name cf c.cl_fields;
 					c.cl_ordered_fields <- cf :: c.cl_ordered_fields;

+ 24 - 0
tests/server/src/DisplayTests.hx

@@ -294,4 +294,28 @@ typedef Foo = {
 
 		Assert.equals(DisplayItemKind.ClassField, result.item.kind);
 	}
+
+	function testIssue9039() {
+		vfs.putContent("I.hx", "interface I { var prop(get,never):Int; }");
+		vfs.putContent("Main.hx", "class Main { static function main() { var i:I = null; } }");
+
+		runHaxe(["--no-output", "-main", "Main"]);
+
+		var content = "class Main { static function main() { var i:I = null; i.{-1-} } }";
+		var transform = Marker.extractMarkers(content);
+
+		vfs.putContent("Main.hx", transform.source);
+		runHaxeJson([], DisplayMethods.Completion, {
+			file: new FsPath("Main.hx"),
+			offset: transform.markers[1],
+			wasAutoTriggered: true
+		});
+
+		assertHasNoCompletion(parseCompletion(), function(item) {
+			return switch item.kind {
+				case ClassField: item.args.field.name == "get_prop";
+				case _: false;
+			}
+		});
+	}
 }