Skip to content

Commit e3d14ed

Browse files
committed
claudetool: remove Go file parsing enforcement
This had a bug, so it almost never triggered. We've been fine without it, and sometimes one legitimately wants a file that doesn't parse. Rather than fix the bug, just delete.
1 parent 10bd3a6 commit e3d14ed

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

claudetool/patch.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ func (p *PatchTool) patchRun(ctx context.Context, m json.RawMessage, input *Patc
157157
likelyGoFile := strings.HasSuffix(input.Path, ".go")
158158

159159
autogenerated := likelyGoFile && IsAutogeneratedGoFile(orig)
160-
parsed := likelyGoFile && parseGo(orig) != nil
161160

162161
origStr := string(orig)
163162
// Process the patches "simultaneously", minimizing them along the way.
@@ -265,13 +264,6 @@ func (p *PatchTool) patchRun(ctx context.Context, m json.RawMessage, input *Patc
265264
response := new(strings.Builder)
266265
fmt.Fprintf(response, "- Applied all patches\n")
267266

268-
if parsed {
269-
parseErr := parseGo(patched)
270-
if parseErr != nil {
271-
return llm.ErrorfToolOut("after applying all patches, the file no longer parses:\n%w", parseErr)
272-
}
273-
}
274-
275267
if autogenerated {
276268
fmt.Fprintf(response, "- WARNING: %q appears to be autogenerated. Patches were applied anyway.\n", input.Path)
277269
}
@@ -285,12 +277,6 @@ func (p *PatchTool) patchRun(ctx context.Context, m json.RawMessage, input *Patc
285277
}
286278
}
287279

288-
func parseGo(buf []byte) error {
289-
fset := token.NewFileSet()
290-
_, err := parser.ParseFile(fset, "", buf, parser.SkipObjectResolution)
291-
return err
292-
}
293-
294280
// IsAutogeneratedGoFile reports whether a Go file has markers indicating it was autogenerated.
295281
func IsAutogeneratedGoFile(buf []byte) bool {
296282
for _, sig := range autogeneratedSignals {

0 commit comments

Comments
 (0)