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

Release 1.0.9 #223

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
98e34ff
MAT-7896 update github actions to v4 and add codecov token
riddhi-desai Nov 8, 2024
3ec3e22
update github actions to v4
riddhi-desai Nov 11, 2024
8484471
MAT-7784: fix functions
Dec 2, 2024
516620e
MAT-7784: Fix typo on pathname
Dec 2, 2024
bcf7bcd
Merge pull request #219 from MeasureAuthoringTool/MAT-7784b
mcmcphillips Dec 2, 2024
2dec58c
MAT-7784c: Release
Dec 2, 2024
ad9722a
Merge pull request #220 from MeasureAuthoringTool/MAT-7784c
mcmcphillips Dec 2, 2024
130fadd
Merge branch 'develop' into MAT-7896-update-github-actions-to-v4
riddhi-desai Dec 3, 2024
1480f77
remove self dependency file
riddhi-desai Dec 5, 2024
f40b5c0
Merge pull request #212 from MeasureAuthoringTool/MAT-7896-update-git…
riddhi-desai Dec 5, 2024
84d639c
MAT-7995 update error message when definition lascks name
Dec 16, 2024
33cf094
MAT-7995 update error message when definition lascks name
Dec 16, 2024
c9ebb35
Merge pull request #222 from MeasureAuthoringTool/MAT-7995_updateErro…
sb-cecilialiu Dec 17, 2024
56e1969
MAT-7998 update error message when definition name is key word
Dec 23, 2024
884d8c7
MAT-7998 update version
Dec 23, 2024
1c60c65
MAT-7998 remove unnecessary check
Dec 23, 2024
39d5e49
Merge pull request #226 from MeasureAuthoringTool/MAT-7998_updatErrMs…
sb-cecilialiu Dec 26, 2024
806502c
MAT-7999: Adding custom error message for case when code system lacks…
gregory-akins Dec 31, 2024
aef9f1c
Merge pull request #230 from MeasureAuthoringTool/MAT-7999_CodeSystem…
gregory-akins Dec 31, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Cache node modules
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/unit_test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Cache node modules
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -56,7 +56,7 @@ jobs:
run: npm run-script coverage

- name: Store the coverage report as an artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/lcov.info
Expand All @@ -67,7 +67,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download coverage artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage

Expand All @@ -83,14 +83,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Download coverage artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage

- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }} # required
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@madie/cql-antlr-parser",
"version": "1.0.7",
"version": "1.0.11",
"description": "Antlr Parsing of CQL in typescript",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -28,7 +28,7 @@
"Fhir"
],
"author": "SemanticBits [email protected]",
"license": "CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE",
"license": "ISC",
"bugs": {
"url": "https://github.com/MeasureAuthoringTool/cql-antlr-parser/issues"
},
Expand Down
22 changes: 3 additions & 19 deletions src/AntlrUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,12 @@ export default class AntlrUtils {
}

static findChildName(children: ParseTree[] | undefined): string | undefined {

if (children?.length != 4) {
console.error(
"########### Entering.. children length is ",
children?.length
);
throw new Error("Definition might be malformed.");

}
return children ? children[1].text : undefined;
}

static findChildExpression(
children: ParseTree[] | undefined
): string | undefined {

if (children?.length != 4) {
console.error(
"########### Entering.. children length is ",
children?.length
)
throw new Error("Definition might be malformed.");
}
return children ? children[3].text : undefined;
}

