@@ -112,21 +112,21 @@ func FormatSnapshot(
112112 b .WriteRune (' ' )
113113 b .WriteString (formatSymbol (occ .Symbol ))
114114
115+ prefix := "\n " + commentSyntax + strings .Repeat (" " , int (pos .Start .Character ))
116+
117+ hasOverrideDocumentation := len (occ .OverrideDocumentation ) > 0
118+ if hasOverrideDocumentation {
119+ documentation := occ .OverrideDocumentation [0 ]
120+ writeDocumentation (& b , documentation , prefix , true )
121+ }
122+
115123 if info , ok := symtab [occ .Symbol ]; ok && isDefinition {
116- prefix := "\n " + commentSyntax + strings .Repeat (" " , int (pos .Start .Character ))
117124 for _ , documentation := range info .Documentation {
118125 // At least get the first line of documentation if there is leading whitespace
119126 documentation = strings .TrimSpace (documentation )
120-
121- b .WriteString (prefix )
122- b .WriteString ("documentation " )
123- truncatedDocumentation := documentation
124- newlineIndex := strings .Index (documentation , "\n " )
125- if newlineIndex >= 0 {
126- truncatedDocumentation = documentation [0 :newlineIndex ]
127- }
128- b .WriteString (truncatedDocumentation )
127+ writeDocumentation (& b , documentation , prefix , false )
129128 }
129+
130130 sort .SliceStable (info .Relationships , func (i , j int ) bool {
131131 return info .Relationships [i ].Symbol < info .Relationships [j ].Symbol
132132 })
@@ -153,6 +153,24 @@ func FormatSnapshot(
153153 return b .String (), formattingError
154154}
155155
156+ func writeDocumentation (b * strings.Builder , documentation string , prefix string , override bool ) {
157+ // At least get the first line of documentation if there is leading whitespace
158+ documentation = strings .TrimSpace (documentation )
159+
160+ b .WriteString (prefix )
161+ if override {
162+ b .WriteString ("override_" )
163+ }
164+ b .WriteString ("documentation " )
165+
166+ truncatedDocumentation := documentation
167+ newlineIndex := strings .Index (documentation , "\n " )
168+ if newlineIndex >= 0 {
169+ truncatedDocumentation = documentation [0 :newlineIndex ]
170+ }
171+ b .WriteString (truncatedDocumentation )
172+ }
173+
156174// isRangeLess compares two SCIP ranges (which are encoded as []int32).
157175func isSCIPRangeLess (a []int32 , b []int32 ) bool {
158176 if a [0 ] != b [0 ] { // start line
0 commit comments