scanner

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OccurenceGroupTypeContent = iota
	OccurenceGroupTypePath    = iota
)

Types of occurence group types.

Variables

This section is empty.

Functions

func GetSurroundingLines

func GetSurroundingLines(lines []string, lineIdx int, count int) (before []string, after []string)

GetSurroundingLines returns the surrounding lines

Types

type Occurence

type Occurence struct {
	Casing                 casing.Casing
	Match                  string
	Line                   string
	StartIndex             int
	LineStartIndex         int
	SurroundingLinesBefore []string
	SurroundingLinesAfter  []string
	LineNumber             int
}

Occurence is an occurence of the search text in a file.

func (Occurence) String

func (o Occurence) String() string

type OccurenceGroup

type OccurenceGroup struct {
	Path       string
	Occurences Occurences
	Type       OccurenceGroupType
}

OccurenceGroup is a grouping of occurences by file path and type.

func (OccurenceGroup) String

func (g OccurenceGroup) String() string

type OccurenceGroupType

type OccurenceGroupType uint8

OccurenceGroupType determines what kind of occurence group it is.

type OccurenceGroups

type OccurenceGroups []*OccurenceGroup

OccurenceGroups is a list of occurence groups. When sorted, files come first.

func ScanFileNodes

func ScanFileNodes(nodes lister.FileNodes, needle string, binaryPattern string) (OccurenceGroups, error)

ScanFileNodes will scan files and folders for occurences of the specified string.

func (OccurenceGroups) Len

func (slice OccurenceGroups) Len() int

func (OccurenceGroups) Less

func (slice OccurenceGroups) Less(i int, j int) bool

func (OccurenceGroups) String

func (slice OccurenceGroups) String() string

func (OccurenceGroups) Swap

func (slice OccurenceGroups) Swap(i int, j int)

type Occurences

type Occurences []*Occurence

Occurences is a slice of occurences.

func ScanFile

func ScanFile(filePath string, variants casing.Variants) (Occurences, error)

ScanFile scans a single file and returns the occurences of the specified variants.

func ScanFilePath

func ScanFilePath(filePath string, variants casing.Variants) Occurences

ScanFilePath scans a file path name for occurences.

func (Occurences) Len

func (slice Occurences) Len() int

func (Occurences) Less

func (slice Occurences) Less(i, j int) bool

func (Occurences) Swap

func (slice Occurences) Swap(i, j int)

Jump to

Keyboard shortcuts

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