@Override public void visitMethodInvocation(MethodInvocationTree syntaxNode) { final ExpressionTree methodSelect = syntaxNode.methodSelect(); if (isClosingResource(syntaxNode.symbol())) { if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { final ExpressionTree targetExpression = ((MemberSelectExpressionTree) methodSelect).expression(); if (targetExpression.is(Tree.Kind.IDENTIFIER)) { final IdentifierTree identifier = (IdentifierTree) targetExpression; programState = closeResource(programState, programState.getValue(identifier.symbol())); } else { programState = closeResource(programState, programState.peekValue()); } } } else if (syntaxNode.methodSelect().is(Tree.Kind.MEMBER_SELECT) && isOpeningResultSet(syntaxNode.symbol())) { final SymbolicValue value = getTargetValue(syntaxNode); constraintManager.setValueFactory(new WrappedValueFactory(value)); } else if (isClosingResultSets(syntaxNode.symbol())) { if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { final SymbolicValue value = getTargetValue(syntaxNode); closeResultSetsRelatedTo(value); } } else { closeArguments(syntaxNode.arguments(), 1); } }
@Override public void visitNewClass(NewClassTree syntaxNode) { final List<SymbolicValue> arguments = programState.peekValues(syntaxNode.arguments().size()); if (isOpeningResource(syntaxNode)) { Iterator<SymbolicValue> iterator = arguments.iterator(); for (ExpressionTree argument : syntaxNode.arguments()) { if (!iterator.hasNext()) { throw new IllegalStateException( "Mismatch between declared constructor arguments and argument values!"); } final Type type = argument.symbolType(); final SymbolicValue value = iterator.next(); if (isCloseable(type)) { constraintManager.setValueFactory(new WrappedValueFactory(value)); break; } } } else { closeArguments(syntaxNode.arguments(), 0); } }