You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gopls/internal/highlight: DocumentHighlight for format strings
This CL introduces functionality for highlighting
printf-style directives and their associated variadic arguments.
Also fix some comments/names in CL 623156
Updates golang/go#70050
Change-Id: I1c4e6678317aa8cf522f41765f5a6600793f3746
GitHub-Last-Rev: d15a3b3
GitHub-Pull-Request: #555
Reviewed-on: https://go-review.googlesource.com/c/tools/+/642095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This test checks functionality of the printf-like directives and operands highlight.
3
+
-- flags --
4
+
-ignore_extra_diags
5
+
-- highlights.go --
6
+
package highlightprintf
7
+
import (
8
+
"fmt"
9
+
)
10
+
11
+
func BasicPrintfHighlights() {
12
+
fmt.Printf("Hello %s, you have %d new messages!", "Alice", 5) //@hiloc(normals, "%s", write),hiloc(normalarg0, "\"Alice\"", read),highlightall(normals, normalarg0)
13
+
fmt.Printf("Hello %s, you have %d new messages!", "Alice", 5) //@hiloc(normald, "%d", write),hiloc(normalargs1, "5", read),highlightall(normald, normalargs1)
14
+
}
15
+
16
+
func ComplexPrintfHighlights() {
17
+
fmt.Printf("Hello %#3.4s, you have %-2.3d new messages!", "Alice", 5) //@hiloc(complexs, "%#3.4s", write),hiloc(complexarg0, "\"Alice\"", read),highlightall(complexs, complexarg0)
18
+
fmt.Printf("Hello %#3.4s, you have %-2.3d new messages!", "Alice", 5) //@hiloc(complexd, "%-2.3d", write),hiloc(complexarg1, "5", read),highlightall(complexd, complexarg1)
19
+
}
20
+
21
+
func MissingDirectives() {
22
+
fmt.Printf("Hello %s, you have 5 new messages!", "Alice", 5) //@hiloc(missings, "%s", write),hiloc(missingargs0, "\"Alice\"", read),highlightall(missings, missingargs0)
23
+
}
24
+
25
+
func TooManyDirectives() {
26
+
fmt.Printf("Hello %s, you have %d new %s %q messages!", "Alice", 5) //@hiloc(toomanys, "%s", write),hiloc(toomanyargs0, "\"Alice\"", read),highlightall(toomanys, toomanyargs0)
27
+
fmt.Printf("Hello %s, you have %d new %s %q messages!", "Alice", 5) //@hiloc(toomanyd, "%d", write),hiloc(toomanyargs1, "5", read),highlightall(toomanyd, toomanyargs1)
0 commit comments