domain

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package domain provides functionality for converting tasks, responses, and classes to and from protocol messages used in the refactoring process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassesToMsg

func ClassesToMsg(classes []Class) *protocol.Message

ClassesToMsg compiles a protocol message from a list of classes.

func TaskToMsg

func TaskToMsg(task Task) *protocol.Message

TaskToMsg converts a Task object to a protocol.Message.

Types

type Class

type Class interface {
	Name() string
	Content() string
	SetContent(content string) error
}

Class represents a code or text entity with a name and content.

func NewClass

func NewClass(name, content string) Class

NewClass creates a new Class instance with the given name and content.

func RespToClass

func RespToClass(resp *protocol.JSONRPCResponse) (Class, error)

RespToClass converts a JSONRPCResponse into a Class, decoding file parts as needed.

func RespToClasses

func RespToClasses(resp *protocol.JSONRPCResponse) ([]Class, error)

RespToClasses converts a protocol.JSONRPCResponse to a slice of Class objects.

type Critic

type Critic interface {
	Review(class Class) ([]Suggestion, error)
}

Critic represents an interface to review a class and provide suggestions.

type Facilitator

type Facilitator interface {
	Refactor(task Task) ([]Class, error)
}

Facilitator represents an interface to refactor tasks into multiple classes.

type Fixer

type Fixer interface {
	Fix(class Class, suggestions []Suggestion, example Class) (Class, error)
}

Fixer represents an interface to fix a class based on suggestions and an example.

type Suggestion

type Suggestion interface {
	Text() string
}

Suggestion represents a proposed improvement or fix for a class.

func NewSuggestion

func NewSuggestion(text string) Suggestion

NewSuggestion creates a new Suggestion instance with the given text.

func RespToSuggestions

func RespToSuggestions(resp *protocol.JSONRPCResponse) []Suggestion

RespToSuggestions converts a protocol.JSONRPCResponse to a slice of Suggestion objects.

type Task

type Task interface {
	Description() string
	Classes() []Class
	Param(name string) (string, bool)
}

Task represents a unit of work that contains classes and associated parameters.

func MsgToTask

func MsgToTask(msg *protocol.Message) (Task, error)

MsgToTask parses a task from a protocol message.

func NewTask

func NewTask(description string, classes []Class, parameters map[string]any) Task

NewTask creates a new Task instance with the given description, classes, and parameters.

Jump to

Keyboard shortcuts

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