errorformat

package
v0.0.0-...-667e8d2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Efm

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

Efm represents a errorformat.

func NewEfm

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

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

Match returns match against given string.

type Entry

type Entry struct {
	// name of a file
	Filename string `json:"filename"`
	// line number
	Lnum int `json:"lnum"`
	// End of line number if the item is multiline
	EndLnum int `json:"end_lnum"`
	// column number (first column is 1)
	Col int `json:"col"`
	// End of column number if the item has range
	EndCol int `json:"end_col"`
	// true: "col" is visual column
	// false: "col" is byte index
	Vcol bool `json:"vcol"`
	// error number
	Nr int `json:"nr"`
	// search pattern used to locate the error
	Pattern string `json:"pattern"`
	// description of the error
	Text string `json:"text"`
	// type of the error, 'E', '1', etc.
	Type rune `json:"type"`
	// true: recognized error message
	Valid bool `json:"valid"`

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

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

func (*Entry) String

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 /path/to/file|1-2 col 14-28| message {filename}|{lnum}[-{end_lnum}][ col {col}[-{end_col}]][ {type} [{nr}]]| {text}

func (*Entry) Types

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

type Errorformat struct {
	Efms []*Efm
}

Errorformat provides errorformat feature.

func NewErrorformat

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

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

NewScanner returns a new Scanner to read from r.

type Match

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

	// Extensions
	E int // (%e) end line number
	K int // (%k) end column number
}

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

type Scanner

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

func (s *Scanner) Entry() *Entry

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

func (*Scanner) Scan

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

Path Synopsis
Package fmts holds defined errorformats.
Package fmts holds defined errorformats.

Jump to

Keyboard shortcuts

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