summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint
diff options
context:
space:
mode:
authorrillig <rillig>2017-01-29 14:30:26 +0000
committerrillig <rillig>2017-01-29 14:30:26 +0000
commit3ef11114bc878fcf96e0f158d118630ae1c45aa8 (patch)
tree4ac57e5661bb40122a258021f1d0e22a15cbafc5 /pkgtools/pkglint
parent881202e1b1e617eeb98eb6ce7bf54ccdaad9a1aa (diff)
downloadpkgsrc-3ef11114bc878fcf96e0f158d118630ae1c45aa8.tar.gz
Removed expecter.go, which had been moved to files/textproc.
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r--pkgtools/pkglint/files/expecter.go98
1 files changed, 0 insertions, 98 deletions
diff --git a/pkgtools/pkglint/files/expecter.go b/pkgtools/pkglint/files/expecter.go
deleted file mode 100644
index e0f141cba7a..00000000000
--- a/pkgtools/pkglint/files/expecter.go
+++ /dev/null
@@ -1,98 +0,0 @@
-package main
-
-import (
- "netbsd.org/pkglint/regex"
- "netbsd.org/pkglint/trace"
-)
-
-// Expecter records the state when checking a list of lines from top to bottom.
-type Expecter struct {
- lines []Line
- index int
- m []string
-}
-
-func NewExpecter(lines []Line) *Expecter {
- return &Expecter{lines, 0, nil}
-}
-
-func (exp *Expecter) CurrentLine() Line {
- if exp.index < len(exp.lines) {
- return exp.lines[exp.index]
- }
-
- return NewLineEOF(exp.lines[0].Filename())
-}
-
-func (exp *Expecter) PreviousLine() Line {
- return exp.lines[exp.index-1]
-}
-
-func (exp *Expecter) EOF() bool {
- return !(exp.index < len(exp.lines))
-}
-
-func (exp *Expecter) Advance() bool {
- exp.index++
- exp.m = nil
- return true
-}
-
-func (exp *Expecter) StepBack() {
- exp.index--
-}
-
-func (exp *Expecter) AdvanceIfMatches(re regex.RegexPattern) bool {
- if trace.Tracing {
- defer trace.Call(exp.CurrentLine().Text(), re)()
- }
-
- if !exp.EOF() {
- if m := regex.Match(exp.lines[exp.index].Text(), re); m != nil {
- exp.index++
- exp.m = m
- return true
- }
- }
- return false
-}
-
-func (exp *Expecter) AdvanceIfPrefix(prefix string) bool {
- if trace.Tracing {
- defer trace.Call2(exp.CurrentLine().Text(), prefix)()
- }
-
- return !exp.EOF() && hasPrefix(exp.lines[exp.index].Text(), prefix) && exp.Advance()
-}
-
-func (exp *Expecter) AdvanceIfEquals(text string) bool {
- if trace.Tracing {
- defer trace.Call2(exp.CurrentLine().Text(), text)()
- }
-
- return !exp.EOF() && exp.lines[exp.index].Text() == text && exp.Advance()
-}
-
-func (exp *Expecter) ExpectEmptyLine() bool {
- if exp.AdvanceIfEquals("") {
- return true
- }
-
- if G.opts.WarnSpace {
- if !exp.CurrentLine().AutofixInsertBefore("") {
- exp.CurrentLine().Notef("Empty line expected.")
- }
- }
- return false
-}
-
-func (exp *Expecter) ExpectText(text string) bool {
- if !exp.EOF() && exp.lines[exp.index].Text() == text {
- exp.index++
- exp.m = nil
- return true
- }
-
- exp.CurrentLine().Warnf("This line should contain the following text: %s", text)
- return false
-}