mirror of
https://github.com/lukaszraczylo/filepuff-mcp.git
synced 2026-10-12 04:54:27 +00:00
fix(parser): stop fabricating { ... } in fallback skeleton
renderSymbolsOnly (fallback for c/cpp/elixir/html/vue) appended each symbol's raw start line plus a literal ' { ... }'. For brace-less languages (Elixir 'def f do', HTML) that is syntactically wrong and wastes tokens. Emit only the accurate symbol list; drop the fabricated line and unused params.
This commit is contained in:
@@ -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 "<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.
|
||||
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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user