code

package
v0.0.0-...-310ba95 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package code provides code completion features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Class   ChoiceClass // is it a type, var, func, or package?
	Display string      // what user is shown
	Insert  string      // what gets inserted into code
}

Choice is an option shown to the user to make a code completion selection

func ParseGocode

func ParseGocode(output []byte) ([]Choice, error)

ParseGocode will parse the output of gocode for code completion choices

type ChoiceClass

type ChoiceClass int

ChoiceClass is an enumeration of all possible classes of identifiers

const (
	// ClassType indicates a type identifier
	ClassType ChoiceClass = iota + 1
	// ClassVar indicates a var identifier
	ClassVar
	// ClassFunc indicates a function identifier
	ClassFunc
	// ClassPackage indicates a package identifier
	ClassPackage
	// ClassConst indicates a constant identifier
	ClassConst
	// ClassPanic may indicate an error in the language server
	ClassPanic
)

type Completer

type Completer struct {
	Predictor Predictor
}

Completer provides code completion

func (Completer) Complete

func (c Completer) Complete(ctx context.Context, env gomate.Env, src io.Reader, dst io.Writer) error

Complete will call on the underlying predictor to provide a list of choices to the user. Once a selection has been made by the user, it will be inserted at the cursor by sending it to stdout.

type GoCode

type GoCode struct {
}

GoCode is the code predictor wrapper for https://github.com/stamblerre/gocode

func (GoCode) Predict

func (gc GoCode) Predict(ctx context.Context, src io.Reader, env gomate.Env) ([]Choice, error)

Predict will return a list of choices for the position at the file

type Predictor

type Predictor interface {
	// Predict will provide a list of choices for the user to choose
	Predict(ctx context.Context, src io.Reader, env gomate.Env) ([]Choice, error)
}

Predictor is a type that can predict potential choices that make sense for the current cursor location

Jump to

Keyboard shortcuts

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