Documentation
¶
Overview ¶
Package Complete provides functions for text completion
Index ¶
- func CompleteText(s string) (result []string, err error)
- func ExtendSeed(matches Completions, seed string) string
- func FindCandidateString(str string) *candidate
- func HasUpperCase(str string) bool
- func Init()
- func MatchSeedString(completions []string, seed string) (matches []string)
- func SeedGolang(text string) string
- func SeedWhiteSpace(text string) string
- type Completion
- type Completions
- type EditData
- type EditFunc
- type MatchData
- type MatchFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteText ¶
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 ¶
HasUpperCase returns true if string has an upper-case letter
func MatchSeedString ¶
MatchSeed returns a list of matches given a list of string possibilities and a seed. The seed is basically a prefix.
func SeedGolang ¶
SeedGolang returns the seed that makes sense for the go language e.g. strip [] or . prefix before matching text
func SeedWhiteSpace ¶
SeedWhiteSpace returns the text after the last whitespace
Types ¶
type Completion ¶
type Completion struct {
Text string `desc:"completion text"`
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"`
}
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
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"`
}
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
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"`
}