cmd

package
v0.0.0-...-ec1a81b Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: BSD-3-Clause Imports: 44 Imported by: 0

Documentation

Overview

Package cmd handles the gopls command line. It contains a handler for each of the modes, along with all the flag handling and the command line output format.

Index

Constants

View Source
const (
	SemanticLeft  = "/*⇐"
	SemanticRight = "/*⇒"
)

prefixes for semantic token comments

Variables

View Source
var ErrInvalidRenamePosition = errors.New("request is not valid at the given position")

ErrInvalidRenamePosition is returned when prepareRename is run at a position that is not a candidate for renaming.

Functions

This section is empty.

Types

type Application

type Application struct {

	// Embed the basic profiling flags supported by the tool package
	tool.Profile

	// We include the server configuration directly for now, so the flags work
	// even without the verb.
	// TODO: Remove this when we stop allowing the serve verb by default.
	Serve Serve

	// Support for remote LSP server.
	Remote string `` /* 344-byte string literal not displayed */

	// Verbose enables verbose logging.
	Verbose bool `flag:"v,verbose" help:"verbose output"`

	// VeryVerbose enables a higher level of verbosity in logging output.
	VeryVerbose bool `flag:"vv,veryverbose" help:"very verbose output"`

	// Control ocagent export of telemetry
	OCAgent string `flag:"ocagent" help:"the address of the ocagent (e.g. http://localhost:55678), or off"`

	// PrepareOptions is called to update the options when a new view is built.
	// It is primarily to allow the behavior of gopls to be modified by hooks.
	PrepareOptions func(*settings.Options)
	// contains filtered or unexported fields
}

Application is the main application as passed to tool.Main It handles the main command line parsing and dispatch to the sub commands.

func New

func New() *Application

New returns a new Application ready to run.

func (*Application) Commands

func (app *Application) Commands() []tool.Application

Commands returns the set of commands supported by the gopls tool on the command line. The command is specified by the first non flag argument.

func (*Application) DetailedHelp

func (app *Application) DetailedHelp(f *flag.FlagSet)

DetailedHelp implements tool.Application returning the main binary help. This includes the short help for all the sub commands.

func (*Application) Name

func (app *Application) Name() string

Name implements tool.Application returning the binary name.

func (*Application) Run

func (app *Application) Run(ctx context.Context, args ...string) error

Run takes the args after top level flag processing, and invokes the correct sub command as specified by the first argument. If no arguments are passed it will invoke the server sub command, as a temporary measure for compatibility.

func (*Application) ShortHelp

func (app *Application) ShortHelp() string

ShortHelp implements tool.Application returning the main binary help.

func (*Application) Usage

func (app *Application) Usage() string

Usage implements tool.Application returning empty extra argument usage.

type Definition

type Definition struct {
	Span        span   `json:"span"`        // span of the definition
	Description string `json:"description"` // description of the denoted object
}

A Definition is the result of a 'definition' query.

type EditFlags

type EditFlags struct {
	Write    bool `flag:"w,write" help:"write edited content to source files"`
	Preserve bool `flag:"preserve" help:"with -write, make copies of original files"`
	Diff     bool `flag:"d,diff" help:"display diffs instead of edited file content"`
	List     bool `flag:"l,list" help:"display names of edited files"`
}

EditFlags defines flags common to {fix,format,imports,rename} that control how edits are applied to the client's files.

The type is exported for flag reflection.

The -write, -diff, and -list flags are orthogonal but any of them suppresses the default behavior, which is to print the edited file contents.

type GoplsStats

type GoplsStats struct {
	GOOS, GOARCH                 string `anon:"ok"`
	GOPLSCACHE                   string
	GoVersion                    string `anon:"ok"`
	GoplsVersion                 string `anon:"ok"`
	GOPACKAGESDRIVER             string
	InitialWorkspaceLoadDuration string `anon:"ok"` // in time.Duration string form
	CacheDir                     string
	BugReports                   []bugpkg.Bug
	MemStats                     command.MemStatsResult       `anon:"ok"`
	WorkspaceStats               command.WorkspaceStatsResult `anon:"ok"`
	DirStats                     dirStats                     `anon:"ok"`
}

GoplsStats holds information extracted from a gopls session in the current workspace.

Fields that should be printed with the -anon flag should be explicitly marked as `anon:"ok"`. Only fields that cannot refer to user files or code should be marked as such.

type Serve

type Serve struct {
	Logfile     string        `flag:"logfile" help:"filename to log to. if value is \"auto\", then logging to a default output file is enabled"`
	Mode        string        `flag:"mode" help:"no effect"`
	Port        int           `flag:"port" help:"port on which to run gopls for debugging purposes"`
	Address     string        `` /* 181-byte string literal not displayed */
	IdleTimeout time.Duration `` /* 127-byte string literal not displayed */
	Trace       bool          `flag:"rpc.trace" help:"print the full rpc trace in lsp inspector format"`
	Debug       string        `flag:"debug" help:"serve debug information on the supplied address"`

	RemoteListenTimeout time.Duration `flag:"remote.listen.timeout" help:"when used with -remote=auto, the -listen.timeout value used to start the daemon"`
	RemoteDebug         string        `flag:"remote.debug" help:"when used with -remote=auto, the -debug value used to start the daemon"`
	RemoteLogfile       string        `flag:"remote.logfile" help:"when used with -remote=auto, the -logfile value used to start the daemon"`
	// contains filtered or unexported fields
}

Serve is a struct that exposes the configurable parts of the LSP server as flags, in the right form for tool.Main to consume.

func (*Serve) DetailedHelp

func (s *Serve) DetailedHelp(f *flag.FlagSet)

func (*Serve) Name

func (s *Serve) Name() string

func (*Serve) Parent

func (s *Serve) Parent() string

func (*Serve) Run

func (s *Serve) Run(ctx context.Context, args ...string) error

Run configures a server based on the flags, and then runs it. It blocks until the server shuts down.

func (*Serve) ShortHelp

func (s *Serve) ShortHelp() string

func (*Serve) Usage

func (s *Serve) Usage() string

Jump to

Keyboard shortcuts

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