| // Copyright 2018 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| "golang.org/x/tools/internal/lsp/source" |
| "golang.org/x/tools/internal/span" |
| // viewFile extends source.File with helper methods for the view package. |
| type viewFile interface { |
| // fileBase holds the common functionality for all files. |
| // It is intended to be embedded in the file implementations |
| func dir(filename string) string { |
| return strings.ToLower(filepath.Dir(filename)) |
| func basename(filename string) string { |
| return strings.ToLower(filepath.Base(filename)) |
| func (f *fileBase) URI() span.URI { |
| func (f *fileBase) Kind() source.FileKind { |
| func (f *fileBase) filename() string { |
| // View returns the view associated with the file. |
| func (f *fileBase) View() source.View { |
| func (f *fileBase) FileSet() *token.FileSet { |
| return f.view.Session().Cache().FileSet() |