data/tools/file_edit_tool
library
Classes
-
DesanitizeResult
-
Normalize a match string by applying desanitization replacements.
Returns the normalized string and which replacements were applied.
-
FileEdit
-
A single file edit operation.
-
FileEditInput
-
Input parameters for the FileEditTool.
-
FileEditOutput
-
Output data from a file edit operation.
-
FileEditTool
-
Edit file with exact string replacement -- full port of
neomage FileEditTool.
-
FileReadMetadata
-
Result of reading a file with metadata.
-
NormalizedEditInput
-
Normalize the input for the FileEditTool.
If the string to replace is not found in the file, try with a
normalized version. Returns the normalized input if successful.
-
SnippetResult
-
Gets a snippet from a file showing the context around a single edit.
Functions
-
addLineNumbers(String content, {int startLine = 1})
→ String
-
Add line numbers to content starting from a given line.
-
applyEditsToFile(String fileContents, List<FileEdit> edits)
→ String
-
Apply a list of edits to file content and return the updated content.
Throws if any edit fails or produces overlapping changes.
-
applyEditToFile(String originalContent, String oldString, String newString, {bool replaceAll = false})
→ String
-
Apply a single edit to file content.
-
areFileEditsEquivalent(List<FileEdit> edits1, List<FileEdit> edits2, String originalContent)
→ bool
-
Compare two sets of edits to determine if they are equivalent
by applying both sets to the original content and comparing results.
-
areFileEditsInputsEquivalent(String filePath1, List<FileEdit> edits1, String filePath2, List<FileEdit> edits2)
→ bool
-
Check if two file edit inputs are equivalent.
-
buildDesanitizations()
→ Map<String, String>
-
Desanitization map for Neomage API tag normalization.
Neomage cannot see the full XML tags (they are sanitized), so it outputs
shortened versions. This map restores them.
-
desanitizeMatchString(String matchString)
→ DesanitizeResult
-
-
findActualString(String fileContent, String searchString)
→ String?
-
Finds the actual string in the file content that matches the search
string, accounting for quote normalization.
-
formatFileSize(int bytes)
→ String
-
Format file size in human-readable format.
-
getSnippet(String originalFile, String oldString, String newString, {int contextLines = 4})
→ SnippetResult
-
-
normalizeFileEditInput(String filePath, List<FileEdit> edits)
→ NormalizedEditInput
-
-
normalizeQuotes(String str)
→ String
-
Normalizes curly quotes to straight quotes.
-
preserveQuoteStyle(String oldString, String actualOldString, String newString)
→ String
-
When old_string matched via quote normalization, apply the same curly
quote style to new_string so the edit preserves the file's typography.
-
readFileForEdit(String absoluteFilePath)
→ FileReadMetadata
-
Read a file with encoding and line-ending detection.
-
stripTrailingWhitespace(String str)
→ String
-
Strips trailing whitespace from each line while preserving line endings.
-
writeTextContent(String absoluteFilePath, String content, String encoding, LineEndingType lineEndings)
→ void
-
Write text content to a file preserving encoding and line endings.