2019-05-15 10:24:49 -06:00
|
|
|
// Copyright 2019 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.
|
|
|
|
|
|
|
|
package cache
|
|
|
|
|
|
|
|
import (
|
2019-05-17 08:51:19 -06:00
|
|
|
"go/token"
|
|
|
|
|
2019-05-15 10:24:49 -06:00
|
|
|
"golang.org/x/tools/internal/lsp/source"
|
|
|
|
"golang.org/x/tools/internal/lsp/xlog"
|
2019-05-17 08:51:19 -06:00
|
|
|
"golang.org/x/tools/internal/span"
|
2019-05-15 10:24:49 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func New() source.Cache {
|
2019-05-17 08:51:19 -06:00
|
|
|
return &cache{
|
|
|
|
fset: token.NewFileSet(),
|
|
|
|
}
|
2019-05-15 10:24:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type cache struct {
|
2019-05-17 08:51:19 -06:00
|
|
|
fset *token.FileSet
|
2019-05-15 10:24:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cache) NewSession(log xlog.Logger) source.Session {
|
|
|
|
return &session{
|
2019-05-17 08:51:19 -06:00
|
|
|
cache: c,
|
|
|
|
log: log,
|
|
|
|
overlays: make(map[span.URI][]byte),
|
2019-05-15 10:24:49 -06:00
|
|
|
}
|
|
|
|
}
|
2019-05-17 08:51:19 -06:00
|
|
|
|
|
|
|
func (c *cache) FileSet() *token.FileSet {
|
|
|
|
return c.fset
|
|
|
|
}
|