use of org.sonar.java.se.ProgramState.SymbolicValueSymbol in project sonar-java by SonarSource.
the class RedundantAssignmentsCheck method handleAssignment.
private void handleAssignment(CheckerContext context, AssignmentExpressionTree assignmentExpressionTree) {
SymbolicValueSymbol assignedVariable = context.getState().peekValueSymbol();
Symbol assignedSymbol = assignedVariable.symbol();
if (assignedSymbol == null || // meaning that 'stream = stream.map(...);' would be detected as redundant assignment if not explicitly excluded
STREAM_TYPES.stream().anyMatch(assignedSymbol.type()::is)) {
return;
}
ExplodedGraph.Node node = context.getNode();
ProgramState previousState = node.programState;
SymbolicValue oldValue = previousState.getValue(assignedSymbol);
SymbolicValue newValue = assignedVariable.symbolicValue();
Symbol fromSymbol = previousState.peekValueSymbol().symbol();
assignmentsByMethod.peek().put(assignmentExpressionTree, new AssignmentDataHolder(assignedSymbol, oldValue, newValue, fromSymbol, node));
}
Aggregations