model

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContextWithProject

func NewContextWithProject(ctx context.Context, project *Project) context.Context

NewContextWithProject returns a new context with the project set

Types

type Config

type Config struct {
	DevContainerConfig devcontainer.Config `json:"devContainerConfig"`
}

type File

type File struct {
	Path  string `json:"path"`
	Lines []Line `json:"lines"`
	// NOTE: should diagnostics be part of a line?
	Diagnostics []protocol.Diagnostic `json:"diagnostics,omitempty"`
}

func EmptyFile

func EmptyFile(path string) *File

func NewFile

func NewFile(path string, content string) *File

NewFile creates a new File from the given path and content. Content is split into lines. Line numbers are 1-based.

func (*File) Equals

func (f *File) Equals(other *File) bool

func (*File) GetContent

func (f *File) GetContent() string

func (*File) GetContentBytes

func (f *File) GetContentBytes() []byte

func (*File) GetLine

func (f *File) GetLine(lineNumber int) Line

GetLine returns the line with the given line number. Line numbers are 1-based.

func (*File) GetLineRange

func (f *File) GetLineRange(start, end int) []Line

GetLineRange returns the lines between start and end (exclusive). Line numbers are 1-based.

func (*File) ReplaceLineRange

func (f *File) ReplaceLineRange(start, end int, content string) (*File, error)

ReplaceLineRange replaces the lines between start and end (exclusive) with the given content. Line numbers are 1-based.

func (*File) WithLineRange

func (f *File) WithLineRange(start, end int) *File

WithLineRange returns a new File with the lines between start and end (exclusive). Line numbers are 1-based.

func (*File) WithPath

func (f *File) WithPath(path string) *File

type Files

type Files []*File

func (Files) String

func (fs Files) String() string

type Line

type Line struct {
	Number  int    `json:"number"`
	Content string `json:"content"`
}

func NewLines

func NewLines(content string) []Line

NewLines splits the given content into lines. Line numbers are 1-based.

type Project

type Project struct {
	Id          ProjectId `json:"id"`
	Path        string    `json:"path"`
	Config      Config    `json:"config"`
	ContainerId string
}

func NewProject

func NewProject(id ProjectId, path string, config Config, containerId string) Project

func ProjectFromContext

func ProjectFromContext(ctx context.Context) (*Project, bool)

ProjectFromContext returns the project from the context

func (*Project) FindTaskByAlias

func (project *Project) FindTaskByAlias(alias string) (devcontainer.Task, error)

func (*Project) GetTasks

func (project *Project) GetTasks() []devcontainer.Task

type ProjectId

type ProjectId = string

type TaskNotFoundError

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

func NewTaskNotFoundError

func NewTaskNotFoundError(taskId string) *TaskNotFoundError

func (TaskNotFoundError) Error

func (e TaskNotFoundError) Error() string

Jump to

Keyboard shortcuts

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