compilerutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2017 License: BSD-3-Clause Imports: 14 Imported by: 19

Documentation

Overview

compilerutil package defines utility methods.

Index

Constants

View Source
const INDENTATION = "  "
View Source
const RECURSIVE_PATTERN = "/..."

RECURSIVE_PATTERN defines the pattern for recursively searching for files.

Variables

This section is empty.

Functions

func DCHECK

func DCHECK(checker checkFn, failMessage string, args ...interface{})

DCHECK executes the checker function only if the DEBUG environment variable is set. If the function returns false, the compiler will panic with the formatted message.

func IsId

func IsId(possibleId string) bool

IsId returns whether the given string is a possible ID as returned by NewUniqueId.

func LatestSemanticVersion

func LatestSemanticVersion(availableVersions []string) (string, bool)

LatestSemanticVersion returns the latest non-patch semantic version found in the list of available versions, if any.

func LogToConsole

func LogToConsole(level ConsoleLogLevel, sourceRange compilercommon.SourceRange, message string, args ...interface{})

LogToConsole logs a message to the console, with the given level and range.

func NewUniqueId

func NewUniqueId() string

NewUniqueId returns a new unique ID.

func ParseFloat

func ParseFloat(strValue string) float64

ParseFloat parses the given string value into a float64, panicing on failure.

func Queue

func Queue() *orderedWorkQueue

Queue returns a new ordered work queue.

func SemanticUpdateVersion

func SemanticUpdateVersion(currentVersionString string, availableVersions []string, option UpdateVersionOption) (string, error)

SemanticUpdateVersion finds the semver in the available versions list that is newer than the current version.

func WalkSourcePath

func WalkSourcePath(path string, handler PathHandler, skipDirectories ...string) (uint, error)

WalkSourcePath walks the given source path, invoking the given handler for each file found. Returns the number of files walked and the error that occurred, if any.

Types

type ConsoleLogLevel

type ConsoleLogLevel int
const (
	InfoLogLevel ConsoleLogLevel = iota
	SuccessLogLevel
	WarningLogLevel
	ErrorLogLevel
)

type Element

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

type ImmutableMap added in v0.1.0

type ImmutableMap interface {
	// Get returns the value found at the given key, if any.
	Get(key string) (interface{}, bool)

	// Set returns a new ImmutableMap which is a copy of this map, but with the given key set
	// to the given value.
	Set(key string, value interface{}) ImmutableMap
}

ImmutableMap defines an immutable map struct, where Set-ing a new key returns a new ImmutableMap.

func NewImmutableMap added in v0.1.0

func NewImmutableMap() ImmutableMap

NewImmutableMap creates a new, empty immutable map.

type IntRange

type IntRange struct {
	StartPosition int
	EndPosition   int
}

IntRange defines a range of integer values, inclusive.

type LockMap

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

LockMap defines a concurrent-safe map that returns a sync Mutex for each key. This is useful when multiple resources are being loaded concurrently and locking is needed, but only on a per-resource basis.

func CreateLockMap

func CreateLockMap() LockMap

CreateLockMap returns a new LockMap.

func (LockMap) GetLock

func (lm LockMap) GetLock(key string) *sync.Mutex

GetLock returns a lock for the given key.

type PathHandler

type PathHandler func(filePath string, info os.FileInfo) (bool, error)

PathHandler defines a handler to be invoked for every file found. Implementations should return false if the file should be skipped.

type RangeMapTree

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

RangeMapTree defines a helper struct for cached, faster lookup of an int range to an associated piece of data, under a specific key (such as a source file path). Note that the ranges for the data must be explicitly *non-overlapping* under each key, or this data structure will fail to work as intended. Ranges *within* other ranges, on the other hand, are allowed.

This data structure is safe for multi-threaded access.

func NewRangeMapTree

func NewRangeMapTree(calculator RangeMapTreeCalculator) *RangeMapTree

NewRangeMapTree creates a new range map tree.

func (*RangeMapTree) Get

func (rmt *RangeMapTree) Get(key string, current IntRange) interface{}

Get returns the data associated with the given key and range. If the data for that range has not yet been calculated, the calculator method is called to do so lazily.

type RangeMapTreeCalculator

type RangeMapTreeCalculator func(key string, current IntRange) (IntRange, interface{})

RangeMapTreeCalculator returns the calculated value for the given key and range. The range returned should encompass the entire range of the returned value. If no valid value is found for the position and key, the range returned should be the range requested.

type Stack

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

func (*Stack) Len

func (s *Stack) Len() int

Return the stack's length

func (*Stack) Peek

func (s *Stack) Peek() interface{}

Peek returns the element on the top of the list, if any. If the stack is empty, return nil

func (*Stack) PeekSecond

func (s *Stack) PeekSecond() interface{}

PeekSecond returns the element second to the top of the list, if any. If the stack contains less than two elemeents, return nil

func (*Stack) Pop

func (s *Stack) Pop() (value interface{})

Remove the top element from the stack and return it's value If the stack is empty, return nil

func (*Stack) Push

func (s *Stack) Push(value interface{})

Push a new element onto the stack

type UpdateVersionOption

type UpdateVersionOption string

UpdateVersionOption defines the options for the SemanticUpdateVersion method.

const (
	// UpdateVersionMinor indicates that only minor version updates are allowed.
	UpdateVersionMinor UpdateVersionOption = "minor"

	// UpdateVersionMajor indicates the both minor and major version updates are allowed.
	UpdateVersionMajor = "major"
)

Jump to

Keyboard shortcuts

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