// addStatementCandidates adds full statement completion candidates // appropriate for the current context. func (c *completer) addStatementCandidates() { … } // addAssignAppend offers a completion candidate of the form: // // someSlice = append(someSlice, ) // // It will offer the "append" completion in either of two situations: // // 1. Position is in RHS of assign, prefix matches "append", and // corresponding LHS object is a slice. For example, // "foo = ap<>" completes to "foo = append(foo, )". // // 2. Prefix is an ident or selector in an *ast.ExprStmt (i.e. // beginning of statement), and our best matching candidate is a // slice. For example: "foo.ba" completes to "foo.bar = append(foo.bar, )". func (c *completer) addAssignAppend() { … } // topCandidate returns the strictly highest scoring candidate // collected so far. If the top two candidates have the same score, // nil is returned. func (c *completer) topCandidate() *CompletionItem { … } // addErrCheck offers a completion candidate of the form: // // if err != nil { // return nil, err // } // // In the case of test functions, it offers a completion candidate of the form: // // if err != nil { // t.Fatal(err) // } // // The position must be in a function that returns an error, and the // statement preceding the position must be an assignment where the // final LHS object is an error. addErrCheck will synthesize // zero values as necessary to make the return statement valid. func (c *completer) addErrCheck() { … } // getTestVar checks the function signature's input parameters and returns // the name of the first parameter that implements "testing.TB". For example, // func someFunc(t *testing.T) returns the string "t", func someFunc(b *testing.B) // returns "b" etc. An empty string indicates that the function signature // does not take a testing.TB parameter or does so but is ignored such // as func someFunc(*testing.T). func getTestVar(enclosingFunc *funcInfo, pkg *cache.Package) string { … } // addReturnZeroValues offers a snippet candidate on the form: // // return 0, "", nil // // Requires a partially or fully written return keyword at position. // Requires current position to be in a function with more than // zero return parameters. func (c *completer) addReturnZeroValues() { … }