src/Pure/General/name_space.ML
changeset 62967 5e8b1aead28f
parent 62241 a4a1f282bcd5
child 62987 dc8a8a7559e7
equal deleted inserted replaced
62966:771b8ad5c7fc 62967:5e8b1aead28f
   249 (* completion *)
   249 (* completion *)
   250 
   250 
   251 fun completion context space (xname, pos) =
   251 fun completion context space (xname, pos) =
   252   Completion.make (xname, pos) (fn completed =>
   252   Completion.make (xname, pos) (fn completed =>
   253     let
   253     let
   254       fun result_ord ((xname1, (_, name1)), (xname2, (_, name2))) =
   254       fun result_ord ((precise1, (xname1, (_, name1))), (precise2, (xname2, (_, name2)))) =
   255         (case bool_ord (apply2 (is_some o Long_Name.dest_local) (name2, name1)) of
   255         (case bool_ord (precise2, precise1) of
   256           EQUAL =>
   256           EQUAL =>
   257             (case int_ord (apply2 Long_Name.qualification (xname1, xname2)) of
   257             (case bool_ord (apply2 (is_some o Long_Name.dest_local) (name2, name1)) of
   258               EQUAL => string_ord (xname1, xname2)
   258               EQUAL =>
       
   259                 (case int_ord (apply2 Long_Name.qualification (xname1, xname2)) of
       
   260                   EQUAL => string_ord (xname1, xname2)
       
   261                 | ord => ord)
   259             | ord => ord)
   262             | ord => ord)
   260         | ord => ord);
   263         | ord => ord);
   261       val Name_Space {kind, internals, ...} = space;
   264       val Name_Space {kind, internals, ...} = space;
   262       val ext = extern_shortest (Context.proof_of context) space;
   265       val ext = extern_shortest (Context.proof_of context) space;
   263     in
   266     in
   264       Change_Table.fold
   267       Change_Table.fold
   265         (fn (a, (name :: _, _)) =>
   268         (fn (a, (name :: _, _)) =>
   266             if completed a andalso not (is_concealed space name) then
   269             if completed a andalso not (is_concealed space name) then
   267               let val a' = ext name
   270               cons (a = ext name, (a, (kind, name)))
   268               in if a = a' then cons (a', (kind, name)) else I end
       
   269             else I
   271             else I
   270           | _ => I) internals []
   272           | _ => I) internals []
   271       |> sort_distinct result_ord
   273       |> sort_distinct result_ord
       
   274       |> map #2
   272     end);
   275     end);
   273 
   276 
   274 
   277 
   275 (* merge *)
   278 (* merge *)
   276 
   279