refactor

package
v0.0.0-...-130c27b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzeDependenciesOperation

type AnalyzeDependenciesOperation struct {
	Request types.AnalyzeDependenciesRequest
}

AnalyzeDependenciesOperation implements analyzing dependency flow

func (*AnalyzeDependenciesOperation) Description

func (op *AnalyzeDependenciesOperation) Description() string

func (*AnalyzeDependenciesOperation) Execute

func (*AnalyzeDependenciesOperation) Type

func (*AnalyzeDependenciesOperation) Validate

type BackwardDep

type BackwardDep struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Reason string `json:"reason"`
}

type BatchOperation

type BatchOperation struct {
	Operations []types.Operation
	Name       string
	Atomic     bool // If true, all operations must succeed or none are applied
}

BatchOperation implements executing multiple operations as a single transaction

func CreateExtractAndRenameWorkflow

func CreateExtractAndRenameWorkflow(structName, methodName, newMethodName string, sourceFile string, startLine, endLine int) *BatchOperation

CreateRefactoringWorkflow creates common refactoring workflows

func CreateInterfaceExtractionWorkflow

func CreateInterfaceExtractionWorkflow(sourceStruct, interfaceName string, methods []string, targetPackage string) *BatchOperation

func CreateMoveAndUpdateWorkflow

func CreateMoveAndUpdateWorkflow(symbolName, fromPackage, toPackage string) *BatchOperation

func (*BatchOperation) Description

func (op *BatchOperation) Description() string

func (*BatchOperation) Execute

func (*BatchOperation) Type

func (op *BatchOperation) Type() types.OperationType

func (*BatchOperation) Validate

func (op *BatchOperation) Validate(ws *types.Workspace) error

type BatchOperationBuilder

type BatchOperationBuilder struct {
	// contains filtered or unexported fields
}

BatchOperationBuilder provides a fluent interface for building batch operations

func NewBatchOperation

