problems

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package problems holds the Problems panel (SPEC §3.2).

Index

Constants

View Source
const (
	// MessageNoProblems is shown while there are no markers.
	MessageNoProblems = "No problems have been detected in the workspace."
	// MessageNoProblemsActiveFile is shown when the markers of the active file are asked for and it has none.
	MessageNoProblemsActiveFile = "No problems have been detected in the current file."
	// MessageNoResults is shown when the filter lets no marker through.
	MessageNoResults = "No results found with provided filter criteria."
	// FilterPlaceholder is the hint of the filter box.
	FilterPlaceholder = "Filter (e.g. text, **/*.ts, !**/node_modules/**, @source:ts)"
)

Messages of the Problems panel.

Ported from VS Code: src/vs/workbench/contrib/markers/browser/messages.ts

All lists the severities the Problems panel shows.

Variables

View Source
var (
	// TreeKey is the key of the tree of the problems.
	TreeKey = foundation.NewValueKey("problems:tree")
	// MessageKey is the key of the message that stands in place of the tree.
	MessageKey = foundation.NewValueKey("problems:message")
	// ClearFiltersKey is the key of the link that clears the filters in the message.
	ClearFiltersKey = foundation.NewValueKey("problems:clear-filters")
	// FilterKey is the key of the filter box.
	FilterKey = foundation.NewValueKey("problems:filter")
	// CollapseAllKey is the key of the button that collapses the tree.
	CollapseAllKey = foundation.NewValueKey("problems:collapse-all")
)

Keys of the widgets of the panel, which tests find them by.

View Source
var ActiveFileKey = foundation.NewValueKey("problems:active-file")

ActiveFileKey is the key of the toggle that shows the markers of the active file only.

Functions

func PositionText

func PositionText(m Marker) string

PositionText is the position of a marker as the panel shows it: "[Ln 3, Col 5]".

Ported from VS Code: src/vs/workbench/contrib/markers/browser/messages.ts (MARKERS_PANEL_AT_LINE_COL_NUMBER)

func SourceText

func SourceText(m Marker) string

SourceText is the source and the code of a marker as the panel shows them after the message: "source(code)", "source" or "(code)".

func ToggleKey

func ToggleKey(s Severity) foundation.Key

ToggleKey is the key of the toggle of a severity (the Severity values) in the actions of the panel.

Types

type Actions

type Actions struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Actions is what the panel shows in its title strip while the Problems are the tab: the filter box, the switches for errors, warnings, infos and the active file, and the button that collapses the tree.

Ported from VS Code: src/vs/workbench/contrib/markers/browser/markersViewActions.ts (MarkersFilterActionViewItem)

func NewActions

func NewActions(view *View) *Actions

NewActions makes the actions of the panel for a view.

func (*Actions) CreateState

func (a *Actions) CreateState() widgets.State

CreateState implements widgets.StatefulWidget.

func (*Actions) TitleActionsWidth added in v1.0.0

func (a *Actions) TitleActionsWidth(room float64) float64

TitleActionsWidth implements kit.TitleActions: the filter box and the buttons take up to filterWidth + buttonsWidth and keep at least filterMinWidth for the box; with less room the box is left out, and under the width of the buttons nothing shows.

type Body

type Body struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Body is the body of the panel: the tree of the problems, or the message that says why there are none.

Ported from VS Code: src/vs/workbench/contrib/markers/browser/markersView.ts and markersTreeViewer.ts (ResourceMarkersRenderer, MarkerRenderer)

func NewBody

func NewBody(view *View) *Body

NewBody makes the body of the panel for a view.

func (*Body) CreateState

func (b *Body) CreateState() widgets.State

CreateState implements widgets.StatefulWidget.

type Change

type Change struct {
	// Resources are the absolute paths whose markers are not what they were, in the order they were
	// first touched.
	Resources []string
}

Change tells which resources a change of the Service touched.

type FilterOptions

type FilterOptions struct {
	// Text is the text of the filter box: words that match the message, source and code of a
	// marker and the name of its file; a leading "!" shows what does not match; patterns separated
	// by commas are globs of files (`**/*.go`, `.go`, `vendor`), and a "!" before one hides its
	// files; `@source:name` (`!@source:name` to exclude) keeps the markers of a source.
	Text string
	// Severities are the severities shown; the zero value shows none.
	Severities Severities
	// ActiveFileOnly shows only the markers of ActiveFile.
	ActiveFileOnly bool
	// ActiveFile is the absolute path of the file of the active editor, or empty.
	ActiveFile string
	// Exclude, when set, tells the files that are hidden for being excluded (files.exclude).
	Exclude func(path string) bool
}

