ソースを参照

[display] for toplevel completion also filter out packages that doesn't start with lowercase letter (closes #4662)

Dan Korostelev 9 年 前
コミット
6c6493cf5b

+ 1 - 0
tests/misc/projects/Issue4662/Main.hx

@@ -0,0 +1 @@
+class Main { static function main() {  } }

+ 18 - 0
tests/misc/projects/Issue4662/Test.hx

@@ -0,0 +1,18 @@
+class Test {
+    static function error(msg, code) {
+        Sys.stderr().writeString(msg);
+        Sys.exit(code);
+    }
+
+    static function main() {
+        var proc = new sys.io.Process("haxe", ["-cp", ".", "--display", "Main.hx@38@toplevel"]);
+        var stderr = proc.stderr.readAll().toString();
+        var exit = proc.exitCode();
+        if (exit != 0) {
+            error(stderr, exit);
+        } else {
+            if (stderr.indexOf('<i k="package">_pkg</i>') != -1)
+                error("The package starting with `_` is not filtered out for completion:\n" + stderr, 1);
+        }
+    }
+}

+ 3 - 0
tests/misc/projects/Issue4662/_pkg/A.hx

@@ -0,0 +1,3 @@
+package _pkg;
+
+class A {}

+ 1 - 0
tests/misc/projects/Issue4662/compile.hxml

@@ -0,0 +1 @@
+--run Test

+ 1 - 1
typer.ml

@@ -505,7 +505,7 @@ let collect_toplevel_identifiers ctx =
 				match file with
 				match file with
 					| "." | ".." ->
 					| "." | ".." ->
 						()
 						()
-					| _ when Sys.is_directory (dir ^ file) ->
+					| _ when Sys.is_directory (dir ^ file) && file.[0] >= 'a' && file.[0] <= 'z' ->
 						add_package file
 						add_package file
 					| _ ->
 					| _ ->
 						let l = String.length file in
 						let l = String.length file in