Skip to content

Commit

Permalink
work on noimports fail
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed Jun 8, 2024
1 parent 10a0fb1 commit 80d8995
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ It is build on top of two awesome packages:
- works with the `vscode-go` extension of Microsoft Visual Studio Code
- imports generated stubs for required Go modules

## goal

- handle code modification during debugging session
- evaluate expression in a debugger session
- restart from stack frame

## install

```
Expand Down
7 changes: 7 additions & 0 deletions api/debug_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package api

import "testing"

func TestExecNoImports(t *testing.T) {
exec("/Users/emicklei/Projects/github.com/emicklei/varvoy/todebug/noimports", nil)
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/emicklei/varvoy

go 1.21.5

// replace github.com/traefik/yaegi => github.com/emicklei/yaegi varvoy
replace github.com/traefik/yaegi => ../yaegi

replace github.com/traefik-contrib/yaegi-debug-adapter => ../yaegi-debug-adapter
Expand Down
53 changes: 53 additions & 0 deletions simdiff/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package main

import (
"fmt"
"go/parser"
"go/token"
)

func main() {
src1 := `
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
`
set := token.NewFileSet()
expr, err := parser.ParseFile(set, "main.go", src1, parser.ParseComments)
if err != nil {
panic(err)
}
fmt.Println(expr)
{
src2 := `
package main
import "fmt"
func main() {
fmt.Println("Hello, Varvoy!")
}
`
set := token.NewFileSet()
expr2, err := parser.ParseFile(set, "main.go", src2, parser.ParseComments)
if err != nil {
panic(err)
}
fmt.Println(expr2)
}
/**
1: strategies for finding the changed functions:
compare functions by comparing the start and end pos of each function
-> need to keep this data in memory
-> also some hashcode, content may have same size but is different
2: dont care about the changes, just reload the whole file
-> see how REPL works
**/
}
2 changes: 1 addition & 1 deletion todebug/debugvars/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
now := time.Now()
fmt.Println(s, m, i, iptr, f, a, ar, ml, now)

// this part is commented because it break yaegi somehow
// this part is commented because it breaks yaegi somehow

// mt := map[string]*time.Time{
// "now": &now,
Expand Down

0 comments on commit 80d8995

Please sign in to comment.