FilterOptions are what narrows the markers the Problems panel shows.

func DefaultFilter

func DefaultFilter() FilterOptions

DefaultFilter shows every severity of every file, as the panel opens.

type Marker

type Marker struct {
	// Owner is who set the marker; the Service fills it in.
	Owner string
	// Resource is the absolute path of the file; the Service fills it in.
	Resource string
	// Severity is how serious the problem is.
	Severity Severity
	// Code is the code of the problem ("S1234"); may be empty.
	Code string
	// Source is the tool that found the problem ("eslint"); may be empty.
	Source string
	// Message describes the problem. A marker with no message is not kept.
	Message string
	// StartLine, StartColumn, EndLine and EndColumn are the range, counted from 1.
	StartLine, StartColumn, EndLine, EndColumn int
	// CodeHref is a link that describes the code (the target of VS Code's code object); may be empty.
	CodeHref string
	// Unnecessary and Deprecated are VS Code's marker tags: the editor fades the text of an unnecessary
	// (unused) marker and strikes through the text of a deprecated one.
	Unnecessary, Deprecated bool
	// Related are the places that are part of the problem.
	Related []RelatedInformation
	// Data is what the producer wants back with the diagnostic when it is asked for the code actions of a place: a language
	// server's diagnostic as JSON (step 12.8); may be empty.
	Data json.RawMessage
}

Marker is a problem found in a file: an error, a warning or information about a range of it. It is what producers (language servers, tasks) give the Service and the Problems panel shows.

The lines and columns count from 1, as the panel shows them ("[Ln 3, Col 5]"); a column counts UTF-16 units, as VS Code's and the language server protocol's do.

Ported from VS Code: src/vs/platform/markers/common/markers.ts (IMarkerData, IMarker)

func (Marker) Holds added in v1.0.0

func (m Marker) Holds(resource string, line, column int) bool

Holds tells whether a position of a file (a line and a column counted from 1, the column in UTF-16 units) is in the range of the marker.

type MarkerList added in v1.0.0

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

