errorformat: github.com/haya14busa/errorformat Index | Examples | Files | Directories

package errorformat

import "github.com/haya14busa/errorformat"

Package errorformat provides 'errorformat' functionality of Vim. :h errorformat

Index

Examples

Package Files

errorformat.go

type Efm Uses

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

Efm represents a errorformat.

func NewEfm Uses

func NewEfm(errorformat string) (*Efm, error)

NewEfm converts a 'errorformat' string to regular expression pattern with flags and returns Efm.

quickfix.c: efm_to_regpat

func (*Efm) Match Uses

func (efm *Efm) Match(s string) *Match

Match returns match against given string.

type Entry Uses

type Entry struct {
    // name of a file
    Filename string
    // line number
    Lnum int
    // column number (first column is 1)
    Col int
    // true: "col" is visual column
    // false: "col" is byte index
    Vcol bool
    // error number
    Nr  int
    // search pattern used to locate the error
    Pattern string
    // description of the error
    Text string
    // type of the error, 'E', '1', etc.
    Type rune
    // true: recognized error message
    Valid bool

    // Original error lines (often one line. more than one line for multi-line
    // errorformat. :h errorformat-multi-line)
    Lines []string
}

Entry represents matched entry of errorformat, equivalent to Vim's quickfix list item.

func (*Entry) String Uses

func (e *Entry) String() string

|| message /path/to/file|| message /path/to/file|1| message /path/to/file|1 col 14| message /path/to/file|1 col 14 error 8| message {filename}|{lnum}[ col {col}][ {type} [{nr}]]| {text}

func (*Entry) Types Uses

func (e *Entry) Types() string

Types makes a nice message out of the error character and the error number:

qf_types in src/quickfix.c

type Errorformat Uses

type Errorformat struct {
    Efms []*Efm
}

Errorformat provides errorformat feature.

Code:

in := `
golint.new.go:3:5: exported var V should have comment or be unexported
golint.new.go:5:5: exported var NewError1 should have comment or be unexported
golint.new.go:7:1: comment on exported function F should be of the form "F ..."
golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."
`
efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`, `%-G%.%#`})
s := efm.NewScanner(strings.NewReader(in))
for s.Scan() {
    fmt.Println(s.Entry())
}

Output:

golint.new.go|3 col 5| exported var V should have comment or be unexported
golint.new.go|5 col 5| exported var NewError1 should have comment or be unexported
golint.new.go|7 col 1| comment on exported function F should be of the form "F ..."
golint.new.go|11 col 1| comment on exported function F2 should be of the form "F2 ..."

func NewErrorformat Uses

func NewErrorformat(efms []string) (*Errorformat, error)

NewErrorformat compiles given errorformats string (efms) and returns a new Errorformat. It returns error if the errorformat is invalid.

func (*Errorformat) NewScanner Uses

func (errorformat *Errorformat) NewScanner(r io.Reader) *Scanner

NewScanner returns a new Scanner to read from r.

type Match Uses

type Match struct {
    F   string // (%f) file name
    N   int    // (%n) error number
    L   int    // (%l) line number
    C   int    // (%c) column number
    T   byte   // (%t) error type
    M   string // (%m) error message
    R   string // (%r) the "rest" of a single-line file message
    P   string // (%p) pointer line
    V   int    // (%v) virtual column number
    S   string // (%s) search text
}

Match represents match of Efm. ref: Basic items in :h errorformat

type Scanner Uses

type Scanner struct {
    *Errorformat
    // contains filtered or unexported fields
}

Scanner provides a interface for scanning compiler/linter/static analyzer result using Errorformat.

func (*Scanner) Entry Uses

func (s *Scanner) Entry() *Entry

Entry returns the most recent entry generated by a call to Scan.

func (*Scanner) Scan Uses

func (s *Scanner) Scan() bool

Scan advances the Scanner to the next entry matched with errorformat, which will then be available through the Entry method. It returns false when the scan stops by reaching the end of the input.

Directories

PathSynopsis
fmtsPackage fmts holds defined errorformats.
writerPackage writer provides error result writers.

Package errorformat imports 8 packages (graph) and is imported by 2 packages. Updated 2017-03-03. Refresh now. Tools for package owners.