diff --git a/internal/parser/skeleton.go b/internal/parser/skeleton.go index 03c6029..ab97514 100644 --- a/internal/parser/skeleton.go +++ b/internal/parser/skeleton.go @@ -36,13 +36,15 @@ func SkeletonFile(ctx context.Context, reg *Registry, filename string, content [ default: // TODO: skeleton for c, cpp, elixir, html, vue — fall back to symbols_only syms := ExtractSymbols(result.Tree, content, lang, filename) - return renderSymbolsOnly(syms, filename, lang, content), false, nil + return renderSymbolsOnly(syms, lang), false, nil } } // renderSymbolsOnly renders a simple symbol list (fallback for unsupported languages). -func renderSymbolsOnly(syms []protocol.Symbol, _ string, lang protocol.Language, content []byte) string { - lines := strings.Split(string(content), "\n") +// It deliberately does not fabricate " { ... }" 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. +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) for _, s := range syms { @@ -50,9 +52,6 @@ func renderSymbolsOnly(syms []protocol.Symbol, _ string, lang protocol.Language, if s.Doc != "" { fmt.Fprintf(&sb, "// doc: %s\n", s.Doc) } - if s.Location.Line >= 1 && s.Location.Line <= len(lines) { - sb.WriteString(lines[s.Location.Line-1] + " { ... }\n") - } } return sb.String() }