Skip to content

Commit 2836832

Browse files
committed
renamed InoHandler.trackedFiles -> docs
1 parent 476eabc commit 2836832

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

Diff for: handler/builder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (handler *InoHandler) generateBuildEnvironment() (*paths.Path, error) {
6262
Overrides map[string]string `json:"overrides"`
6363
}
6464
data := overridesFile{Overrides: map[string]string{}}
65-
for uri, trackedFile := range handler.trackedFiles {
65+
for uri, trackedFile := range handler.docs {
6666
rel, err := uri.AsPath().RelFrom(handler.sketchRoot)
6767
if err != nil {
6868
return nil, errors.WithMessage(err, "dumping tracked files")

Diff for: handler/handler.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,34 @@ func Setup(cliPath string, clangdPath string, _enableLogging bool, _asyncProcess
4040
// CLangdStarter starts clangd and returns its stdin/out/err
4141
type CLangdStarter func() (stdin io.WriteCloser, stdout io.ReadCloser, stderr io.ReadCloser)
4242

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+
4367
// NewInoHandler creates and configures an InoHandler.
4468
func NewInoHandler(stdio io.ReadWriteCloser, board lsp.Board) *InoHandler {
4569
handler := &InoHandler{
46-
trackedFiles: map[lsp.DocumentURI]*lsp.TextDocumentItem{},
70+
docs: map[lsp.DocumentURI]*lsp.TextDocumentItem{},
4771
config: lsp.BoardConfig{
4872
SelectedBoard: board,
4973
},
@@ -66,30 +90,6 @@ func NewInoHandler(stdio io.ReadWriteCloser, board lsp.Board) *InoHandler {
6690
return handler
6791
}
6892

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-
9393
// FileData gathers information on a .ino source file.
9494
type FileData struct {
9595
sourceText string
@@ -504,7 +504,7 @@ func startClangd(compileCommandsDir, sketchCpp *paths.Path) (io.WriteCloser, io.
504504
func (handler *InoHandler) didOpen(ctx context.Context, params *lsp.DidOpenTextDocumentParams) (*lsp.DidOpenTextDocumentParams, error) {
505505
// Add the TextDocumentItem in the tracked files list
506506
doc := params.TextDocument
507-
handler.trackedFiles[doc.URI] = &doc
507+
handler.docs[doc.URI] = &doc
508508

509509
// If we are tracking a .ino...
510510
if doc.URI.AsPath().Ext() == ".ino" {
@@ -534,7 +534,7 @@ func (handler *InoHandler) didOpen(ctx context.Context, params *lsp.DidOpenTextD
534534
func (handler *InoHandler) didChange(ctx context.Context, req *lsp.DidChangeTextDocumentParams) (*lsp.DidChangeTextDocumentParams, error) {
535535
doc := req.TextDocument
536536

537-
trackedDoc, ok := handler.trackedFiles[doc.URI]
537+
trackedDoc, ok := handler.docs[doc.URI]
538538
if !ok {
539539
return nil, unknownURI(doc.URI)
540540
}
@@ -1045,7 +1045,7 @@ func (handler *InoHandler) FromClangd(ctx context.Context, connection *jsonrpc2.
10451045
// XXX: Optimize this to publish "empty diagnostics" only to .ino that are
10461046
// currently showing previous diagnostics.
10471047

1048-
for sourceURI := range handler.trackedFiles {
1048+
for sourceURI := range handler.docs {
10491049
msg := lsp.PublishDiagnosticsParams{
10501050
URI: sourceURI,
10511051
Diagnostics: []lsp.Diagnostic{},

0 commit comments

Comments
 (0)