func NewBatchOperation(name string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddExtractInterfaceOperation

func (b *BatchOperationBuilder) AddExtractInterfaceOperation(sourceStruct, interfaceName string, methods []string, targetPackage string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddExtractMethodOperation

func (b *BatchOperationBuilder) AddExtractMethodOperation(sourceFile string, startLine, endLine int, methodName, targetStruct string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddExtractVariableOperation

func (b *BatchOperationBuilder) AddExtractVariableOperation(sourceFile string, startLine, endLine int, variableName, expression string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddInlineConstantOperation

func (b *BatchOperationBuilder) AddInlineConstantOperation(constantName, sourceFile string, scope types.RenameScope) *BatchOperationBuilder

func (*BatchOperationBuilder) AddInlineFunctionOperation

func (b *BatchOperationBuilder) AddInlineFunctionOperation(functionName, sourceFile string, targetFiles []string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddInlineMethodOperation

func (b *BatchOperationBuilder) AddInlineMethodOperation(methodName, sourceStruct, targetFile string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddInlineVariableOperation

func (b *BatchOperationBuilder) AddInlineVariableOperation(variableName, sourceFile string, startLine, endLine int) *BatchOperationBuilder

func (*BatchOperationBuilder) AddMoveOperation

func (b *BatchOperationBuilder) AddMoveOperation(symbolName, fromPackage, toPackage string) *BatchOperationBuilder

func (*BatchOperationBuilder) AddOperation

func (*BatchOperationBuilder) AddRenameOperation

func (b *BatchOperationBuilder) AddRenameOperation(symbolName, newName, packagePath string, scope types.RenameScope) *BatchOperationBuilder

func (*BatchOperationBuilder) Build

func (*BatchOperationBuilder) SetAtomic

func (b *BatchOperationBuilder) SetAtomic(atomic bool) *BatchOperationBuilder

type BatchOperationOperation

type BatchOperationOperation struct {
	Request types.BatchOperationRequest
}

BatchOperationOperation implements executing multiple operations atomically

func (*BatchOperationOperation) Description

func (op *BatchOperationOperation) Description() string

func (*BatchOperationOperation) Execute

func (*BatchOperationOperation) Type

func (*BatchOperationOperation) Validate

func (op *BatchOperationOperation) Validate(ws *types.Workspace) error

type BlockInfo

type BlockInfo struct {
	StartLine int
	EndLine   int
	BlockType string // "if", "for", "switch", "function", etc.
}

BlockInfo represents information about a detected block

type ChangeSignatureOperation

type ChangeSignatureOperation struct {
	FunctionName string
	SourceFile   string
	NewParams    []Parameter
	NewReturns   []string
	Scope        pkgtypes.RenameScope // PackageScope or WorkspaceScope
}

ChangeSignatureOperation implements changing function/method signatures

func (*ChangeSignatureOperation) Description

func (op *ChangeSignatureOperation) Description() string

func (*ChangeSignatureOperation) Execute

func (*ChangeSignatureOperation) Type

func (*ChangeSignatureOperation) Validate

type CleanAliasesOperation

type CleanAliasesOperation struct {
	Request types.CleanAliasesRequest
}

CleanAliasesOperation implements cleaning import aliases

func (*CleanAliasesOperation) Description

func (op *CleanAliasesOperation) Description() string

func (*CleanAliasesOperation) Execute

func (*CleanAliasesOperation) Type

func (*CleanAliasesOperation) Validate

func (op *CleanAliasesOperation) Validate(ws *types.Workspace) error

type ConstantReference

type ConstantReference struct {
	File  string
	Start int
	End   int
}

type ConvertAliasesOperation

type ConvertAliasesOperation struct {
	Request types.ConvertAliasesRequest
}

ConvertAliasesOperation implements converting between aliased and non-aliased imports

func (*ConvertAliasesOperation) Description

func (op *ConvertAliasesOperation) Description() string

func (*ConvertAliasesOperation) Execute

func (*ConvertAliasesOperation) Type

func (*ConvertAliasesOperation) Validate

func (op *ConvertAliasesOperation) Validate(ws *types.Workspace) error

type CreateFacadeOperation

type CreateFacadeOperation struct {
	Request types.CreateFacadeRequest
}

CreateFacadeOperation implements creating facade packages

func (*CreateFacadeOperation) Description

func (op *CreateFacadeOperation) Description() string

func (*CreateFacadeOperation) Execute

func (*CreateFacadeOperation) Type

func (*CreateFacadeOperation) Validate

func (op *CreateFacadeOperation) Validate(ws *types.Workspace) error

type DefaultEngine

type DefaultEngine struct {
	// contains filtered or unexported fields
}

DefaultEngine implements the Engine interface

func (*DefaultEngine) AnalyzeDependencies

AnalyzeDependencies implements analyzing dependency flow

func (*DefaultEngine) AnalyzeImpact

func (e *DefaultEngine) AnalyzeImpact(ws *types.Workspace, op types.Operation) (*types.ImpactAnalysis, error)

AnalyzeImpact analyzes the impact of a refactoring operation

func (*DefaultEngine) BatchOperations

BatchOperations implements executing multiple operations atomically

func (*DefaultEngine) BatchRefactor

func (e *DefaultEngine) BatchRefactor(ws *types.Workspace, ops []types.Operation) (*types.RefactoringPlan, error)

BatchRefactor executes multiple refactoring operations as a batch

func (*DefaultEngine) CleanAliases

CleanAliases implements cleaning import aliases

func (*DefaultEngine) ConvertAliases

ConvertAliases implements converting between aliased and non-aliased imports

func (*DefaultEngine) CreateFacade

CreateFacade implements creating facade packages

func (*DefaultEngine) CreatePlan

CreatePlan implements creating a refactoring plan

func (*DefaultEngine) ExecutePlan

func (e *DefaultEngine) ExecutePlan(plan *types.RefactoringPlan) error

ExecutePlan applies a refactoring plan to the workspace

func (*DefaultEngine) ExecutePlanFromFile

func (e *DefaultEngine) ExecutePlanFromFile(req types.ExecuteOperationRequest) (*types.RefactoringPlan, error)

ExecutePlanFromFile implements executing a previously created plan

func (*DefaultEngine) ExtractFunction

ExtractFunction implements function extraction from code blocks

func (*DefaultEngine) ExtractInterface

ExtractInterface implements interface extraction from structs

func (*DefaultEngine) ExtractMethod

ExtractMethod implements method extraction from code blocks

func (*DefaultEngine) ExtractVariable

ExtractVariable implements variable extraction from expressions

func (*DefaultEngine) FixCycles

FixCycles implements detecting and fixing circular dependencies

func (*DefaultEngine) GenerateFacades

GenerateFacades implements auto-generating facades

func (*DefaultEngine) InlineFunction

InlineFunction implements function call inlining

func (*DefaultEngine) InlineMethod

InlineMethod implements method call inlining

func (*DefaultEngine) InlineVariable

InlineVariable implements variable inlining

func (*DefaultEngine) LoadWorkspace

func (e *DefaultEngine) LoadWorkspace(path string) (*types.Workspace, error)

LoadWorkspace loads and parses a complete workspace

func (*DefaultEngine) MoveByDependencies

MoveByDependencies implements moving symbols based on dependency analysis

func (*DefaultEngine) MoveDir

MoveDir implements moving directory structures

func (*DefaultEngine) MovePackage

MovePackage implements moving entire packages

func (*DefaultEngine) MovePackages

MovePackages implements moving multiple packages atomically

func (*DefaultEngine) MoveSymbol

MoveSymbol implements symbol moving between packages

func (*DefaultEngine) OrganizeByLayers

OrganizeByLayers implements organizing packages by architectural layers

func (*DefaultEngine) PreviewPlan

func (e *DefaultEngine) PreviewPlan(plan *types.RefactoringPlan) (string, error)

PreviewPlan generates a preview of the changes without applying them

func (*DefaultEngine) RenameInterfaceMethod

RenameInterfaceMethod implements interface method renaming

func (*DefaultEngine) RenameMethod

RenameMethod implements renaming methods on specific types (structs or interfaces)

func (*DefaultEngine) RenamePackage

RenamePackage implements package renaming

func (*DefaultEngine) RenameSymbol

RenameSymbol implements symbol renaming

func (*DefaultEngine) ResolveAliasConflicts

ResolveAliasConflicts implements resolving import alias conflicts

func (*DefaultEngine) RollbackOperations

func (e *DefaultEngine) RollbackOperations(req types.RollbackOperationRequest) (*types.RefactoringPlan, error)

RollbackOperations implements rolling back operations

func (*DefaultEngine) SaveWorkspace

func (e *DefaultEngine) SaveWorkspace(ws *types.Workspace) error

SaveWorkspace saves all changes in the workspace to disk

func (*DefaultEngine) StandardizeImports

StandardizeImports implements standardizing import aliases

func (*DefaultEngine) UpdateFacades

UpdateFacades implements updating existing facades

func (*DefaultEngine) ValidateRefactoring

func (e *DefaultEngine) ValidateRefactoring(plan *types.RefactoringPlan) error

ValidateRefactoring validates a complete refactoring plan

type DependencyAnalysis

type DependencyAnalysis struct {
	Workspace      string                   `json:"workspace"`
	TotalPackages  int                      `json:"total_packages"`
	BackwardsDeps  []BackwardDep            `json:"backwards_dependencies,omitempty"`
	SuggestedMoves []SuggestedMove          `json:"suggested_moves,omitempty"`
	PackageMetrics map[string]PackageMetric `json:"package_metrics"`
}

type EngineConfig

type EngineConfig struct {
	SkipCompilation bool
	AllowBreaking   bool
}

EngineConfig contains configuration options for the refactoring engine

func DefaultConfig

func DefaultConfig() *EngineConfig

DefaultConfig returns the default engine configuration

type ExecuteOperation

type ExecuteOperation struct {
	Request types.ExecuteOperationRequest
}

ExecuteOperation implements executing a previously created plan

func (*ExecuteOperation) Description

func (op *ExecuteOperation) Description() string

func (*ExecuteOperation) Execute

func (*ExecuteOperation) Type

func (*ExecuteOperation) Validate

func (op *ExecuteOperation) Validate(ws *types.Workspace) error

type ExtractBlockOperation

type ExtractBlockOperation struct {
	SourceFile      string
	Position        int // Line or character position within the target block
	NewFunctionName string
}

ExtractBlockOperation implements extracting a function from a block (auto-detects boundaries)

func (*ExtractBlockOperation) Description

func (op *ExtractBlockOperation) Description() string

func (*ExtractBlockOperation) Execute

func (*ExtractBlockOperation) Type

func (*ExtractBlockOperation) Validate

func (op *ExtractBlockOperation) Validate(ws *types.Workspace) error

type ExtractConstantOperation

type ExtractConstantOperation struct {
	SourceFile   string
	Position     token.Pos // Position of the literal to extract
	ConstantName string
	Scope        pkgtypes.RenameScope // PackageScope or WorkspaceScope
	TargetFile   string               // Optional: specific file to place the constant
}

ExtractConstantOperation implements extracting a literal value into a constant

func (*ExtractConstantOperation) Description

func (op *ExtractConstantOperation) Description() string

func (*ExtractConstantOperation) Execute

func (*ExtractConstantOperation) Type

func (*ExtractConstantOperation) Validate

type ExtractFunctionOperation

type ExtractFunctionOperation struct {
	SourceFile      string
	StartLine       int
	EndLine         int
	NewFunctionName string
}

ExtractFunctionOperation implements extracting a function from a code block

func (*ExtractFunctionOperation) Description

func (op *ExtractFunctionOperation) Description() string

func (*ExtractFunctionOperation) Execute

func (*ExtractFunctionOperation) Type

func (*ExtractFunctionOperation) Validate

func (op *ExtractFunctionOperation) Validate(ws *types.Workspace) error

type ExtractInterfaceOperation

type ExtractInterfaceOperation struct {
	SourceStruct  string
	InterfaceName string
	Methods       []string
	TargetPackage string
}

ExtractInterfaceOperation implements extracting an interface from a struct

func (*ExtractInterfaceOperation) Description

func (op *ExtractInterfaceOperation) Description() string

func (*ExtractInterfaceOperation) Execute

func (*ExtractInterfaceOperation) Type

func (*ExtractInterfaceOperation) Validate

func (op *ExtractInterfaceOperation) Validate(ws *types.Workspace) error

type ExtractMethodOperation

type ExtractMethodOperation struct {
	SourceFile    string
	StartLine     int
	EndLine       int
	NewMethodName string
	TargetStruct  string
}

ExtractMethodOperation implements extracting a method from a code block

func (*ExtractMethodOperation) Description

func (op *ExtractMethodOperation) Description() string

func (*ExtractMethodOperation) Execute

func (*ExtractMethodOperation) Type

func (*ExtractMethodOperation) Validate

func (op *ExtractMethodOperation) Validate(ws *types.Workspace) error

type ExtractVariableOperation

type ExtractVariableOperation struct {
	SourceFile   string
	StartLine    int
	EndLine      int
	VariableName string
	Expression   string
}

ExtractVariableOperation implements extracting a variable from an expression

func (*ExtractVariableOperation) Description

func (op *ExtractVariableOperation) Description() string

func (*ExtractVariableOperation) Execute

func (*ExtractVariableOperation) Type

func (*ExtractVariableOperation) Validate

func (op *ExtractVariableOperation) Validate(ws *types.Workspace) error

type FixCyclesOperation

type FixCyclesOperation struct {
	Request types.FixCyclesRequest
}

FixCyclesOperation implements detecting and fixing circular dependencies

func (*FixCyclesOperation) Description

func (op *FixCyclesOperation) Description() string

func (*FixCyclesOperation) Execute

func (*FixCyclesOperation) Type

func (*FixCyclesOperation) Validate

func (op *FixCyclesOperation) Validate(ws *types.Workspace) error

type GenerateFacadesOperation

type GenerateFacadesOperation struct {
	Request types.GenerateFacadesRequest
}

GenerateFacadesOperation implements auto-generating facades

func (*GenerateFacadesOperation) Description

func (op *GenerateFacadesOperation) Description() string

func (*GenerateFacadesOperation) Execute

func (*GenerateFacadesOperation) Type

func (*GenerateFacadesOperation) Validate

func (op *GenerateFacadesOperation) Validate(ws *types.Workspace) error

type InlineConstantOperation

type InlineConstantOperation struct {
	ConstantName string
	SourceFile   string
	Scope        types.RenameScope
}

InlineConstantOperation implements inlining a constant

func (*InlineConstantOperation) Description

func (op *InlineConstantOperation) Description() string

func (*InlineConstantOperation) Execute

func (*InlineConstantOperation) Type

func (*InlineConstantOperation) Validate

func (op *InlineConstantOperation) Validate(ws *types.Workspace) error

type InlineFunctionOperation

type InlineFunctionOperation struct {
	FunctionName string
	SourceFile   string
	TargetFiles  []string
}

InlineFunctionOperation implements inlining a function

func (*InlineFunctionOperation) Description

func (op *InlineFunctionOperation) Description() string

func (*InlineFunctionOperation) Execute

func (*InlineFunctionOperation) Type

func (*InlineFunctionOperation) Validate

func (op *InlineFunctionOperation) Validate(ws *types.Workspace) error

type InlineMethodOperation

type InlineMethodOperation struct {
	MethodName   string
	SourceStruct string
	TargetFile   string
}

InlineMethodOperation implements inlining a method call with its implementation

func (*InlineMethodOperation) Description

func (op *InlineMethodOperation) Description() string

func (*InlineMethodOperation) Execute

func (*InlineMethodOperation) Type

func (*InlineMethodOperation) Validate

func (op *InlineMethodOperation) Validate(ws *types.Workspace) error

type InlineVariableOperation

type InlineVariableOperation struct {
	VariableName string
	SourceFile   string
	StartLine    int
	EndLine      int
}

InlineVariableOperation implements inlining a variable with its value

func (*InlineVariableOperation) Description

func (op *InlineVariableOperation) Description() string

func (*InlineVariableOperation) Execute

func (*InlineVariableOperation) Type

func (*InlineVariableOperation) Validate

func (op *InlineVariableOperation) Validate(ws *types.Workspace) error

type LiteralOccurrence

type LiteralOccurrence struct {
	File string
	Pos  token.Pos
	End  token.Pos
}

LiteralOccurrence represents a location where a literal value appears

type MethodCall

type MethodCall struct {
	Start     int
	End       int
	CallText  string
	Arguments []string
}

type MoveByDependenciesOperation

type MoveByDependenciesOperation struct {
	Request types.MoveByDependenciesRequest
}

MoveByDependenciesOperation implements moving symbols based on dependency analysis

func (*MoveByDependenciesOperation) Description

func (op *MoveByDependenciesOperation) Description() string

func (*MoveByDependenciesOperation) Execute

func (*MoveByDependenciesOperation) Type

func (*MoveByDependenciesOperation) Validate

type MoveDirOperation

type MoveDirOperation struct {
	Request types.MoveDirRequest
}

MoveDirOperation implements moving directory structures

func (*MoveDirOperation) Description

func (op *MoveDirOperation) Description() string

func (*MoveDirOperation) Execute

func (*MoveDirOperation) Type

func (*MoveDirOperation) Validate

func (op *MoveDirOperation) Validate(ws *types.Workspace) error

type MovePackageOperation

type MovePackageOperation struct {
	Request types.MovePackageRequest
}

MovePackageOperation implements moving entire packages

func (*MovePackageOperation) Description

func (op *MovePackageOperation) Description() string

func (*MovePackageOperation) Execute

func (*MovePackageOperation) Type

func (*MovePackageOperation) Validate

func (op *MovePackageOperation) Validate(ws *types.Workspace) error

type MovePackagesOperation

type MovePackagesOperation struct {
	Request types.MovePackagesRequest
}

MovePackagesOperation implements moving multiple packages atomically

func (*MovePackagesOperation) Description

func (op *MovePackagesOperation) Description() string

func (*MovePackagesOperation) Execute

func (*MovePackagesOperation) Type

func (*MovePackagesOperation) Validate

func (op *MovePackagesOperation) Validate(ws *types.Workspace) error

type MoveSymbolOperation

type MoveSymbolOperation struct {
	Request types.MoveSymbolRequest
}

MoveSymbolOperation implements moving symbols between packages

func (*MoveSymbolOperation) Description

func (op *MoveSymbolOperation) Description() string

func (*MoveSymbolOperation) Execute

func (*MoveSymbolOperation) Type

func (*MoveSymbolOperation) Validate

func (op *MoveSymbolOperation) Validate(ws *types.Workspace) error

type OrganizeByLayersOperation

type OrganizeByLayersOperation struct {
	Request types.OrganizeByLayersRequest
}

OrganizeByLayersOperation implements organizing packages by architectural layers

func (*OrganizeByLayersOperation) Description

func (op *OrganizeByLayersOperation) Description() string

func (*OrganizeByLayersOperation) Execute

func (*OrganizeByLayersOperation) Type

func (*OrganizeByLayersOperation) Validate

func (op *OrganizeByLayersOperation) Validate(ws *types.Workspace) error

type PackageMetric

type PackageMetric struct {
	IncomingDeps int `json:"incoming_deps"`
	OutgoingDeps int `json:"outgoing_deps"`
	SymbolCount  int `json:"symbol_count"`
}

type Parameter

type Parameter struct {
	Name string
	Type string
}

Parameter represents a function parameter

type PlanOperation

type PlanOperation struct {
	Request types.PlanOperationRequest
}

PlanOperation implements creating a refactoring plan

func (*PlanOperation) Description

func (op *PlanOperation) Description() string

func (*PlanOperation) Execute

func (op *PlanOperation) Execute(ws *types.Workspace) (*types.RefactoringPlan, error)

func (*PlanOperation) Type

func (op *PlanOperation) Type() types.OperationType

func (*PlanOperation) Validate

func (op *PlanOperation) Validate(ws *types.Workspace) error

type RefactorEngine

type RefactorEngine interface {
	// Workspace management
	LoadWorkspace(path string) (*types.Workspace, error)
	SaveWorkspace(ws *types.Workspace) error

	// Refactoring operations
	MoveSymbol(ws *types.Workspace, req types.MoveSymbolRequest) (*types.RefactoringPlan, error)
	RenameSymbol(ws *types.Workspace, req types.RenameSymbolRequest) (*types.RefactoringPlan, error)
	RenamePackage(ws *types.Workspace, req types.RenamePackageRequest) (*types.RefactoringPlan, error)
	RenameInterfaceMethod(ws *types.Workspace, req types.RenameInterfaceMethodRequest) (*types.RefactoringPlan, error)
	RenameMethod(ws *types.Workspace, req types.RenameMethodRequest) (*types.RefactoringPlan, error)
	ExtractMethod(ws *types.Workspace, req types.ExtractMethodRequest) (*types.RefactoringPlan, error)
	ExtractFunction(ws *types.Workspace, req types.ExtractFunctionRequest) (*types.RefactoringPlan, error)
	ExtractInterface(ws *types.Workspace, req types.ExtractInterfaceRequest) (*types.RefactoringPlan, error)
	ExtractVariable(ws *types.Workspace, req types.ExtractVariableRequest) (*types.RefactoringPlan, error)
	InlineMethod(ws *types.Workspace, req types.InlineMethodRequest) (*types.RefactoringPlan, error)
	InlineVariable(ws *types.Workspace, req types.InlineVariableRequest) (*types.RefactoringPlan, error)
	InlineFunction(ws *types.Workspace, req types.InlineFunctionRequest) (*types.RefactoringPlan, error)
	BatchRefactor(ws *types.Workspace, ops []types.Operation) (*types.RefactoringPlan, error)

	// Bulk operations
	MovePackage(ws *types.Workspace, req types.MovePackageRequest) (*types.RefactoringPlan, error)
	MoveDir(ws *types.Workspace, req types.MoveDirRequest) (*types.RefactoringPlan, error)
	MovePackages(ws *types.Workspace, req types.MovePackagesRequest) (*types.RefactoringPlan, error)

	// Facade operations
	CreateFacade(ws *types.Workspace, req types.CreateFacadeRequest) (*types.RefactoringPlan, error)
	GenerateFacades(ws *types.Workspace, req types.GenerateFacadesRequest) (*types.RefactoringPlan, error)
	UpdateFacades(ws *types.Workspace, req types.UpdateFacadesRequest) (*types.RefactoringPlan, error)

	// Import alias operations
	CleanAliases(ws *types.Workspace, req types.CleanAliasesRequest) (*types.RefactoringPlan, error)
	StandardizeImports(ws *types.Workspace, req types.StandardizeImportsRequest) (*types.RefactoringPlan, error)
	ResolveAliasConflicts(ws *types.Workspace, req types.ResolveAliasConflictsRequest) (*types.RefactoringPlan, error)
	ConvertAliases(ws *types.Workspace, req types.ConvertAliasesRequest) (*types.RefactoringPlan, error)

	// Dependency graph operations
	MoveByDependencies(ws *types.Workspace, req types.MoveByDependenciesRequest) (*types.RefactoringPlan, error)
	OrganizeByLayers(ws *types.Workspace, req types.OrganizeByLayersRequest) (*types.RefactoringPlan, error)
	FixCycles(ws *types.Workspace, req types.FixCyclesRequest) (*types.RefactoringPlan, error)
	AnalyzeDependencies(ws *types.Workspace, req types.AnalyzeDependenciesRequest) (*types.RefactoringPlan, error)

	// Batch operations with rollback
	BatchOperations(ws *types.Workspace, req types.BatchOperationRequest) (*types.RefactoringPlan, error)
	CreatePlan(ws *types.Workspace, req types.PlanOperationRequest) (*types.RefactoringPlan, error)
	ExecutePlanFromFile(req types.ExecuteOperationRequest) (*types.RefactoringPlan, error)
	RollbackOperations(req types.RollbackOperationRequest) (*types.RefactoringPlan, error)

	// Analysis
	AnalyzeImpact(ws *types.Workspace, op types.Operation) (*types.ImpactAnalysis, error)
	ValidateRefactoring(plan *types.RefactoringPlan) error

	// Execution
	ExecutePlan(plan *types.RefactoringPlan) error
	PreviewPlan(plan *types.RefactoringPlan) (string, error)
}

Engine is the main interface for refactoring operations

func CreateEngine

func CreateEngine() RefactorEngine

func CreateEngineWithConfig

func CreateEngineWithConfig(config *EngineConfig) RefactorEngine

type RefactoringPlanFile

type RefactoringPlanFile struct {
	Version   string           `json:"version"`
	CreatedAt string           `json:"created_at"`
	Workspace string           `json:"workspace"`
	Steps     []types.PlanStep `json:"steps"`
	DryRun    bool             `json:"dry_run"`
}

type RenameInterfaceMethodOperation

type RenameInterfaceMethodOperation struct {
	Request types.RenameInterfaceMethodRequest
}

RenameInterfaceMethodOperation implements interface method renaming

func (*RenameInterfaceMethodOperation) Description

func (op *RenameInterfaceMethodOperation) Description() string

func (*RenameInterfaceMethodOperation) Execute

func (*RenameInterfaceMethodOperation) Type

func (*RenameInterfaceMethodOperation) Validate

type RenameMethodOperation

type RenameMethodOperation struct {
	Request types.RenameMethodRequest
}

RenameMethodOperation implements renaming methods on specific types (structs or interfaces)

func (*RenameMethodOperation) Description

func (op *RenameMethodOperation) Description() string

func (*RenameMethodOperation) Execute

func (*RenameMethodOperation) Type

func (*RenameMethodOperation) Validate

func (op *RenameMethodOperation) Validate(ws *types.Workspace) error

type RenamePackageOperation

type RenamePackageOperation struct {
	Request types.RenamePackageRequest
}

RenamePackageOperation implements package renaming

func (*RenamePackageOperation) Description

func (op *RenamePackageOperation) Description() string

func (*RenamePackageOperation) Execute

func (*RenamePackageOperation) Type

func (*RenamePackageOperation) Validate

func (op *RenamePackageOperation) Validate(ws *types.Workspace) error

type RenameSymbolOperation

type RenameSymbolOperation struct {
	Request types.RenameSymbolRequest
}

RenameSymbolOperation implements symbol renaming

func (*RenameSymbolOperation) Description

func (op *RenameSymbolOperation) Description() string

func (*RenameSymbolOperation) Execute

func (*RenameSymbolOperation) Type

func (*RenameSymbolOperation) Validate

func (op *RenameSymbolOperation) Validate(ws *types.Workspace) error

type ResolveAliasConflictsOperation

type ResolveAliasConflictsOperation struct {
	Request types.ResolveAliasConflictsRequest
}

ResolveAliasConflictsOperation implements resolving import alias conflicts

func (*ResolveAliasConflictsOperation) Description

func (op *ResolveAliasConflictsOperation) Description() string

func (*ResolveAliasConflictsOperation) Execute

func (*ResolveAliasConflictsOperation) Type

func (*ResolveAliasConflictsOperation) Validate

type RollbackOperation

type RollbackOperation struct {
	Request types.RollbackOperationRequest
}

RollbackOperation implements rolling back operations

func (*RollbackOperation) Description

func (op *RollbackOperation) Description() string

func (*RollbackOperation) Execute

func (*RollbackOperation) Type

func (*RollbackOperation) Validate

func (op *RollbackOperation) Validate(ws *types.Workspace) error

type SafeDeleteOperation

type SafeDeleteOperation struct {
	SymbolName string
	SourceFile string
	Scope      pkgtypes.RenameScope // PackageScope or WorkspaceScope
	Force      bool                 // If true, delete even if references exist
}

SafeDeleteOperation implements safe deletion of symbols with usage verification

func (*SafeDeleteOperation) Description

func (op *SafeDeleteOperation) Description() string

func (*SafeDeleteOperation) Execute

func (*SafeDeleteOperation) Type

func (*SafeDeleteOperation) Validate

func (op *SafeDeleteOperation) Validate(ws *pkgtypes.Workspace) error

type Serializer

type Serializer struct {
	// contains filtered or unexported fields
}

Serializer applies refactoring changes to files while preserving formatting

func NewSerializer

func NewSerializer() *Serializer

func (*Serializer) ApplyChanges

func (s *Serializer) ApplyChanges(ws *refactorTypes.Workspace, changes []refactorTypes.Change) error

ApplyChanges applies a list of changes to the workspace files

func (*Serializer) BackupFile

func (s *Serializer) BackupFile(filePath string) (string, error)

BackupFile creates a backup of a file before modifications

func (*Serializer) GenerateDiff

func (s *Serializer) GenerateDiff(filePath string, originalContent, modifiedContent string) (string, error)

GenerateDiff generates a unified diff between original and modified content

func (*Serializer) GetFileLines

func (s *Serializer) GetFileLines(filePath string, startLine, endLine int) ([]string, error)

GetFileLines reads a file and returns its lines with line numbers

func (*Serializer) PreviewChanges

func (s *Serializer) PreviewChanges(ws *refactorTypes.Workspace, changes []refactorTypes.Change) (string, error)

PreviewChanges generates a preview of what changes would be applied

func (*Serializer) RestoreFromBackup

func (s *Serializer) RestoreFromBackup(filePath, backupPath string) error

RestoreFromBackup restores a file from its backup

func (*Serializer) ValidateFileStructure

func (s *Serializer) ValidateFileStructure(filePath string) error

ValidateFileStructure ensures that the file structure is valid after changes

type StandardizeImportsOperation

type StandardizeImportsOperation struct {
	Request types.StandardizeImportsRequest
}

StandardizeImportsOperation implements standardizing import aliases

func (*StandardizeImportsOperation) Description

func (op *StandardizeImportsOperation) Description() string

func (*StandardizeImportsOperation) Execute

func (*StandardizeImportsOperation) Type

func (*StandardizeImportsOperation) Validate

type SuggestedMove

type SuggestedMove struct {
	Symbol      string `json:"symbol"`
	FromPackage string `json:"from_package"`
	ToPackage   string `json:"to_package"`
	Reason      string `json:"reason"`
}

type UpdateFacadesOperation

type UpdateFacadesOperation struct {
	Request types.UpdateFacadesRequest
}

UpdateFacadesOperation implements updating existing facades

func (*UpdateFacadesOperation) Description

func (op *UpdateFacadesOperation) Description() string

func (*UpdateFacadesOperation) Execute

func (*UpdateFacadesOperation) Type

func (*UpdateFacadesOperation) Validate

func (op *UpdateFacadesOperation) Validate(ws *types.Workspace) error

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates refactoring operations for safety

func NewValidator

func NewValidator() *Validator

func (*Validator) ValidateMove

ValidateMove validates a move operation specifically

func (*Validator) ValidatePlan

func (v *Validator) ValidatePlan(plan *refactorTypes.RefactoringPlan) error

ValidatePlan validates a complete refactoring plan

func (*Validator) ValidatePlanWithConfig

func (v *Validator) ValidatePlanWithConfig(plan *refactorTypes.RefactoringPlan, config *EngineConfig) error

ValidatePlanWithConfig validates a complete refactoring plan with configuration options

func (*Validator) ValidateRename

ValidateRename validates a rename operation specifically

type VariableReference

type VariableReference struct {
	Start int
	End   int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL