Explorar o código

[display] don't trigger completion in line-comments

see #7050
Simon Krajewski %!s(int64=7) %!d(string=hai) anos
pai
achega
7294673339

+ 3 - 1
src/compiler/displayOutput.ml

@@ -664,4 +664,6 @@ let handle_syntax_completion com kind p = match com.json_out with
 		| Parser.SCInterfaceRelation ->
 			let l = [ITKeyword Extends] in
 			let ctx = Genjson.create_context GMFull in
-			f(fields_to_json ctx l CRTypeRelation None false)
+			f(fields_to_json ctx l CRTypeRelation None false)
+		| Parser.SCComment ->
+			()

+ 2 - 1
src/compiler/main.ml

@@ -1017,7 +1017,8 @@ with
 			end
 		end
 	| Parser.SyntaxCompletion(kind,pos) ->
-		DisplayOutput.handle_syntax_completion com kind pos
+		DisplayOutput.handle_syntax_completion com kind pos;
+		error ctx ("Error: No completion point was found") null_pos
 	| DisplayException(ModuleSymbols s | Diagnostics s | Statistics s | Metadata s) ->
 		raise (DisplayOutput.Completion s)
 	| EvalExceptions.Sys_exit i | Hlinterp.Sys_exit i ->

+ 3 - 2
src/syntax/parser.ml

@@ -32,6 +32,7 @@ type error_msg =
 	| Custom of string
 
 type syntax_completion =
+	| SCComment
 	| SCClassRelation
 	| SCInterfaceRelation
 
@@ -131,7 +132,7 @@ let type_path sl in_import = match sl with
 	| _ -> raise (TypePath (List.rev sl,None,in_import))
 
 let is_resuming_file file =
-	Path.unique_full_path file = !resume_display.pfile
+	do_resume() && Path.unique_full_path file = !resume_display.pfile
 
 let is_resuming p =
 	let p2 = !resume_display in
@@ -141,7 +142,7 @@ let set_resume p =
 	resume_display := { p with pfile = Path.unique_full_path p.pfile }
 
 let encloses_resume p =
-	p.pmin < !resume_display.pmin && p.pmax >= !resume_display.pmax
+	do_resume() && p.pmin < !resume_display.pmin && p.pmax >= !resume_display.pmax
 
 let would_skip_resume p1 s =
 	match Stream.npeek 1 s with

+ 2 - 0
src/syntax/parserEntry.ml

@@ -85,6 +85,7 @@ let parse ctx code =
 	and process_token tk =
 		match fst tk with
 		| Comment s ->
+			(* if encloses_resume (pos tk) then syntax_completion SCComment (pos tk); *)
 			let tk = next_token() in
 			if !use_doc then begin
 				let l = String.length s in
@@ -92,6 +93,7 @@ let parse ctx code =
 			end;
 			tk
 		| CommentLine s ->
+			if encloses_resume (pos tk) then syntax_completion SCComment (pos tk);
 			next_token()
 		| Sharp "end" ->
 			(match !mstack with

+ 14 - 0
tests/display/src/cases/Issue7050.hx

@@ -0,0 +1,14 @@
+package cases;
+
+class Issue7050 extends DisplayTestCase {
+	/**
+	class Main {
+		static function main() {
+			// {-1-}
+		}
+	}
+	**/
+	function test() {
+		eq(true, noCompletionPoint(toplevel.bind(pos(1))));
+	}
+}