Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59ac2d3

Browse files
committed
Move TransformPath into FileLabelFor
This way we don't have to remember to transform it at all call sites.
1 parent 8668473 commit 59ac2d3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

go/extractor/extractor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,12 +815,12 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
815815
displayPath = rawPath
816816
}
817817
if i == len(components)-1 {
818-
lbl := tw.Labeler.FileLabelFor(path)
818+
lbl := tw.Labeler.FileLabelFor(file)
819819
dbscheme.FilesTable.Emit(tw, lbl, displayPath)
820820
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
821821
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
822822
extraction.Lock.Lock()
823-
slbl := extraction.StatWriter.Labeler.FileLabelFor(path)
823+
slbl := extraction.StatWriter.Labeler.FileLabelFor(file)
824824
if !isDummy {
825825
dbscheme.CompilationCompilingFilesTable.Emit(extraction.StatWriter, extraction.Label, extraction.GetFileIdx(file), slbl)
826826
}

go/extractor/trap/labels.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func (l *Labeler) GlobalID(key string) Label {
6969
// FileLabel returns the label for a file with path `path`.
7070
func (l *Labeler) FileLabel() Label {
7171
if l.fileLabel == InvalidLabel {
72-
l.fileLabel = l.FileLabelFor(srcarchive.TransformPath(l.tw.path))
72+
l.fileLabel = l.FileLabelFor(l.tw.path)
7373
}
7474
return l.fileLabel
7575
}
7676

7777
// FileLabelFor returns the label for the file for which the trap writer `tw` is associated
7878
func (l *Labeler) FileLabelFor(path string) Label {
79-
return l.GlobalID(util.EscapeTrapSpecialChars(filepath.ToSlash(path)) + ";sourcefile")
79+
return l.GlobalID(util.EscapeTrapSpecialChars(filepath.ToSlash(srcarchive.TransformPath(path))) + ";sourcefile")
8080
}
8181

8282
// LocalID associates a label with the given AST node `nd` and returns it

0 commit comments

Comments
 (0)