diff --git a/src/main/java/com/ibm/northstar/SymbolTable.java b/src/main/java/com/ibm/northstar/SymbolTable.java index 4e4af8f9..8e68981f 100644 --- a/src/main/java/com/ibm/northstar/SymbolTable.java +++ b/src/main/java/com/ibm/northstar/SymbolTable.java @@ -3,6 +3,7 @@ import com.github.javaparser.ParseResult; import com.github.javaparser.Problem; import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.*; import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.FieldAccessExpr; @@ -10,6 +11,7 @@ import com.github.javaparser.ast.expr.NameExpr; import com.github.javaparser.ast.nodeTypes.NodeWithName; import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.type.ReferenceType; import com.github.javaparser.ast.type.Type; import com.github.javaparser.resolution.UnsolvedSymbolException; import com.github.javaparser.resolution.types.ResolvedType; @@ -222,7 +224,6 @@ private static EnumConstant processEnumConstantDeclaration(EnumConstantDeclarati return enumConstant; } - /** * Process parameter declarations on callables. * @@ -260,6 +261,13 @@ private static Pair processCallableDeclaration(CallableDeclara // add method or constructor modifiers callableNode.setModifiers((List) callableDecl.getModifiers().stream().map(mod -> mod.toString().strip()).collect(Collectors.toList())); + // add exceptions declared in "throws" clause + callableNode.setThrownExceptions( + ((NodeList)callableDecl.getThrownExceptions()) + .stream() + .map(SymbolTable::resolveType) + .collect(Collectors.toList())); + // add the complete declaration string, including modifiers, throws, and // parameter names callableNode.setDeclaration(callableDecl.getDeclarationAsString(true, true, true).strip()); @@ -427,8 +435,8 @@ private static String resolveExpression(Expression expression) { if (resolvedType.isReferenceType() || resolvedType.isUnionType()) { return resolvedType.describe(); } - } catch (UnsolvedSymbolException use) { - Log.warn("Could not resolve expression: "+expression+"\n"+use.getMessage()); + } catch (UnsolvedSymbolException | IllegalStateException exception) { + Log.warn("Could not resolve expression: "+expression+"\n"+exception.getMessage()); } return ""; } diff --git a/src/main/java/com/ibm/northstar/entities/Callable.java b/src/main/java/com/ibm/northstar/entities/Callable.java index 0e841c29..b623e991 100644 --- a/src/main/java/com/ibm/northstar/entities/Callable.java +++ b/src/main/java/com/ibm/northstar/entities/Callable.java @@ -9,6 +9,7 @@ public class Callable { private String comment; private List annotations; private List modifiers; + private List thrownExceptions; private String declaration; private List parameters; private String code;