Skip to content

Commit

Permalink
Add warning for PUT64 usage in COBOL
Browse files Browse the repository at this point in the history
Added a warning/error when PUT64 is used, inform user that it is for Assembly only, add a test for it.
  • Loading branch information
mm-broadcom committed Jan 15, 2025
1 parent a077783 commit 8d04f17
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ protected <E extends ParseTree> void checkHasIllegalOptions(List<E> rules, Strin
}
}

protected <E extends ParseTree> void checkHasIllegalOptions(E rule, String options) {
if (rule != null) {
throwException(ErrorSeverity.ERROR, getLocality(rule), "Invalid option provided: ", options);
}
}

/**
* Helper function to check and see if more than one rule was visited out of a set provided.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public CICSPutContainerOptionsCheckUtility(DialectProcessingContext context, Lis
* @param <E> A subclass of ParserRuleContext
*/
public <E extends ParserRuleContext> void checkOptions(E ctx) {
CICSParser.Cics_put_containerContext mainCtx = (CICSParser.Cics_put_containerContext) ctx.getParent();
if (mainCtx.getRuleIndex() == RULE_INDEX)
checkHasIllegalOptions(mainCtx.PUT64(), "PUT64 is only available in Assembly");

switch (ctx.getRuleIndex()) {
case CICSParser.RULE_cics_put_container_bts:
checkBTS((CICSParser.Cics_put_container_btsContext) ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class TestCicsPutContainerStatement {

private static final String PUT_CHANNEL_VALID_1 = "PUT CONTAINER({$varOne}) CHANNEL({$varOne}) FROM({$varOne}) FLENGTH({$varOne}) BIT FROMCCSID({$varOne}) APPEND";
private static final String PUT_CHANNEL_VALID_2 = "PUT CONTAINER({$varOne}) FROM({$varOne})";
private static final String PUT64_CHANNEL = "{PUT64|errorOne} CONTAINER({$varOne}) FROM({$varOne})";

private static final String PUT_BTS_INVALID = "PUT CONTAINER({$varOne}) ACTIVITY({$varOne}) {ACQACTIVITY|errorOne} FROM({$varOne}) FLENGTH({$varOne})";
private static final String PUT_CHANNEL_INVALID = "PUT CONTAINER({$varOne}) CHANNEL({$varOne}) FROM({$varOne}) FLENGTH({$varOne}) BIT {DATATYPE|errorOne}({$varOne}) APPEND";
Expand All @@ -58,6 +59,13 @@ void testChannelValid() {
}

// Invalid Tests
@Test
void testPut64() {
HashMap<String, Diagnostic> expectedDiagnostics = new HashMap<>();
expectedDiagnostics.put("errorOne", new Diagnostic(new Range(), "Invalid option provided: PUT64 is only available in Assembly", DiagnosticSeverity.Error, ErrorSource.PARSING.getText()));
CICSTestUtils.errorTest(PUT64_CHANNEL, expectedDiagnostics);
}

@Test
void testBTSInvalid() {
HashMap<String, Diagnostic> expectedDiagnostics = new HashMap<>();
Expand Down

0 comments on commit 8d04f17

Please sign in to comment.