Skip to content

Implementation of POINT statement in CICS #2615

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ cics_move: MOVE ((CONTAINER | FROMACTIVITY | TOACTIVITY | AS | CHANNEL | TOCHANN
TOPROCESS | cics_handle_response)+;

/** POINT */
cics_point: POINT (CONVID cics_name | SESSION cics_name | cics_handle_response)?;
cics_point: POINT cics_point_options;
cics_point_options: ((CONVID | SESSION) cics_name | cics_handle_response)*;

/** POP HANDLE */
cics_pop: POP cics_handle_response? HANDLE cics_handle_response?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public CICSOptionsCheckUtility(DialectProcessingContext context, List<SyntaxErro
optionsMap.put(
CICSLoadOptionsCheckUtility.RULE_INDEX,
new CICSLoadOptionsCheckUtility(context, errors));
optionsMap.put(
CICSPointOptionsCheckUtility.RULE_INDEX,
new CICSPointOptionsCheckUtility(context, errors));
spOptionsMap.put(
CICSInquireSPOptionsCheckUtility.RULE_INDEX,
new CICSInquireSPOptionsCheckUtility(context, errors));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2024 Broadcom.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*
*/
package org.eclipse.lsp.cobol.implicitDialects.cics.utility;

import org.antlr.v4.runtime.ParserRuleContext;
import org.eclipse.lsp.cobol.common.dialects.DialectProcessingContext;
import org.eclipse.lsp.cobol.common.error.ErrorSeverity;
import org.eclipse.lsp.cobol.common.error.SyntaxError;
import org.eclipse.lsp.cobol.implicitDialects.cics.CICSLexer;
import org.eclipse.lsp.cobol.implicitDialects.cics.CICSParser;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.eclipse.lsp.cobol.implicitDialects.cics.CICSParser.RULE_cics_point;

/** Checks CICS POINT rules for required and invalid options */
public class CICSPointOptionsCheckUtility extends CICSOptionsCheckBaseUtility {
public static final int RULE_INDEX = RULE_cics_point;

private static final Map<Integer, ErrorSeverity> DUPLICATE_CHECK_OPTIONS =
new HashMap<Integer, ErrorSeverity>() {
{
put(CICSLexer.POINT, ErrorSeverity.ERROR);
put(CICSLexer.CONVID, ErrorSeverity.ERROR);
put(CICSLexer.SESSION, ErrorSeverity.ERROR);
}
};

public CICSPointOptionsCheckUtility(DialectProcessingContext context, List<SyntaxError> errors) {
super(context, errors, DUPLICATE_CHECK_OPTIONS);
}

/**
* Entrypoint to check CICS POINT rule options
*
* @param ctx ParserRuleContext subclass containing options
* @param <E> A subclass of ParserRuleContext
*/
public <E extends ParserRuleContext> void checkOptions(E ctx) {
if (ctx instanceof CICSParser.Cics_point_optionsContext) {
checkPoint((CICSParser.Cics_point_optionsContext) ctx);
}
checkDuplicates(ctx);
}

@SuppressWarnings("unchecked")
private void checkPoint(CICSParser.Cics_point_optionsContext ctx) {
checkHasMutuallyExclusiveOptions("CONVID or SESSION", ctx.CONVID(), ctx.SESSION());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2024 Broadcom.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*
*/
package org.eclipse.lsp.cobol.usecases;

import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.usecases.common.CICSTestUtils;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.eclipse.lsp4j.Range;
import org.junit.jupiter.api.Test;

/**
* Test CICS POINT command. Documentation link: <a
* href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=summary-point">POINT Command</a>
*
* <p>This class tests the POINT command.
*/
public class TestCICSPoint {
private static final String POINT_VALID =
"POINT";

private static final String POINT_VALID_CONVID =
"POINT CONVID({$varOne})";

private static final String POINT_VALID_SESSION =
"POINT SESSION({$varOne})";

private static final String POINT_INVALID_DUPLICATE_SESSION =
"POINT SESSION({$varOne}) {SESSION|errorOne}({$varTwo})";

private static final String POINT_INVALID_BOTH_OPTIONS =
"POINT {CONVID|errorOne}({$varOne}) {SESSION|errorTwo}({$varTwo})";

@Test
void testPointValid() {
CICSTestUtils.noErrorTest(POINT_VALID);
}

@Test
void testPointValidConvid() {
CICSTestUtils.noErrorTest(POINT_VALID_CONVID);
}

@Test
void testPointValidSession() {
CICSTestUtils.noErrorTest(POINT_VALID_SESSION);
}

@Test
void testPointInvalidDuplicateSession() {
CICSTestUtils.errorTest(
POINT_INVALID_DUPLICATE_SESSION,
ImmutableMap.of(
"errorOne",
new Diagnostic(
new Range(),
"Excessive options provided for: SESSION",
DiagnosticSeverity.Error,
ErrorSource.PARSING.getText())));
}

@Test
void testPointInvalidBothOptions() {
CICSTestUtils.errorTest(
POINT_INVALID_BOTH_OPTIONS,
ImmutableMap.of(
"errorOne",
new Diagnostic(
new Range(),
"Exactly one option required, options are mutually exclusive: CONVID or SESSION",
DiagnosticSeverity.Error,
ErrorSource.PARSING.getText()),
"errorTwo",
new Diagnostic(
new Range(),
"Exactly one option required, options are mutually exclusive: CONVID or SESSION",
DiagnosticSeverity.Error,
ErrorSource.PARSING.getText())));
}
}
Loading