Move TransformPath into FileLabelFor

This way we don't have to remember to transform it at all call sites.
This commit is contained in:
Owen Mansel-Chan
2025-11-14 10:24:22 +00:00
parent 8668473916
commit 59ac2d3d3e
2 changed files with 4 additions and 4 deletions

View File

@@ -815,12 +815,12 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
displayPath = rawPath
}
if i == len(components)-1 {
lbl := tw.Labeler.FileLabelFor(path)
lbl := tw.Labeler.FileLabelFor(file)
dbscheme.FilesTable.Emit(tw, lbl, displayPath)
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
extraction.Lock.Lock()
slbl := extraction.StatWriter.Labeler.FileLabelFor(path)
slbl := extraction.StatWriter.Labeler.FileLabelFor(file)
if !isDummy {
dbscheme.CompilationCompilingFilesTable.Emit(extraction.StatWriter, extraction.Label, extraction.GetFileIdx(file), slbl)
}

View File

@@ -69,14 +69,14 @@ func (l *Labeler) GlobalID(key string) Label {
// FileLabel returns the label for a file with path `path`.
func (l *Labeler) FileLabel() Label {
if l.fileLabel == InvalidLabel {
l.fileLabel = l.FileLabelFor(srcarchive.TransformPath(l.tw.path))
l.fileLabel = l.FileLabelFor(l.tw.path)
}
return l.fileLabel
}
// FileLabelFor returns the label for the file for which the trap writer `tw` is associated
func (l *Labeler) FileLabelFor(path string) Label {
return l.GlobalID(util.EscapeTrapSpecialChars(filepath.ToSlash(path)) + ";sourcefile")
return l.GlobalID(util.EscapeTrapSpecialChars(filepath.ToSlash(srcarchive.TransformPath(path))) + ";sourcefile")
}
// LocalID associates a label with the given AST node `nd` and returns it