Skip to content

Commit

Permalink
MAT-7403: Segregating definitions by whether they're only in the loca…
Browse files Browse the repository at this point in the history
…l CQL, or included libraries
  • Loading branch information
gregory-akins committed Sep 10, 2024
1 parent 0f6e4a9 commit 9b36a33
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>gov.cms.madie</groupId>
<artifactId>madie-translator-commons</artifactId>
<version>0.0.3-cqframework3.14.0-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
@Builder
public class CqlBuilderLookup {
private Set<Lookup> parameters;
private Set<Lookup> definitions;
private Set<Lookup> allDefinitions;
private Set<Lookup> localDefinitions;
private Set<Lookup> functions;
private Set<Lookup> fluentFunctions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -59,6 +58,7 @@
import gov.cms.madie.cql_elm_translator.utils.cql.parsing.model.CQLValueSet;
import gov.cms.madie.cql_elm_translator.utils.cql.parsing.model.DefinitionContent;
import lombok.Getter;
import lombok.NonNull;

@Slf4j
public class Cql2ElmListener extends cqlBaseListener {
Expand Down Expand Up @@ -228,7 +228,7 @@ public void enterReferentialIdentifier(ReferentialIdentifierContext ctx) {
}

@Override
public void enterQualifiedIdentifier(@NotNull cqlParser.QualifiedIdentifierContext ctx) {
public void enterQualifiedIdentifier(@NonNull cqlParser.QualifiedIdentifierContext ctx) {
String identifier = parseString(ctx.identifier().getText());
String qualifier = "";

Expand Down Expand Up @@ -257,14 +257,14 @@ private boolean shouldResolve(String identifier) {
}

@Override
public void enterFunction(@NotNull cqlParser.FunctionContext ctx) {
public void enterFunction(@NonNull cqlParser.FunctionContext ctx) {
String identifier = parseString(ctx.referentialIdentifier().getText());
resolve(identifier, getCurrentLibraryContext());
libraryAccessor = null;
}

@Override
public void enterExpressionDefinition(@NotNull cqlParser.ExpressionDefinitionContext ctx) {
public void enterExpressionDefinition(@NonNull cqlParser.ExpressionDefinitionContext ctx) {
String identifier = parseString(ctx.identifier().getText());
this.currentContext = libraryIdentifier + identifier;
String content =
Expand All @@ -277,8 +277,9 @@ public void enterExpressionDefinition(@NotNull cqlParser.ExpressionDefinitionCon
}

@Override
public void enterFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext ctx) {
String identifier = parseString(ctx.identifierOrFunctionIdentifier().getText());
public void enterFunctionDefinition(@NonNull cqlParser.FunctionDefinitionContext ctx) {
String functionDef = ctx.identifierOrFunctionIdentifier().getText();
String identifier = parseString(functionDef);
this.currentContext = libraryIdentifier + identifier;
for (cqlParser.OperandDefinitionContext operand : ctx.operandDefinition()) {
namespace.push(operand.referentialIdentifier().getText());
Expand All @@ -299,7 +300,7 @@ public void enterFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext
}

@Override
public void exitFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext ctx) {
public void exitFunctionDefinition(@NonNull cqlParser.FunctionDefinitionContext ctx) {
for (cqlParser.OperandDefinitionContext operand : ctx.operandDefinition()) {
namespace.pop();
}
Expand Down Expand Up @@ -345,14 +346,16 @@ private static String getFullText(ParserRuleContext context) {
|| context.stop.getStopIndex() < 0) {
return context.getText();
}
return context
.start
.getInputStream()
.getText(Interval.of(context.start.getStartIndex(), context.stop.getStopIndex()));
String result =
context
.start
.getInputStream()
.getText(Interval.of(context.start.getStartIndex(), context.stop.getStopIndex()));
return result;
}

@Override
public void enterParameterDefinition(@NotNull cqlParser.ParameterDefinitionContext ctx) {
public void enterParameterDefinition(@NonNull cqlParser.ParameterDefinitionContext ctx) {
String identifier = parseString(ctx.identifier().getText());
this.currentContext = libraryIdentifier + identifier;
graph.addNode(currentContext);
Expand All @@ -363,7 +366,7 @@ public void enterParameterDefinition(@NotNull cqlParser.ParameterDefinitionConte
}

@Override
public void enterRetrieve(@NotNull cqlParser.RetrieveContext ctx) {
public void enterRetrieve(@NonNull cqlParser.RetrieveContext ctx) {

// we only care about entering a retrieve if it has a terminology
if (ctx.terminology() == null || ctx.codePath() != null) {
Expand Down

0 comments on commit 9b36a33

Please sign in to comment.