mirror of
https://github.com/lukaszraczylo/filepuff-mcp.git
synced 2026-10-12 04:54:27 +00:00
fix(parser): deterministic order for remaining doc-comment tags
FormatDocComment emitted leftover tags by ranging a map, so multi-tag comments (@example/@see/@deprecated) rendered in random order run-to-run — nondeterministic output that defeats caching/diffing. Sort the remaining tag names before emitting.
This commit is contained in:
@@ -3,6 +3,7 @@ package parser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/lukaszraczylo/mcp-filepuff/pkg/protocol"
|
"github.com/lukaszraczylo/mcp-filepuff/pkg/protocol"
|
||||||
@@ -530,11 +531,16 @@ func FormatDocComment(doc *DocComment) string {
|
|||||||
written[t] = true
|
written[t] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
for tagName, val := range doc.Tags {
|
remaining := make([]string, 0, len(doc.Tags))
|
||||||
|
for tagName := range doc.Tags {
|
||||||
if !written[tagName] {
|
if !written[tagName] {
|
||||||
sb.WriteString("@" + tagName + " " + val + "\n")
|
remaining = append(remaining, tagName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sort.Strings(remaining) // deterministic output (map order is random)
|
||||||
|
for _, tagName := range remaining {
|
||||||
|
sb.WriteString("@" + tagName + " " + doc.Tags[tagName] + "\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(sb.String())
|
return strings.TrimSpace(sb.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user