Skip to content

Commit cbcd098

Browse files
authored
feat: Add CCF support for CICS RETURN statement (#2229)
1 parent 0c9717d commit cbcd098

File tree

6 files changed

+56
-3
lines changed

6 files changed

+56
-3
lines changed

server/engine/src/main/java/org/eclipse/lsp/cobol/cfg/CFASTBuilderImpl.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.eclipse.lsp.cobol.common.model.tree.statements.StatementNode;
1919
import org.eclipse.lsp.cobol.common.model.variables.DivisionType;
2020
import org.eclipse.lsp.cobol.core.model.extendedapi.*;
21+
import org.eclipse.lsp.cobol.implicitDialects.cics.nodes.ExecCicsNode;
2122
import org.eclipse.lsp4j.Position;
2223
import org.eclipse.lsp4j.Range;
2324

@@ -107,6 +108,11 @@ private void traverse(CFASTNode parent, Node node) {
107108
addChild(parent, new CFASTNode(CFASTNodeType.EXIT.getValue(), convertLocation(node)));
108109
} else if (node instanceof GoBackNode) {
109110
addChild(parent, new CFASTNode(CFASTNodeType.GOBACK.getValue(), convertLocation(node)));
111+
} else if (node instanceof ExecCicsNode) {
112+
ExecCicsNode execCicsNode = (ExecCicsNode) node;
113+
if (execCicsNode.isStopRun()) {
114+
addChild(parent, new CFASTNode(CFASTNodeType.STOP.getValue(), convertLocation(node)));
115+
}
110116
} else if (node instanceof StopNode) {
111117
addChild(parent, new CFASTNode(CFASTNodeType.STOP.getValue(), convertLocation(node)));
112118
} else if (node instanceof ParagraphsNode || node instanceof ProcedureDivisionBodyNode) {

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public List<Node> visitQualifiedDataName(CICSParser.QualifiedDataNameContext ctx
7979
public List<Node> visitCicsExecBlock(CICSParser.CicsExecBlockContext ctx) {
8080
areaBWarning(ctx);
8181
addReplacementContext(ctx);
82-
return addTreeNode(ctx, locality -> new ExecCicsNode(locality, STATEMENT, CICSDialect.DIALECT_NAME));
82+
83+
boolean stopRun = (ctx.allCicsRule() != null && ctx.allCicsRule().size() > 0 && ctx.allCicsRule().get(0).cics_return() != null);
84+
return addTreeNode(ctx, locality -> new ExecCicsNode(locality, STATEMENT, CICSDialect.DIALECT_NAME, stopRun));
8385
}
8486

8587
@Override

server/engine/src/main/java/org/eclipse/lsp/cobol/implicitDialects/cics/nodes/ExecCicsNode.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@
1515

1616
package org.eclipse.lsp.cobol.implicitDialects.cics.nodes;
1717

18+
import lombok.Getter;
1819
import org.eclipse.lsp.cobol.common.model.Locality;
1920
import org.eclipse.lsp.cobol.common.model.NodeType;
2021
import org.eclipse.lsp.cobol.common.model.tree.Node;
2122

2223
/** EXEC CICS block node */
2324
public class ExecCicsNode extends Node {
24-
public ExecCicsNode(Locality location, NodeType nodeType, String dialect) {
25+
26+
@Getter
27+
private final boolean stopRun;
28+
29+
public ExecCicsNode(Locality location, NodeType nodeType, String dialect, boolean stopRun) {
2530
super(location, nodeType, dialect);
31+
this.stopRun = stopRun;
2632
}
2733
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. CBACT01C.
3+
PROCEDURE DIVISION.
4+
EXEC CICS HANDLE ABEND
5+
END-EXEC.
6+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"name": "CBACT01C",
4+
"type": "program",
5+
"location": {
6+
"uri": "fake/path",
7+
"start": {
8+
"line": 3,
9+
"character": 9
10+
},
11+
"end": {
12+
"line": 5,
13+
"character": 21
14+
}
15+
}
16+
}
17+
]

server/engine/src/test/resources/cfast/case_execCicsReturn.result.json

+17-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212
"line": 4,
1313
"character": 30
1414
}
15-
}
15+
},
16+
"children": [
17+
{
18+
"type": "stop",
19+
"location": {
20+
"uri": "fake/path",
21+
"start": {
22+
"line": 4,
23+
"character": 13
24+
},
25+
"end": {
26+
"line": 4,
27+
"character": 29
28+
}
29+
}
30+
}
31+
]
1632
}
1733
]

0 commit comments

Comments
 (0)