Expand Down Expand Up @@ -85,11 +68,12 @@ export default class AntlrUtils {
* @param comment -> a comment with comment characters
*/
static formatComment(comment: string): string {
return comment.replace(AntlrUtils.SINGLE_LINE_COMMENT_REGEX, "")
return comment
.replace(AntlrUtils.SINGLE_LINE_COMMENT_REGEX, "")
.replace(AntlrUtils.MULTI_LINE_COMMENT_REGEX, "")
.split("\n")
.map((line) => line.trim())
.filter(line=> line !== "")
.filter((line) => line !== "")
.join("\n");
}

Expand Down
9 changes: 6 additions & 3 deletions src/CqlAntlr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BufferedTokenStream, CharStreams, CommonTokenStream} from "antlr4ts";
import { BufferedTokenStream, CharStreams, CommonTokenStream } from "antlr4ts";
import { CodePointCharStream } from "antlr4ts/CodePointCharStream";
import { ParseTreeWalker } from "antlr4ts/tree";
import { cqlLexer, cqlParser, LibraryContext, cqlListener } from "../generated";
Expand All @@ -18,9 +18,12 @@ class CqlAntlr {
const charStream: CodePointCharStream = CharStreams.fromString(this.cql);
const lexer: cqlLexer = new cqlLexer(charStream);
const bufferedTokenStream = new BufferedTokenStream(lexer);
bufferedTokenStream.fill()
bufferedTokenStream.fill();

const listener: cqlListener = new CqlAntlrListener(result, bufferedTokenStream);
const listener: cqlListener = new CqlAntlrListener(
result,
bufferedTokenStream
);
ParseTreeWalker.DEFAULT.walk(listener, tree);
/**
* Disabled. Only partially implemented and would be
Expand Down
58 changes: 39 additions & 19 deletions src/CqlAntlrListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
cqlLexer,
cqlListener,
ExpressionDefinitionContext,
FunctionDefinitionContext,
IncludeDefinitionContext,
LibraryDefinitionContext,
ParameterDefinitionContext,
Expand All @@ -27,13 +28,14 @@ import CqlParameter from "./dto/CqlParameter";
import CqlContextCreator from "./CqlContextCreator";
import CqlExpressionDefinition from "./dto/CqlExpressionDefinition";
import CqlExpressionDefinitionCreator from "./CqlExpressionDefinitionCreator";
import {CqlCode} from "./dto";
import { CqlCode } from "./dto";
import CqlIdentifier from "./dto/CqlIdentifier";
import CqlIdentifierCreator from "./CqlIdentifierCreator";
import CqlRetrieve from "./dto/CqlRetrieve";
import CqlRetrieveCreator from "./CqlRetrieveCreator";
import {BufferedTokenStream} from "antlr4ts";
import { BufferedTokenStream } from "antlr4ts";
import AntlrUtils from "./AntlrUtils";
import { ParserRuleContext } from "antlr4ts/ParserRuleContext";

export default class CqlAntlrListener implements cqlListener {
// save bufferedTokenStream from lexer
Expand Down Expand Up @@ -107,30 +109,48 @@ export default class CqlAntlrListener implements cqlListener {
this.cqlResult.context = new CqlContextCreator(ctx).buildDao();
}

enterExpressionDefinition(ctx: ExpressionDefinitionContext): void {
const cqlExpressionCreator = new CqlExpressionDefinitionCreator(ctx);
const expressionDefinition: CqlExpressionDefinition | undefined = cqlExpressionCreator.buildDao();

if (expressionDefinition) {
if (ctx.start.inputStream) {
const hiddenTokens = this.bufferedTokenStream.getHiddenTokensToLeft(ctx.start.tokenIndex, cqlLexer.HIDDEN)
let comment = "";
hiddenTokens.forEach((token) => {
if (token.text){
comment += token.text;
}
})
comment = comment.trim();
if (comment){
// if expression has comment, start needs to be adjusted to consider comments as comment is part of definition
expressionDefinition.start = cqlExpressionCreator.buildLineInfo(hiddenTokens[1]);
private processDefinitionWithComments(
ctx: ParserRuleContext,
buildDao: () => CqlExpressionDefinition | undefined
): void {
const expressionDefinition: CqlExpressionDefinition | undefined =
buildDao();

if (expressionDefinition && ctx.start.inputStream) {
const hiddenTokens = this.bufferedTokenStream.getHiddenTokensToLeft(
ctx.start.tokenIndex,
cqlLexer.HIDDEN
);

if (hiddenTokens && hiddenTokens.length > 0) {
const comment = hiddenTokens
.map((token) => token.text?.trim())
.filter(Boolean)
.join(" ");

if (comment) {
expressionDefinition.start = new CqlExpressionDefinitionCreator(
ctx
).buildLineInfo(hiddenTokens[1]);
expressionDefinition.comment = AntlrUtils.formatComment(comment);
}
}
this.cqlResult.expressionDefinitions.push(expressionDefinition);
}
}

enterExpressionDefinition(ctx: ExpressionDefinitionContext): void {
this.processDefinitionWithComments(ctx, () => {
return new CqlExpressionDefinitionCreator(ctx).buildDao();
});
}

enterFunctionDefinition(ctx: FunctionDefinitionContext): void {
this.processDefinitionWithComments(ctx, () => {
return new CqlExpressionDefinitionCreator(ctx).buildDao();
});
}

enterAggregateClause(ctx: AggregateClauseContext): void {
const identifier: CqlIdentifier | undefined = new CqlIdentifierCreator(
ctx
Expand Down
3 changes: 2 additions & 1 deletion src/CustomErrorListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Recognizer } from "antlr4ts/Recognizer";
import { Token } from "antlr4ts/Token";
import { ParserATNSimulator } from "antlr4ts/atn/ParserATNSimulator";
import CqlResult from "./dto/CqlResult";
import convertCustomError from "./util/CustomeErrorConverter";

/**
* Fires on grammar errors.
Expand Down Expand Up @@ -32,7 +33,7 @@ export default class CustomErrorListener implements ANTLRErrorListener<Token> {
1, // plus 1 to ensure full text is included in Ace Editor highlight
},
name: offendingSymbol.text,
message: msg,
message: convertCustomError(msg),
});
}
}
Expand Down
Loading
Loading