fileposition

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToLines

func BytesToLines(data []byte) []string

func ExtractDelimitedRegexpPositionInBlock

func ExtractDelimitedRegexpPositionInBlock(block []string, str string, blockStartLine int, prefix string, suffix string) *models.FilePosition

func ExtractDelimitedStringPositionInBlock

func ExtractDelimitedStringPositionInBlock(block []string, str string, blockStartLine int, prefix string, suffix string) *models.FilePosition

func ExtractStringPositionInBlock

func ExtractStringPositionInBlock(block []string, str string, blockStartLine int) *models.FilePosition

func GetFirstNonEmptyCharacterIndexInLine

func GetFirstNonEmptyCharacterIndexInLine(line string) int

func GetLastNonEmptyCharacterIndexInLine

func GetLastNonEmptyCharacterIndexInLine(line string) int

func InBunLockPackages added in v1.18.1

func InBunLockPackages(sanitized []byte) map[string]models.FilePosition

InBunLockPackages scans a JSONC-sanitized bun.lock buffer and returns a map keyed by the exact package key found inside the top-level "packages" object, mapping each key to the source FilePosition of its tuple entry.

The input is expected to be CRLF-normalized and JSONC-sanitized so that positions map 1:1 to the raw file. All positions are 1-indexed:

  • Line.Start / Line.End span the entry's opening line (the key) through the line containing the tuple's closing "]".
  • Column.Start is the column of the key's opening quote.
  • Column.End is the column immediately after the tuple's closing "]".

The returned FilePosition leaves Filename empty; the caller sets it.

The scan is a single pass over the bytes. Brackets and braces only affect the combined nesting depth when they occur outside a quoted string; a string is closed by a double quote preceded by an even number of consecutive backslashes. The "packages" object is matched by its exact quoted token at root-object depth, so decoy keys such as "packages/a" (a workspace key) are never mistaken for it.

func InJSON

func InJSON[P models.IFilePosition](groupKey string, dependencies map[string]P, lines []string, offset int)

func InTOML

func InTOML[P models.IFilePosition](groupKey string, otherKey string, dependencies []P, lines []string)

func IsFilePositionExtractedSuccessfully

func IsFilePositionExtractedSuccessfully(filePosition models.FilePosition) bool

func ShouldExcludePath added in v0.0.3

func ShouldExcludePath(dir, path string, excludePaths []string) (bool, string, error)

ShouldExcludePath checks if a given path should be excluded based on a list of exclusion patterns.

func ToRelativePath

func ToRelativePath(scanPath string, packagePath string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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