@@ -48,6 +48,13 @@ type Location =
4848 Column: int
4949 }
5050
51+ type CompletionResponse =
52+ {
53+ Name: string
54+ Glyph: string
55+ GlyphChar: string
56+ }
57+
5158type ProjectResponse =
5259 {
5360 Project: string
@@ -267,6 +274,48 @@ module internal CommandInput =
267274 let cmds = compilerlocation <|> outputmode <|> helptext <|> help <|> declarations <|> parse <|> project <|> completionTipOrDecl <|> quit <|> error
268275 reader |> Parsing.getFirst cmds
269276
277+ module internal CompletionUtils =
278+ let map =
279+ [ 0x0000 , ( " Class" , " C" )
280+ 0x0003 , ( " Enum" , " E" )
281+ 0x00012 , ( " Struct" , " S" )
282+ 0x00018 , ( " Struct" , " S" ) (* value type *)
283+ 0x0002 , ( " Delegate" , " D" )
284+ 0x0008 , ( " Interface" , " I" )
285+ 0x000e , ( " Module" , " N" ) (* module *)
286+ 0x000f , ( " Namespace" , " N" )
287+ 0x000c , ( " Method" , " M" )
288+ 0x000d , ( " Extension Method" , " M" ) (* method2 ? *)
289+ 0x00011 , ( " Property" , " P" )
290+ 0x0005 , ( " Event" , " e" )
291+ 0x0007 , ( " Field" , " F" ) (* fieldblue ? *)
292+ 0x0020 , ( " Field" , " F" ) (* fieldyellow ? *)
293+ 0x0001 , ( " Field" , " F" ) (* const *)
294+ 0x0004 , ( " Property" , " P" ) (* enummember *)
295+ 0x0006 , ( " Exception" , " X" ) (* exception *)
296+ 0x0009 , ( " Text File Icon" , " t" ) (* TextLine *)
297+ 0x000a , ( " Regular File" , " R" ) (* Script *)
298+ 0x000b , ( " Script" , " s" ) (* Script2 *)
299+ 0x0010 , ( " Tip of the day" , " t" ) (* Formula *) ;
300+ 0x00013 , ( " Class" , " C" ) (* Template *)
301+ 0x00014 , ( " Class" , " C" ) (* Typedef *)
302+ 0x00015 , ( " Type" , " T" ) (* Type *)
303+ 0x00016 , ( " Type" , " T" ) (* Union *)
304+ 0x00017 , ( " Field" , " F" ) (* Variable *)
305+ 0x00019 , ( " Class" , " C" ) (* Intrinsic *)
306+ 0x0001f , ( " Other" , " o" ) (* error *)
307+ 0x00021 , ( " Other" , " o" ) (* Misc1 *)
308+ 0x0022 , ( " Other" , " o" ) (* Misc2 *)
309+ 0x00023 , ( " Other" , " o" ) (* Misc3 *) ] |> Map.ofSeq
310+
311+ /// Translates icon code that we get from F# language service into a MonoDevelop icon
312+ let getIcon glyph =
313+ match map.TryFind ( glyph / 6 ), map.TryFind ( glyph % 6 ) with
314+ | Some( s), _ -> s // Is the second number good for anything?
315+ | _, _ -> ( " " , " " )
316+
317+
318+
270319// --------------------------------------------------------------------------------------
271320// Main application command-line loop
272321// --------------------------------------------------------------------------------------
@@ -488,7 +537,9 @@ module internal Main =
488537 prAsJson { Kind = " helptext" ; Data = helptext }
489538
490539 prAsJson { Kind = " completion"
491- Data = [ for d in decls.Items do yield d.Name ] }
540+ Data = [ for d in decls.Items do
541+ let ( glyph , glyphChar ) = CompletionUtils.getIcon d.Glyph
542+ yield { Name = d.Name; Glyph = glyph; GlyphChar = glyphChar } ] }
492543
493544 let helptext =
494545 Seq.fold ( fun m ( d : FSharpDeclarationListItem ) -> Map.add d.Name d.DescriptionText m) Map.empty decls.Items
0 commit comments