Skip to content

Commit 2b6292d

Browse files
authored
fix: Commands only available in Assembly (#2731)
1 parent 96d0e35 commit 2b6292d

File tree

4 files changed

+26
-58
lines changed

4 files changed

+26
-58
lines changed

server/engine/src/main/java/org/eclipse/lsp/cobol/implicitDialects/cics/utility/CICSFreeMainOptionsCheckUtility.java

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public <E extends ParserRuleContext> void checkOptions(E ctx) {
6060
checkDuplicates(ctx);
6161
}
6262
private void checkOpts(CICSParser.Cics_freemain_optsContext ctx) {
63+
CICSParser.Cics_freemainContext parentCtx = (CICSParser.Cics_freemainContext) ctx.getParent();
64+
checkHasIllegalOptions(parentCtx.FREEMAIN64(), "FREEMAIN64 is only available in Assembly");
6365
checkHasExactlyOneOption("DATA or DATAPOINTER", ctx, ctx.DATA(), ctx.DATAPOINTER());
6466
}
6567

server/engine/src/main/java/org/eclipse/lsp/cobol/implicitDialects/cics/utility/CICSGetMain64OptionsUtility.java

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public <E extends ParserRuleContext> void checkOptions(E ctx) {
6666

6767
@SuppressWarnings("unchecked")
6868
private void checkGetMain(CICSParser.Cics_getmain64_bodyContext ctx) {
69+
CICSParser.Cics_getmain64Context parentCtx = (CICSParser.Cics_getmain64Context) ctx.getParent();
70+
checkHasIllegalOptions(parentCtx.GETMAIN64(), "GETMAIN64 is only available in Assembly");
6971
checkHasMandatoryOptions(ctx.SET(), ctx, "SET");
7072
checkHasMandatoryOptions(ctx.FLENGTH(), ctx, "FLENGTH");
7173
if (ctx.LOCATION().isEmpty()) checkHasIllegalOptions(ctx.EXECUTABLE(), "EXECUTABLE without LOCATION");

server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/TestCICSFreeMainStatement.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626

2727
/**
2828
* Test CICS Freemain & Freemain64 commands. Documentation link:
29-
*<a https://www.ibm.com/docs/en/cics-ts/6.x?topic=summary-freemain"> Freemain Command</a>
30-
*<a https://www.ibm.com/docs/en/cics-ts/6.x?topic=summary-freemain64"> Freemain64 Command</a>
29+
*<a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=summary-freemain"> Freemain Command</a>
30+
*<a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=summary-freemain64"> Freemain64 Command</a>
3131
* <p>This class tests all variations of the Freemain commands found in the links above.
3232
*/
3333
public class TestCICSFreeMainStatement {
3434
private static final String FREEMAIN_DATA_VALID =
3535
"FREEMAIN DATA({$varFour})";
36+
private static final String FREEMAIN64_DATA_INVALID =
37+
"{FREEMAIN64|errorOne} DATA({$varFour})";
3638
private static final String FREEMAIN_DATAPOINTER_VALID =
3739
"FREEMAIN DATAPOINTER({$varFour})";
3840
private static final String FREEMAIN_DATA_MISSING_INVALID =
@@ -44,6 +46,21 @@ public class TestCICSFreeMainStatement {
4446
void testFreeMainDataValid() {
4547
CICSTestUtils.noErrorTest(FREEMAIN_DATA_VALID);
4648
}
49+
50+
@Test
51+
void testFreeMain64Invalid() {
52+
Map<String, Diagnostic> expectedDiagnostic =
53+
ImmutableMap.of(
54+
"errorOne",
55+
new Diagnostic(
56+
new Range(),
57+
"Invalid option provided: FREEMAIN64 is only available in Assembly",
58+
DiagnosticSeverity.Error,
59+
ErrorSource.PARSING.getText())
60+
);
61+
CICSTestUtils.errorTest(FREEMAIN64_DATA_INVALID, expectedDiagnostic);
62+
}
63+
4764
@Test
4865
void testFreeMainDataPointerValid() {
4966
CICSTestUtils.noErrorTest(FREEMAIN_DATAPOINTER_VALID);

server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/TestCicsGetMain64.java

+3-56
Original file line numberDiff line numberDiff line change
@@ -32,71 +32,18 @@
3232
* <p>This class tests all variations of the GETMAIN64 command found in the link above.
3333
*/
3434
public class TestCicsGetMain64 {
35-
private static final String ALL_VALID_ONE = "GETMAIN64 SET({$varOne}) FLENGTH({$varTwo}) LOCATION({$varThree}) EXECUTABLE SHARED NOSUSPEND USERDATAKEY";
36-
private static final String ALL_VALID_TWO = "GETMAIN64 FLENGTH({$varTwo}) SHARED EXECUTABLE LOCATION({$varTwo}) NOSUSPEND CICSDATAKEY SET({$varOne})";
37-
38-
private static final String SOME_VALID_ONE = "GETMAIN64 FLENGTH({$varThree}) SHARED CICSDATAKEY SET({$varOne}) LOCATION({$varTwo})";
39-
private static final String SOME_VALID_TWO = "GETMAIN64 NOSUSPEND FLENGTH({$varThree}) SET({$varOne}) LOCATION({$varTwo}) EXECUTABLE";
40-
private static final String SOME_VALID_THREE = "GETMAIN64 SET({$varOne}) NOSUSPEND FLENGTH({$varTwo}) USERDATAKEY";
41-
42-
private static final String BARE_VALID = "GETMAIN64 FLENGTH({$varTwo}) SET({$varOne})";
43-
44-
private static final String INVALID_ONE = "GETMAIN64 SET({$varTwo}) FLENGTH({$varThree}) {EXECUTABLE|error1} SHARED";
45-
private static final String INVALID_TWO = "GETMAIN64 {USERDATAKEY|error1} FLENGTH({$varTwo}) SET({$varOne}) {CICSDATAKEY|error1}";
46-
47-
@Test
48-
void testAllValidOne() {
49-
CICSTestUtils.noErrorTest(ALL_VALID_ONE);
50-
}
51-
52-
@Test
53-
void testAllValidTwo() {
54-
CICSTestUtils.noErrorTest(ALL_VALID_TWO);
55-
}
56-
57-
@Test
58-
void testSomeValidOne() {
59-
CICSTestUtils.noErrorTest(SOME_VALID_ONE);
60-
}
61-
62-
@Test
63-
void testSomeValidTwo() {
64-
CICSTestUtils.noErrorTest(SOME_VALID_TWO);
65-
}
66-
67-
@Test
68-
void testSomeValidThree() {
69-
CICSTestUtils.noErrorTest(SOME_VALID_THREE);
70-
}
71-
72-
@Test
73-
void testBareValidOne() {
74-
CICSTestUtils.noErrorTest(BARE_VALID);
75-
}
35+
private static final String INVALID_ONE = "{GETMAIN64|errorOne} SET({$varTwo}) FLENGTH({$varThree}) SHARED";
7636

7737
@Test
7838
void testInvalidOne() {
7939
Map<String, Diagnostic> expectedDiagnostic =
8040
ImmutableMap.of(
81-
"error1",
41+
"errorOne",
8242
new Diagnostic(
8343
new Range(),
84-
"Invalid option provided: EXECUTABLE without LOCATION",
44+
"Invalid option provided: GETMAIN64 is only available in Assembly",
8545
DiagnosticSeverity.Error,
8646
ErrorSource.PARSING.getText()));
8747
CICSTestUtils.errorTest(INVALID_ONE, expectedDiagnostic);
8848
}
89-
90-
@Test
91-
void testInvalidTwo() {
92-
Map<String, Diagnostic> expectedDiagnostic =
93-
ImmutableMap.of(
94-
"error1",
95-
new Diagnostic(
96-
new Range(),
97-
"Exactly one option required, options are mutually exclusive: USERDATAKEY or CICSDATAKEY",
98-
DiagnosticSeverity.Error,
99-
ErrorSource.PARSING.getText()));
100-
CICSTestUtils.errorTest(INVALID_TWO, expectedDiagnostic);
101-
}
10249
}

0 commit comments

Comments
 (0)