8 sig |
8 sig |
9 type T |
9 type T |
10 val names: Position.T -> (string * (string * string)) list -> T |
10 val names: Position.T -> (string * (string * string)) list -> T |
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 reported_text: T -> string |
14 val reported_text: T -> string |
14 val suppress_abbrevs: string -> Markup.T list |
15 val suppress_abbrevs: string -> Markup.T list |
15 end; |
16 end; |
16 |
17 |
17 structure Completion: COMPLETION = |
18 structure Completion: COMPLETION = |
38 fun make (name, pos) make_names = |
39 fun make (name, pos) make_names = |
39 if Position.is_reported pos andalso name <> "" andalso name <> "_" |
40 if Position.is_reported pos andalso name <> "" andalso name <> "_" |
40 then names pos (make_names (String.isPrefix (Name.clean name))) |
41 then names pos (make_names (String.isPrefix (Name.clean name))) |
41 else none; |
42 else none; |
42 |
43 |
|
44 fun encode completion = |
|
45 let |
|
46 val {total, names, ...} = dest completion; |
|
47 open XML.Encode; |
|
48 in pair int (list (pair string (pair string string))) (total, names) end; |
|
49 |
43 fun reported_text completion = |
50 fun reported_text completion = |
44 let val {pos, total, names} = dest completion in |
51 let val {pos, names, ...} = dest completion in |
45 if Position.is_reported pos andalso not (null names) then |
52 if Position.is_reported pos andalso not (null names) then |
46 let |
53 let |
47 val markup = Position.markup pos Markup.completion; |
54 val markup = Position.markup pos Markup.completion; |
48 val body = (total, names) |> |
55 in YXML.string_of (XML.Elem (markup, encode completion)) end |
49 let open XML.Encode in pair int (list (pair string (pair string string))) end; |
|
50 in YXML.string_of (XML.Elem (markup, body)) end |
|
51 else "" |
56 else "" |
52 end; |
57 end; |
53 |
58 |
54 |
59 |
55 (* suppress short abbreviations *) |
60 (* suppress short abbreviations *) |