refactor

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package refactor implements different refactoring operations over Rego modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message  string        `json:"message"`
	Location *ast.Location `json:"location,omitempty"`
}

Error defines the structure of errors returned by refactor.

func (Error) Error

func (e Error) Error() string

type MoveQuery

type MoveQuery struct {
	Modules       map[string]*ast.Module
	SrcDstMapping map[string]string
	// contains filtered or unexported fields
}

MoveQuery holds the set of Rego modules whose package paths and other references are to be rewritten as per the mapping defined in SrcDstMapping. If validate is true, the moved modules will be compiled to ensure they are valid.

func (MoveQuery) WithValidation

func (mq MoveQuery) WithValidation(v bool) MoveQuery

WithValidation controls whether to compile moved modules to ensure they are valid.

type MoveQueryResult

type MoveQueryResult struct {
	Result map[string]*ast.Module `json:"result"`
}

MoveQueryResult defines the output of a move query and holds the rewritten modules with updated packages paths and references.

type Refactor

type Refactor struct {
}

Refactor implements different refactoring operations over Rego modules eg. renaming packages.

func New

func New() *Refactor

New returns a new Refactor object.

func (*Refactor) Move

func (r *Refactor) Move(q MoveQuery) (*MoveQueryResult, error)

Move rewrites Rego code by updating package paths and other references in q's modules as per the mapping specified in q.

Jump to

Keyboard shortcuts

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