|
7 | 7 | import org.apache.logging.log4j.Logger; |
8 | 8 | import org.eclipse.jdt.core.dom.ASTVisitor; |
9 | 9 | import org.eclipse.jdt.core.dom.CompilationUnit; |
| 10 | +import org.eclipse.jdt.core.dom.ITypeBinding; |
10 | 11 | import org.eclipse.jdt.core.dom.MethodDeclaration; |
| 12 | +import org.eclipse.jdt.core.dom.SingleVariableDeclaration; |
11 | 13 | import org.eclipse.jdt.core.dom.Type; |
12 | 14 |
|
13 | 15 | import ca.concordia.jtratch.pattern.ThrowsBlock; |
| 16 | +import ca.concordia.jtratch.utility.ASTUtilities; |
14 | 17 |
|
15 | 18 | public class MethodDeclarationVisitor extends ASTVisitor{ |
16 | 19 | List<ThrowsBlock> throwsList = new ArrayList<ThrowsBlock>(); |
@@ -51,7 +54,23 @@ public void evaluateThrownExceptionTypes (MethodDeclaration node, int size) { |
51 | 54 | { |
52 | 55 | ThrowsBlock throwsBlockInfo = new ThrowsBlock(); |
53 | 56 | 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 | + |
55 | 74 | Integer startLine = tree.getLineNumber(node.getStartPosition() + 1); |
56 | 75 | Integer endLine = tree.getLineNumber(node.getStartPosition() + node.getLength() + 1); |
57 | 76 |
|
|
0 commit comments