From 79f7a1ce0713715a288ff80cdfd8d1a15dda63d1 Mon Sep 17 00:00:00 2001 From: k Date: Sat, 26 Nov 2022 23:55:13 +0100 Subject: [PATCH] Use origin instead of source User defined source can still be called 'source' I guess? --- src/compiler/compiler.ml | 2 +- src/core/define.ml | 6 +++--- src/core/display/completionItem.ml | 8 ++++---- src/core/meta.ml | 10 +++++----- std/haxe/display/Display.hx | 1 + 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/compiler/compiler.ml b/src/compiler/compiler.ml index 5b919d2f00c..2780c4ff04d 100644 --- a/src/compiler/compiler.ml +++ b/src/compiler/compiler.ml @@ -617,4 +617,4 @@ module HighLevel = struct in let code = loop args in comm.exit code -end \ No newline at end of file +end diff --git a/src/core/define.ml b/src/core/define.ml index 547c4e873d4..e8bbbb429ef 100644 --- a/src/core/define.ml +++ b/src/core/define.ml @@ -35,7 +35,7 @@ let get_define_key d = match (infos d) with (s,_,_) -> s let get_documentation d = - let t, (doc,flags), src = infos d in + let t, (doc,flags), origin = infos d in let params = ref [] and pfs = ref [] in List.iter (function | HasParam s -> params := s :: !params @@ -46,12 +46,12 @@ let get_documentation d = | [] -> "" | l -> "<" ^ String.concat ">, <" l ^ "> " ) in - let source = match src with + let origin = match origin with | UserDefined Some s -> " (from " ^ s ^ ")" | Compiler | UserDefined None -> "" in let pfs = platform_list_help (List.rev !pfs) in - (String.concat "-" (ExtString.String.nsplit t "_")), params ^ doc ^ pfs ^ source + (String.concat "-" (ExtString.String.nsplit t "_")), params ^ doc ^ pfs ^ origin let get_documentation_list() = let m = ref 0 in diff --git a/src/core/display/completionItem.ml b/src/core/display/completionItem.ml index 7f58786b2b5..4c52f154612 100644 --- a/src/core/display/completionItem.ml +++ b/src/core/display/completionItem.ml @@ -759,7 +759,7 @@ let to_json ctx index item = ] | ITMetadata meta -> let open Meta in - let name,(doc,params),src = Meta.get_info meta in + let name,(doc,params),origin = Meta.get_info meta in let name = "@" ^ name in let usage_to_string = function | TClass -> "TClass" @@ -773,7 +773,7 @@ let to_json ctx index item = | TTypeParameter -> "TTypeParameter" | TVariable -> "TVariable" in - let source = match src with + let origin = match origin with | Compiler -> Some "haxe compiler" | UserDefined s -> s in @@ -794,7 +794,7 @@ let to_json ctx index item = "targets",jlist jstring targets; "internal",jbool internal; "links",jlist jstring links; - "source",jopt jstring source; + "origin",jopt jstring origin; ] | ITKeyword kwd ->"Keyword",jobject [ "name",jstring (s_keyword kwd) @@ -833,4 +833,4 @@ let to_json ctx index item = | Some t -> ("type",CompletionType.to_json ctx (snd t)) :: jindex ) - ) \ No newline at end of file + ) diff --git a/src/core/meta.ml b/src/core/meta.ml index 3014f6554b5..d5ba7526a0c 100644 --- a/src/core/meta.ml +++ b/src/core/meta.ml @@ -18,7 +18,7 @@ type user_meta = { let user_meta : (string, user_meta) Hashtbl.t = Hashtbl.create 0 -type meta_source = +type meta_origin = | Compiler | UserDefined of string option @@ -56,7 +56,7 @@ let from_string s = | _ -> Custom s let get_documentation d = - let t, (doc,flags), src = get_info d in + let t, (doc,flags), origin = get_info d in if not (List.mem UsedInternally flags) then begin let params = ref [] and used = ref [] and pfs = ref [] in List.iter (function @@ -71,12 +71,12 @@ let get_documentation d = | l -> "(<" ^ String.concat ">, <" l ^ ">) " ) in let pfs = platform_list_help (List.rev !pfs) in - let source = match src with + let origin = match origin with | UserDefined Some s -> " (from " ^ s ^ ")" | Compiler | UserDefined None -> "" in let str = "@" ^ t in - Some (str,params ^ doc ^ pfs ^ source) + Some (str,params ^ doc ^ pfs ^ origin) end else None @@ -121,4 +121,4 @@ let get_user_documentation_list () = let copy_from_to m src dst = try (get m src) :: dst - with Not_found -> dst \ No newline at end of file + with Not_found -> dst diff --git a/std/haxe/display/Display.hx b/std/haxe/display/Display.hx index e5acd760a1b..9873f7b1bf0 100644 --- a/std/haxe/display/Display.hx +++ b/std/haxe/display/Display.hx @@ -294,6 +294,7 @@ typedef Metadata = { var parameters:Array; var platforms:Array; var targets:Array; + var origin:String; var internal:Bool; var ?links:Array; }