@@ -112,21 +112,21 @@ func FormatSnapshot(
112
112
b .WriteRune (' ' )
113
113
b .WriteString (formatSymbol (occ .Symbol ))
114
114
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
+
115
123
if info , ok := symtab [occ .Symbol ]; ok && isDefinition {
116
- prefix := "\n " + commentSyntax + strings .Repeat (" " , int (pos .Start .Character ))
117
124
for _ , documentation := range info .Documentation {
118
125
// At least get the first line of documentation if there is leading whitespace
119
126
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 )
129
128
}
129
+
130
130
sort .SliceStable (info .Relationships , func (i , j int ) bool {
131
131
return info .Relationships [i ].Symbol < info .Relationships [j ].Symbol
132
132
})
@@ -153,6 +153,24 @@ func FormatSnapshot(
153
153
return b .String (), formattingError
154
154
}
155
155
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
+
156
174
// isRangeLess compares two SCIP ranges (which are encoded as []int32).
157
175
func isSCIPRangeLess (a []int32 , b []int32 ) bool {
158
176
if a [0 ] != b [0 ] { // start line
0 commit comments