зеркало из https://github.com/golang/tools.git
all: fix some comments
Change-Id: I44a562ec6d71dcf638333a855083f46201ef9a5e Reviewed-on: https://go-review.googlesource.com/c/tools/+/464236 TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Родитель
072fca58f7
Коммит
bd5dfbb418
|
@ -389,7 +389,7 @@ func rewritePackage(client *listPackage, canonical map[string]canonicalName) boo
|
|||
return ok
|
||||
}
|
||||
|
||||
// rewrite reads, modifies, and writes filename, replacing all imports
|
||||
// rewriteFile reads, modifies, and writes filename, replacing all imports
|
||||
// of packages P in canonical by canonical[P].
|
||||
// It records in used which canonical packages were imported.
|
||||
// used[P]=="" indicates that P was imported but its canonical path is unknown.
|
||||
|
|
|
@ -55,12 +55,12 @@ type queryPos struct {
|
|||
info *loader.PackageInfo // type info for the queried package (nil for fastQueryPos)
|
||||
}
|
||||
|
||||
// TypeString prints type T relative to the query position.
|
||||
// typeString prints type T relative to the query position.
|
||||
func (qpos *queryPos) typeString(T types.Type) string {
|
||||
return types.TypeString(T, types.RelativeTo(qpos.info.Pkg))
|
||||
}
|
||||
|
||||
// ObjectString prints object obj relative to the query position.
|
||||
// objectString prints object obj relative to the query position.
|
||||
func (qpos *queryPos) objectString(obj types.Object) string {
|
||||
return types.ObjectString(obj, types.RelativeTo(qpos.info.Pkg))
|
||||
}
|
||||
|
|
|
@ -703,7 +703,7 @@ type referrersPackageResult struct {
|
|||
refs []*ast.Ident // set of all other references to it
|
||||
}
|
||||
|
||||
// forEachRef calls f(id, text) for id in r.refs, in order.
|
||||
// foreachRef calls f(id, text) for id in r.refs, in order.
|
||||
// Text is the text of the line on which id appears.
|
||||
func (r *referrersPackageResult) foreachRef(f func(id *ast.Ident, text string)) {
|
||||
// Show referring lines, like grep.
|
||||
|
|
|
@ -107,7 +107,7 @@ func docmd(cmd []string, dir string) int {
|
|||
return st
|
||||
}
|
||||
|
||||
// docodmout forks and execs command 'cmd' in dir 'dir', redirecting
|
||||
// docmdout forks and execs command 'cmd' in dir 'dir', redirecting
|
||||
// stderr and stdout from the execution to file 'outfile'.
|
||||
func docmdout(cmd []string, dir string, outfile string) int {
|
||||
of, err := os.OpenFile(outfile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
|
|
|
@ -929,7 +929,7 @@ func factType(fact analysis.Fact) reflect.Type {
|
|||
return t
|
||||
}
|
||||
|
||||
// allObjectFacts implements Pass.AllObjectFacts.
|
||||
// allPackageFacts implements Pass.AllPackageFacts.
|
||||
func (act *action) allPackageFacts() []analysis.PackageFact {
|
||||
facts := make([]analysis.PackageFact, 0, len(act.packageFacts))
|
||||
for k := range act.packageFacts {
|
||||
|
|
|
@ -1167,7 +1167,7 @@ func (p *parser) maybeCreatePackage() {
|
|||
}
|
||||
}
|
||||
|
||||
// parseInitDateDirective parses an InitDataDirective:
|
||||
// parseInitDataDirective parses an InitDataDirective:
|
||||
//
|
||||
// InitDataDirective = ( "v1" | "v2" | "v3" ) ";" |
|
||||
// "priority" int ";" |
|
||||
|
|
|
@ -97,7 +97,7 @@ func (c *Config) AddQuery(v ssa.Value) {
|
|||
c.Queries[v] = struct{}{}
|
||||
}
|
||||
|
||||
// AddQuery adds v to Config.IndirectQueries.
|
||||
// AddIndirectQuery adds v to Config.IndirectQueries.
|
||||
// Precondition: CanPoint(v.Type().Underlying().(*types.Pointer).Elem()).
|
||||
func (c *Config) AddIndirectQuery(v ssa.Value) {
|
||||
if c.IndirectQueries == nil {
|
||||
|
|
|
@ -206,7 +206,7 @@ func (a *analysis) makeRtype(T types.Type) nodeid {
|
|||
return id
|
||||
}
|
||||
|
||||
// rtypeValue returns the type of the *reflect.rtype-tagged object obj.
|
||||
// rtypeTaggedValue returns the type of the *reflect.rtype-tagged object obj.
|
||||
func (a *analysis) rtypeTaggedValue(obj nodeid) types.Type {
|
||||
tDyn, t, _ := a.taggedValue(obj)
|
||||
if tDyn != a.reflectRtypePtr {
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"golang.org/x/tools/internal/typeparams"
|
||||
)
|
||||
|
||||
// Instances returns all of the instances generated by runtime types for this function in an unspecified order.
|
||||
// _Instances returns all of the instances generated by runtime types for this function in an unspecified order.
|
||||
//
|
||||
// Thread-safe.
|
||||
//
|
||||
|
|
|
@ -83,7 +83,7 @@ func isRuneSlice(t types.Type) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// isBasicConvType returns true when a type set can be
|
||||
// isBasicConvTypes returns true when a type set can be
|
||||
// one side of a Convert operation. This is when:
|
||||
// - All are basic, []byte, or []rune.
|
||||
// - At least 1 is basic.
|
||||
|
|
|
@ -1422,7 +1422,7 @@ func (x *Index) LookupRegexp(r *regexp.Regexp, n int) (found int, result []FileL
|
|||
return
|
||||
}
|
||||
|
||||
// InvalidateIndex should be called whenever any of the file systems
|
||||
// invalidateIndex should be called whenever any of the file systems
|
||||
// under godoc's observation change so that the indexer is kicked on.
|
||||
func (c *Corpus) invalidateIndex() {
|
||||
c.fsModified.Set(nil)
|
||||
|
|
|
@ -60,7 +60,7 @@ func extractMetadata(b []byte) (meta Metadata, tail []byte, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// UpdateMetadata scans $GOROOT/doc for HTML and Markdown files, reads their metadata,
|
||||
// updateMetadata scans $GOROOT/doc for HTML and Markdown files, reads their metadata,
|
||||
// and updates the DocMetadata map.
|
||||
func (c *Corpus) updateMetadata() {
|
||||
metadata := make(map[string]*Metadata)
|
||||
|
@ -147,7 +147,7 @@ func (c *Corpus) refreshMetadata() {
|
|||
}
|
||||
}
|
||||
|
||||
// RefreshMetadataLoop runs forever, updating DocMetadata when the underlying
|
||||
// refreshMetadataLoop runs forever, updating DocMetadata when the underlying
|
||||
// file system changes. It should be launched in a goroutine.
|
||||
func (c *Corpus) refreshMetadataLoop() {
|
||||
for {
|
||||
|
|
|
@ -274,7 +274,7 @@ func (m *moduleErrorMap) Error() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// workspaceLayoutErrors returns an error decribing a misconfiguration of the
|
||||
// workspaceLayoutError returns an error describing a misconfiguration of the
|
||||
// workspace, along with related diagnostic.
|
||||
//
|
||||
// The unusual argument ordering of results is intentional: if the resulting
|
||||
|
|
|
@ -285,7 +285,7 @@ func modWhyImpl(ctx context.Context, snapshot *snapshot, fh source.FileHandle) (
|
|||
return why, nil
|
||||
}
|
||||
|
||||
// extractGoCommandError tries to parse errors that come from the go command
|
||||
// extractGoCommandErrors tries to parse errors that come from the go command
|
||||
// and shape them into go.mod diagnostics.
|
||||
// TODO: rename this to 'load errors'
|
||||
func (s *snapshot) extractGoCommandErrors(ctx context.Context, goCmdError error) []*source.Diagnostic {
|
||||
|
|
|
@ -229,7 +229,7 @@ func (app *Application) Run(ctx context.Context, args ...string) error {
|
|||
return tool.CommandLineErrorf("Unknown command %v", command)
|
||||
}
|
||||
|
||||
// commands returns the set of commands supported by the gopls tool on the
|
||||
// Commands returns the set of commands supported by the gopls tool on the
|
||||
// command line.
|
||||
// The command is specified by the first non flag argument.
|
||||
func (app *Application) Commands() []tool.Application {
|
||||
|
|
|
@ -192,14 +192,14 @@ type Server struct {
|
|||
ClientID string
|
||||
}
|
||||
|
||||
// AddClient adds a client to the set being served.
|
||||
// addClient adds a client to the set being served.
|
||||
func (st *State) addClient(session *cache.Session) {
|
||||
st.mu.Lock()
|
||||
defer st.mu.Unlock()
|
||||
st.clients = append(st.clients, &Client{Session: session})
|
||||
}
|
||||
|
||||
// DropClient removes a client from the set being served.
|
||||
// dropClient removes a client from the set being served.
|
||||
func (st *State) dropClient(session *cache.Session) {
|
||||
st.mu.Lock()
|
||||
defer st.mu.Unlock()
|
||||
|
@ -213,7 +213,7 @@ func (st *State) dropClient(session *cache.Session) {
|
|||
}
|
||||
}
|
||||
|
||||
// AddServer adds a server to the set being queried. In practice, there should
|
||||
// updateServer updates a server to the set being queried. In practice, there should
|
||||
// be at most one remote server.
|
||||
func (st *State) updateServer(server *Server) {
|
||||
st.mu.Lock()
|
||||
|
@ -232,7 +232,7 @@ func (st *State) updateServer(server *Server) {
|
|||
st.servers = append(st.servers, server)
|
||||
}
|
||||
|
||||
// DropServer drops a server from the set being queried.
|
||||
// dropServer drops a server from the set being queried.
|
||||
func (st *State) dropServer(id string) {
|
||||
st.mu.Lock()
|
||||
defer st.mu.Unlock()
|
||||
|
|
|
@ -793,7 +793,7 @@ func (e *Editor) GoToTypeDefinition(ctx context.Context, loc protocol.Location)
|
|||
return e.extractFirstLocation(ctx, resp)
|
||||
}
|
||||
|
||||
// extractFirstPathAndPos returns the first location.
|
||||
// extractFirstLocation returns the first location.
|
||||
// It opens the file if needed.
|
||||
func (e *Editor) extractFirstLocation(ctx context.Context, locs []protocol.Location) (protocol.Location, error) {
|
||||
if len(locs) == 0 {
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/tools/gopls/internal/lsp/protocol"
|
||||
"golang.org/x/tools/internal/event"
|
||||
"golang.org/x/tools/internal/event/tag"
|
||||
"golang.org/x/tools/gopls/internal/lsp/protocol"
|
||||
"golang.org/x/tools/internal/xcontext"
|
||||
)
|
||||
|
||||
|
@ -167,7 +167,7 @@ func (wd *WorkDone) doCancel() {
|
|||
}
|
||||
}
|
||||
|
||||
// report reports an update on WorkDone report back to the client.
|
||||
// Report reports an update on WorkDone report back to the client.
|
||||
func (wd *WorkDone) Report(ctx context.Context, message string, percentage float64) {
|
||||
ctx = xcontext.Detach(ctx) // progress messages should not be cancelled
|
||||
if wd == nil {
|
||||
|
@ -202,7 +202,7 @@ func (wd *WorkDone) Report(ctx context.Context, message string, percentage float
|
|||
}
|
||||
}
|
||||
|
||||
// end reports a workdone completion back to the client.
|
||||
// End reports a workdone completion back to the client.
|
||||
func (wd *WorkDone) End(ctx context.Context, message string) {
|
||||
ctx = xcontext.Detach(ctx) // progress messages should not be cancelled
|
||||
if wd == nil {
|
||||
|
|
|
@ -419,7 +419,7 @@ func (m *Mapper) PosPosition(tf *token.File, pos token.Pos) (Position, error) {
|
|||
return m.OffsetPosition(offset)
|
||||
}
|
||||
|
||||
// PosPosition converts a token range to a protocol (UTF-16) location.
|
||||
// PosLocation converts a token range to a protocol (UTF-16) location.
|
||||
func (m *Mapper) PosLocation(tf *token.File, start, end token.Pos) (Location, error) {
|
||||
startOffset, endOffset, err := safetoken.Offsets(tf, start, end)
|
||||
if err != nil {
|
||||
|
@ -432,7 +432,7 @@ func (m *Mapper) PosLocation(tf *token.File, start, end token.Pos) (Location, er
|
|||
return m.RangeLocation(rng), nil
|
||||
}
|
||||
|
||||
// PosPosition converts a token range to a protocol (UTF-16) range.
|
||||
// PosRange converts a token range to a protocol (UTF-16) range.
|
||||
func (m *Mapper) PosRange(tf *token.File, start, end token.Pos) (Range, error) {
|
||||
startOffset, endOffset, err := safetoken.Offsets(tf, start, end)
|
||||
if err != nil {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"golang.org/x/tools/gopls/internal/lsp/snippet"
|
||||
)
|
||||
|
||||
// structFieldSnippets calculates the snippet for struct literal field names.
|
||||
// structFieldSnippet calculates the snippet for struct literal field names.
|
||||
func (c *completer) structFieldSnippet(cand candidate, detail string, snip *snippet.Builder) {
|
||||
if !c.wantStructFieldCompletions() {
|
||||
return
|
||||
|
@ -49,7 +49,7 @@ func (c *completer) structFieldSnippet(cand candidate, detail string, snip *snip
|
|||
}
|
||||
}
|
||||
|
||||
// functionCallSnippets calculates the snippet for function calls.
|
||||
// functionCallSnippet calculates the snippet for function calls.
|
||||
func (c *completer) functionCallSnippet(name string, tparams, params []string, snip *snippet.Builder) {
|
||||
// If there is no suffix then we need to reuse existing call parens
|
||||
// "()" if present. If there is an identifier suffix then we always
|
||||
|
|
|
@ -441,7 +441,7 @@ func (r *renamer) checkStructField(from *types.Var) {
|
|||
r.checkSelections(from)
|
||||
}
|
||||
|
||||
// checkSelection checks that all uses and selections that resolve to
|
||||
// checkSelections checks that all uses and selections that resolve to
|
||||
// the specified object would continue to do so after the renaming.
|
||||
func (r *renamer) checkSelections(from types.Object) {
|
||||
for typ, pkg := range r.packages {
|
||||
|
|
|
@ -419,7 +419,7 @@ func (pgf *ParsedGoFile) NodeLocation(node ast.Node) (protocol.Location, error)
|
|||
return pgf.Mapper.PosLocation(pgf.Tok, node.Pos(), node.End())
|
||||
}
|
||||
|
||||
// RangeToSpanRange parses a protocol Range back into the go/token domain.
|
||||
// RangeToTokenRange parses a protocol Range back into the go/token domain.
|
||||
func (pgf *ParsedGoFile) RangeToTokenRange(r protocol.Range) (safetoken.Range, error) {
|
||||
start, end, err := pgf.Mapper.RangeOffsets(r)
|
||||
if err != nil {
|
||||
|
|
|
@ -369,7 +369,7 @@ func (p *iexporter) stringOff(s string) uint64 {
|
|||
return off
|
||||
}
|
||||
|
||||
// fileIndex returns the index of the token.File and the byte offset of pos within it.
|
||||
// fileIndexAndOffset returns the index of the token.File and the byte offset of pos within it.
|
||||
func (p *iexporter) fileIndexAndOffset(file *token.File, pos token.Pos) (uint64, uint64) {
|
||||
index, ok := p.fileInfo[file]
|
||||
if !ok {
|
||||
|
|
|
@ -373,7 +373,7 @@ func (r *Decoder) Int64() int64 {
|
|||
return r.rawVarint()
|
||||
}
|
||||
|
||||
// Int64 decodes and returns a uint64 value from the element bitstream.
|
||||
// Uint64 decodes and returns a uint64 value from the element bitstream.
|
||||
func (r *Decoder) Uint64() uint64 {
|
||||
r.Sync(SyncUint64)
|
||||
return r.rawUvarint()
|
||||
|
|
|
@ -293,7 +293,7 @@ func (w *Encoder) Len(x int) { assert(x >= 0); w.Uint64(uint64(x)) }
|
|||
// Int encodes and writes an int value into the element bitstream.
|
||||
func (w *Encoder) Int(x int) { w.Int64(int64(x)) }
|
||||
|
||||
// Len encodes and writes a uint value into the element bitstream.
|
||||
// Uint encodes and writes a uint value into the element bitstream.
|
||||
func (w *Encoder) Uint(x uint) { w.Uint64(uint64(x)) }
|
||||
|
||||
// Reloc encodes and writes a relocation for the given (section,
|
||||
|
|
|
@ -478,7 +478,7 @@ func (r *renamer) checkStructField(from *types.Var) {
|
|||
r.checkSelections(from)
|
||||
}
|
||||
|
||||
// checkSelection checks that all uses and selections that resolve to
|
||||
// checkSelections checks that all uses and selections that resolve to
|
||||
// the specified object would continue to do so after the renaming.
|
||||
func (r *renamer) checkSelections(from types.Object) {
|
||||
for pkg, info := range r.packages {
|
||||
|
|
Загрузка…
Ссылка в новой задаче