Skip to content

Instantly share code, notes, and snippets.

@nrolland
Last active December 15, 2015 01:18
Show Gist options
  • Save nrolland/5178901 to your computer and use it in GitHub Desktop.
Save nrolland/5178901 to your computer and use it in GitHub Desktop.
type DataTipElement(wrapped:obj) =
member x.Wrapped = wrapped
let (|DataTipElementNone|DataTipElement|DataTipElementGroup|DataTipElementCompositionError|) (el:DataTipElement) =
if el.Wrapped?IsDataTipElementNone then
DataTipElementNone
elif el.Wrapped?IsDataTipElement then
let (s:string) = el.Wrapped?Item1
let xml = XmlComment(el.Wrapped?Item2)
DataTipElement(s, xml)
elif el.Wrapped?IsDataTipElementGroup then
let list = el.Wrapped?Item |> List.untypedMap (fun tup ->
let (s:string) = tup?Item1
let xml = XmlComment(tup?Item2)
s, xml )
DataTipElementGroup(list)
elif el.Wrapped?IsDataTipElementCompositionError then
DataTipElementCompositionError(el.Wrapped?Item : string)
else
failwith "Unexpected DataTipElement value!"
type DataTipText(wrapped:obj) =
member x.Wrapped = wrapped
static member Empty = DataTipText(null)
static member Create(line:string) =
let fsc = FSharpCompiler.Current
let dte = fsc.DataTipElement
let comment = fsc.XmlComment?XmlCommentNone
let datatipelement : obj = dte?DataTipElement?``.ctor``(line, comment)
let parameters = fsc.MakeList(fsc.DataTipElement, [datatipelement])
let datatiptext = fsc.DataTipText?NewDataTipText(parameters)
DataTipText(datatiptext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment