Skip to content

Commit c0c117c

Browse files
committed
Changed If Else Functioanlity
1 parent 8acb5a2 commit c0c117c

File tree

2 files changed

+90
-7
lines changed

2 files changed

+90
-7
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package Flow;
2+
3+
4+
5+
public class TestFlowIfElse {
6+
7+
8+
9+
10+
11+
public static void main(String args[])
12+
{
13+
int a=13;
14+
int b=12;
15+
16+
if(a>b)
17+
{
18+
System.out.println("Inside IF");
19+
if(a>b)
20+
{
21+
System.getenv();
22+
}
23+
else
24+
{
25+
System.console();
26+
}
27+
28+
29+
}
30+
else if(a==b)
31+
{
32+
System.exit(0);
33+
//System.out.println("Inside ELSEIF");
34+
35+
36+
}
37+
else
38+
{
39+
System.currentTimeMillis();
40+
41+
42+
}
43+
44+
45+
46+
47+
48+
49+
50+
}
51+
}
52+
53+
54+

javacodeanalyzer/src/astparsing/BaselineBugramVisitor.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public void setTrace(String trace_elemt)
3636

3737
public void addTOTrace(String trace_elemt)
3838
{
39-
System.out.println(trace_elemt);
4039
System.out.println(trace_elemt);
4140
if(trace_elemt.contains("::UNRESOLVEBLK::"))
4241
{
@@ -72,6 +71,7 @@ public boolean visit( ClassInstanceCreation node)
7271
this.addTOTrace(trace_elemt);
7372
}
7473
return super.visit(node);
74+
//return false;
7575
}
7676

7777
public boolean visit(ConstructorInvocation node)
@@ -188,20 +188,49 @@ public boolean visit(TryStatement node)
188188
public boolean visit(IfStatement node)
189189
{
190190
try
191-
{
192-
String trace_elemt="<IF>,";
193-
194-
this.addTOTrace(trace_elemt);
191+
{
192+
IfStatement ifstmt = (IfStatement) node;
193+
Statement thenStatement = ifstmt.getThenStatement();
194+
Statement elseStatement = ifstmt.getElseStatement();
195+
Expression condition = ifstmt.getExpression();
196+
//System.out.println(ifstmt.getParent().getClass());
197+
String trace_elemt="";
198+
//if(!ifstmt.getParent().getClass().toString().equals("class org.eclipse.jdt.core.dom.IfStatement"))
199+
if(1==1)
200+
{
201+
202+
trace_elemt="<IF>,";
203+
this.addTOTrace(trace_elemt);
204+
205+
}
206+
if(thenStatement!=null)
207+
{
208+
thenStatement.accept(this);
209+
//this.addTOTrace(trace_elemt);
210+
}
211+
212+
if(elseStatement!=null)
213+
{
214+
trace_elemt="<ELSE>,";
215+
this.addTOTrace(trace_elemt);
216+
elseStatement.accept(this);
217+
}
218+
//elseStatement.accept(this);
219+
220+
//this.addTOTrace(trace_elemt);
195221

196222
}
197223
catch (Exception e)
198224
{
199225
// TODO: handle exception
200226
String trace_elemt="::UNRESOLVEBLK:: if statement::UNRESOLVEBLK:: "+ node.toString();
201227

202-
this.addTOTrace(trace_elemt);
228+
this.addTOTrace(trace_elemt);
203229
}
204-
return super.visit(node);
230+
//return super.visit(node);
231+
//return !(ifStatement.getThenStatement() instanceof Block)
232+
// && !(ifStatement.getElseStatement() instanceof Block);
233+
return false;
205234
}
206235

207236

0 commit comments

Comments
 (0)