Skip to content

Commit

Permalink
Ignore error instead of panic for completion store
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Sep 22, 2023
1 parent 74f2e8a commit 8ef90b4
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions internal/lsp/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,19 @@ func InitCompletionStore(dirs []string) *CompletionStore {

pkgDirs, err := ListGnoPackages(dirs)
if err != nil {
panic(err)
// Ignore error
return &CompletionStore{
pkgs: pkgs,
time: time.Now(),
}
}

for _, p := range pkgDirs {
files, err := ListGnoFiles(p)
if err != nil {
panic(err)
// Ignore error
// Continue with rest of the packages
continue
}
symbols := []*Symbol{}
for _, file := range files {
Expand Down Expand Up @@ -167,20 +173,20 @@ func InitCompletionStore(dirs []string) *CompletionStore {
func getSymbols(fname string) []*Symbol {
var symbols []*Symbol

// Create a FileSet to work with.
fset := token.NewFileSet()

// Parse the file and create an AST.
file, err := parser.ParseFile(fset, fname, nil, parser.ParseComments)
bsrc, err := os.ReadFile(fname)
if err != nil {
panic(err)
// Ignore error and return empty symbol list
return symbols
}
text := string(bsrc)

bsrc, err := os.ReadFile(fname)
// Parse the file and create an AST.
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, fname, nil, parser.ParseComments)
if err != nil {
panic(err)
// Ignore error and return empty symbol list
return symbols
}
text := string(bsrc)

// Trim AST to exported declarations only.
ast.FileExports(file)
Expand Down

0 comments on commit 8ef90b4

Please sign in to comment.