src/Pure/General/completion.ML
changeset 67208 16519cd83ed4
parent 60731 4ac4b314d93c
child 69289 bf6937af7fe8
equal deleted inserted replaced
67207:ad538f6c5d2f 67208:16519cd83ed4
    11   val none: T
    11   val none: T
    12   val make: string * Position.T -> ((string -> bool) -> (string * (string * string)) list) -> T
    12   val make: string * Position.T -> ((string -> bool) -> (string * (string * string)) list) -> T
    13   val encode: T -> XML.body
    13   val encode: T -> XML.body
    14   val reported_text: T -> string
    14   val reported_text: T -> string
    15   val suppress_abbrevs: string -> Markup.T list
    15   val suppress_abbrevs: string -> Markup.T list
       
    16   val check_option: Options.T -> Proof.context -> string * Position.T -> string
       
    17   val check_option_value:
       
    18     Proof.context -> string * Position.T -> string * Position.T -> Options.T -> string * Options.T
    16 end;
    19 end;
    17 
    20 
    18 structure Completion: COMPLETION =
    21 structure Completion: COMPLETION =
    19 struct
    22 struct
    20 
    23 
    62 fun suppress_abbrevs s =
    65 fun suppress_abbrevs s =
    63   if not (Symbol.is_ascii_identifier s) andalso (length (Symbol.explode s) <= 1 orelse s = "::")
    66   if not (Symbol.is_ascii_identifier s) andalso (length (Symbol.explode s) <= 1 orelse s = "::")
    64   then [Markup.no_completion]
    67   then [Markup.no_completion]
    65   else [];
    68   else [];
    66 
    69 
       
    70 
       
    71 (* system options *)
       
    72 
       
    73 fun check_option options ctxt (name, pos) =
       
    74   let
       
    75     val markup =
       
    76       Options.markup options (name, pos) handle ERROR msg =>
       
    77         let
       
    78           val completion =
       
    79             make (name, pos) (fn completed =>
       
    80                 Options.names options
       
    81                 |> filter completed
       
    82                 |> map (fn a => (a, ("system_option", a))));
       
    83           val report = Markup.markup_report (reported_text completion);
       
    84         in error (msg ^ report) end;
       
    85     val _ = Context_Position.report ctxt pos markup;
       
    86   in name end;
       
    87 
       
    88 fun check_option_value ctxt (name, pos) (value, pos') options =
       
    89   let
       
    90     val _ = check_option options ctxt (name, pos);
       
    91     val options' =
       
    92       Options.update name value options
       
    93         handle ERROR msg => error (msg ^ Position.here pos');
       
    94   in (name, options') end;
       
    95 
    67 end;
    96 end;