Skip to content

CDL: Improve performance by simplifying CDS location identification #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/run-codeql-unit-tests-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,20 @@ jobs:
# Compile .cds files to .cds.json files.
- name: Compile CAP CDS files
run: |
for cds_file in $(find . -type f \( -iname '*.cds' \) -print)
for test_dir in $(find . -type f -name '*.expected' -exec dirname {} \;);
do
echo "I am compiling $cds_file"
cds compile $cds_file \
-2 json \
-o "$cds_file.json" \
--locations
# The CDS compiler produces locations relative to the working directory
# so we switch to the test directory before running the compiler.
pushd $test_dir
for cds_file in $(find . -type f \( -iname '*.cds' \) -print)
do
echo "I am compiling $cds_file"
cds compile $cds_file \
-2 json \
-o "$cds_file.json" \
--locations
done
popd
done

- name: Run test suites
Expand All @@ -105,7 +112,7 @@ jobs:
CODEQL_STDLIB_IDENT: ${{matrix.codeql_standard_library_ident}}
RUNNER_TMP: ${{ runner.temp }}
LGTM_INDEX_XML_MODE: all
LGTM_INDEX_FILETYPES: ".json:JSON"
LGTM_INDEX_FILETYPES: ".json:JSON\n.cds:JSON"

shell: bash
run: >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ abstract class CdlObject extends JsonObject {
exists(Location loc, JsonValue locValue |
loc = this.getLocation() and
locValue = this.getPropValue("$location") and
path =
any(File f |
f.getAbsolutePath()
.matches("%" + locValue.getPropValue("file").getStringValue() + ".json")
).getAbsolutePath().regexpReplaceAll("\\.json$", "") 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 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
6 changes: 3 additions & 3 deletions qlt.conf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CodeQLCLI": "2.19.0",
"CodeQLStandardLibrary": "codeql-cli/v2.19.0",
"CodeQLCLIBundle": "codeql-bundle-v2.19.0"
"CodeQLCLI": "2.19.4",
"CodeQLStandardLibrary": "codeql-cli/v2.19.4",
"CodeQLCLIBundle": "codeql-bundle-v2.19.4"
}
Loading