perf(parser): denser symbols-only skeleton fallback

The fallback skeleton (c/cpp/elixir/html/vue) is not valid source, so the '// ' comment framing and '(line N)' wording just cost tokens. Use a compact 'kind name :line' form. ~15-25% fewer tokens on fallback skeletons; output stays accurate.
This commit is contained in:
2026-06-20 00:33:33 +01:00
parent d0f649a9b8
commit 13b1a22102
+9 -7
View File
@@ -40,17 +40,19 @@ func SkeletonFile(ctx context.Context, reg *Registry, filename string, content [
}
}
// renderSymbolsOnly renders a simple symbol list (fallback for unsupported languages).
// It deliberately does not fabricate "<source line> { ... }" output: the raw start
// line plus a guessed brace is wrong for brace-less languages (e.g. Elixir's "def f do",
// HTML) and only wastes tokens. The symbol list (kind, name, line, doc) is accurate.
// renderSymbolsOnly renders a compact symbol list (fallback for unsupported
// languages). It deliberately does not fabricate "<source line> { ... }" output:
// the raw start line plus a guessed brace is wrong for brace-less languages (e.g.
// Elixir's "def f do", HTML) and only wastes tokens. The output is not valid
// source, so it drops "// " comment framing and uses a dense "kind name :line"
// form to minimise tokens. The symbol list (kind, name, line, doc) is accurate.
func renderSymbolsOnly(syms []protocol.Symbol, lang protocol.Language) string {
var sb strings.Builder
fmt.Fprintf(&sb, "// skeleton unavailable for %s — symbol list only\n", lang)
fmt.Fprintf(&sb, "symbols only (no skeleton for %s):\n", lang)
for _, s := range syms {
fmt.Fprintf(&sb, "// %s %s (line %d)\n", s.Kind, s.Name, s.Location.Line)
fmt.Fprintf(&sb, "%s %s :%d\n", s.Kind, s.Name, s.Location.Line)
if s.Doc != "" {
fmt.Fprintf(&sb, "// doc: %s\n", s.Doc)
fmt.Fprintf(&sb, " doc: %s\n", s.Doc)
}
}
return sb.String()