Skip to content

Commit 496d684

Browse files
committed
icpc cr get kind for the exceptions in throws block
1 parent 6f76687 commit 496d684

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/main/java/ca/concordia/jtratch/pattern/ThrowsBlock.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public class ThrowsBlock extends CommonFeature {
1010

1111
public ThrowsBlock()
1212
{
13+
OperationFeatures.put("Binded", -9);
14+
OperationFeatures.put("RecoveredBinding", -9);
15+
OperationFeatures.put("Kind", -9);
16+
1317
OperationFeatures.put("Line", 0);
1418
OperationFeatures.put("LOC", 0);
1519
OperationFeatures.put("Start", 0);

src/main/java/ca/concordia/jtratch/visitors/MethodDeclarationVisitor.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
import org.apache.logging.log4j.Logger;
88
import org.eclipse.jdt.core.dom.ASTVisitor;
99
import org.eclipse.jdt.core.dom.CompilationUnit;
10+
import org.eclipse.jdt.core.dom.ITypeBinding;
1011
import org.eclipse.jdt.core.dom.MethodDeclaration;
12+
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
1113
import org.eclipse.jdt.core.dom.Type;
1214

1315
import ca.concordia.jtratch.pattern.ThrowsBlock;
16+
import ca.concordia.jtratch.utility.ASTUtilities;
1417

1518
public class MethodDeclarationVisitor extends ASTVisitor{
1619
List<ThrowsBlock> throwsList = new ArrayList<ThrowsBlock>();
@@ -51,7 +54,23 @@ public void evaluateThrownExceptionTypes (MethodDeclaration node, int size) {
5154
{
5255
ThrowsBlock throwsBlockInfo = new ThrowsBlock();
5356
throwsBlockInfo.ExceptionType = type.toString();
54-
57+
58+
ITypeBinding exceptionTypeBinding = type.resolveBinding();
59+
60+
//Binding info:
61+
if(exceptionTypeBinding != null)
62+
{
63+
throwsBlockInfo.ExceptionType = exceptionTypeBinding.getQualifiedName();
64+
throwsBlockInfo.OperationFeatures.put("Binded", 1);
65+
throwsBlockInfo.OperationFeatures.put("RecoveredBinding", exceptionTypeBinding.isRecovered() ? 1 : 0 );
66+
int kind = ASTUtilities.findKind(exceptionTypeBinding, tree);
67+
throwsBlockInfo.OperationFeatures.put("Kind", kind);
68+
} else
69+
{
70+
throwsBlockInfo.ExceptionType = type.toString();
71+
throwsBlockInfo.OperationFeatures.put("Binded", 0);
72+
}
73+
5574
Integer startLine = tree.getLineNumber(node.getStartPosition() + 1);
5675
Integer endLine = tree.getLineNumber(node.getStartPosition() + node.getLength() + 1);
5776

0 commit comments

Comments
 (0)