Browse Source

[display] don't show type-related keywords in import.hx completion

Jens Fischer 6 years ago
parent
commit
5317cd49dd
3 changed files with 7 additions and 3 deletions
  1. 2 1
      .vscode/settings.json
  2. 3 1
      src/compiler/displayOutput.ml
  3. 2 1
      src/typing/typeloadModule.ml

+ 2 - 1
.vscode/settings.json

@@ -9,5 +9,6 @@
 	"files.exclude": {
 		"**/_build": true
 	},
-	"reason.server.languages": ["ocaml"]
+	"reason.server.languages": ["ocaml"],
+	"haxe.diagnosticsPathFilter": "${workspaceRoot}/std"
 }

+ 3 - 1
src/compiler/displayOutput.ml

@@ -1,6 +1,7 @@
 open Globals
 open Ast
 open Common
+open Filename
 open CompilationServer
 open Timer
 open DisplayTypes.DisplayMode
@@ -657,7 +658,8 @@ let handle_syntax_completion com kind p =
 		| SCComment ->
 			[],CRTypeRelation
 		| SCTypeDecl mode ->
-			let l = [Private;Extern;Class;Interface;Enum;Abstract;Typedef;Final] in
+			let in_import_hx = Filename.basename p.pfile = "import.hx" in
+			let l = if in_import_hx then [] else [Private;Extern;Class;Interface;Enum;Abstract;Typedef;Final] in
 			let l = match mode with
 				| TCBeforePackage -> Package :: Import :: Using :: l
 				| TCAfterImport -> Import :: Using :: l

+ 2 - 1
src/typing/typeloadModule.ml

@@ -21,6 +21,7 @@
 
 open Globals
 open Ast
+open Filename
 open Type
 open Typecore
 open DisplayTypes.DisplayMode
@@ -348,7 +349,7 @@ let init_module_type ctx context_init do_init (decl,p) =
 	in
 	let check_path_display path p = match ctx.com.display.dms_kind with
 		(* We cannot use ctx.is_display_file because the import could come from an import.hx file. *)
-		| DMDiagnostics b when (b || DisplayPosition.is_display_file p.pfile) && not (ExtString.String.ends_with p.pfile "import.hx") ->
+		| DMDiagnostics b when (b || DisplayPosition.is_display_file p.pfile) && Filename.basename p.pfile <> "import.hx" ->
 			ImportHandling.add_import_position ctx.com p path;
 		| DMStatistics ->
 			ImportHandling.add_import_position ctx.com p path;