mirror of https://github.com/golang/go.git
internal/lsp/semantic: fix some type definitions
xyz and err in
type A func(xyz int) (err error), or
type B struct{xyz int}
were incorrectly marked as types, when they are not.
These are now marked as variables (although the choice is somewhat
arbitrary for A).
Fixes golang/go#45233
Change-Id: I2df4eab7606c356f30bf3337c12d9190e74bc392
Reviewed-on: https://go-review.googlesource.com/c/tools/+/305209
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Peter Weinberger <pjw@google.com>
This commit is contained in:
parent
0459589001
commit
ca627f833c
|
|
@ -451,6 +451,15 @@ func (e *encoded) definitionFor(x *ast.Ident) (tokenType, []string) {
|
|||
case *ast.InterfaceType:
|
||||
return tokMember, mods
|
||||
case *ast.TypeSpec:
|
||||
// GenDecl/Typespec/FuncType/FieldList/Field/Ident
|
||||
// (type A func(b uint64)) (err error)
|
||||
// b and err should not be tokType, but tokVaraible
|
||||
// and in GenDecl/TpeSpec/StructType/FieldList/Field/Ident
|
||||
// (type A struct{b uint64})
|
||||
fldm := e.stack[len(e.stack)-2]
|
||||
if _, ok := fldm.(*ast.Field); ok {
|
||||
return tokVariable, mods
|
||||
}
|
||||
return tokType, mods
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
)
|
||||
|
||||
/*⇒4,keyword,[]*/type /*⇒1,type,[definition]*/A /*⇒6,keyword,[]*/struct {
|
||||
/*⇒1,type,[definition]*/X /*⇒3,type,[defaultLibrary]*/int /*⇒6,comment,[]*/`foof`
|
||||
/*⇒1,variable,[definition]*/X /*⇒3,type,[defaultLibrary]*/int /*⇒6,comment,[]*/`foof`
|
||||
}
|
||||
/*⇒4,keyword,[]*/type /*⇒1,type,[definition]*/B /*⇒9,keyword,[]*/interface {
|
||||
/*⇒1,type,[]*/A
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ path and heading into a -run argument:
|
|||
|
||||
```bash
|
||||
cd /path/to/tools
|
||||
go test ./internal/lsp -v -run TestLSP/Modules/SuggestedFix/bar_11_21
|
||||
go test ./internal/lsp/... -v -run TestLSP/Modules/SuggestedFix/bar_11_21
|
||||
```
|
||||
|
||||
## Resetting marker tests
|
||||
|
|
|
|||
Loading…
Reference in New Issue