MCPcopy Index your code
hub / github.com/Aider-AI/aider / _parse_add_file_content

Method _parse_add_file_content

aider/coders/patch_coder.py:516–547  ·  view source on GitHub ↗

Parses the content (+) lines for an Add File action.

(self, lines: List[str], index: int)

Source from the content-addressed store, hash-verified

514 return action, index, total_fuzz
515
516 def _parse_add_file_content(self, lines: List[str], index: int) -> Tuple[PatchAction, int]:
517 """Parses the content (+) lines for an Add File action."""
518 added_lines: List[str] = []
519 while index < len(lines):
520 line = lines[index]
521 norm_line = _norm(line)
522 # Stop if we hit another action or end marker
523 if norm_line.startswith(
524 (
525 "*** End Patch",
526 "*** Update File:",
527 "*** Delete File:",
528 "*** Add File:",
529 )
530 ):
531 break
532
533 # Expect lines to start with '+'
534 if not line.startswith("+"):
535 # Tolerate blank lines? Or require '+'? Reference implies '+' required.
536 if norm_line.strip() == "":
537 # Treat blank line as adding a blank line
538 added_lines.append("")
539 else:
540 raise DiffError(f"Invalid Add File line (missing '+'): {line}")
541 else:
542 added_lines.append(line[1:]) # Strip leading '+'
543
544 index += 1
545
546 action = PatchAction(type=ActionType.ADD, path="", new_content="\n".join(added_lines))
547 return action, index
548
549 def apply_edits(self, edits: List[PatchAction]):
550 """

Callers 1

_parse_patch_textMethod · 0.95

Calls 3

_normFunction · 0.85
DiffErrorClass · 0.85
PatchActionClass · 0.85

Tested by

no test coverage detected