@@ -11,8 +11,17 @@ open Microsoft.FSharp.Core.Printf
1111#nowarn " 62" // This construct is for ML compatibility.
1212
1313type layout = Internal.Utilities.StructuredFormat.Layout
14+ type LayoutTag = Internal.Utilities.StructuredFormat.LayoutTag
1415type TaggedText = Internal.Utilities.StructuredFormat.TaggedText
1516
17+ type NavigableTaggedText ( tag , text , range : Range.range ) =
18+ member val Range = range
19+ interface TaggedTextwith
20+ member x.Tag = tag
21+ member x.Text = text
22+ static member Create ( tt : TaggedText , range ) =
23+ NavigableTaggedText( tt.Tag, tt.Text, range)
24+
1625let spaces n = new String( ' ' , n)
1726
1827
@@ -33,8 +42,8 @@ let rec juxtRight = function
3342| Attr(_ tag,_ attrs, l) -> juxtRight l
3443
3544// NOTE: emptyL might be better represented as a constructor, so then (Sep"") would have true meaning
36- let emptyL = Leaf( true , TaggedText .Text" " , true )
37- let isEmptyL = function Leaf( true , tag, true ) when tag.Value = " " -> true | _ -> false
45+ let emptyL = Leaf( true , Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .Text" " , true )
46+ let isEmptyL = function Leaf( true , tag, true ) when tag.Text = " " -> true | _ -> false
3847
3948let mkNode l r joint =
4049if isEmptyL lthen relse
@@ -55,11 +64,11 @@ let rightL (str:TaggedText) = Leaf (true ,str,false)
5564let leftL ( str : TaggedText ) = Leaf( false , str, true )
5665
5766module TaggedTextOps =
58- let tagActivePatternCase = Internal.Utilities.StructuredFormat.TaggedText .ActivePatternCase
59- let tagActivePatternResult = Internal.Utilities.StructuredFormat.TaggedText .ActivePatternResult
67+ let tagActivePatternCase = Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .ActivePatternCase
68+ let tagActivePatternResult = Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .ActivePatternResult
6069let tagAlias = Internal.Utilities.StructuredFormat.TaggedTextOps.tagAlias
6170let tagClass = Internal.Utilities.StructuredFormat.TaggedTextOps.tagClass
62- let tagUnion = Internal.Utilities.StructuredFormat.TaggedText .Union
71+ let tagUnion = Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .Union
6372let tagUnionCase = Internal.Utilities.StructuredFormat.TaggedTextOps.tagUnionCase
6473let tagDelegate = Internal.Utilities.StructuredFormat.TaggedTextOps.tagDelegate
6574let tagEnum = Internal.Utilities.StructuredFormat.TaggedTextOps.tagEnum
@@ -72,7 +81,7 @@ module TaggedTextOps =
7281let tagRecord = Internal.Utilities.StructuredFormat.TaggedTextOps.tagRecord
7382let tagRecordField = Internal.Utilities.StructuredFormat.TaggedTextOps.tagRecordField
7483let tagMethod = Internal.Utilities.StructuredFormat.TaggedTextOps.tagMethod
75- let tagMember = Internal.Utilities.StructuredFormat.TaggedText .Member
84+ let tagMember = Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .Member
7685let tagModule = Internal.Utilities.StructuredFormat.TaggedTextOps.tagModule
7786let tagModuleBinding = Internal.Utilities.StructuredFormat.TaggedTextOps.tagModuleBinding
7887let tagNamespace = Internal.Utilities.StructuredFormat.TaggedTextOps.tagNamespace
@@ -86,8 +95,8 @@ module TaggedTextOps =
8695let tagTypeParameter = Internal.Utilities.StructuredFormat.TaggedTextOps.tagTypeParameter
8796let tagText = Internal.Utilities.StructuredFormat.TaggedTextOps.tagText
8897let tagPunctuation = Internal.Utilities.StructuredFormat.TaggedTextOps.tagPunctuation
89- let tagUnknownEntity = Internal.Utilities.StructuredFormat.TaggedText .UnknownEntity
90- let tagUnknownType = Internal.Utilities.StructuredFormat.TaggedText .UnknownType
98+ let tagUnknownEntity = Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .UnknownEntity
99+ let tagUnknownType = Internal.Utilities.StructuredFormat.TaggedTextOps.tag LayoutTag .UnknownType
91100
92101module Literals =
93102// common tagged literals
@@ -317,8 +326,8 @@ let squashTo maxWidth layout =
317326let breaks , layout , pos , offset = fit breaks( pos, l)
318327let layout = Attr( tag, attrs, layout)
319328 breaks, layout, pos, offset
320- | Leaf(_ jl, text ,_ jr) ->
321- let textWidth = text .Length
329+ | Leaf(_ jl, taggedText ,_ jr) ->
330+ let textWidth = taggedText.Text .Length
322331let rec fitLeaf breaks pos =
323332if pos+ textWidth<= maxWidththen
324333 breaks, layout, pos+ textWidth, textWidth(* great, it fits*)
@@ -382,7 +391,7 @@ let renderL (rr: LayoutRenderer<_,_>) layout =
382391| ObjLeaf_ -> failwith" ObjLeaf should never apper here"
383392(* pos is tab level*)
384393| Leaf(_, text,_) ->
385- k( rr.AddText z text, i+ text.Length)
394+ k( rr.AddText z text, i+ text.Text. Length)
386395| Node(_, l,_, r,_, Broken indent) ->
387396 addL z pos i l<|
388397fun ( z , _i ) ->
@@ -409,7 +418,7 @@ let renderL (rr: LayoutRenderer<_,_>) layout =
409418let stringR =
410419{ new LayoutRenderer< string, string list> with
411420member x.Start () = []
412- member x.AddText rstrstext = text.Value :: rstrs
421+ member x.AddText rstrstaggedText = taggedText.Text :: rstrs
413422member x.AddBreak rstrs n = ( spaces n) :: " \n " :: rstrs
414423member x.AddTag z ( _ , _ , _ ) = z
415424member x.Finish rstrs = String.Join( " " , Array.ofList( List.rev rstrs)) }
@@ -431,7 +440,7 @@ let taggedTextListR collector =
431440let channelR ( chan : TextWriter ) =
432441{ new LayoutRenderer< NoResult, NoState> with
433442member r.Start () = NoState
434- member r.AddText z s = chan.Write s.Value ; z
443+ member r.AddText z s = chan.Write s.Text ; z
435444member r.AddBreak z n = chan.WriteLine(); chan.Write( spaces n); z
436445member r.AddTag z ( tag , attrs , start ) = z
437446member r.Finish z = NoResult}
@@ -440,7 +449,7 @@ let channelR (chan:TextWriter) =
440449let bufferR os =
441450{ new LayoutRenderer< NoResult, NoState> with
442451member r.Start () = NoState
443- member r.AddText z s = bprintf os" %s " s.Value ; z
452+ member r.AddText z s = bprintf os" %s " s.Text ; z
444453member r.AddBreak z n = bprintf os" \n " ; bprintf os" %s " ( spaces n); z
445454member r.AddTag z ( tag , attrs , start ) = z
446455member r.Finish z = NoResult}