util

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: BSD-3-Clause Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFiles

func FindFiles(paths []string) (result []string)

FindFiles recursively searches the directories and files contained in paths and returns a unique list of files

Types

type LineKeeper

type LineKeeper struct {
	EOLLocations []int // end-of-line locations
	// contains filtered or unexported fields
}

LineKeeper keeps track of line numberson a textual source file and can map character location to the relevant `code.Position`

func (*LineKeeper) GetPositionFromCharacterIndex

func (lk *LineKeeper) GetPositionFromCharacterIndex(pos int64) code.Position

GetPositionFromCharacterIndex returns the `code.Position` given the index of the character in the file

type PathConsumer

type PathConsumer interface {
	ConsumePath(path string)
	diagnostics.ExclusionProvider
}

PathConsumer is a sink for paths and URIs

type PathMultiplexer

type PathMultiplexer interface {
	SetPathConsumers(consumers ...PathConsumer)
	ConsumePath(path string)
}

PathMultiplexer interface defines an aggregator of analysers that can consume filesystem paths and URIs and process them

func NewPathMultiplexer

func NewPathMultiplexer(consumers ...PathConsumer) PathMultiplexer

NewPathMultiplexer creates a choreographer that orchestrates the consumption of paths by consumers

type PositionProvider

type PositionProvider interface {
	GetPosition(index int64) code.Position
}

PositionProvider provides a "global" view of code location, given an arbitrary character index.

type ResourceConsumer

type ResourceConsumer interface {
	//Consume allows a source processor receive `source` data streamed in "chunks", with `startIndex` indicating the
	//character location of the first character in the stream
	Consume(startIndex int64, source string)
	//ConsumePath allows resource consumers that process filepaths directly to analyse files on disk
	ConsumePath(filePath string)
	SetLineKeeper(*LineKeeper)
	//ShouldProvideSourceInDiagnostics toggles whether source evidence should be provided with diagnostics, defaults to false
	ShouldProvideSourceInDiagnostics(bool)
	//used to signal to the consumer that the source stream has ended
	End()
}

ResourceConsumer is a sink for streaming source

type ResourceMultiplexer

type ResourceMultiplexer interface {
	//SetSource is the source reader to multiplex to multiple consumers, which will be provided with a copy of the source data as it is being streamed in from the source
	SetResourceAndConsumers(filePath string, source *io.Reader, provideSourceInDiagnostics bool, consumers ...ResourceConsumer)
}

ResourceMultiplexer interface defines a path or source reader that can be multiplexed to multiple consumers. It provides additional utility such as mapping a source index to the line and character, i.e. the `code.Position` in the source

func NewResourceMultiplexer

func NewResourceMultiplexer(filePath string, source *io.Reader, provideSource bool, consumers ...ResourceConsumer) ResourceMultiplexer

NewResourceMultiplexer creates a source multiplexer over an input reader

type UUID

type UUID [16]byte

func NewRandomUUID

func NewRandomUUID() UUID

func (UUID) String

func (uuid UUID) String() string

String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx , or "" if uuid is invalid.

Jump to

Keyboard shortcuts

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