Quellcode durchsuchen

[display] don't show `implements` on interfaces

Simon Krajewski vor 7 Jahren
Ursprung
Commit
f486b3440b
5 geänderte Dateien mit 19 neuen und 14 gelöschten Zeilen
  1. 6 2
      src/compiler/displayOutput.ml
  2. 1 1
      src/compiler/main.ml
  3. 1 1
      src/core/displayTypes.ml
  4. 9 9
      src/syntax/grammar.mly
  5. 2 1
      src/syntax/parser.ml

+ 6 - 2
src/compiler/displayOutput.ml

@@ -657,7 +657,11 @@ let handle_syntax_completion com kind p = match com.json_out with
 		()
 	| Some(f,_) ->
 		match kind with
-		| Parser.SCClassHerit ->
+		| Parser.SCClassRelation ->
 			let l = [ITKeyword Extends;ITKeyword Implements] in
 			let ctx = Genjson.create_context GMFull in
-			f(fields_to_json ctx l CRClassHerit None false)
+			f(fields_to_json ctx l CRTypeRelation None false)
+		| Parser.SCInterfaceRelation ->
+			let l = [ITKeyword Extends] in
+			let ctx = Genjson.create_context GMFull in
+			f(fields_to_json ctx l CRTypeRelation None false)

+ 1 - 1
src/compiler/main.ml

@@ -976,7 +976,7 @@ with
 			| CRUsing
 			| CRNew
 			| CRPattern
-			| CRClassHerit ->
+			| CRTypeRelation ->
 				DisplayOutput.print_toplevel fields
 			| CRField
 			| CRStructureField

+ 1 - 1
src/core/displayTypes.ml

@@ -78,7 +78,7 @@ module CompletionResultKind = struct
 		| CRNew
 		| CRPattern
 		| CROverride
-		| CRClassHerit
+		| CRTypeRelation
 end
 
 module DisplayMode = struct

+ 9 - 9
src/syntax/grammar.mly

@@ -158,23 +158,23 @@ and parse_type_decl s =
 				}, punion p1 p2)
 			end
 		| [< n , p1 = parse_class_flags; name = type_name; tl = parse_constraint_params >] ->
-			let rec loop had_display p0 acc = match s with parser
+			let rec loop had_display p0 acc =
+				let check_display p0 p1 =
+					if not had_display && encloses_resume p1 then syntax_completion (if List.mem HInterface n then SCInterfaceRelation else SCClassRelation) p0
+				in
+				match s with parser
 				| [< '(Kwd Extends,p1); t,b = parse_type_path_or_resume p1 >] ->
-					if not had_display && encloses_resume {p1 with pmin = p0.pmax; pmax = p1.pmin} then
-						syntax_completion SCClassHerit p0;
+					check_display p0 {p1 with pmin = p0.pmax; pmax = p1.pmin};
 					loop (had_display || b) (pos t) ((HExtends t) :: acc)
 				| [< '(Kwd Implements,p1); t,b = parse_type_path_or_resume p1 >] ->
-					if not had_display && encloses_resume {p1 with pmin = p0.pmax; pmax = p1.pmin} then
-						syntax_completion SCClassHerit p0;
+					check_display p0 {p1 with pmin = p0.pmax; pmax = p1.pmin};
 					loop (had_display || b) (pos t) ((HImplements t) :: acc)
 				| [< '(BrOpen,p1) >] ->
-					if not had_display && encloses_resume {p1 with pmin = p0.pmax; pmax = p1.pmin} then
-						syntax_completion SCClassHerit p0;
+					check_display p0 {p1 with pmin = p0.pmax; pmax = p1.pmin};
 					List.rev acc
 				| [< >] ->
 					if not (do_resume()) then serror() else begin
-						if not had_display && encloses_resume {p1 with pmin = p0.pmax; pmax = (next_pos s).pmax} then
-							syntax_completion SCClassHerit p0;
+						check_display p0 {p1 with pmin = p0.pmax; pmax = (next_pos s).pmax};
 						List.rev acc
 					end
 			in

+ 2 - 1
src/syntax/parser.ml

@@ -32,7 +32,8 @@ type error_msg =
 	| Custom of string
 
 type syntax_completion =
-	| SCClassHerit
+	| SCClassRelation
+	| SCInterfaceRelation
 
 exception Error of error_msg * pos
 exception TypePath of string list * (string * bool) option * bool (* in import *)