public Set<RelationalSymbolicValue> knownRelations() { if(knownRelations == null) { knownRelations = Collections.unmodifiableSet(getValuesWithConstraints(BooleanConstraint.TRUE) .stream() .filter(RelationalSymbolicValue.class::isInstance) .map(RelationalSymbolicValue.class::cast) .collect(Collectors.toSet())); } return knownRelations; }
public Set<RelationalSymbolicValue> knownRelations() { if(knownRelations == null) { knownRelations = Collections.unmodifiableSet(getValuesWithConstraints(BooleanConstraint.TRUE) .stream() .filter(RelationalSymbolicValue.class::isInstance) .map(RelationalSymbolicValue.class::cast) .collect(Collectors.toSet())); } return knownRelations; }
private static ProgramState removeNotConsumedConstraints(ProgramState programState) { ProgramState intermediateState = programState; for (SymbolicValue notConsumed : intermediateState.getValuesWithConstraints(StreamPipelineConstraint.NOT_CONSUMED)) { intermediateState = intermediateState.removeConstraintsOnDomain(notConsumed, StreamPipelineConstraint.class); } return intermediateState; }
private static ProgramState removeNotConsumedConstraints(ProgramState programState) { ProgramState intermediateState = programState; for (SymbolicValue notConsumed : intermediateState.getValuesWithConstraints(StreamPipelineConstraint.NOT_CONSUMED)) { intermediateState = intermediateState.removeConstraintsOnDomain(notConsumed, StreamPipelineConstraint.class); } return intermediateState; }
private static Set<SymbolicValue> symbolicValuesToReport(CheckerContext context) { List<SymbolicValue> openSymbolicValues = context.getState().getValuesWithConstraints(OPEN); Set<SymbolicValue> svToReport = new HashSet<>(openSymbolicValues); // report only outermost OPEN symbolic value for (SymbolicValue openSymbolicValue : openSymbolicValues) { if (openSymbolicValue instanceof ResourceWrapperSymbolicValue) { svToReport.remove(openSymbolicValue.wrappedValue()); } } return svToReport; }
private static Set<SymbolicValue> symbolicValuesToReport(CheckerContext context) { List<SymbolicValue> openSymbolicValues = context.getState().getValuesWithConstraints(OPEN); Set<SymbolicValue> svToReport = new HashSet<>(openSymbolicValues); // report only outermost OPEN symbolic value for (SymbolicValue openSymbolicValue : openSymbolicValues) { if (openSymbolicValue instanceof ResourceWrapperSymbolicValue) { svToReport.remove(openSymbolicValue.wrappedValue()); } } return svToReport; }
private void closeResultSetsRelatedTo(SymbolicValue value) { for (Map.Entry<SymbolicValue, ObjectConstraint> constrainedValue : programState.getValuesWithConstraints(Status.OPENED).entrySet()) { if (constrainedValue.getKey() instanceof ResourceWrapperSymbolicValue) { ResourceWrapperSymbolicValue rValue = (ResourceWrapperSymbolicValue) constrainedValue.getKey(); if (value.equals(rValue.dependent)) { programState = programState.addConstraint(rValue, constrainedValue.getValue().withStatus(Status.CLOSED)); } } } }
private void closeResultSetsRelatedTo(SymbolicValue value) { for (SymbolicValue constrainedValue : programState.getValuesWithConstraints(OPEN)) { if (constrainedValue instanceof ResourceWrapperSymbolicValue) { ResourceWrapperSymbolicValue rValue = (ResourceWrapperSymbolicValue) constrainedValue; if (value.equals(rValue.dependent)) { programState = programState.addConstraintTransitively(rValue, CLOSED); } } } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(LockConstraint.LOCKED).stream() .flatMap(lockedSv -> FlowComputation.flowWithoutExceptions(node, lockedSv, LockConstraint.LOCKED::equals, LockConstraint.UNLOCKED::equals, LOCK_CONSTRAINT_DOMAIN).stream()) .flatMap(Flow::firstFlowLocation) .forEach(this::reportIssue); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(LockConstraint.LOCKED).stream() .flatMap(lockedSv -> FlowComputation.flowWithoutExceptions(node, lockedSv, LockConstraint.LOCKED::equals, LockConstraint.UNLOCKED::equals, LOCK_CONSTRAINT_DOMAIN).stream()) .flatMap(Flow::firstFlowLocation) .forEach(this::reportIssue); }
private void closeResultSetsRelatedTo(SymbolicValue value) { for (SymbolicValue constrainedValue : programState.getValuesWithConstraints(OPEN)) { if (constrainedValue instanceof ResourceWrapperSymbolicValue) { ResourceWrapperSymbolicValue rValue = (ResourceWrapperSymbolicValue) constrainedValue; if (value.equals(rValue.dependent)) { programState = programState.addConstraintTransitively(rValue, CLOSED); } } } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitValue() instanceof SymbolicValue.ExceptionalSymbolicValue) { // don't report when exiting on exception return; } ProgramState state = context.getState(); List<SymbolicValue> notConsumed = state.getValuesWithConstraints(NOT_CONSUMED); notConsumed.forEach(sv -> { Set<Flow> flows = FlowComputation.flow(context.getNode(), Collections.singleton(sv), NOT_CONSUMED::equals, NOT_CONSUMED::equals, Collections.singletonList(StreamConsumedCheck.StreamPipelineConstraint.class), Collections.emptySet()); Flow flow = flows.iterator().next(); JavaFileScannerContext.Location location = flow.elements().get(0); reportIssue(location.syntaxNode, "Refactor the code so this stream pipeline is used."); }); } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitValue() instanceof SymbolicValue.ExceptionalSymbolicValue) { // don't report when exiting on exception return; } ProgramState state = context.getState(); List<SymbolicValue> notConsumed = state.getValuesWithConstraints(NOT_CONSUMED); notConsumed.forEach(sv -> { Set<Flow> flows = FlowComputation.flow(context.getNode(), Collections.singleton(sv), NOT_CONSUMED::equals, NOT_CONSUMED::equals, Collections.singletonList(StreamConsumedCheck.StreamPipelineConstraint.class), Collections.emptySet()); Flow flow = flows.iterator().next(); JavaFileScannerContext.Location location = flow.elements().get(0); reportIssue(location.syntaxNode, "Refactor the code so this stream pipeline is used."); }); } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(OPENED).forEach(sv -> processUnclosedSymbolicValue(node, sv)); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(OPENED).forEach(sv -> processUnclosedSymbolicValue(node, sv)); }