Skip to content
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
10 changes: 8 additions & 2 deletions internal/fourslash/_scripts/updateFailing.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { main as convertFourslash } from "./convertFourslash.mts";
const failingTestsPath = path.join(import.meta.dirname, "failingTests.txt");

function main() {
const oldFailingTests = fs.readFileSync(failingTestsPath, "utf-8");
fs.writeFileSync(failingTestsPath, "", "utf-8");
convertFourslash();
const go = which.sync("go");
Expand All @@ -17,11 +18,16 @@ function main() {
catch (error) {
testOutput = (error as { stdout: string; }).stdout as string;
}
const regex = /--- FAIL: ([\S]+)/gm;
const panicRegex = /^panic/m;
if (panicRegex.test(testOutput)) {
fs.writeFileSync(failingTestsPath, oldFailingTests, "utf-8");
throw new Error("Unrecovered panic detected in tests");
}
const failRegex = /--- FAIL: ([\S]+)/gm;
const failingTests: string[] = [];
let match;

while ((match = regex.exec(testOutput)) !== null) {
while ((match = failRegex.exec(testOutput)) !== null) {
failingTests.push(match[1]);
}

Expand Down
24 changes: 13 additions & 11 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (s *Server) readLoop(ctx context.Context) error {
if s.initializeParams == nil && msg.Kind == lsproto.MessageKindRequest {
req := msg.AsRequest()
if req.Method == lsproto.MethodInitialize {
resp, err := s.handleInitialize(ctx, req.Params.(*lsproto.InitializeParams), func() {})
resp, err := s.handleInitialize(ctx, req.Params.(*lsproto.InitializeParams), req)
if err != nil {
return err
}
Expand Down Expand Up @@ -480,16 +480,18 @@ func registerNotificationHandler[Req any](handlers handlerMap, info lsproto.Noti
}
}

func registerRequestHandler[Req, Resp any](handlers handlerMap, info lsproto.RequestInfo[Req, Resp], fn func(*Server, context.Context, Req, func()) (Resp, error)) {
func registerRequestHandler[Req, Resp any](
handlers handlerMap,
info lsproto.RequestInfo[Req, Resp],
fn func(*Server, context.Context, Req, *lsproto.RequestMessage) (Resp, error),
) {
handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error {
var params Req
// Ignore empty params.
if req.Params != nil {
params = req.Params.(Req)
}
resp, err := fn(s, ctx, params, func() {
s.recover(req)
})
resp, err := fn(s, ctx, params, req)
if err != nil {
return err
}
Expand Down Expand Up @@ -537,7 +539,7 @@ func (s *Server) recover(req *lsproto.RequestMessage) {
}
}

func (s *Server) handleInitialize(ctx context.Context, params *lsproto.InitializeParams, _ func()) (lsproto.InitializeResponse, error) {
func (s *Server) handleInitialize(ctx context.Context, params *lsproto.InitializeParams, _ *lsproto.RequestMessage) (lsproto.InitializeResponse, error) {
if s.initializeParams != nil {
return nil, lsproto.ErrInvalidRequest
}
Expand Down Expand Up @@ -661,7 +663,7 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali
return nil
}

func (s *Server) handleShutdown(ctx context.Context, params any, _ func()) (lsproto.ShutdownResponse, error) {
func (s *Server) handleShutdown(ctx context.Context, params any, _ *lsproto.RequestMessage) (lsproto.ShutdownResponse, error) {
s.session.Close()
return lsproto.ShutdownResponse{}, nil
}
Expand Down Expand Up @@ -758,7 +760,7 @@ func (s *Server) handleCompletion(ctx context.Context, languageService *ls.Langu
&ls.UserPreferences{})
}

func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsproto.CompletionItem, recoverAndSendError func()) (lsproto.CompletionResolveResponse, error) {
func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsproto.CompletionItem, reqMsg *lsproto.RequestMessage) (lsproto.CompletionResolveResponse, error) {
data, err := ls.GetCompletionItemData(params)
if err != nil {
return nil, err
Expand All @@ -767,7 +769,7 @@ func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsprot
if err != nil {
return nil, err
}
defer recoverAndSendError()
defer s.recover(reqMsg)
return languageService.ResolveCompletionItem(
ctx,
params,
Expand Down Expand Up @@ -804,10 +806,10 @@ func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, ls *ls.Language
)
}

func (s *Server) handleWorkspaceSymbol(ctx context.Context, params *lsproto.WorkspaceSymbolParams, recoverAndSendError func()) (lsproto.WorkspaceSymbolResponse, error) {
func (s *Server) handleWorkspaceSymbol(ctx context.Context, params *lsproto.WorkspaceSymbolParams, reqMsg *lsproto.RequestMessage) (lsproto.WorkspaceSymbolResponse, error) {
snapshot, release := s.session.Snapshot()
defer release()
defer recoverAndSendError()
defer s.recover(reqMsg)
programs := core.Map(snapshot.ProjectCollection.Projects(), (*project.Project).GetProgram)
return ls.ProvideWorkspaceSymbols(ctx, programs, snapshot.Converters(), params.Query)
}
Expand Down
Loading