Skip to content

Add CI workflow to lint and check formatting of Go code #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Made sketchRebuilder private
  • Loading branch information
cmaglie authored and MatteoPologruto committed Aug 4, 2022
commit edeb72716525652fc9d08529f026d92d55770011
14 changes: 7 additions & 7 deletions ls/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import (
"google.golang.org/grpc"
)

type SketchRebuilder struct {
type sketchRebuilder struct {
ls *INOLanguageServer
trigger chan chan<- bool
cancel func()
mutex sync.Mutex
}

// NewSketchBuilder makes a new SketchRebuilder and returns its pointer
func NewSketchBuilder(ls *INOLanguageServer) *SketchRebuilder {
res := &SketchRebuilder{
// newSketchBuilder makes a new SketchRebuilder and returns its pointer
func newSketchBuilder(ls *INOLanguageServer) *sketchRebuilder {
res := &sketchRebuilder{
trigger: make(chan chan<- bool, 1),
cancel: func() {},
ls: ls,
Expand All @@ -59,7 +59,7 @@ func (ls *INOLanguageServer) triggerRebuild() {
}

// TriggerRebuild schedule a sketch rebuild (it will be executed asynchronously)
func (r *SketchRebuilder) TriggerRebuild(completed chan<- bool) {
func (r *sketchRebuilder) TriggerRebuild(completed chan<- bool) {
r.mutex.Lock()
defer r.mutex.Unlock()

Expand All @@ -70,7 +70,7 @@ func (r *SketchRebuilder) TriggerRebuild(completed chan<- bool) {
}
}

func (r *SketchRebuilder) rebuilderLoop() {
func (r *sketchRebuilder) rebuilderLoop() {
logger := NewLSPFunctionLogger(color.HiMagentaString, "SKETCH REBUILD: ")
for {
completed := <-r.trigger
Expand Down Expand Up @@ -106,7 +106,7 @@ func (r *SketchRebuilder) rebuilderLoop() {
}
}

func (r *SketchRebuilder) doRebuildArduinoPreprocessedSketch(ctx context.Context, logger jsonrpc.FunctionLogger) error {
func (r *sketchRebuilder) doRebuildArduinoPreprocessedSketch(ctx context.Context, logger jsonrpc.FunctionLogger) error {
ls := r.ls
if success, err := ls.generateBuildEnvironment(ctx, !r.ls.config.SkipLibrariesDiscoveryOnRebuild, logger); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions ls/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type INOLanguageServer struct {
sketchTrackedFilesCount int
trackedIdeDocs map[string]lsp.TextDocumentItem
ideInoDocsWithDiagnostics map[lsp.DocumentURI]bool
sketchRebuilder *SketchRebuilder
sketchRebuilder *sketchRebuilder
}

// Config describes the language server configuration.
Expand Down Expand Up @@ -123,7 +123,7 @@ func NewINOLanguageServer(stdin io.Reader, stdout io.Writer, config *Config) *IN
config: config,
}
ls.clangdStarted = sync.NewCond(&ls.dataMux)
ls.sketchRebuilder = NewSketchBuilder(ls)
ls.sketchRebuilder = newSketchBuilder(ls)

if tmp, err := paths.MkTempDir("", "arduino-language-server"); err != nil {
log.Fatalf("Could not create temp folder: %s", err)
Expand Down
1 change: 1 addition & 0 deletions sourcemapper/ino.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var NotIno = InoLine{"/not-ino", 0}
// NotInoURI is the DocumentURI that do not belongs to an .ino file
var NotInoURI, _ = lsp.NewDocumentURIFromURL("file:///not-ino")

// SourceRevision is a source code tagged with a version number
type SourceRevision struct {
Version int
Text string
Expand Down