complete

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package Complete provides functions for text completion

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompleteText

func CompleteText(s string) (result []string, err error)

CompleteText is the function for completing text files

func ExtendSeed

func ExtendSeed(matches Completions, seed string) string

ExtendSeed tries to extend the current seed checking possible completions for a longer common seed e.g. if the current seed is "ab" and the completions are "abcde" and "abcdf" then Extend returns "cd" but if the possible completions are "abcde" and "abz" then Extend returns ""

func FindCandidateString

func FindCandidateString(str string) *candidate

func HasUpperCase

func HasUpperCase(str string) bool

HasUpperCase returns true if string has an upper-case letter

func Init

func Init()

func MatchSeedString

func MatchSeedString(completions []string, seed string) (matches []string)

MatchSeed returns a list of matches given a list of string possibilities and a seed. The seed is basically a prefix.

func SeedGolang

func SeedGolang(text string) string

SeedGolang returns the seed that makes sense for the go language e.g. strip [] or . prefix before matching text

func SeedWhiteSpace

func SeedWhiteSpace(text string) string

SeedWhiteSpace returns the text after the last whitespace

Types

type Completion

type Completion struct {
	Text  string            `desc:"completion text -- what will actually be inserted if selected"`
	Label string            `desc:"label to show the user -- only used for menu display if non-empty -- otherwise Text is used"`
	Icon  string            `desc:"icon name"`
	Desc  string            `desc:"possible extra information, e.g. type, arguments, etc. - not currently used"	`
	Extra map[string]string `desc:"lang specific or other, e.g. class or type"`
}

Completion holds one potential completion

func CompleteGo

func CompleteGo(bytes []byte, pos token.Position) []Completion

CompleteGo is the function for completing Go code

func FirstPass

func FirstPass(bytes []byte, pos token.Position) ([]Completion, bool)

FirstPass handles some cases of completion that gocode either doesn't handle or doesn't do well - this will be expanded to more cases

func MatchSeedCompletion

func MatchSeedCompletion(completions []Completion, seed string) (matches []Completion)

MatchSeedCompletion returns a list of matching completion structs given a list of possibilities and a seed. The seed is basically a prefix.

func SecondPass

func SecondPass(bytes []byte, pos token.Position) []Completion

SecondPass uses the gocode server to find possible completions at the specified position in the src (i.e. the byte slice passed in) bytes should be the current in memory version of the file

type Completions

type Completions []Completion

Completions is a full list (slice) of completion options

type EditData

type EditData struct {
	NewText       string `desc:"completion text after special edits"`
	ForwardDelete int    `desc:"number of runes, past the cursor, to delete, if any"`
	CursorAdjust  int    `desc:"cursor adjustment if cursor should be placed in a location other than at end of newText"`
}

EditData is returned from completion edit function to incorporate the selected completion

func EditGoCode

func EditGoCode(text string, cp int, completion Completion, seed string) (ed EditData)

EditGoCode is a chance to modify the completion selection before it is inserted

func EditText

func EditText(text string, cp int, completion string, seed string) (ed EditData)

EditText is a chance to modify the completion selection before it is inserted

func EditWord

func EditWord(text string, cp int, completion string, seed string) (ed EditData)

EditWord replaces the completion seed and any text up to the next whitespace with completion

type EditFunc

type EditFunc func(data interface{}, text string, cursorPos int, completion Completion, seed string) EditData

EditFunc is passed the current text and the selected completion for text editing. Allows for other editing, e.g. adding "()" or adding "/", etc.

type MatchData

type MatchData struct {
	Matches Completions `desc:"the matches based on seed"`
	Seed    string      `desc:"seed is the prefix we use to find possible completions"`
}

MatchData is used for passing completions around -- contains seed in addition to completions

type MatchFunc

type MatchFunc func(data interface{}, text string, pos token.Position) MatchData

MatchFunc is the function called to get the list of possible completions and also determines the correct seed based on the text passed as a parameter of CompletionFunc

Jump to

Keyboard shortcuts

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