compiler: use absolute paths for debug data

It's not a perfect thing, but neo-debugger just doesn't work at all with
relative pathes. Notice that `saveSequencePoint` still used absolute ones
leading to invalid debug.json data, but fixing it there doesn't help,
neo-debugger can't load source code using relatives.
This commit is contained in:
Roman Khimov 2022-04-06 15:46:54 +03:00
parent e390981747
commit f5d5019b70

View file

@ -5,7 +5,6 @@ import (
"go/ast" "go/ast"
"go/token" "go/token"
"go/types" "go/types"
"path/filepath"
"strings" "strings"
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
@ -235,11 +234,6 @@ func (c *codegen) fillDocumentInfo() {
fset := c.buildInfo.config.Fset fset := c.buildInfo.config.Fset
fset.Iterate(func(f *token.File) bool { fset.Iterate(func(f *token.File) bool {
filePath := f.Position(f.Pos(0)).Filename filePath := f.Position(f.Pos(0)).Filename
rel, err := filepath.Rel(c.buildInfo.config.Dir, filePath)
// It's OK if we can't construct relative path, e.g. for interop dependencies.
if err == nil {
filePath = rel
}
c.docIndex[filePath] = len(c.documents) c.docIndex[filePath] = len(c.documents)
c.documents = append(c.documents, filePath) c.documents = append(c.documents, filePath)
return true return true