Skip to content

Fix cics extract #2463

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
merged 40 commits into from
Sep 19, 2024
Merged

Conversation

chacebot
Copy link
Contributor

@chacebot chacebot commented Sep 4, 2024

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • TestCICSExtract.java
  • Test required args against compiler

Checklist:

  • Each of my commits contains one meaningful change
  • I have performed rebase of my branch on top of the development
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

@chacebot chacebot marked this pull request as draft September 9, 2024 16:22
@chacebot
Copy link
Contributor Author

chacebot commented Sep 9, 2024

Drafted to wait for #2464

@chacebot chacebot marked this pull request as ready for review September 11, 2024 13:25
@chacebot
Copy link
Contributor Author

@slavek-kucera

checkHasMutuallyExclusiveOptions("INTO or SET", ctx.INTO(), ctx.SET());
if (!ctx.SET().isEmpty())
checkHasExactlyOneOption("LENGTH or FLENGTH", ctx, ctx.cics_length_flength());
checkHasMutuallyExclusiveOptions("MAXLENGTH or MAXFLENGTH", ctx.cics_maxlength());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be checkCicsMaxlength function, that internally calls checkHasMutuallyExclusiveOptions("...", ctx.MAXLENGTH(), ctx.MAXDLENGTH())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach allows the use of getClass() that you mentioned above. Will try it out and change the generic List<E> to be a List<TerminalNode>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chacebot, see how I did it here: 1e19608

if (ctx.FROM().isEmpty()) checkHasIllegalOptions(ctx.LENGTH(), "LENGTH");
if (ctx.TERMINAL().isEmpty()) checkHasIllegalOptions(ctx.INPARTN(), "INPARTN");
if (ctx.FROM().isEmpty()) checkHasIllegalOptions(ctx.LENGTH(), "LENGTH without FROM");
checkHasMutuallyExclusiveOptions("INTO or SET", ctx.cics_into_set());
Copy link
Contributor

@slavek-kucera slavek-kucera Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something similar here, I'd expect checkIntoSet(ctx.cics_into_set()) and then in it, length check + checkHasMutuallyExclusiveOptions("...", ctx.get(0).INTO(), ctx.get(0).SET())

or maybe the forEach approach as in the ISSUE command.

@slavek-kucera slavek-kucera merged commit 2494159 into eclipse-che4z:development Sep 19, 2024
17 checks passed

// Only raise error if this validates mutual exclusivity and is not an artifact of duplicate
// options
if (!nodes.stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were not allowed to use Stream due to it being Java 9?


List<TerminalNode> children = new ArrayList<>();

Stream.of(rules)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More use of Stream

* @param rules Lists of TerminalNode to iterate through
* @return Number of TerminalNode instances found
*/
protected int checkHasMutuallyExclusiveOptions(String options, List<TerminalNode>... rules) {
Copy link
Contributor

@mm-broadcom mm-broadcom Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No generic and check for class? What about if we want to enforce sets of ParserRuleContext variables inconjunction with TerminalNodes as well?

I had the best of both worlds set up, but the PRs are going slowly. See my commit here: development...mm-broadcom:che-che4z-lsp-for-cobol:CICS-WEB-Command-Fix-V2#diff-50eac5e66277f894df3f0b69a3d008dfc1aa9d9f0460c5c3c1b5ff41898af1f7R203

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mm-broadcom - We kinda landed on the idea of using a custom checkXYZContext() for all custom context's in the CheckXYZOptionsCheckUtility subclasses where we "unpack" each context manually for mutual exclusivity. However, checkHasExactlyOneOption() persists the usage of mixed type passing for both TerminalNodes and ParserRuleContexts

ap891843 pushed a commit that referenced this pull request Mar 14, 2025
adds mutually exclusive options checking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants