Skip to content

Commit 10cadc2

Browse files
committed
Made all message callback private
1 parent df2947a commit 10cadc2

File tree

3 files changed

+50
-75
lines changed

3 files changed

+50
-75
lines changed

Diff for: ls/ls.go

+25-50
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ func NewINOLanguageServer(stdin io.Reader, stdout io.Writer, config *Config) *IN
155155
return ls
156156
}
157157

158-
// InitializeReqFromIDE initializes a new request from the IDE
159-
func (ls *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.InitializeParams) (*lsp.InitializeResult, *jsonrpc.ResponseError) {
158+
func (ls *INOLanguageServer) initializeReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.InitializeParams) (*lsp.InitializeResult, *jsonrpc.ResponseError) {
160159
ls.writeLock(logger, false)
161160
ls.sketchRoot = ideParams.RootURI.AsPath()
162161
ls.sketchName = ls.sketchRoot.Base()
@@ -364,8 +363,7 @@ func (ls *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logger js
364363
return resp, nil
365364
}
366365

367-
// ShutdownReqFromIDE executes a shutdown request from the IDE
368-
func (ls *INOLanguageServer) ShutdownReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger) *jsonrpc.ResponseError {
366+
func (ls *INOLanguageServer) shutdownReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger) *jsonrpc.ResponseError {
369367
done := make(chan bool)
370368
go func() {
371369
ls.progressHandler.Shutdown()
@@ -376,8 +374,7 @@ func (ls *INOLanguageServer) ShutdownReqFromIDE(ctx context.Context, logger json
376374
return nil
377375
}
378376

379-
// TextDocumentCompletionReqFromIDE handles a text document completion request received from the IDE
380-
func (ls *INOLanguageServer) TextDocumentCompletionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.CompletionParams) (*lsp.CompletionList, *jsonrpc.ResponseError) {
377+
func (ls *INOLanguageServer) textDocumentCompletionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.CompletionParams) (*lsp.CompletionList, *jsonrpc.ResponseError) {
381378
ls.readLock(logger, true)
382379
defer ls.readUnlock(logger)
383380

@@ -471,8 +468,7 @@ func (ls *INOLanguageServer) TextDocumentCompletionReqFromIDE(ctx context.Contex
471468
return ideCompletionList, nil
472469
}
473470

474-
// TextDocumentHoverReqFromIDE handles a text document hover request received from the IDE
475-
func (ls *INOLanguageServer) TextDocumentHoverReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.HoverParams) (*lsp.Hover, *jsonrpc.ResponseError) {
471+
func (ls *INOLanguageServer) textDocumentHoverReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.HoverParams) (*lsp.Hover, *jsonrpc.ResponseError) {
476472
ls.readLock(logger, true)
477473
defer ls.readUnlock(logger)
478474

@@ -523,8 +519,7 @@ func (ls *INOLanguageServer) TextDocumentHoverReqFromIDE(ctx context.Context, lo
523519
return &ideResp, nil
524520
}
525521

526-
// TextDocumentSignatureHelpReqFromIDE handles a text document signature help request received from the IDE
527-
func (ls *INOLanguageServer) TextDocumentSignatureHelpReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.SignatureHelpParams) (*lsp.SignatureHelp, *jsonrpc.ResponseError) {
522+
func (ls *INOLanguageServer) textDocumentSignatureHelpReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.SignatureHelpParams) (*lsp.SignatureHelp, *jsonrpc.ResponseError) {
528523
ls.readLock(logger, true)
529524
defer ls.readUnlock(logger)
530525

@@ -555,8 +550,7 @@ func (ls *INOLanguageServer) TextDocumentSignatureHelpReqFromIDE(ctx context.Con
555550
return ideSignatureHelp, nil
556551
}
557552

558-
// TextDocumentDefinitionReqFromIDE handles a text document definition request received from the IDE
559-
func (ls *INOLanguageServer) TextDocumentDefinitionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DefinitionParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
553+
func (ls *INOLanguageServer) textDocumentDefinitionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DefinitionParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
560554
ls.readLock(logger, true)
561555
defer ls.readUnlock(logger)
562556

@@ -600,8 +594,7 @@ func (ls *INOLanguageServer) TextDocumentDefinitionReqFromIDE(ctx context.Contex
600594
return ideLocations, ideLocationLinks, nil
601595
}
602596

603-
// TextDocumentTypeDefinitionReqFromIDE handles a text document type definition request received from the IDE
604-
func (ls *INOLanguageServer) TextDocumentTypeDefinitionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.TypeDefinitionParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
597+
func (ls *INOLanguageServer) textDocumentTypeDefinitionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.TypeDefinitionParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
605598
// XXX: This capability is not advertised in the initialization message (clangd
606599
// does not advertise it either, so maybe we should just not implement it)
607600
ls.readLock(logger, true)
@@ -647,8 +640,7 @@ func (ls *INOLanguageServer) TextDocumentTypeDefinitionReqFromIDE(ctx context.Co
647640
return ideLocations, ideLocationLinks, nil
648641
}
649642

650-
// TextDocumentImplementationReqFromIDE handles a text document implementation request received from the IDE
651-
func (ls *INOLanguageServer) TextDocumentImplementationReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.ImplementationParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
643+
func (ls *INOLanguageServer) textDocumentImplementationReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.ImplementationParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
652644
ls.readLock(logger, true)
653645
defer ls.readUnlock(logger)
654646

@@ -692,8 +684,7 @@ func (ls *INOLanguageServer) TextDocumentImplementationReqFromIDE(ctx context.Co
692684
return ideLocations, inoLocationLinks, nil
693685
}
694686

695-
// TextDocumentDocumentHighlightReqFromIDE handles a text document highlight request received from the IDE
696-
func (ls *INOLanguageServer) TextDocumentDocumentHighlightReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentHighlightParams) ([]lsp.DocumentHighlight, *jsonrpc.ResponseError) {
687+
func (ls *INOLanguageServer) textDocumentDocumentHighlightReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentHighlightParams) ([]lsp.DocumentHighlight, *jsonrpc.ResponseError) {
697688
ls.readLock(logger, true)
698689
defer ls.readUnlock(logger)
699690

@@ -740,8 +731,7 @@ func (ls *INOLanguageServer) TextDocumentDocumentHighlightReqFromIDE(ctx context
740731
return ideHighlights, nil
741732
}
742733

743-
// TextDocumentDocumentSymbolReqFromIDE handles a text document symbol request received from the IDE
744-
func (ls *INOLanguageServer) TextDocumentDocumentSymbolReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentSymbolParams) ([]lsp.DocumentSymbol, []lsp.SymbolInformation, *jsonrpc.ResponseError) {
734+
func (ls *INOLanguageServer) textDocumentDocumentSymbolReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentSymbolParams) ([]lsp.DocumentSymbol, []lsp.SymbolInformation, *jsonrpc.ResponseError) {
745735
ls.readLock(logger, true)
746736
defer ls.readUnlock(logger)
747737

@@ -787,8 +777,7 @@ func (ls *INOLanguageServer) TextDocumentDocumentSymbolReqFromIDE(ctx context.Co
787777
return ideDocSymbols, ideSymbolsInformation, nil
788778
}
789779

790-
// TextDocumentCodeActionReqFromIDE handles a text document code action request received from the IDE
791-
func (ls *INOLanguageServer) TextDocumentCodeActionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.CodeActionParams) ([]lsp.CommandOrCodeAction, *jsonrpc.ResponseError) {
780+
func (ls *INOLanguageServer) textDocumentCodeActionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.CodeActionParams) ([]lsp.CommandOrCodeAction, *jsonrpc.ResponseError) {
792781
ls.readLock(logger, true)
793782
defer ls.readUnlock(logger)
794783

@@ -857,8 +846,7 @@ func (ls *INOLanguageServer) TextDocumentCodeActionReqFromIDE(ctx context.Contex
857846
return ideCommandsOrCodeActions, nil
858847
}
859848

860-
// TextDocumentFormattingReqFromIDE handles a text document formatting request received from the IDE
861-
func (ls *INOLanguageServer) TextDocumentFormattingReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentFormattingParams) ([]lsp.TextEdit, *jsonrpc.ResponseError) {
849+
func (ls *INOLanguageServer) textDocumentFormattingReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentFormattingParams) ([]lsp.TextEdit, *jsonrpc.ResponseError) {
862850
ls.writeLock(logger, true)
863851
defer ls.writeUnlock(logger)
864852

@@ -913,8 +901,7 @@ func (ls *INOLanguageServer) TextDocumentFormattingReqFromIDE(ctx context.Contex
913901
return inoEdits, nil
914902
}
915903

916-
// TextDocumentRangeFormattingReqFromIDE handles a text document range formatting request received from the IDE
917-
func (ls *INOLanguageServer) TextDocumentRangeFormattingReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentRangeFormattingParams) ([]lsp.TextEdit, *jsonrpc.ResponseError) {
904+
func (ls *INOLanguageServer) textDocumentRangeFormattingReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentRangeFormattingParams) ([]lsp.TextEdit, *jsonrpc.ResponseError) {
918905
ls.writeLock(logger, true)
919906
defer ls.writeUnlock(logger)
920907

@@ -967,20 +954,17 @@ func (ls *INOLanguageServer) TextDocumentRangeFormattingReqFromIDE(ctx context.C
967954
return inoEdits, nil
968955
}
969956

970-
// InitializedNotifFromIDE initializes a notification from the IDE
971-
func (ls *INOLanguageServer) InitializedNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.InitializedParams) {
957+
func (ls *INOLanguageServer) initializedNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.InitializedParams) {
972958
logger.Logf("Notification is not propagated to clangd")
973959
}
974960

975-
// ExitNotifFromIDE logs an exit notification from the IDE
976-
func (ls *INOLanguageServer) ExitNotifFromIDE(logger jsonrpc.FunctionLogger) {
961+
func (ls *INOLanguageServer) exitNotifFromIDE(logger jsonrpc.FunctionLogger) {
977962
ls.Clangd.conn.Exit()
978963
logger.Logf("Arduino Language Server is shutting down.")
979964
os.Exit(0)
980965
}
981966

982-
// TextDocumentDidOpenNotifFromIDE handles a notification from the IDE that TextDocument is open
983-
func (ls *INOLanguageServer) TextDocumentDidOpenNotifFromIDE(logger jsonrpc.FunctionLogger, ideParam *lsp.DidOpenTextDocumentParams) {
967+
func (ls *INOLanguageServer) textDocumentDidOpenNotifFromIDE(logger jsonrpc.FunctionLogger, ideParam *lsp.DidOpenTextDocumentParams) {
984968
ls.writeLock(logger, true)
985969
defer ls.writeUnlock(logger)
986970

@@ -1039,8 +1023,7 @@ func (ls *INOLanguageServer) TextDocumentDidOpenNotifFromIDE(logger jsonrpc.Func
10391023
}
10401024
}
10411025

1042-
// TextDocumentDidChangeNotifFromIDE handles a notification from the IDE that TextDocument changed
1043-
func (ls *INOLanguageServer) TextDocumentDidChangeNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.DidChangeTextDocumentParams) {
1026+
func (ls *INOLanguageServer) textDocumentDidChangeNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.DidChangeTextDocumentParams) {
10441027
ls.writeLock(logger, true)
10451028
defer ls.writeUnlock(logger)
10461029

@@ -1136,8 +1119,7 @@ func (ls *INOLanguageServer) TextDocumentDidChangeNotifFromIDE(logger jsonrpc.Fu
11361119
}
11371120
}
11381121

1139-
// TextDocumentDidSaveNotifFromIDE handles a notification from the IDE that TextDocument has been saved
1140-
func (ls *INOLanguageServer) TextDocumentDidSaveNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.DidSaveTextDocumentParams) {
1122+
func (ls *INOLanguageServer) textDocumentDidSaveNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.DidSaveTextDocumentParams) {
11411123
ls.writeLock(logger, true)
11421124
defer ls.writeUnlock(logger)
11431125

@@ -1148,8 +1130,7 @@ func (ls *INOLanguageServer) TextDocumentDidSaveNotifFromIDE(logger jsonrpc.Func
11481130
ls.triggerRebuild()
11491131
}
11501132

1151-
// TextDocumentDidCloseNotifFromIDE handles a notification from the IDE that TextDocument has been closed
1152-
func (ls *INOLanguageServer) TextDocumentDidCloseNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.DidCloseTextDocumentParams) {
1133+
func (ls *INOLanguageServer) textDocumentDidCloseNotifFromIDE(logger jsonrpc.FunctionLogger, ideParams *lsp.DidCloseTextDocumentParams) {
11531134
ls.writeLock(logger, true)
11541135
defer ls.writeUnlock(logger)
11551136

@@ -1192,8 +1173,7 @@ func (ls *INOLanguageServer) TextDocumentDidCloseNotifFromIDE(logger jsonrpc.Fun
11921173
}
11931174
}
11941175

1195-
// FullBuildCompletedFromIDE receives a full build from the IDE and copies the results
1196-
func (ls *INOLanguageServer) FullBuildCompletedFromIDE(logger jsonrpc.FunctionLogger, params *DidCompleteBuildParams) {
1176+
func (ls *INOLanguageServer) fullBuildCompletedFromIDE(logger jsonrpc.FunctionLogger, params *DidCompleteBuildParams) {
11971177
ls.writeLock(logger, true)
11981178
defer ls.writeUnlock(logger)
11991179

@@ -1212,8 +1192,7 @@ func (ls *INOLanguageServer) CopyFullBuildResults(logger jsonrpc.FunctionLogger,
12121192
}
12131193
}
12141194

1215-
// PublishDiagnosticsNotifFromClangd publishes a diagnostics if notified from Clangd
1216-
func (ls *INOLanguageServer) PublishDiagnosticsNotifFromClangd(logger jsonrpc.FunctionLogger, clangParams *lsp.PublishDiagnosticsParams) {
1195+
func (ls *INOLanguageServer) publishDiagnosticsNotifFromClangd(logger jsonrpc.FunctionLogger, clangParams *lsp.PublishDiagnosticsParams) {
12171196
if ls.config.DisableRealTimeDiagnostics {
12181197
logger.Logf("Ignored by configuration")
12191198
return
@@ -1293,8 +1272,7 @@ func (ls *INOLanguageServer) PublishDiagnosticsNotifFromClangd(logger jsonrpc.Fu
12931272
}
12941273
}
12951274

1296-
// TextDocumentRenameReqFromIDE handles a request from the IDE to rename TextDocument
1297-
func (ls *INOLanguageServer) TextDocumentRenameReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.RenameParams) (*lsp.WorkspaceEdit, *jsonrpc.ResponseError) {
1275+
func (ls *INOLanguageServer) textDocumentRenameReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.RenameParams) (*lsp.WorkspaceEdit, *jsonrpc.ResponseError) {
12981276
ls.writeLock(logger, false)
12991277
defer ls.writeUnlock(logger)
13001278

@@ -1340,8 +1318,7 @@ func (ls *INOLanguageServer) ideURIIsPartOfTheSketch(ideURI lsp.DocumentURI) boo
13401318
return res
13411319
}
13421320

1343-
// ProgressNotifFromClangd handles a progress request from clangd
1344-
func (ls *INOLanguageServer) ProgressNotifFromClangd(logger jsonrpc.FunctionLogger, progress *lsp.ProgressParams) {
1321+
func (ls *INOLanguageServer) progressNotifFromClangd(logger jsonrpc.FunctionLogger, progress *lsp.ProgressParams) {
13451322
var token string
13461323
if err := json.Unmarshal(progress.Token, &token); err != nil {
13471324
logger.Logf("error decoding progress token: %s", err)
@@ -1362,8 +1339,7 @@ func (ls *INOLanguageServer) ProgressNotifFromClangd(logger jsonrpc.FunctionLogg
13621339
}
13631340
}
13641341

1365-
// WindowWorkDoneProgressCreateReqFromClangd handles a progress create request from clangd
1366-
func (ls *INOLanguageServer) WindowWorkDoneProgressCreateReqFromClangd(ctx context.Context, logger jsonrpc.FunctionLogger, params *lsp.WorkDoneProgressCreateParams) *jsonrpc.ResponseError {
1342+
func (ls *INOLanguageServer) windowWorkDoneProgressCreateReqFromClangd(ctx context.Context, logger jsonrpc.FunctionLogger, params *lsp.WorkDoneProgressCreateParams) *jsonrpc.ResponseError {
13671343
var token string
13681344
if err := json.Unmarshal(params.Token, &token); err != nil {
13691345
logger.Logf("error decoding progress token: %s", err)
@@ -1373,8 +1349,7 @@ func (ls *INOLanguageServer) WindowWorkDoneProgressCreateReqFromClangd(ctx conte
13731349
return nil
13741350
}
13751351

1376-
// SetTraceNotifFromIDE gets a notification from the IDE to Set Trace to parameters
1377-
func (ls *INOLanguageServer) SetTraceNotifFromIDE(logger jsonrpc.FunctionLogger, params *lsp.SetTraceParams) {
1352+
func (ls *INOLanguageServer) setTraceNotifFromIDE(logger jsonrpc.FunctionLogger, params *lsp.SetTraceParams) {
13781353
logger.Logf("Notification level set to: %s", params.Value)
13791354
ls.Clangd.conn.SetTrace(params)
13801355
}

Diff for: ls/lsp_client_clangd.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (client *clangdLSPClient) WindowShowDocument(context.Context, jsonrpc.Funct
108108

109109
// WindowWorkDoneProgressCreate is not implemented
110110
func (client *clangdLSPClient) WindowWorkDoneProgressCreate(ctx context.Context, logger jsonrpc.FunctionLogger, params *lsp.WorkDoneProgressCreateParams) *jsonrpc.ResponseError {
111-
return client.ls.WindowWorkDoneProgressCreateReqFromClangd(ctx, logger, params)
111+
return client.ls.windowWorkDoneProgressCreateReqFromClangd(ctx, logger, params)
112112
}
113113

114114
// ClientRegisterCapability is not implemented
@@ -143,7 +143,7 @@ func (client *clangdLSPClient) WorkspaceCodeLensRefresh(context.Context, jsonrpc
143143

144144
// Progress sends a Progress notification
145145
func (client *clangdLSPClient) Progress(logger jsonrpc.FunctionLogger, progress *lsp.ProgressParams) {
146-
client.ls.ProgressNotifFromClangd(logger, progress)
146+
client.ls.progressNotifFromClangd(logger, progress)
147147
}
148148

149149
// LogTrace is not implemented
@@ -168,5 +168,5 @@ func (client *clangdLSPClient) TelemetryEvent(jsonrpc.FunctionLogger, json.RawMe
168168

169169
// TextDocumentPublishDiagnostics sends a notification to Publish Dignostics
170170
func (client *clangdLSPClient) TextDocumentPublishDiagnostics(logger jsonrpc.FunctionLogger, params *lsp.PublishDiagnosticsParams) {
171-
go client.ls.PublishDiagnosticsNotifFromClangd(logger, params)
171+
go client.ls.publishDiagnosticsNotifFromClangd(logger, params)
172172
}

0 commit comments

Comments
 (0)