Skip to content

Commit

Permalink
icpc cr get kind for the exceptions in throws block
Browse files Browse the repository at this point in the history
  • Loading branch information
guipadua committed Mar 27, 2017
1 parent 6f76687 commit 496d684
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/ca/concordia/jtratch/pattern/ThrowsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class ThrowsBlock extends CommonFeature {

public ThrowsBlock()
{
OperationFeatures.put("Binded", -9);
OperationFeatures.put("RecoveredBinding", -9);
OperationFeatures.put("Kind", -9);

OperationFeatures.put("Line", 0);
OperationFeatures.put("LOC", 0);
OperationFeatures.put("Start", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
import org.apache.logging.log4j.Logger;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Type;

import ca.concordia.jtratch.pattern.ThrowsBlock;
import ca.concordia.jtratch.utility.ASTUtilities;

public class MethodDeclarationVisitor extends ASTVisitor{
List<ThrowsBlock> throwsList = new ArrayList<ThrowsBlock>();
Expand Down Expand Up @@ -51,7 +54,23 @@ public void evaluateThrownExceptionTypes (MethodDeclaration node, int size) {
{
ThrowsBlock throwsBlockInfo = new ThrowsBlock();
throwsBlockInfo.ExceptionType = type.toString();


ITypeBinding exceptionTypeBinding = type.resolveBinding();

//Binding info:
if(exceptionTypeBinding != null)
{
throwsBlockInfo.ExceptionType = exceptionTypeBinding.getQualifiedName();
throwsBlockInfo.OperationFeatures.put("Binded", 1);
throwsBlockInfo.OperationFeatures.put("RecoveredBinding", exceptionTypeBinding.isRecovered() ? 1 : 0 );
int kind = ASTUtilities.findKind(exceptionTypeBinding, tree);
throwsBlockInfo.OperationFeatures.put("Kind", kind);
} else
{
throwsBlockInfo.ExceptionType = type.toString();
throwsBlockInfo.OperationFeatures.put("Binded", 0);
}

Integer startLine = tree.getLineNumber(node.getStartPosition() + 1);
Integer endLine = tree.getLineNumber(node.getStartPosition() + node.getLength() + 1);

Expand Down

0 comments on commit 496d684

Please sign in to comment.