Change-Id: Idad45a4c8352116b68eca172329214dbfb89b294
Reviewed-on: https://go-review.googlesource.com/c/tools/+/509696
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
This commit is contained in:
cui fliter 2023-07-14 14:55:17 +08:00 коммит произвёл Gopher Robot
Родитель 2842ed8496
Коммит 9161e3af9e
21 изменённых файлов: 24 добавлений и 24 удалений

Просмотреть файл

@ -226,7 +226,7 @@ func main() {
} else { } else {
// Try to download dependencies that are not in the module cache in order to // Try to download dependencies that are not in the module cache in order to
// to show their documentation. // show their documentation.
// This may fail if module downloading is disallowed (GOPROXY=off) or due to // This may fail if module downloading is disallowed (GOPROXY=off) or due to
// limited connectivity, in which case we print errors to stderr and show // limited connectivity, in which case we print errors to stderr and show
// documentation only for packages that are available. // documentation only for packages that are available.

Просмотреть файл

@ -75,8 +75,8 @@ func run(pass *analysis.Pass) (interface{}, error) {
func check64BitAlignment(pass *analysis.Pass, funcName string, arg ast.Expr) { func check64BitAlignment(pass *analysis.Pass, funcName string, arg ast.Expr) {
// Checks the argument is made of the address operator (&) applied to // Checks the argument is made of the address operator (&) applied to
// to a struct field (as opposed to a variable as the first word of // a struct field (as opposed to a variable as the first word of
// uint64 and int64 variables can be relied upon to be 64-bit aligned. // uint64 and int64 variables can be relied upon to be 64-bit aligned).
unary, ok := arg.(*ast.UnaryExpr) unary, ok := arg.(*ast.UnaryExpr)
if !ok || unary.Op != token.AND { if !ok || unary.Op != token.AND {
return return

Просмотреть файл

@ -378,7 +378,7 @@ func (b *Builder) merge(c Collision, lhs, rhs node) node {
} }
} }
// Last remaining case is branch branch merging. // Last remaining case is branch merging.
// For brevity, we adopt the Okasaki and Gill naming conventions // For brevity, we adopt the Okasaki and Gill naming conventions
// for branching and prefixes. // for branching and prefixes.
s, t := lhs.(*branch), rhs.(*branch) s, t := lhs.(*branch), rhs.(*branch)
@ -472,7 +472,7 @@ func (b *Builder) intersect(c Collision, l, r node) node {
// fallthrough // fallthrough
} }
} }
// Last remaining case is branch branch intersection. // Last remaining case is branch intersection.
s, t := l.(*branch), r.(*branch) s, t := l.(*branch), r.(*branch)
p, m := s.prefix, s.branching p, m := s.prefix, s.branching
q, n := t.prefix, t.branching q, n := t.prefix, t.branching

Просмотреть файл

