diff --git a/src/context/display/displayToplevel.ml b/src/context/display/displayToplevel.ml index facb253d13b..41536c6f43a 100644 --- a/src/context/display/displayToplevel.ml +++ b/src/context/display/displayToplevel.ml @@ -266,7 +266,7 @@ let collect ctx tk with_type sort = let tname,is_private,meta = match d with | EClass d -> fst d.d_name,List.mem HPrivate d.d_flags,d.d_meta | EEnum d -> fst d.d_name,List.mem EPrivate d.d_flags,d.d_meta - | ETypedef d -> fst d.d_name,List.mem EPrivate d.d_flags,d.d_meta + | ETypedef d -> fst d.d_name,List.mem TDPrivate d.d_flags,d.d_meta | EAbstract d -> fst d.d_name,List.mem AbPrivate d.d_flags,d.d_meta | EStatic d -> fst d.d_name,List.exists (fun (a,_) -> a = APrivate) d.d_flags,d.d_meta | EImport _ | EUsing _ -> raise Exit diff --git a/src/core/ast.ml b/src/core/ast.ml index e25cd3a4816..32acc2d470e 100644 --- a/src/core/ast.ml +++ b/src/core/ast.ml @@ -352,6 +352,10 @@ type abstract_flag = | AbExtern | AbEnum +type typedef_flag = + | TDPrivate + | TDExtern + type enum_constructor = { ec_name : placed_name; ec_doc : documentation; @@ -381,7 +385,7 @@ type import = placed_name list * import_mode type type_def = | EClass of (class_flag, class_field list) definition | EEnum of (enum_flag, enum_constructor list) definition - | ETypedef of (enum_flag, type_hint) definition + | ETypedef of (typedef_flag, type_hint) definition | EAbstract of (abstract_flag, class_field list) definition | EStatic of (placed_access, class_field_kind) definition | EImport of import diff --git a/src/core/display/completionItem.ml b/src/core/display/completionItem.ml index b9032ece4d8..f3f4b804bb5 100644 --- a/src/core/display/completionItem.ml +++ b/src/core/display/completionItem.ml @@ -126,11 +126,11 @@ module CompletionModuleType = struct name = fst d.d_name; module_name = module_name; pos = p; - is_private = List.mem EPrivate d.d_flags; + is_private = List.mem TDPrivate d.d_flags; params = d.d_params; meta = d.d_meta; doc = d.d_doc; - is_extern = List.mem EExtern d.d_flags; + is_extern = List.mem TDExtern d.d_flags; is_final = false; is_abstract = false; kind = kind; diff --git a/src/macro/macroApi.ml b/src/macro/macroApi.ml index 155ed8c08ce..2cf59590cfe 100644 --- a/src/macro/macroApi.ml +++ b/src/macro/macroApi.ml @@ -1617,7 +1617,7 @@ let decode_type_def v = in EEnum (mk (if isExtern then [EExtern] else []) (List.map conv fields)) | 1, [] -> - ETypedef (mk (if isExtern then [EExtern] else []) (CTAnonymous fields,pos)) + ETypedef (mk (if isExtern then [TDExtern] else []) (CTAnonymous fields,pos)) | 2, [ext;impl;interf;final;abstract] -> let flags = if isExtern then [HExtern] else [] in let is_interface = decode_opt_bool interf in @@ -1636,7 +1636,7 @@ let decode_type_def v = let flags = if is_abstract then HAbstract :: flags else flags in EClass (mk flags fields) | 3, [t] -> - ETypedef (mk (if isExtern then [EExtern] else []) (decode_ctype t)) + ETypedef (mk (if isExtern then [TDExtern] else []) (decode_ctype t)) | 4, [tthis;tflags;tfrom;tto] -> let flags = match opt decode_array tflags with | None -> [] diff --git a/src/syntax/grammar.mly b/src/syntax/grammar.mly index cce1e22bfa3..01bc95fcb8c 100644 --- a/src/syntax/grammar.mly +++ b/src/syntax/grammar.mly @@ -300,7 +300,7 @@ and parse_type_decl mode s = d_doc = doc_from_string_opt doc; d_meta = meta; d_params = tl; - d_flags = ExtList.List.filter_map decl_flag_to_enum_flag c; + d_flags = ExtList.List.filter_map decl_flag_to_typedef_flag c; d_data = t; }, punion p1 (pos t)) | [< '(Kwd Abstract,p1) >] -> diff --git a/src/syntax/parser.ml b/src/syntax/parser.ml index eda1d6ab303..1e07ea201e8 100644 --- a/src/syntax/parser.ml +++ b/src/syntax/parser.ml @@ -212,6 +212,7 @@ let unsupported_decl_flag decl flag pos = let unsupported_decl_flag_class = unsupported_decl_flag "classes" let unsupported_decl_flag_enum = unsupported_decl_flag "enums" let unsupported_decl_flag_abstract = unsupported_decl_flag "abstracts" +let unsupported_decl_flag_typedef = unsupported_decl_flag "typedefs" let unsupported_decl_flag_module_field = unsupported_decl_flag "module-level fields" let decl_flag_to_class_flag (flag,p) = match flag with @@ -230,6 +231,11 @@ let decl_flag_to_abstract_flag (flag,p) = match flag with | DExtern -> Some AbExtern | DFinal | DMacro | DDynamic | DInline | DPublic | DStatic | DOverload -> unsupported_decl_flag_abstract flag p +let decl_flag_to_typedef_flag (flag,p) = match flag with + | DPrivate -> Some TDPrivate + | DExtern -> Some TDExtern + | DFinal | DMacro | DDynamic | DInline | DPublic | DStatic | DOverload -> unsupported_decl_flag_typedef flag p + let decl_flag_to_module_field_flag (flag,p) = match flag with | DPrivate -> Some (APrivate,p) | DMacro -> Some (AMacro,p) diff --git a/src/typing/typeloadModule.ml b/src/typing/typeloadModule.ml index 906492bcfa7..fff4e9b963f 100644 --- a/src/typing/typeloadModule.ml +++ b/src/typing/typeloadModule.ml @@ -144,7 +144,7 @@ module ModuleLevel = struct let name = fst d.d_name in check_type_name name d.d_meta; has_declaration := true; - let priv = List.mem EPrivate d.d_flags in + let priv = List.mem TDPrivate d.d_flags in let path = make_path name priv d.d_meta p in let t = {(mk_typedef m path p (pos d.d_name) (mk_mono())) with t_doc = d.d_doc; diff --git a/src/typing/typeloadParse.ml b/src/typing/typeloadParse.ml index 238ab8ade5b..cfad8bff5f1 100644 --- a/src/typing/typeloadParse.ml +++ b/src/typing/typeloadParse.ml @@ -315,7 +315,7 @@ let parse_module com m p = d_doc = None; d_meta = []; d_params = d.d_params; - d_flags = if priv then [EPrivate] else []; + d_flags = if priv then [TDPrivate] else []; d_data = begin let tp = if priv then @@ -335,7 +335,7 @@ let parse_module com m p = match t with | EClass d -> build HPrivate d | EEnum d -> build EPrivate d - | ETypedef d -> build EPrivate d + | ETypedef d -> build TDPrivate d | EAbstract d -> build AbPrivate d | EStatic d -> build (AStatic,null_pos) d | EImport _ | EUsing _ -> acc