@@ -729,6 +729,7 @@ var actionMarkerFuncs = map[string]func(marker){
729
729
"highlight" : actionMarkerFunc (highlightMarker ),
730
730
"hover" : actionMarkerFunc (hoverMarker ),
731
731
"implementation" : actionMarkerFunc (implementationMarker ),
732
+ "inlayhints" : actionMarkerFunc (inlayhintsMarker ),
732
733
"preparerename" : actionMarkerFunc (prepareRenameMarker ),
733
734
"rank" : actionMarkerFunc (rankMarker ),
734
735
"rankl" : actionMarkerFunc (ranklMarker ),
@@ -1129,11 +1130,25 @@ func (mark marker) uri() protocol.DocumentURI {
1129
1130
return mark .run .env .Sandbox .Workdir .URI (mark .run .test .fset .File (mark .note .Pos ).Name ())
1130
1131
}
1131
1132
1133
+ // document returns a protocol.TextDocumentIdentifier for the current file.
1134
+ func (mark marker ) document () protocol.TextDocumentIdentifier {
1135
+ return protocol.TextDocumentIdentifier {URI : mark .uri ()}
1136
+ }
1137
+
1132
1138
// path returns the relative path to the file containing the marker.
1133
1139
func (mark marker ) path () string {
1134
1140
return mark .run .env .Sandbox .Workdir .RelPath (mark .run .test .fset .File (mark .note .Pos ).Name ())
1135
1141
}
1136
1142
1143
+ // mapper returns a *protocol.Mapper for the current file.
1144
+ func (mark marker ) mapper () * protocol.Mapper {
1145
+ mapper , err := mark .run .env .Editor .Mapper (mark .path ())
1146
+ if err != nil {
1147
+ mark .run .env .T .Fatalf ("failed to get mapper for current mark: %v" , err )
1148
+ }
1149
+ return mapper
1150
+ }
1151
+
1137
1152
// fmtLoc formats the given pos in the context of the test, using
1138
1153
// archive-relative paths for files and including the line number in the full
1139
1154
// archive file.
@@ -1647,12 +1662,7 @@ func acceptCompletionMarker(mark marker, src protocol.Location, label string, go
1647
1662
return
1648
1663
}
1649
1664
filename := mark .path ()
1650
- mapper , err := mark .run .env .Editor .Mapper (filename )
1651
- if err != nil {
1652
- mark .errorf ("Editor.Mapper(%s) failed: %v" , filename , err )
1653
- return
1654
- }
1655
-
1665
+ mapper := mark .mapper ()
1656
1666
patched , _ , err := source .ApplyProtocolEdits (mapper , append ([]protocol.TextEdit {
1657
1667
* selected .TextEdit ,
1658
1668
}, selected .AdditionalTextEdits ... ))
@@ -1690,7 +1700,7 @@ func typedefMarker(mark marker, src, dst protocol.Location) {
1690
1700
func foldingRangeMarker (mark marker , g * Golden ) {
1691
1701
env := mark .run .env
1692
1702
ranges , err := mark .server ().FoldingRange (env .Ctx , & protocol.FoldingRangeParams {
1693
- TextDocument : protocol. TextDocumentIdentifier { URI : mark .uri ()} ,
1703
+ TextDocument : mark .document () ,
1694
1704
})
1695
1705
if err != nil {
1696
1706
mark .errorf ("foldingRange failed: %v" , err )
@@ -1731,7 +1741,7 @@ func foldingRangeMarker(mark marker, g *Golden) {
1731
1741
// formatMarker implements the @format marker.
1732
1742
func formatMarker (mark marker , golden * Golden ) {
1733
1743
edits , err := mark .server ().Formatting (mark .run .env .Ctx , & protocol.DocumentFormattingParams {
1734
- TextDocument : protocol. TextDocumentIdentifier { URI : mark .uri ()} ,
1744
+ TextDocument : mark .document () ,
1735
1745
})
1736
1746
var got []byte
1737
1747
if err != nil {
@@ -2224,6 +2234,35 @@ func implementationMarker(mark marker, src protocol.Location, want ...protocol.L
2224
2234
}
2225
2235
}
2226
2236
2237
+ func inlayhintsMarker (mark marker , g * Golden ) {
2238
+ hints := mark .run .env .InlayHints (mark .path ())
2239
+
2240
+ // Map inlay hints to text edits.
2241
+ edits := make ([]protocol.TextEdit , len (hints ))
2242
+ for i , hint := range hints {
2243
+ var paddingLeft , paddingRight string
2244
+ if hint .PaddingLeft {
2245
+ paddingLeft = " "
2246
+ }
2247
+ if hint .PaddingRight {
2248
+ paddingRight = " "
2249
+ }
2250
+ edits [i ] = protocol.TextEdit {
2251
+ Range : protocol.Range {Start : hint .Position , End : hint .Position },
2252
+ NewText : fmt .Sprintf ("<%s%s%s>" , paddingLeft , hint .Label [0 ].Value , paddingRight ),
2253
+ }
2254
+ }
2255
+
2256
+ m := mark .mapper ()
2257
+ got , _ , err := source .ApplyProtocolEdits (m , edits )
2258
+ if err != nil {
2259
+ mark .errorf ("ApplyProtocolEdits: %v" , err )
2260
+ return
2261
+ }
2262
+
2263
+ compareGolden (mark , "inlay hints" , got , g )
2264
+ }
2265
+
2227
2266
func prepareRenameMarker (mark marker , src , spn protocol.Location , placeholder string ) {
2228
2267
params := & protocol.PrepareRenameParams {
2229
2268
TextDocumentPositionParams : protocol .LocationTextDocumentPositionParams (src ),
0 commit comments