Skip to content
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

Translator 3.7.1 fixes #296

Merged
merged 2 commits into from
Mar 13, 2024
Merged
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
16 changes: 14 additions & 2 deletions src/helpers/ClauseResultsHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
emptyResultClauses: any[],
parentNode: any | null
): any {
// Stop recursing if this node happens to be any TypeSpecifier. We do not want to collect localIds for these clauses
// as they are not executed and will negatively affect clause coverage if captured here. ChoiceTypeSpecifiers do not
// identify their type and instead put [] at the `type` attribute which is a deprecated field.
if (statement?.type && (Array.isArray(statement.type) || statement.type.endsWith('TypeSpecifier'))) {
return localIds;
}
// looking at the key and value of everything on this object or array
for (const k in statement) {
let alId;
Expand All @@ -94,8 +100,14 @@
if (statement.expression != null && statement.expression.localId != null) {
// Keep track of the localId of the expression that the alias references
aliasMap[v] = statement.expression.localId;
// Determine the localId in the elm_annotation for this alias.
alId = (parseInt(statement.expression.localId, 10) + 1).toString();
// Determine the localId for this alias.
if (statement.localId) {
alId = statement.localId;
} else {
// Older translator versions created an elm_annotation localId that was not always in the elm. This was a
// single increment up from the expression that defines the alias.
alId = (parseInt(statement.expression.localId, 10) + 1).toString();

Check warning on line 109 in src/helpers/ClauseResultsHelpers.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 110 in src/helpers/ClauseResultsHelpers.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
emptyResultClauses.push({ lib: libraryName, aliasLocalId: alId, expressionLocalId: aliasMap[v] });
}
} else if (k === 'scope') {
Expand Down
Loading