Skip to content

Commit

Permalink
feat: Support regular cobol statement for CCF processing (#2422)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurkambay authored Aug 7, 2024
1 parent 4a97756 commit 485806e
Show file tree
Hide file tree
Showing 22 changed files with 826 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
* The extensions should encapsulate the logic of all the applicable semantic checks.
*/
@Slf4j
public abstract class StatementNode extends Node {
public class StatementNode extends Node {

protected StatementNode(Locality locality) {
public StatementNode(Locality locality) {
super(locality, STATEMENT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ private void traverse(CFASTNode parent, Node node) {
node.getChildren().forEach(child -> traverse(parent, child));
addChild(parent, new CFASTNode(CFASTNodeType.END_ON.getValue(), convertLocation(node)));
} else if (node instanceof StatementNode) {
addChild(parent, new CFASTNode(CFASTNodeType.STATEMENT.getValue(), convertLocation(node)));
node.getChildren().forEach(child -> traverse(parent, child));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public enum CFASTNodeType {
XML_PARSE("xmlparse"),
END_XML("endxml"),
USE("use"),
USE_FOR_DEBUGGING("usefordebugging");
USE_FOR_DEBUGGING("usefordebugging"),
STATEMENT("statement");

@Getter final String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.lsp.cobol.common.model.tree.statements.SetToBooleanStatement;
import org.eclipse.lsp.cobol.common.model.tree.statements.SetToOnOffStatement;
import org.eclipse.lsp.cobol.common.model.tree.statements.SetUpDownByStatement;
import org.eclipse.lsp.cobol.common.model.tree.statements.StatementNode;
import org.eclipse.lsp.cobol.common.model.tree.variable.*;
import org.eclipse.lsp.cobol.common.model.tree.variable.VariableDefinitionNode.Builder;
import org.eclipse.lsp.cobol.common.model.variables.DivisionType;
Expand Down Expand Up @@ -1264,6 +1265,186 @@ public List<Node> visitAlterStatement(CobolParser.AlterStatementContext ctx) {
return visitChildren(ctx);
}

@Override
public List<Node> visitAcceptStatement(CobolParser.AcceptStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitAddStatement(CobolParser.AddStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitAllocateStatement(CobolParser.AllocateStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitCancelStatement(CobolParser.CancelStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitCloseStatement(CobolParser.CloseStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitComputeStatement(CobolParser.ComputeStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitContinueStatement(CobolParser.ContinueStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitDisableStatement(CobolParser.DisableStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitDisplayStatement(CobolParser.DisplayStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitDivideStatement(CobolParser.DivideStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitEnableStatement(CobolParser.EnableStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitEntryStatement(CobolParser.EntryStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitExhibitStatement(CobolParser.ExhibitStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitFreeStatement(CobolParser.FreeStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitGenerateStatement(CobolParser.GenerateStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitInitializeStatement(CobolParser.InitializeStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitInitiateStatement(CobolParser.InitiateStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitInspectStatement(CobolParser.InspectStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitMoveStatement(CobolParser.MoveStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitMultiplyStatement(CobolParser.MultiplyStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitOpenStatement(CobolParser.OpenStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitPurgeStatement(CobolParser.PurgeStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitReadyResetTraceStatement(CobolParser.ReadyResetTraceStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitReceiveStatement(CobolParser.ReceiveStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitReleaseStatement(CobolParser.ReleaseStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitReturnStatement(CobolParser.ReturnStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitSearchStatement(CobolParser.SearchStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitSendStatement(CobolParser.SendStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitServiceReloadStatement(CobolParser.ServiceReloadStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitServiceLabelStatement(CobolParser.ServiceLabelStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitSetStatement(CobolParser.SetStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitStringStatement(CobolParser.StringStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitSubtractStatement(CobolParser.SubtractStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitTerminateStatement(CobolParser.TerminateStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitUnstringStatement(CobolParser.UnstringStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

@Override
public List<Node> visitJsonStatement(CobolParser.JsonStatementContext ctx) {
return addTreeNode(ctx, StatementNode::new);
}

private ProcedureName parseProcedureName(CobolParser.ProcedureNameContext procedureNameContext) {
if (procedureNameContext == null) {
return null;
Expand Down
50 changes: 48 additions & 2 deletions server/engine/src/test/resources/cfast/case3.result.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
}
},
"children": [
{
"type": "statement",
"location": {
"uri": "fake/path",
"start": {
"line": 16,
"character": 12
},
"end": {
"line": 16,
"character": 25
}
}
},
{
"snippet": "PARAG1.\r\n DISPLAY \u0027PARAG1\u0027.",
"name": "PARAG1",
Expand All @@ -28,7 +42,23 @@
"line": 18,
"character": 29
}
}
},
"children": [
{
"type": "statement",
"location": {
"uri": "fake/path",
"start": {
"line": 18,
"character": 12
},
"end": {
"line": 18,
"character": 28
}
}
}
]
},
{
"snippet": "PARAG2.\r\n DISPLAY \u0027PARAG2\u0027.",
Expand All @@ -44,7 +74,23 @@
"line": 20,
"character": 29
}
}
},
"children": [
{
"type": "statement",
"location": {
"uri": "fake/path",
"start": {
"line": 20,
"character": 12
},
"end": {
"line": 20,
"character": 28
}
}
}
]
}
]
}
Expand Down
46 changes: 45 additions & 1 deletion server/engine/src/test/resources/cfast/case4.result.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
}
},
"children": [
{
"type": "statement",
"location": {
"uri": "fake/path",
"start": {
"line": 16,
"character": 12
},
"end": {
"line": 16,
"character": 25
}
}
},
{
"targetName": [
"PARAG1"
Expand Down Expand Up @@ -47,6 +61,20 @@
}
},
"children": [
{
"type": "statement",
"location": {
"uri": "fake/path",
"start": {
"line": 19,
"character": 12
},
"end": {
"line": 19,
"character": 28
}
}
},
{
"targetName": "PARAG2",
"type": "perform",
Expand Down Expand Up @@ -78,7 +106,23 @@
"line": 22,
"character": 29
}
}
},
"children": [
{
"type": "statement",
"location": {
"uri": "fake/path",
"start": {
"line": 22,
"character": 12
},
"end": {
"line": 22,
"character": 28
}
}
}
]
}
]
}
Expand Down
Loading

0 comments on commit 485806e

Please sign in to comment.