Documentation ¶
Overview ¶
compilerutil package defines utility methods.
Index ¶
- Constants
- func DCHECK(checker checkFn, failMessage string, args ...interface{})
- func IsId(possibleId string) bool
- func LatestSemanticVersion(availableVersions []string) (string, bool)
- func LogToConsole(level ConsoleLogLevel, sourceRange compilercommon.SourceRange, message string, ...)
- func NewUniqueId() string
- func ParseFloat(strValue string) float64
- func Queue() *orderedWorkQueue
- func SemanticUpdateVersion(currentVersionString string, availableVersions []string, ...) (string, error)
- func WalkSourcePath(path string, handler PathHandler, skipDirectories ...string) (uint, error)
- type ConsoleLogLevel
- type Element
- type ImmutableMap
- type IntRange
- type LockMap
- type PathHandler
- type RangeMapTree
- type RangeMapTreeCalculator
- type Stack
- type UpdateVersionOption
Constants ¶
const INDENTATION = " "
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 LatestSemanticVersion ¶
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 ParseFloat ¶
ParseFloat parses the given string value into a float64, panicing on failure.
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 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 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.
type PathHandler ¶
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 ¶
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) 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
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" )