Browse Source

support completion for static extensions (closes #5766)

Simon Krajewski 8 years ago
parent
commit
f493eb6d5c
3 changed files with 35 additions and 0 deletions
  1. 4 0
      extra/CHANGES.txt
  2. 1 0
      src/syntax/parser.ml
  3. 30 0
      tests/display/src/cases/IImport.hx

+ 4 - 0
extra/CHANGES.txt

@@ -1,5 +1,9 @@
 2017-??-??: 3.4.0
 
+	General improvements and optimizations:
+
+	all : support completion for static extensions (#5766)
+
 	Bugfixes:
 
 	all : fixed `using` picking up non-static abstract functions (#5888)

+ 1 - 0
src/syntax/parser.ml

@@ -745,6 +745,7 @@ and parse_using s p1 =
 			| [< '(Kwd Extern,p) >] ->
 				loop (("extern",p) :: acc)
 			| [< >] ->
+				if is_resuming p then type_path (List.map fst acc) false;
 				serror()
 			end
 		| [< '(Semicolon,p2) >] ->

+ 30 - 0
tests/display/src/cases/IImport.hx

@@ -16,6 +16,21 @@ class IImport extends DisplayTestCase {
 		// TODO: test @position display. A bit annoying because it actually ends up in other files and we can't use markers.
 	}
 
+	/**
+	import haxe.{-1-}
+	**/
+	function testImport2() {
+		eq(true, hasPath(fields(pos(1)), "Serializer"));
+	}
+
+	/**
+	import haxe.Serializer.{-1-}
+	**/
+	function testImport3() {
+		eq(true, hasPath(fields(pos(1)), "run"));
+		eq(true, hasPath(fields(pos(1)), "Serializer"));
+	}
+
 	/**
 	using ha{-1-}xe.ma{-2-}cro.Exp{-3-}rTools.Expr{-4-}ArrayTools;
 	**/
@@ -26,4 +41,19 @@ class IImport extends DisplayTestCase {
 		eq(true, hasField(fields(pos(4)), "iter", "el : Array<haxe.macro.Expr> -> f : (haxe.macro.Expr -> Void) -> Void"));
 		// TODO: test @position display. A bit annoying because it actually ends up in other files and we can't use markers.
 	}
+
+	/**
+	using haxe.{-1-}
+	**/
+	function testUsing2() {
+		eq(true, hasPath(fields(pos(1)), "Serializer"));
+	}
+
+	/**
+	using haxe.Serializer.{-1-}
+	**/
+	function testUsing3() {
+		eq(false, hasPath(fields(pos(1)), "run"));
+		eq(true, hasPath(fields(pos(1)), "Serializer"));
+	}
 }