type CompletionItem … type completionOptions … // Snippet is a convenience returns the snippet if available, otherwise // the InsertText. // used for an item, depending on if the callee wants placeholders or not. func (i *CompletionItem) Snippet() string { … } const stdScore … const highScore … const lowScore … type matcher … type prefixMatcher … func (pm prefixMatcher) Score(candidateLabel string) float32 { … } type insensitivePrefixMatcher … func (ipm insensitivePrefixMatcher) Score(candidateLabel string) float32 { … } type completer … // tooNew reports whether obj is a standard library symbol that is too // new for the specified Go version. func (c *completer) tooNew(obj types.Object) bool { … } type funcInfo … type compLitInfo … type importInfo … type methodSetKey … type completionContext … type Selection … // Range returns the surrounding identifier's protocol.Range. func (p Selection) Range() (protocol.Range, error) { … } // PrefixRange returns the protocol.Range of the prefix of the selection. func (p Selection) PrefixRange() (protocol.Range, error) { … } func (p Selection) Prefix() string { … } func (p Selection) Suffix() string { … } func (c *completer) setSurrounding(ident *ast.Ident) { … } func (c *completer) setMatcherFromPrefix(prefix string) { … } func (c *completer) getSurrounding() *Selection { … } type candidate … func (c candidate) hasMod(mod typeModKind) bool { … } // Completion returns a list of possible candidates for completion, given a // a file and a position. // // The selection is computed based on the preceding identifier and can be used by // the client to score the quality of the completion. For instance, some clients // may tolerate imperfect matches as valid completion results, since users may make typos. func Completion(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, protoPos protocol.Position, protoContext protocol.CompletionContext) ([]CompletionItem, *Selection, error) { … } // collectCompletions adds possible completion candidates to either the deep // search queue or completion items directly for different completion contexts. func (c *completer) collectCompletions(ctx context.Context) error { … } // containingIdent returns the *ast.Ident containing pos, if any. It // synthesizes an *ast.Ident to allow completion in the face of // certain syntax errors. func (c *completer) containingIdent(src []byte) *ast.Ident { … } // scanToken scans pgh's contents for the token containing pos. func (c *completer) scanToken(contents []byte) (token.Pos, token.Token, string) { … } func (c *completer) sortItems() { … } // emptySwitchStmt reports whether pos is in an empty switch or select // statement. func (c *completer) emptySwitchStmt() bool { … } // populateImportCompletions yields completions for an import path around the cursor. // // Completions are suggested at the directory depth of the given import path so // that we don't overwhelm the user with a large list of possibilities. As an // example, a completion for the prefix "golang" results in "golang.org/". // Completions for "golang.org/" yield its subdirectories // (i.e. "golang.org/x/"). The user is meant to accept completion suggestions // until they reach a complete import path. func (c *completer) populateImportCompletions(searchImport *ast.ImportSpec) error { … } // populateCommentCompletions yields completions for comments preceding or in declarations. func (c *completer) populateCommentCompletions(comment *ast.CommentGroup) { … } // sets word boundaries surrounding a cursor for a comment func (c *completer) setSurroundingForComment(comments *ast.CommentGroup) { … } // isValidIdentifierChar returns true if a byte is a valid go identifier // character, i.e. unicode letter or digit or underscore. func isValidIdentifierChar(char byte) bool { … } // adds struct fields, interface methods, function declaration fields to completion func (c *completer) addFieldItems(fields *ast.FieldList) { … } func (c *completer) wantStructFieldCompletions() bool { … } func (c *completer) wantTypeName() bool { … } const maxUnimportedPackageNames … const unimportedMemberTarget … // selector finds completions for the specified selector expression. func (c *completer) selector(ctx context.Context, sel *ast.SelectorExpr) error { … } // unimportedScore returns a score for an unimported package that is generally // lower than other candidates. func unimportedScore(relevance float64) float64 { … } func (c *completer) packageMembers(pkg *types.Package, score float64, imp *importInfo, cb func(candidate)) { … } // ignoreUnimportedCompletion reports whether an unimported completion // resulting in the given import should be ignored. func ignoreUnimportedCompletion(fix *imports.ImportFix) bool { … } func (c *completer) methodsAndFields(typ types.Type, addressable bool, imp *importInfo, cb func(candidate)) { … } // isStarTestingDotF reports whether typ is *testing.F. func isStarTestingDotF(typ types.Type) bool { … } // lexical finds completions in the lexical environment. func (c *completer) lexical(ctx context.Context) error { … } // injectType manufactures candidates based on the given type. This is // intended for types not discoverable via lexical search, such as // composite and/or generic types. For example, if the type is "[]int", // this method makes sure you get candidates "[]int{}" and "[]int" // (the latter applies when completing a type name). func (c *completer) injectType(ctx context.Context, t types.Type) { … } func (c *completer) unimportedPackages(ctx context.Context, seen map[string]struct{ … } // alreadyImports reports whether f has an import with the specified path. func alreadyImports(f *ast.File, path golang.ImportPath) bool { … } func (c *completer) inConstDecl() bool { … } // structLiteralFieldName finds completions for struct field names inside a struct literal. func (c *completer) structLiteralFieldName(ctx context.Context) error { … } // enclosingCompositeLiteral returns information about the composite literal enclosing the // position. func enclosingCompositeLiteral(path []ast.Node, pos token.Pos, info *types.Info) *compLitInfo { … } // enclosingFunction returns the signature and body of the function // enclosing the given position. func enclosingFunction(path []ast.Node, info *types.Info) *funcInfo { … } func (c *completer) expectedCompositeLiteralType() types.Type { … } type typeMod … type typeModKind … const dereference … const reference … const chanRead … const sliceType … const arrayType … const invoke … const takeSlice … const takeDotDotDot … const index … type objKind … const kindAny … const kindArray … const kindSlice … const kindChan … const kindMap … const kindStruct … const kindString … const kindInt … const kindBool … const kindBytes … const kindPtr … const kindInterface … const kindFloat … const kindComplex … const kindError … const kindStringer … const kindFunc … const kindRange0Func … const kindRange1Func … const kindRange2Func … type penalizedObj … type candidateInference … type typeNameInference … // expectedCandidate returns information about the expected candidate // for an expression at the query position. func expectedCandidate(ctx context.Context, c *completer) (inf candidateInference) { … } func (c *completer) expectedCallParamType(inf candidateInference, node *ast.CallExpr, sig *types.Signature) candidateInference { … } func expectedConstraint(t types.Type, idx int) types.Type { … } // objChain decomposes e into a chain of objects if possible. For // example, "foo.bar().baz" will yield []types.Object{foo, bar, baz}. // If any part can't be turned into an object, return nil. func objChain(info *types.Info, e ast.Expr) []types.Object { … } // applyTypeModifiers applies the list of type modifiers to a type. // It returns nil if the modifiers could not be applied. func (ci candidateInference) applyTypeModifiers(typ types.Type, addressable bool) types.Type { … } // applyTypeNameModifiers applies the list of type modifiers to a type name. func (ci candidateInference) applyTypeNameModifiers(typ types.Type) types.Type { … } // matchesVariadic returns true if we are completing a variadic // parameter and candType is a compatible slice type. func (ci candidateInference) matchesVariadic(candType types.Type) bool { … } // findSwitchStmt returns an *ast.CaseClause's corresponding *ast.SwitchStmt or // *ast.TypeSwitchStmt. path should start from the case clause's first ancestor. func findSwitchStmt(path []ast.Node, pos token.Pos, c *ast.CaseClause) ast.Stmt { … } // breaksExpectedTypeInference reports if an expression node's type is unrelated // to its child expression node types. For example, "Foo{Bar: x.Baz(<>)}" should // expect a function argument, not a composite literal value. func breaksExpectedTypeInference(n ast.Node, pos token.Pos) bool { … } // expectTypeName returns information about the expected type name at position. func expectTypeName(c *completer) typeNameInference { … } func (c *completer) fakeObj(T types.Type) *types.Var { … } // derivableTypes iterates types you can derive from t. For example, // from "foo" we might derive "&foo", and "foo()". func derivableTypes(t types.Type, addressable bool, f func(t types.Type, addressable bool, mod typeModKind) bool) bool { … } // anyCandType reports whether f returns true for any candidate type // derivable from c. It searches up to three levels of type // modification. For example, given "foo" we could discover "***foo" // or "*foo()". func (c *candidate) anyCandType(f func(t types.Type, addressable bool) bool) bool { … } // matchingCandidate reports whether cand matches our type inferences. // It mutates cand's score in certain cases. func (c *completer) matchingCandidate(cand *candidate) bool { … } // candTypeMatches reports whether cand makes a good completion // candidate given the candidate inference. cand's score may be // mutated to downrank the candidate in certain situations. func (ci *candidateInference) candTypeMatches(cand *candidate) bool { … } // considerTypeConversion returns true if we should offer a completion // automatically converting "from" to "to". func considerTypeConversion(from, to types.Type, path []types.Object) bool { … } // typeMatches reports whether an object of candType makes a good // completion candidate given the expected type expType. func (ci *candidateInference) typeMatches(expType, candType types.Type) bool { … } // kindMatches reports whether candType's kind matches our expected // kind (e.g. slice, map, etc.). func (ci *candidateInference) kindMatches(candType types.Type) bool { … } // assigneesMatch reports whether an invocation of sig matches the // number and type of any assignees. func (ci *candidateInference) assigneesMatch(cand *candidate, sig *types.Signature) bool { … } func (c *completer) matchingTypeName(cand *candidate) bool { … } var errorIntf … var stringerIntf … var byteType … var boolType … // candKind returns the objKind of candType, if any. func candKind(candType types.Type) objKind { … } // If sig looks like a range func, return param count, else return -1. func rangeFuncParamCount(sig *types.Signature) int { … } // innermostScope returns the innermost scope for c.pos. func (c *completer) innermostScope() *types.Scope { … } // isSlice reports whether the object's underlying type is a slice. func isSlice(obj types.Object) bool { … } // forEachPackageMember calls f(tok, id, fn) for each package-level // TYPE/VAR/CONST/FUNC declaration in the Go source file, based on a // quick partial parse. fn is non-nil only for function declarations. // The AST position information is garbage. func forEachPackageMember(content []byte, f func(tok token.Token, id *ast.Ident, fn *ast.FuncDecl)) { … } func is[T any](x any) bool { … }