Skip to content
This repository was archived by the owner on Jan 31, 2024. It is now read-only.

[elastic] Fix the compile errors after sync to the upstream. #81

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/packages/golist.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ var (
goListLRUEntries = 16 * 32
)

func golistDriverLRUCached(cfg *Config, rootsDirs func() map[string]string, words ...string) (*driverResponse, error) {
func golistDriverLRUCached(cfg *Config, rootsDirs func() *goInfo, words ...string) (*driverResponse, error) {
createGoListLRUCache.Do(func() {
goListLRUCache, _ = lru.New(goListLRUEntries)
})
Expand Down
27 changes: 19 additions & 8 deletions internal/lsp/elasticserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ func (s *ElasticServer) RunElasticServer(ctx context.Context) error {
func (s *ElasticServer) EDefinition(ctx context.Context, params *protocol.TextDocumentPositionParams) ([]protocol.SymbolLocator, error) {
uri := span.NewURI(params.TextDocument.URI)
view := s.session.ViewOf(uri)
f, m, err := getGoFile(ctx, view, uri)
f, err := getGoFile(ctx, view, uri)
if err != nil {
return nil, err
}
m, err := getMapper(ctx, f)
spn, err := m.PointSpan(params.Position)
if err != nil {
return nil, err
Expand All @@ -117,15 +118,19 @@ func (s *ElasticServer) EDefinition(ctx context.Context, params *protocol.TextDo
}
qname := getQName(ctx, f, declObj, kind)

declSpan, err := ident.DeclarationRange().Span()
decSpan, err := ident.DeclarationRange().Span()
if err != nil {
return nil, err
}
_, decM, err := getSourceFile(ctx, view, declSpan.URI())
decFile, err := getGoFile(ctx, view, decSpan.URI())
if err != nil {
return nil, err
}
loc, err := decM.Location(declSpan)
decM, err := getMapper(ctx, decFile)
if err != nil {
return nil, err
}
loc, err := decM.Location(decSpan)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -156,15 +161,16 @@ func (s *ElasticServer) Full(ctx context.Context, fullParams *protocol.FullParam
return fullResponse, nil
}
view := s.session.ViewOf(uri)
f, _, err := getGoFile(ctx, view, uri)
f, err := getGoFile(ctx, view, uri)
if err != nil {
return fullResponse, err
}
path := f.URI().Filename()
if f.GetPackage(ctx) == nil {
pkg, err := f.GetPackage(ctx)
if err != nil {
return fullResponse, err
}
pkgLocator, _ := collectPkgMetadata(f.GetPackage(ctx).GetTypes(), view.Folder().Filename(), s, path)
pkgLocator, _ := collectPkgMetadata(pkg.GetTypes(), view.Folder().Filename(), s, path)

detailSyms, err := constructDetailSymbol(s, ctx, &params, &pkgLocator)
if err != nil {
Expand Down Expand Up @@ -605,7 +611,12 @@ func getDeclObj(ctx context.Context, f source.GoFile, pos token.Pos) types.Objec
case *ast.SelectorExpr:
astIdent = node.Sel
}
return f.GetPackage(ctx).GetTypesInfo().ObjectOf(astIdent)
pkg, err := f.GetPackage(ctx)
if err != nil {
return nil
}

return pkg.GetTypesInfo().ObjectOf(astIdent)
}

func constructDetailSymbol(s *ElasticServer, ctx context.Context, params *protocol.DocumentSymbolParams, pkgLocator *protocol.PackageLocator) (detailSyms []protocol.DetailSymbolInformation, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/protocol/elasticserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/lsp/telemetry/log"
"golang.org/x/tools/internal/telemetry/log"
)

type ElasticServer interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"context"

"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/telemetry/log"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/telemetry/log"
errors "golang.org/x/xerrors"
"os/exec"
)
Expand Down