Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing: clean up ctags parser wrapper #708

Merged
merged 9 commits into from
Dec 6, 2023
13 changes: 2 additions & 11 deletions ctags/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package ctags

import (
"fmt"
"sync"
"time"

goctags "github.com/sourcegraph/go-ctags"
Expand All @@ -38,7 +37,6 @@ type parseResp struct {
}

type lockedParser struct {
mu sync.Mutex
opts goctags.Options
p Parser
send chan<- parseReq
Expand All @@ -51,13 +49,9 @@ type lockedParser struct {
const parseTimeout = time.Minute

// Parse wraps go-ctags Parse. It lazily starts the process and adds a timeout
// around parse requests. Additionally it serializes access to the parsing
// process. The timeout is important since we occasionally come across
// documents which hang universal-ctags.
// around parse requests. The timeout is important since we occasionally come
// across documents which hang universal-ctags.
func (lp *lockedParser) Parse(name string, content []byte) ([]*Entry, error) {
lp.mu.Lock()
defer lp.mu.Unlock()
jtibshirani marked this conversation as resolved.
Show resolved Hide resolved

if lp.p == nil {
p, err := goctags.New(lp.opts)
if err != nil {
Expand Down Expand Up @@ -96,12 +90,9 @@ func (lp *lockedParser) Parse(name string, content []byte) ([]*Entry, error) {
}

func (lp *lockedParser) Close() {
lp.mu.Lock()
defer lp.mu.Unlock()
lp.close()
}

// close assumes lp.mu is held.
func (lp *lockedParser) close() {
if lp.p == nil {
return
Expand Down