Skip to content

Commit

Permalink
Spotless and quality gate fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brynrhodes committed Oct 30, 2024
1 parent 49ff33b commit 4866823
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,10 @@ public Object visitListSelector(cqlParser.ListSelectorContext ctx) {
for (cqlParser.ExpressionContext elementContext : ctx.expression()) {
Expression element = parseExpression(elementContext);

if (element == null) {
throw new RuntimeException("Element failed to parse");
}

if (elementType != null) {
libraryBuilder.verifyType(element.getResultType(), elementType);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,7 @@ public Invocation resolveProperContainsInvocation(

private int getTypeScore(OperatorResolution resolution) {
int typeScore = ConversionMap.ConversionScore.ExactMatch.score();
for (DataType operand :
resolution.getOperator().getSignature().getOperandTypes()) {
for (DataType operand : resolution.getOperator().getSignature().getOperandTypes()) {
typeScore += ConversionMap.getTypePrecedenceScore(operand);
}

Expand All @@ -1114,10 +1113,12 @@ private Expression lowestScoringInvocation(Invocation primary, Invocation second
if (secondary.getResolution().getScore()
< primary.getResolution().getScore()) {
return secondary.getExpression();
} else if (primary.getResolution().getScore() < secondary.getResolution().getScore()) {
} else if (primary.getResolution().getScore()
< secondary.getResolution().getScore()) {
return primary.getExpression();
}
if (primary.getResolution().getScore() == secondary.getResolution().getScore()) {
if (primary.getResolution().getScore()
== secondary.getResolution().getScore()) {
int primaryTypeScore = getTypeScore(primary.getResolution());
int secondaryTypeScore = getTypeScore(secondary.getResolution());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ private OperatorResolution getOperatorResolution(
boolean requireConversions) {
Conversion[] conversions = getConversions(
callSignature, operator.getSignature(), conversionMap, operatorMap, allowPromotionAndDemotion);
OperatorResolution result = new OperatorResolution(
operator, conversions);
OperatorResolution result = new OperatorResolution(operator, conversions);
if (requireConversions && conversions == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,67 +341,67 @@ void resolutionProperlyIncludesTests() throws IOException {

ExpressionDef test = statements.get(0);
assertThat(test.getExpression(), instanceOf(ProperContains.class));
ProperContains properContains = (ProperContains)test.getExpression();
ProperContains properContains = (ProperContains) test.getExpression();
assertThat(properContains.getOperand().get(0), instanceOf(Interval.class));
Interval interval = (Interval)properContains.getOperand().get(0);
Interval interval = (Interval) properContains.getOperand().get(0);
assertThat(interval.getResultType(), instanceOf(IntervalType.class));
IntervalType intervalType = (IntervalType)interval.getResultType();
IntervalType intervalType = (IntervalType) interval.getResultType();
assertThat(intervalType.getPointType(), instanceOf(SimpleType.class));
SimpleType pointType = (SimpleType)intervalType.getPointType();
SimpleType pointType = (SimpleType) intervalType.getPointType();
assertThat(pointType.getName(), equalTo("System.Integer"));
assertThat(properContains.getOperand().get(1), instanceOf(As.class));
As _as = (As)properContains.getOperand().get(1);
As _as = (As) properContains.getOperand().get(1);
assertThat(_as.getAsType().toString(), equalTo("{urn:hl7-org:elm-types:r1}Integer"));
assertThat(_as.getOperand(), instanceOf(Null.class));

test = statements.get(1);
assertThat(test.getExpression(), instanceOf(ProperContains.class));
properContains = (ProperContains)test.getExpression();
properContains = (ProperContains) test.getExpression();
assertThat(properContains.getOperand().get(0), instanceOf(Interval.class));
interval = (Interval)properContains.getOperand().get(0);
interval = (Interval) properContains.getOperand().get(0);
assertThat(interval.getResultType(), instanceOf(IntervalType.class));
intervalType = (IntervalType)interval.getResultType();
intervalType = (IntervalType) interval.getResultType();
assertThat(intervalType.getPointType(), instanceOf(SimpleType.class));
pointType = (SimpleType)intervalType.getPointType();
pointType = (SimpleType) intervalType.getPointType();
assertThat(pointType.getName(), equalTo("System.Integer"));
assertThat(properContains.getOperand().get(1), instanceOf(As.class));
_as = (As)properContains.getOperand().get(1);
_as = (As) properContains.getOperand().get(1);
assertThat(_as.getAsType().toString(), equalTo("{urn:hl7-org:elm-types:r1}Integer"));
assertThat(_as.getOperand(), instanceOf(Null.class));

test = statements.get(2);
assertThat(test.getExpression(), instanceOf(ProperContains.class));
properContains = (ProperContains)test.getExpression();
properContains = (ProperContains) test.getExpression();
assertThat(properContains.getOperand().get(0), instanceOf(Interval.class));
interval = (Interval)properContains.getOperand().get(0);
interval = (Interval) properContains.getOperand().get(0);
assertThat(interval.getResultType(), instanceOf(IntervalType.class));
intervalType = (IntervalType)interval.getResultType();
intervalType = (IntervalType) interval.getResultType();
assertThat(intervalType.getPointType(), instanceOf(SimpleType.class));
pointType = (SimpleType)intervalType.getPointType();
pointType = (SimpleType) intervalType.getPointType();
assertThat(pointType.getName(), equalTo("System.Any"));
assertThat(properContains.getOperand().get(1), instanceOf(Null.class));

test = statements.get(3);
assertThat(test.getExpression(), instanceOf(ProperContains.class));
properContains = (ProperContains)test.getExpression();
properContains = (ProperContains) test.getExpression();
assertThat(properContains.getOperand().get(0), instanceOf(Interval.class));
interval = (Interval)properContains.getOperand().get(0);
interval = (Interval) properContains.getOperand().get(0);
assertThat(interval.getResultType(), instanceOf(IntervalType.class));
intervalType = (IntervalType)interval.getResultType();
intervalType = (IntervalType) interval.getResultType();
assertThat(intervalType.getPointType(), instanceOf(SimpleType.class));
pointType = (SimpleType)intervalType.getPointType();
pointType = (SimpleType) intervalType.getPointType();
assertThat(pointType.getName(), equalTo("System.Any"));
assertThat(properContains.getOperand().get(1), instanceOf(Null.class));

test = statements.get(4);
assertThat(test.getExpression(), instanceOf(ProperContains.class));
properContains = (ProperContains)test.getExpression();
properContains = (ProperContains) test.getExpression();
assertThat(properContains.getOperand().get(0), instanceOf(Interval.class));
interval = (Interval)properContains.getOperand().get(0);
interval = (Interval) properContains.getOperand().get(0);
assertThat(interval.getResultType(), instanceOf(IntervalType.class));
intervalType = (IntervalType)interval.getResultType();
intervalType = (IntervalType) interval.getResultType();
assertThat(intervalType.getPointType(), instanceOf(SimpleType.class));
pointType = (SimpleType)intervalType.getPointType();
pointType = (SimpleType) intervalType.getPointType();
assertThat(pointType.getName(), equalTo("System.Integer"));
assertThat(properContains.getOperand().get(1), instanceOf(As.class));
}
Expand Down

0 comments on commit 4866823

Please sign in to comment.