Module srgn

Module srgn 

Source
Expand description

Srgn (code surgeon) tool integration for VTCode

This tool provides access to srgn, a grep-like tool that understands source code syntax and allows for manipulation in addition to search. It supports various programming languages and provides precise code modification capabilities.

§Supported Languages and Prepared Queries

§Rust

  • comments - Comments (line and block styles; excluding doc comments)
  • doc-comments - Doc comments (comment chars included)
  • uses - Use statements (paths only; excl. use/as/*)
  • strings - Strings (regular, raw, byte; includes interpolation parts)
  • attribute - Attributes like #[attr]
  • struct - struct definitions
  • struct~<PATTERN> - Structs whose name matches PATTERN
  • enum - enum definitions
  • enum~<PATTERN> - Enums whose name matches PATTERN
  • fn - Function definitions
  • fn~<PATTERN> - Functions whose name matches PATTERN
  • unsafe - unsafe keyword usages

§Python

  • comments - Comments
  • strings - Strings (raw, byte, f-strings; interpolation not included)
  • imports - Module names in imports
  • doc-strings - Docstrings
  • function-names - Function names at definition site
  • function-calls - Function calls
  • class - Class definitions
  • def - All function definitions
  • methods - Function definitions inside classes

§JavaScript/TypeScript

  • comments - Comments
  • strings - Strings (literal, template)
  • imports - Imports (module specifiers)
  • function - Function definitions
  • class - Class definitions
  • interface - Interface definitions

§Go

  • comments - Comments
  • strings - Strings (interpreted and raw)
  • imports - Imports
  • struct - Struct type definitions
  • struct~<PATTERN> - Structs whose name matches PATTERN
  • func - Function definitions
  • func~<PATTERN> - Functions whose name matches PATTERN

§C/C++/C#

  • comments - Comments
  • strings - Strings
  • function - Function definitions
  • struct - Struct definitions
  • class - Class definitions

§HCL (Terraform)

  • comments - Comments
  • strings - Literal strings
  • variable - Variable blocks
  • resource - Resource blocks
  • data - Data blocks

§Usage Examples

// Replace println with eprintln in Rust functions
SrgnInput {
    path: "*.rs".to_string(),
    language_scope: Some("rust fn".to_string()),
    scope: Some("println".to_string()),
    replacement: Some("eprintln".to_string()),
    action: SrgnAction::Replace,
    dry_run: true,
    ..Default::default()
}

// Find all unsafe Rust code
SrgnInput {
    path: "*.rs".to_string(),
    language_scope: Some("rust unsafe".to_string()),
    fail_any: true,
    ..Default::default()
}

Structs§

GermanOptions
German-specific options for srgn
SrgnInput
Input structure for srgn operations
SrgnTool
Srgn tool implementation

Enums§

SrgnAction
Available srgn actions