Skip to content

Commit

Permalink
Revert "WIP: attempt to use fsnotify reliably"
Browse files Browse the repository at this point in the history
This reverts commit f0bce94.

I am going to use a simple polling approach.
  • Loading branch information
charlieegan3 committed Jul 31, 2024
1 parent f0bce94 commit e9aa1fd
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 396 deletions.
1 change: 0 additions & 1 deletion cmd/languageserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func init() {
go ls.StartHoverWorker(ctx)
go ls.StartCommandWorker(ctx)
go ls.StartConfigWorker(ctx)
go ls.StartWorkspaceStateWorker(ctx)

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
Expand Down
46 changes: 0 additions & 46 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/styrainc/regal/internal/lsp/opa/oracle"
"github.com/styrainc/regal/internal/lsp/types"
"github.com/styrainc/regal/internal/lsp/uri"
"github.com/styrainc/regal/internal/lsp/workspace"
rparse "github.com/styrainc/regal/internal/parse"
"github.com/styrainc/regal/internal/update"
"github.com/styrainc/regal/internal/util"
Expand Down Expand Up @@ -84,8 +83,6 @@ type LanguageServer struct {
loadedConfig *config.Config
loadedConfigLock sync.Mutex

workspaceDirWatcher *workspace.DirWatcher

workspaceRootURI string
clientIdentifier clients.Identifier

Expand Down Expand Up @@ -400,49 +397,6 @@ func (l *LanguageServer) StartConfigWorker(ctx context.Context) {
}
}

func (l *LanguageServer) StartWorkspaceStateWorker(ctx context.Context) {
ready := make(chan struct{})
go func() {
for l.workspaceRootURI == "" {
time.Sleep(300 * time.Millisecond)
}
ready <- struct{}{}
}()
select {
case <-ctx.Done():
return
case <-ready:
}

l.logError(fmt.Errorf("starting workspace state worker"))

dw, err := workspace.NewDirWatcher(&workspace.DirWatcherOpts{
ErrorLog: l.errorLog,
PollingInterval: 500 * time.Millisecond,
RootPath: uri.ToPath(l.clientIdentifier, l.workspaceRootURI),
})
if err != nil {
l.logError(fmt.Errorf("failed to create dir watcher: %w", err))
}

l.workspaceDirWatcher = dw

l.workspaceDirWatcher.Start(ctx)

for {
select {
case <-ctx.Done():
return
case path := <-dw.CreateChan:
l.logError(fmt.Errorf("file created: %s", path))
case path := <-dw.UpdateChan:
l.logError(fmt.Errorf("file updated: %s", path))
case path := <-dw.RemoveChan:
l.logError(fmt.Errorf("file removed: %s", path))
}
}
}

func (l *LanguageServer) StartCommandWorker(ctx context.Context) {
// note, in this function conn.Call is used as the workspace/applyEdit message is a request, not a notification
// as per the spec. In order to be 'routed' to the correct handler on the client it must have an ID
Expand Down
217 changes: 0 additions & 217 deletions internal/lsp/workspace/dirwatcher.go

This file was deleted.

Loading

0 comments on commit e9aa1fd

Please sign in to comment.