Skip to content

Commit

Permalink
Update to use the sourceLocationPrefix
Browse files Browse the repository at this point in the history
In our testing framework we don't always have the .cds file indexed
so we can't guarantee the presence of the File entry. Instead,
compose the path using the sourceLocationPrefix, which will be
robust to whether the .cds file was indexed or not.
  • Loading branch information
lcartey committed Dec 17, 2024
1 parent 8959b02 commit 7040473
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ abstract class CdlObject extends JsonObject {
locValue = this.getPropValue("$location") and
// The path in the cds.json file is relative to the working directory used when running
// the cds compile command. In our extractor, that's always the root of the repository,
// so we can identify the entry in the `File` table by its relative path.
path =
any(File f | f.getRelativePath() = locValue.getPropValue("file").getStringValue())
.getAbsolutePath() and
// so we can identify the sourceLocationPrefix to find the path of the root of the repo
// then append the relative path
exists(string sourceLocationPrefix |
sourceLocationPrefix(sourceLocationPrefix) and
path =
sourceLocationPrefix.regexpReplaceAll("/$", "") + "/" +
locValue.getPropValue("file").getStringValue()
) and
if
not exists(locValue.getPropValue("line")) and
not exists(locValue.getPropValue("col"))
Expand Down

0 comments on commit 7040473

Please sign in to comment.