validateapi

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConflictAction

type ConflictAction struct {
	// The action ID.
	ActionID string
	// The context or condition for the action (optional).
	Context string
}

ConflictAction represents an action involved in a keybinding conflict.

type DanglingAction

type DanglingAction struct {
	// The action that is dangling.
	Action string
	// The target editor where the action is not found.
	TargetEditor string
	// A suggestion for fixing the issue.
	Suggestion string
}

DanglingAction is a dangling action detected during validation.

type DuplicateMapping

type DuplicateMapping struct {
	// The action that has duplicate mappings.
	Action string
	// The keybinding that is duplicated.
	Keybinding string
}

DuplicateMapping is a duplicate mapping detected during validation.

type IssueDetails

type IssueDetails interface {
	// contains filtered or unexported methods
}

IssueDetails holds the details for different issue types.

type IssueType

type IssueType string

IssueType represents the type of validation issue.

const (
	IssueTypeKeybindConflict    IssueType = "keybind_conflict"
	IssueTypeDanglingAction     IssueType = "dangling_action"
	IssueTypeUnsupportedAction  IssueType = "unsupported_action"
	IssueTypeDuplicateMapping   IssueType = "duplicate_mapping"
	IssueTypePotentialShadowing IssueType = "potential_shadowing"
)

type KeybindConflict

type KeybindConflict struct {
	// The keybinding that is in conflict.
	Keybinding string
	// The actions that are in conflict.
	Actions []ConflictAction
}

KeybindConflict is a keybinding conflict detected during validation.

type PotentialShadowing

type PotentialShadowing struct {
	// The keybinding that might shadow a critical shortcut.
	Keybinding string
	// The action being mapped.
	Action string
	// Description of the critical shortcut being shadowed.
	CriticalShortcutDescription string
}

PotentialShadowing is a potential shadowing issue detected during validation.

type Summary

type Summary struct {
	// The total number of mappings processed.
	MappingsProcessed int
	// The number of mappings that succeeded.
	MappingsSucceeded int
}

Summary is the summary of a validation run.

type UnsupportedAction

type UnsupportedAction struct {
	// The action that is unsupported.
	Action string
	// The keybinding for the unsupported action.
	Keybinding string
	// The target editor that does not support the action.
	TargetEditor string
}

UnsupportedAction is an unsupported action detected during validation.

type ValidationContext

type ValidationContext struct {
	Setting    keymap.Keymap
	Report     *ValidationReport
	EditorType pluginapi.EditorType
}

ValidationContext holds all the necessary data for a validation rule to execute.

type ValidationIssue

type ValidationIssue struct {
	// Type indicates the kind of issue
	Type IssueType
	// Details contains the issue-specific data
	Details IssueDetails
}

ValidationIssue is a single issue detected during validation.

type ValidationReport

type ValidationReport struct {
	// The source editor of the validation run.
	SourceEditor string
	// The summary of the validation run.
	Summary Summary
	// The issues detected during the validation run.
	Issues []ValidationIssue
	// The warnings issued during the validation run.
	Warnings []ValidationIssue
}

ValidationReport is the overall report of a validation run.

type ValidationRule

type ValidationRule interface {
	Validate(ctx context.Context, validationContext *ValidationContext) error
}

type Validator

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

Validator is a chain of responsibility container for validation rules.

func NewValidator

func NewValidator(rules ...ValidationRule) *Validator

NewValidator creates a new validator with no rules.

func (*Validator) Validate

func (v *Validator) Validate(
	ctx context.Context,
	setting keymap.Keymap,
	editorType pluginapi.EditorType,
) (*ValidationReport, error)

Validate executes all validation rules in the chain.

Jump to

Keyboard shortcuts

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