@ -630,7 +630,7 @@ func newLoader(cfg *Config) *loader {
return ld return ld
} }
// refine connects the supplied packages into a graph and then adds type and // refine connects the supplied packages into a graph and then adds type
// and syntax information as requested by the LoadMode. // and syntax information as requested by the LoadMode.
func (ld *loader) refine(response *driverResponse) ([]*Package, error) { func (ld *loader) refine(response *driverResponse) ([]*Package, error) {
roots := response.Roots roots := response.Roots

Просмотреть файл

@ -950,7 +950,7 @@ func (b *builder) stmtList(fn *Function, list []ast.Stmt) {
// returns the effective receiver after applying the implicit field // returns the effective receiver after applying the implicit field
// selections of sel. // selections of sel.
// //
// wantAddr requests that the result is an an address. If // wantAddr requests that the result is an address. If
// !sel.indirect, this may require that e be built in addr() mode; it // !sel.indirect, this may require that e be built in addr() mode; it
// must thus be addressable. // must thus be addressable.
// //

Просмотреть файл

@ -101,7 +101,7 @@ func emitArith(f *Function, op token.Token, x, y Value, t types.Type, pos token.
} }
// emitCompare emits to f code compute the boolean result of // emitCompare emits to f code compute the boolean result of
// comparison comparison 'x op y'. // comparison 'x op y'.
func emitCompare(f *Function, op token.Token, x, y Value, pos token.Pos) Value { func emitCompare(f *Function, op token.Token, x, y Value, pos token.Pos) Value {
xt := x.Type().Underlying() xt := x.Type().Underlying()
yt := y.Type().Underlying() yt := y.Type().Underlying()

Просмотреть файл

@ -628,7 +628,7 @@ func (x *Indexer) addFile(f vfs.ReadSeekCloser, filename string, goFile bool) (f
// The file set's base offset and x.sources size must be in lock-step; // The file set's base offset and x.sources size must be in lock-step;
// this permits the direct mapping of suffix array lookup results to // this permits the direct mapping of suffix array lookup results to
// to corresponding Pos values. // corresponding Pos values.
// //
// When a file is added to the file set, its offset base increases by // When a file is added to the file set, its offset base increases by
// the size of the file + 1; and the initial base offset is 1. Add an // the size of the file + 1; and the initial base offset is 1. Add an

Просмотреть файл

@ -72,7 +72,7 @@ type versionedRow struct {
structName string // for struct fields, the outer struct name structName string // for struct fields, the outer struct name
} }
// versionParser parses $GOROOT/api/go*.txt files and stores them in in its rows field. // versionParser parses $GOROOT/api/go*.txt files and stores them in its rows field.
type versionParser struct { type versionParser struct {
res apiVersions // initialized lazily res apiVersions // initialized lazily
} }

Просмотреть файл

@ -32,7 +32,7 @@ func (e *emptyVFS) Open(path string) (ReadSeekCloser, error) {
return nil, os.ErrNotExist return nil, os.ErrNotExist
} }
// Stat returns os.FileInfo for an empty directory if the path is // Stat returns os.FileInfo for an empty directory if the path
// is root "/" or error. os.FileInfo is implemented by emptyVFS // is root "/" or error. os.FileInfo is implemented by emptyVFS
func (e *emptyVFS) Stat(path string) (os.FileInfo, error) { func (e *emptyVFS) Stat(path string) (os.FileInfo, error) {
if path == "/" { if path == "/" {

Просмотреть файл

@ -263,7 +263,7 @@ func (s *Server) diagnose(ctx context.Context, snapshot source.Snapshot, analyze
// Wait for a free diagnostics slot. // Wait for a free diagnostics slot.
// TODO(adonovan): opt: shouldn't it be the analysis implementation's // TODO(adonovan): opt: shouldn't it be the analysis implementation's
// job to de-dup and limit resource consumption? In any case this // job to de-dup and limit resource consumption? In any case this
// this function spends most its time waiting for awaitLoaded, at // function spends most its time waiting for awaitLoaded, at
// least initially. // least initially.
select { select {
case <-ctx.Done(): case <-ctx.Done():

Просмотреть файл

@ -267,7 +267,7 @@ func (sb *Sandbox) RunGoCommand(ctx context.Context, dir, verb string, args, env
return fmt.Errorf("go command failed (stdout: %s) (stderr: %s): %v", stdout.String(), stderr.String(), err) return fmt.Errorf("go command failed (stdout: %s) (stderr: %s): %v", stdout.String(), stderr.String(), err)
} }
// Since running a go command may result in changes to workspace files, // Since running a go command may result in changes to workspace files,
// check if we need to send any any "watched" file events. // check if we need to send any "watched" file events.
// //
// TODO(rFindley): this side-effect can impact the usability of the sandbox // TODO(rFindley): this side-effect can impact the usability of the sandbox
// for benchmarks. Consider refactoring. // for benchmarks. Consider refactoring.

Просмотреть файл

@ -302,7 +302,7 @@ func SetBudget(new int64) (old int64) {
// In particular, each gopls process attempts to garbage collect // In particular, each gopls process attempts to garbage collect
// the entire gopls directory so that newer binaries can clean up // the entire gopls directory so that newer binaries can clean up
// after older ones: in the development cycle especially, new // after older ones: in the development cycle especially, new
// new versions may be created frequently. // versions may be created frequently.
func filename(kind string, key [32]byte) (string, error) { func filename(kind string, key [32]byte) (string, error) {
base := fmt.Sprintf("%x-%s", key, kind) base := fmt.Sprintf("%x-%s", key, kind)
dir, err := getCacheDir() dir, err := getCacheDir()

Просмотреть файл

@ -25,7 +25,7 @@ import (
const concurrentAnalyses = 1 const concurrentAnalyses = 1
// NewServer creates an LSP server and binds it to handle incoming client // NewServer creates an LSP server and binds it to handle incoming client
// messages on on the supplied stream. // messages on the supplied stream.
func NewServer(session *cache.Session, client protocol.ClientCloser) *Server { func NewServer(session *cache.Session, client protocol.ClientCloser) *Server {
return &Server{ return &Server{
diagnostics: map[span.URI]*fileReports{}, diagnostics: map[span.URI]*fileReports{},

Просмотреть файл

@ -157,7 +157,7 @@ func parameterNames(node ast.Node, m *protocol.Mapper, tf *token.File, info *typ
if param.Name() == "" { if param.Name() == "" {
continue continue
} }
// Skip the parameter name hint if the arg matches the // Skip the parameter name hint if the arg matches
// the parameter name. // the parameter name.
if i, ok := v.(*ast.Ident); ok && i.Name == param.Name() { if i, ok := v.(*ast.Ident); ok && i.Name == param.Name() {
continue continue

Просмотреть файл

@ -332,7 +332,7 @@ func ordinaryReferences(ctx context.Context, snapshot Snapshot, uri span.URI, pp
// The scope is the union of rdeps of each variant. // The scope is the union of rdeps of each variant.
// (Each set is disjoint so there's no benefit to // (Each set is disjoint so there's no benefit to
// to combining the metadata graph traversals.) // combining the metadata graph traversals.)
for _, m := range variants { for _, m := range variants {
if err := addRdeps(m.ID, transitive); err != nil { if err := addRdeps(m.ID, transitive); err != nil {
return nil, err return nil, err

Просмотреть файл

@ -774,7 +774,7 @@ func renamePackage(ctx context.Context, s Snapshot, f FileHandle, newName Packag
edits := make(map[span.URI][]diff.Edit) edits := make(map[span.URI][]diff.Edit)
for _, m := range allMetadata { for _, m := range allMetadata {
// Special case: x_test packages for the renamed package will not have the // Special case: x_test packages for the renamed package will not have the
// package path as as a dir prefix, but still need their package clauses // package path as a dir prefix, but still need their package clauses
// renamed. // renamed.
if m.PkgPath == oldPkgPath+"_test" { if m.PkgPath == oldPkgPath+"_test" {
if err := renamePackageClause(ctx, m, s, newName+"_test", edits); err != nil { if err := renamePackageClause(ctx, m, s, newName+"_test", edits); err != nil {

Просмотреть файл

@ -153,7 +153,7 @@ expand:
// expandEdit returns edit expanded to complete whole lines. // expandEdit returns edit expanded to complete whole lines.
func expandEdit(edit Edit, src string) Edit { func expandEdit(edit Edit, src string) Edit {
// Expand start left to start of line. // Expand start left to start of line.
// (delta is the zero-based column number of of start.) // (delta is the zero-based column number of start.)
start := edit.Start start := edit.Start
if delta := start - 1 - strings.LastIndex(src[:start], "\n"); delta > 0 { if delta := start - 1 - strings.LastIndex(src[:start], "\n"); delta > 0 {
edit.Start -= delta edit.Start -= delta

Просмотреть файл

@ -319,7 +319,7 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
// Per https://pkg.go.dev/os#File.Close, the call to stdoutR.Close // Per https://pkg.go.dev/os#File.Close, the call to stdoutR.Close
// should cause the Read call in io.Copy to unblock and return // should cause the Read call in io.Copy to unblock and return
// immediately, but we still need to receive from stdoutErr to confirm // immediately, but we still need to receive from stdoutErr to confirm
// that that has happened. // that it has happened.
<-stdoutErr <-stdoutErr
err2 = ctx.Err() err2 = ctx.Err()
} }
@ -333,7 +333,7 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
// one goroutine at a time will call Write.” // one goroutine at a time will call Write.”
// //
// Since we're starting a goroutine that writes to cmd.Stdout, we must // Since we're starting a goroutine that writes to cmd.Stdout, we must
// also update cmd.Stderr so that that still holds. // also update cmd.Stderr so that it still holds.
func() { func() {
defer func() { recover() }() defer func() { recover() }()
if cmd.Stderr == prevStdout { if cmd.Stderr == prevStdout {

Просмотреть файл

@ -12,7 +12,7 @@ import (
"golang.org/x/tools/internal/gopathwalk" "golang.org/x/tools/internal/gopathwalk"
) )
// To find packages to import, the resolver needs to know about all of the // To find packages to import, the resolver needs to know about all of
// the packages that could be imported. This includes packages that are // the packages that could be imported. This includes packages that are
// already in modules that are in (1) the current module, (2) replace targets, // already in modules that are in (1) the current module, (2) replace targets,
// and (3) packages in the module cache. Packages in (1) and (2) may change over // and (3) packages in the module cache. Packages in (1) and (2) may change over

Просмотреть файл

@ -104,7 +104,7 @@ func (s *Server) run(ctx context.Context) {
rwc, err := s.listener.Accept(ctx) rwc, err := s.listener.Accept(ctx)
if err != nil { if err != nil {
// Only Shutdown closes the listener. If we get an error after Shutdown is // Only Shutdown closes the listener. If we get an error after Shutdown is
// called, assume that that was the cause and don't report the error; // called, assume that was the cause and don't report the error;
// otherwise, report the error in case it is unexpected. // otherwise, report the error in case it is unexpected.
if atomic.LoadInt32(&s.closing) == 0 { if atomic.LoadInt32(&s.closing) == 0 {
s.async.setError(err) s.async.setError(err)

Просмотреть файл

@ -242,7 +242,7 @@ func union(first, second *mapNode, less func(a, b interface{}) bool, overwrite b
// //
// split(n:-0) (left:+1, mid:+1, right:+1) // split(n:-0) (left:+1, mid:+1, right:+1)
// Split borrows n without affecting its refcount, and returns three // Split borrows n without affecting its refcount, and returns three
// new references that that caller is expected to call decref. // new references that the caller is expected to call decref.
func split(n *mapNode, key interface{}, less func(a, b interface{}) bool, requireMid bool) (left, mid, right *mapNode) { func split(n *mapNode, key interface{}, less func(a, b interface{}) bool, requireMid bool) (left, mid, right *mapNode) {
if n == nil { if n == nil {
return nil, nil, nil return nil, nil, nil