@@ -40,10 +40,34 @@ func Setup(cliPath string, clangdPath string, _enableLogging bool, _asyncProcess
40
40
// CLangdStarter starts clangd and returns its stdin/out/err
41
41
type CLangdStarter func () (stdin io.WriteCloser , stdout io.ReadCloser , stderr io.ReadCloser )
42
42
43
+ // InoHandler is a JSON-RPC handler that delegates messages to clangd.
44
+ type InoHandler struct {
45
+ StdioConn * jsonrpc2.Conn
46
+ ClangdConn * jsonrpc2.Conn
47
+ lspInitializeParams * lsp.InitializeParams
48
+ buildPath * paths.Path
49
+ buildSketchRoot * paths.Path
50
+ buildSketchCpp * paths.Path
51
+ buildSketchCppVersion int
52
+ buildSketchSymbols []lsp.DocumentSymbol
53
+ buildSketchSymbolsLoad bool
54
+ buildSketchSymbolsCheck bool
55
+ rebuildSketchDeadline * time.Time
56
+ rebuildSketchDeadlineMutex sync.Mutex
57
+ sketchRoot * paths.Path
58
+ sketchName string
59
+ sketchMapper * sourcemapper.InoMapper
60
+ sketchTrackedFilesCount int
61
+ docs map [lsp.DocumentURI ]* lsp.TextDocumentItem
62
+
63
+ config lsp.BoardConfig
64
+ synchronizer Synchronizer
65
+ }
66
+
43
67
// NewInoHandler creates and configures an InoHandler.
44
68
func NewInoHandler (stdio io.ReadWriteCloser , board lsp.Board ) * InoHandler {
45
69
handler := & InoHandler {
46
- trackedFiles : map [lsp.DocumentURI ]* lsp.TextDocumentItem {},
70
+ docs : map [lsp.DocumentURI ]* lsp.TextDocumentItem {},
47
71
config : lsp.BoardConfig {
48
72
SelectedBoard : board ,
49
73
},
@@ -66,30 +90,6 @@ func NewInoHandler(stdio io.ReadWriteCloser, board lsp.Board) *InoHandler {
66
90
return handler
67
91
}
68
92
69
- // InoHandler is a JSON-RPC handler that delegates messages to clangd.
70
- type InoHandler struct {
71
- StdioConn * jsonrpc2.Conn
72
- ClangdConn * jsonrpc2.Conn
73
- lspInitializeParams * lsp.InitializeParams
74
- buildPath * paths.Path
75
- buildSketchRoot * paths.Path
76
- buildSketchCpp * paths.Path
77
- buildSketchCppVersion int
78
- buildSketchSymbols []lsp.DocumentSymbol
79
- buildSketchSymbolsLoad bool
80
- buildSketchSymbolsCheck bool
81
- rebuildSketchDeadline * time.Time
82
- rebuildSketchDeadlineMutex sync.Mutex
83
- sketchRoot * paths.Path
84
- sketchName string
85
- sketchMapper * sourcemapper.InoMapper
86
- sketchTrackedFilesCount int
87
- trackedFiles map [lsp.DocumentURI ]* lsp.TextDocumentItem
88
-
89
- config lsp.BoardConfig
90
- synchronizer Synchronizer
91
- }
92
-
93
93
// FileData gathers information on a .ino source file.
94
94
type FileData struct {
95
95
sourceText string
@@ -504,7 +504,7 @@ func startClangd(compileCommandsDir, sketchCpp *paths.Path) (io.WriteCloser, io.
504
504
func (handler * InoHandler ) didOpen (ctx context.Context , params * lsp.DidOpenTextDocumentParams ) (* lsp.DidOpenTextDocumentParams , error ) {
505
505
// Add the TextDocumentItem in the tracked files list
506
506
doc := params .TextDocument
507
- handler .trackedFiles [doc .URI ] = & doc
507
+ handler .docs [doc .URI ] = & doc
508
508
509
509
// If we are tracking a .ino...
510
510
if doc .URI .AsPath ().Ext () == ".ino" {
@@ -534,7 +534,7 @@ func (handler *InoHandler) didOpen(ctx context.Context, params *lsp.DidOpenTextD
534
534
func (handler * InoHandler ) didChange (ctx context.Context , req * lsp.DidChangeTextDocumentParams ) (* lsp.DidChangeTextDocumentParams , error ) {
535
535
doc := req .TextDocument
536
536
537
- trackedDoc , ok := handler .trackedFiles [doc .URI ]
537
+ trackedDoc , ok := handler .docs [doc .URI ]
538
538
if ! ok {
539
539
return nil , unknownURI (doc .URI )
540
540
}
@@ -1045,7 +1045,7 @@ func (handler *InoHandler) FromClangd(ctx context.Context, connection *jsonrpc2.
1045
1045
// XXX: Optimize this to publish "empty diagnostics" only to .ino that are
1046
1046
// currently showing previous diagnostics.
1047
1047
1048
- for sourceURI := range handler .trackedFiles {
1048
+ for sourceURI := range handler .docs {
1049
1049
msg := lsp.PublishDiagnosticsParams {
1050
1050
URI : sourceURI ,
1051
1051
Diagnostics : []lsp.Diagnostic {},
0 commit comments