Skip to content

Commit f740063

Browse files
committed
Correcting Issue #17, some more workds needs to be done for other keywords
1 parent cc0f87b commit f740063

File tree

9 files changed

+22
-14
lines changed

9 files changed

+22
-14
lines changed

Code/Library/GraphBuilder/BreakBuilder.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ public void CreateSpecialEdge()
5656
if (node.label == null)
5757
{
5858
breakablenode = node.FindNodesUp(x => x is ForeachNode || x is WhileNode || x is DoWhileNode || x is DoUntilNode || x is ForNode || x is SwitchNode);
59-
specialedge = new DotEdge(node.Id,breakablenode.GetNextId());
60-
specialedge.Label = $"Break From {node.Label}";
6159

60+
// New fix for Issue #17
61+
if (breakablenode == null){
62+
specialedge = new DotEdge(node.Id,"end_of_script");
63+
} else {
64+
specialedge = new DotEdge(node.Id,breakablenode.GetNextId());
65+
specialedge.Label = $"Break From {node.Label}";
66+
}
6267
} else {
6368
breakablenode = node.FindNodesUp(x => x.label == node.label);
6469
specialedge = new DotEdge(node.Id,breakablenode.GetNextId());

Code/Library/Nodes - Keywords/BreakNode.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ public class BreakNode : Node
1111
public string Label { get => label;}
1212
internal override int OffSetStatementStart {get => RawAst.Extent.StartOffset-OffSetToRemove;}
1313

14-
public BreakNode(BreakStatementAst _ast, int _depth, int _position, Node _parent)
14+
public BreakNode(BreakStatementAst _ast, int _depth, int _position, Node _parent, Tree _tree)
1515
{
1616
name = "BreakNode";
1717
position = _position;
1818
depth = _depth;
1919
parent = _parent;
2020
RawAst = _ast;
21+
parentroot = _tree;
2122
SetLabel();
2223

2324
}

Code/Library/Nodes - Keywords/ContinueNode.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ public class ContinueNode : Node
1111
public string Label { get => label;}
1212
internal override int OffSetStatementStart {get => RawAst.Extent.StartOffset-OffSetToRemove;}
1313

14-
public ContinueNode(ContinueStatementAst _ast, int _depth, int _position, Node _parent)
14+
public ContinueNode(ContinueStatementAst _ast, int _depth, int _position, Node _parent, Tree _tree)
1515
{
1616
name = "ContinueNode";
1717
position = _position;
1818
depth = _depth;
1919
parent = _parent;
2020
RawAst = _ast;
21+
parentroot = _tree;
2122

2223
SetLabel();
2324

Code/Library/Nodes - Keywords/ExitNode.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ public class ExitNode : Node
1111
public string Label { get => label;}
1212
internal override int OffSetStatementStart {get => RawAst.Extent.StartOffset-OffSetToRemove;}
1313

14-
public ExitNode(ExitStatementAst _ast, int _depth, int _position, Node _parent)
14+
public ExitNode(ExitStatementAst _ast, int _depth, int _position, Node _parent, Tree _tree)
1515
{
1616
name = "ExitNode";
1717
position = _position;
1818
depth = _depth;
1919
parent = _parent;
2020
RawAst = _ast;
21+
parentroot = _tree;
2122

2223
}
2324

Code/Library/extension.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public static Node CreateNode (this Ast _ast, int _depth, int _position, Node _p
3434
case Ast a when _ast is CatchClauseAst :
3535
return ((CatchClauseAst)_ast).CreateNodeFromAst(_depth, _position, _parent);
3636
case Ast a when _ast is BreakStatementAst :
37-
return ((BreakStatementAst)_ast).CreateNodeFromAst(_depth, _position, _parent);
37+
return ((BreakStatementAst)_ast).CreateNodeFromAst(_depth, _position, _parent, _tree);
3838
case Ast a when _ast is ContinueStatementAst :
39-
return ((ContinueStatementAst)_ast).CreateNodeFromAst(_depth, _position, _parent);
39+
return ((ContinueStatementAst)_ast).CreateNodeFromAst(_depth, _position, _parent, _tree);
4040
case Ast a when _ast is ExitStatementAst :
41-
return ((ExitStatementAst)_ast).CreateNodeFromAst(_depth, _position, _parent);
41+
return ((ExitStatementAst)_ast).CreateNodeFromAst(_depth, _position, _parent, _tree);
4242
case Ast a when _ast is PipelineAst :
4343
return ((PipelineAst)_ast).CreateNodeFromAst(_depth, _position, _parent, _tree);
4444
}
@@ -79,9 +79,9 @@ public static class ExitStatementExtension {
7979
// New Methods Available:
8080
// - CreateNodeFromAST(NodeDepth, NodePosition, Parent) => Creates a Node
8181
// - GetChildAst() => retourne only ASTs we are looking for ...
82-
public static ExitNode CreateNodeFromAst(this ExitStatementAst _ast,int _depth, int _position, Node _parent)
82+
public static ExitNode CreateNodeFromAst(this ExitStatementAst _ast,int _depth, int _position, Node _parent, Tree _tree)
8383
{
84-
return new ExitNode(_ast,_depth, _position, _parent);
84+
return new ExitNode(_ast,_depth, _position, _parent,_tree);
8585
}
8686

8787
}
@@ -91,9 +91,9 @@ public static class ContinueStatementExtension {
9191
// New Methods Available:
9292
// - CreateNodeFromAST(NodeDepth, NodePosition, Parent) => Creates a Node
9393
// - GetChildAst() => retourne only ASTs we are looking for ...
94-
public static ContinueNode CreateNodeFromAst(this ContinueStatementAst _ast,int _depth, int _position, Node _parent)
94+
public static ContinueNode CreateNodeFromAst(this ContinueStatementAst _ast,int _depth, int _position, Node _parent, Tree _tree)
9595
{
96-
return new ContinueNode(_ast,_depth, _position, _parent);
96+
return new ContinueNode(_ast,_depth, _position, _parent,_tree);
9797
}
9898

9999
}
@@ -103,9 +103,9 @@ public static class BreakStatementExtension {
103103
// New Methods Available:
104104
// - CreateNodeFromAST(NodeDepth, NodePosition, Parent) => Creates a Node
105105
// - GetChildAst() => retourne only ASTs we are looking for ...
106-
public static BreakNode CreateNodeFromAst(this BreakStatementAst _ast,int _depth, int _position, Node _parent)
106+
public static BreakNode CreateNodeFromAst(this BreakStatementAst _ast,int _depth, int _position, Node _parent, Tree _tree)
107107
{
108-
return new BreakNode(_ast,_depth, _position, _parent);
108+
return new BreakNode(_ast,_depth, _position, _parent,_tree);
109109
}
110110

111111
}
0 Bytes
Binary file not shown.
52 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
52 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)