Skip to content

Latest commit

 

History

History
86 lines (50 loc) · 6.04 KB

File metadata and controls

86 lines (50 loc) · 6.04 KB
graph LR
    Refactoring_Operations["Refactoring Operations"]
    AST_Representation_Manipulation["AST Representation & Manipulation"]
    Code_Element_Locator["Code Element Locator"]
    Import_Management_Utilities["Import Management Utilities"]
    Atomic_Change_Generation["Atomic Change Generation"]
    Code_Pattern_Analysis["Code Pattern Analysis"]
    Refactoring_Operations -- "uses" --> AST_Representation_Manipulation
    Refactoring_Operations -- "uses" --> Code_Element_Locator
    Refactoring_Operations -- "generates" --> Atomic_Change_Generation
    Refactoring_Operations -- "uses" --> Import_Management_Utilities
    Code_Element_Locator -- "uses" --> AST_Representation_Manipulation
    Import_Management_Utilities -- "uses" --> AST_Representation_Manipulation
    Code_Pattern_Analysis -- "uses" --> AST_Representation_Manipulation
Loading

CodeBoardingDemoContact

Details

The rope.refactor subsystem is designed around a core principle of precise, non-destructive code transformation. At its heart, the AST Representation & Manipulation component provides an enhanced Abstract Syntax Tree, serving as the canonical data model for all code operations. Refactoring Operations act as the orchestrators, implementing specific refactoring algorithms by interacting with the AST. These operations rely on the Code Element Locator to identify target code elements and the Import Management Utilities to maintain correct import paths during transformations. All refactoring actions culminate in the generation of Atomic Change Generation objects, which represent the immutable modifications to be applied to the source code. Additionally, the Code Pattern Analysis component supports identifying refactoring opportunities by analyzing code structures. This architecture ensures a modular, extensible, and robust approach to code refactoring.

Refactoring Operations

This component encapsulates the specific algorithms and logic for various refactoring types (e.g., rename, move, extract). It acts as the orchestrator for a given refactoring, coordinating with other components to analyze code, identify targets, and generate changes. This aligns with the Strategy/Command pattern, where each refactoring is a distinct operation.

Related Classes/Methods:

AST Representation & Manipulation

Provides an enhanced Abstract Syntax Tree (AST) representation that is crucial for non-destructive and precise code transformations. It serves as the central data model for the code being refactored and offers interfaces for manipulating its structure while preserving formatting.

Related Classes/Methods:

Code Element Locator

Offers mechanisms to accurately find and identify all occurrences of specific code elements (e.g., variables, functions, classes) within a given scope or project. This is vital for ensuring comprehensive and correct refactorings.

Related Classes/Methods:

Import Management Utilities

Provides specialized utilities for parsing, analyzing, and modifying import statements within Python modules. This component ensures that import paths are correctly adjusted after code relocation or restructuring, maintaining code integrity.

Related Classes/Methods:

Atomic Change Generation

Represents an atomic, immutable modification to the source code (e.g., text insertion, deletion, replacement). These objects are the standardized output of all refactoring operations, allowing for a consistent application of changes.

Related Classes/Methods:

Code Pattern Analysis

Detects and identifies similar code blocks or patterns within the codebase. This analysis can be used to suggest refactoring opportunities, such as "extract method," by highlighting redundant code.

Related Classes/Methods: