1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:24:41 -07:00

go/types: provide full source file extent to file scope

Change-Id: Ib3472ab9e6b5bae0b03474ea57857fde1afbd43a
Reviewed-on: https://go-review.googlesource.com/10995
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2015-06-12 15:56:23 -07:00
parent 44761a8f84
commit ee0cf325b1
2 changed files with 8 additions and 1 deletions

View File

@ -144,6 +144,10 @@ func TestEvalPos(t *testing.T) {
type FT /* FT => , p.FT */ interface{}
}
`,
`
package p
/* T => , p.T */
`,
}
fset := token.NewFileSet()

View File

@ -153,7 +153,10 @@ func (check *Checker) collectObjects() {
// but there is no corresponding package object.
check.recordDef(file.Name, nil)
fileScope := NewScope(check.pkg.scope, file.Pos(), file.End(), check.filename(fileNo))
// Use the actual source file extent rather than *ast.File extent since the
// latter doesn't include comments which appear at the end of the file.
f := check.fset.File(file.Pos())
fileScope := NewScope(check.pkg.scope, token.Pos(f.Base()), token.Pos(f.Base()+f.Size()), check.filename(fileNo))
check.recordScope(file, fileScope)
for _, decl := range file.Decls {