MarkerList is the list that Go to Next Problem and Go to Previous Problem go through: the errors, warnings and infos of one file or of every file, ordered by file, then by seriousness (errors first), then by position (VS Code's default of problems.sortOrder, "severity"), with the place of the problem shown last. It follows the markers: when they change, the place is forgotten.

Ported from VS Code: src/vs/editor/contrib/gotoError/browser/markerNavigationService.ts (MarkerList)

func NewMarkerList added in v1.0.0

func NewMarkerList(svc *Service, resource string) *MarkerList

NewMarkerList makes the list of the problems of a file (a path), or of every file when the path is empty.

func (*MarkerList) Matches added in v1.0.0

func (l *MarkerList) Matches(resource string) bool

Matches tells whether the list is for the file (or for every file when the path is empty), as VS Code's MarkerList.matches.

func (*MarkerList) Move added in v1.0.0

func (l *MarkerList) Move(forward bool, resource string, line, column int) bool

Move goes to the next or the previous marker, wrapping around, and says whether the place moved. The first move, or the first after ResetIndex, starts from the position (a line and a column counted from 1) in the file with the path: the first marker at or after it, or the last one before it going back; a file with no markers starts at the file that follows it.

Ported from VS Code: markerNavigationService.ts (MarkerList._initIdx, move)

func (*MarkerList) Refresh added in v1.0.0

func (l *MarkerList) Refresh() bool

Refresh reads the markers again; when they are not the same the place is forgotten. It says whether they changed.

func (*MarkerList) ResetIndex added in v1.0.0

func (l *MarkerList) ResetIndex()

ResetIndex forgets the place: the next move starts from the position it is given.

func (*MarkerList) Selected added in v1.0.0

func (l *MarkerList) Selected() (m Marker, index, total int, ok bool)

Selected is the marker shown last, its place in the list counted from 1 and the number of markers; false when none is.

func (*MarkerList) Total added in v1.0.0

func (l *MarkerList) Total() int

Total is the number of markers in the list.

type Model

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

Model is the Problems panel's view of a Service: the markers grouped by file, narrowed by a filter, sorted the way the panel sorts them. It is used on the UI thread only; the Service tells it about changes through the poster it was made with.

Ported from VS Code: src/vs/workbench/contrib/markers/browser/markersModel.ts (MarkersModel)

func NewModel

func NewModel(svc *Service, post func(func())) *Model

NewModel makes a model of the markers of svc, with the default filter. post hands a function to the UI thread (the binding's Post); changes of the service are read there, many in one go.

func (*Model) ClearFilters

func (m *Model) ClearFilters()

ClearFilters resets the text, the severities and the active file switch.

func (*Model) Close

func (m *Model) Close()

Close stops following the service.

func (*Model) Filtered

func (m *Model) Filtered() int

Filtered is how many markers the filter lets through.

func (*Model) Filtering

func (m *Model) Filtering() bool

Filtering tells whether the filter narrows anything: it has text, hides a severity or shows the active file only.

func (*Model) OnChange

func (m *Model) OnChange(fn func()) (unsubscribe func())

OnChange calls fn after the markers or the filter changed, and returns the function that stops it.

func (*Model) Options

func (m *Model) Options() FilterOptions

Options are the options of the filter.

func (*Model) Refresh

func (m *Model) Refresh()

Refresh reads the service again and applies the filter.

func (*Model) Resource

func (m *Model) Resource(path string) (ResourceMarkers, bool)

Resource gives the markers of a file that are shown.

func (*Model) Resources

func (m *Model) Resources() []ResourceMarkers

Resources are the files with markers that the filter lets through, in the order the panel shows them: files whose first marker is more serious come first, then by path.

func (*Model) Root

func (m *Model) Root() string

Root is the folder of the window, which the folders of the files are shown relative to.

func (*Model) Service

func (m *Model) Service() *Service

Service is the service the model shows.

func (*Model) SetActiveFile

func (m *Model) SetActiveFile(path string)

SetActiveFile tells the model which file the active editor shows ("" for none).

func (*Model) SetOptions

func (m *Model) SetOptions(opts FilterOptions)

SetOptions changes the filter.

func (*Model) SetRoot

func (m *Model) SetRoot(root string)

SetRoot sets the folder of the window.

func (*Model) SetText

func (m *Model) SetText(text string)

SetText changes the text of the filter.

func (*Model) Stats

func (m *Model) Stats() Stats

Stats counts the markers the filter lets through by severity.

func (*Model) ToggleActiveFileOnly

func (m *Model) ToggleActiveFileOnly()

ToggleActiveFileOnly shows the markers of the active file only, or those of every file.

func (*Model) ToggleSeverity

func (m *Model) ToggleSeverity(s Severity)

ToggleSeverity shows the markers of a severity, or hides them.

func (*Model) Total

func (m *Model) Total() int

Total is how many markers there are in all (errors, warnings and infos).

type ReadFilter

type ReadFilter struct {
	// Owner, when set, limits the markers to those of an owner.
	Owner string
	// Resource, when set, limits them to those of a file.
	Resource string
	// Severities limits them to some severities; the zero value is every severity.
	Severities Severities
	// Take, when positive, is the most markers to give.
	Take int
}

ReadFilter says which markers Service.Read gives.

type RelatedInformation

type RelatedInformation struct {
	// Resource is the absolute path of the file.
	Resource string
	// Message says why the place is related.
	Message string
	// StartLine, StartColumn, EndLine and EndColumn are the range, counted from 1.
	StartLine, StartColumn, EndLine, EndColumn int
}

RelatedInformation is a place that is part of a problem, such as the other declaration of a name that is declared twice.

type ResourceMarkers

type ResourceMarkers struct {
	// Resource is the absolute path of the file.
	Resource string
	// Name is the name of the file.
	Name string
	// Dir is the folder of the file as the panel shows it: relative to the folder of the window
	// when the file is inside it, else absolute; empty for a file in the folder itself.
	Dir string
	// Markers are the markers that are shown, errors first and each severity by position.
	Markers []Marker
	// Total is how many markers the file has in all.
	Total int
}

ResourceMarkers are the markers of one file that the filter lets through, as the Problems panel shows them.

Ported from VS Code: src/vs/workbench/contrib/markers/browser/markersModel.ts (ResourceMarkers)

type Service

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

Service holds the markers that producers set: per owner and per resource, replaced as a whole. It is safe for use from any goroutine; subscribers are called on the goroutine that changed it (after the change, with no lock held), so a UI subscriber hands the change to the UI thread itself.

Ported from VS Code: src/vs/platform/markers/common/markerService.ts

func NewService

func NewService() *Service

NewService makes a Service with no markers.

func (*Service) Read

func (s *Service) Read(filter ReadFilter) []Marker

Read gives the markers that the filter accepts, sorted by seriousness and then by resource and position.

func (*Service) Remove

func (s *Service) Remove(owner string, resources ...string)

Remove removes the markers of an owner: those of the given resources, or all of them when no resource is given.

func (*Service) Set

func (s *Service) Set(owner, resource string, markers []Marker)

Set replaces the markers an owner has for a resource, a path (relative paths are the producer's to resolve). An empty list removes them. A marker with no message is dropped and the range of a marker is made valid. The owner and resource fields of the markers are filled in.

func (*Service) Stats

func (s *Service) Stats() Stats

Stats counts the markers of the service by severity.

func (*Service) Subscribe

func (s *Service) Subscribe(fn func(Change)) (unsubscribe func())

Subscribe calls fn after every change of the markers and returns the function that stops it. fn must not call Subscribe or the returned function from inside the call.

type Severities

type Severities int

Severities is a set of severities, as a bit mask of their values.

func (Severities) Has

func (s Severities) Has(sev Severity) bool

Has tells whether the set holds a severity.

type Severity

type Severity int

Severity is how serious a marker is. The values are VS Code's MarkerSeverity, so they order by seriousness.

Ported from VS Code: src/vs/platform/markers/common/markers.ts (MarkerSeverity)

const (
	// SeverityHint is a suggestion; the Problems panel does not show hints.
	SeverityHint Severity = 1
	// SeverityInfo is information.
	SeverityInfo Severity = 2
	// SeverityWarning is a warning.
	SeverityWarning Severity = 4
	// SeverityError is an error.
	SeverityError Severity = 8
)

The severities of a marker.

func ParseSeverity

func ParseSeverity(name string) (Severity, bool)

ParseSeverity reads the name of a severity: "error", "warning", "info" or "hint".

func (Severity) String

func (s Severity) String() string

String is the name of the severity as VS Code shows it: "Error", "Warning" or "Info"; a hint has none.

type Stats

type Stats struct {
	Errors, Warnings, Infos, Unknowns int
}

Stats counts markers by severity.

Ported from VS Code: src/vs/platform/markers/common/markers.ts (MarkerStatistics)

func (Stats) Total

func (s Stats) Total() int

Total is the number of errors, warnings and infos: what the badge of the Problems panel shows.

type View

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

View is the Problems panel without its widgets: the model of the markers, the tree that shows it, and the text of the filter box. The window makes one; NewBody and NewActions are the widgets that show it, and the commands of the panel call its methods. It is used on the UI thread only.

Ported from VS Code: src/vs/workbench/contrib/markers/browser/markersView.ts (MarkersView)

func NewView

func NewView(svc *Service, opts ViewOpts) *View

NewView makes the view of the markers of svc.

func (*View) ClearFilterText

func (v *View) ClearFilterText()

ClearFilterText empties the filter box.

func (*View) CollapseAll

func (v *View) CollapseAll()

CollapseAll folds every file of the tree.

func (*View) Dispose

func (v *View) Dispose()

Dispose stops following the markers and releases the widgets' controllers.

func (*View) Filter

func (v *View) Filter() *kit.InputBoxController

Filter is the controller of the filter box.

func (*View) FocusFilter

func (v *View) FocusFilter()

FocusFilter gives the focus to the filter box and selects its text.

func (*View) FocusTree

func (v *View) FocusTree()

FocusTree gives the focus to the tree.

func (*View) Model

func (v *View) Model() *Model

Model is the model of the markers.

func (*View) OnChange

func (v *View) OnChange(fn func()) (unsubscribe func())

OnChange calls fn after the markers, the filter or the tree changed, and returns the function that stops it.

func (*View) SetActiveFile

func (v *View) SetActiveFile(path string)

SetActiveFile tells the view which file the active editor shows.

func (*View) Tree

func (v *View) Tree() *kit.TreeModel

Tree is the model of the tree that shows the markers.

type ViewOpts

type ViewOpts struct {
	// Post hands a function to the UI thread (the binding's Post); changes of the markers are read
	// there. Without it they are read at once, which is for tests.
	Post func(func())
	// Root is the folder of the window; the folders of the files are shown relative to it.
	Root string
	// Keys is the scope of the context keys of the window: the view sets problemFocus,
	// problemsFilterFocus and problems.filter.errors, .warnings, .info and .activeFile there.
	Keys *contextkey.Scope
	// OnOpen is called when the user opens a marker: a click on it or Enter (pinned is false), a
	// double click (pinned is true). It shows the file with the cursor at the start of the range.
	OnOpen func(m Marker, pinned bool)
	// Logger gets the failures that have nobody to tell; slog.Default() when nil.
	Logger *slog.Logger
}

ViewOpts configure a View.

Jump to

Keyboard shortcuts

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