rename constants
LAST_READ -> READ LAST_WRITTEN -> WRITTEN_AFTER_READ
This commit is contained in:
@@ -529,7 +529,7 @@ public class JetFlowInformationProvider {
|
||||
if (instruction instanceof WriteValueInstruction) {
|
||||
if (trace.get(CAPTURED_IN_CLOSURE, variableDescriptor) != null) return;
|
||||
JetElement element = ((WriteValueInstruction) instruction).getElement();
|
||||
if (variableUseState != LAST_READ) {
|
||||
if (variableUseState != READ) {
|
||||
if (element instanceof JetBinaryExpression &&
|
||||
((JetBinaryExpression) element).getOperationToken() == JetTokens.EQ) {
|
||||
JetExpression right = ((JetBinaryExpression) element).getRight();
|
||||
@@ -572,7 +572,7 @@ public class JetFlowInformationProvider {
|
||||
else if (variableUseState == ONLY_WRITTEN_NEVER_READ && JetPsiUtil.isVariableNotParameterDeclaration(element)) {
|
||||
report(Errors.ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE.on((JetNamedDeclaration) element, variableDescriptor), ctxt);
|
||||
}
|
||||
else if (variableUseState == LAST_WRITTEN && element instanceof JetVariableDeclaration) {
|
||||
else if (variableUseState == WRITTEN_AFTER_READ && element instanceof JetVariableDeclaration) {
|
||||
if (element instanceof JetProperty) {
|
||||
JetExpression initializer = ((JetProperty) element).getInitializer();
|
||||
if (initializer != null) {
|
||||
|
||||
@@ -257,7 +257,7 @@ public class PseudocodeVariablesData {
|
||||
}
|
||||
Map<VariableDescriptor, VariableUseState> exitResult = Maps.newHashMap(enterResult);
|
||||
if (instruction instanceof ReadValueInstruction) {
|
||||
exitResult.put(variableDescriptor, VariableUseState.LAST_READ);
|
||||
exitResult.put(variableDescriptor, VariableUseState.READ);
|
||||
}
|
||||
else { //instruction instanceof WriteValueInstruction
|
||||
VariableUseState variableUseState = enterResult.get(variableDescriptor);
|
||||
@@ -269,9 +269,9 @@ public class PseudocodeVariablesData {
|
||||
case ONLY_WRITTEN_NEVER_READ:
|
||||
exitResult.put(variableDescriptor, VariableUseState.ONLY_WRITTEN_NEVER_READ);
|
||||
break;
|
||||
case LAST_WRITTEN:
|
||||
case LAST_READ:
|
||||
exitResult.put(variableDescriptor, VariableUseState.LAST_WRITTEN);
|
||||
case WRITTEN_AFTER_READ:
|
||||
case READ:
|
||||
exitResult.put(variableDescriptor, VariableUseState.WRITTEN_AFTER_READ);
|
||||
}
|
||||
}
|
||||
return Edges.create(enterResult, exitResult);
|
||||
@@ -314,19 +314,19 @@ public class PseudocodeVariablesData {
|
||||
}
|
||||
|
||||
public static enum VariableUseState {
|
||||
LAST_READ(3),
|
||||
LAST_WRITTEN(2),
|
||||
READ(3),
|
||||
WRITTEN_AFTER_READ(2),
|
||||
ONLY_WRITTEN_NEVER_READ(1),
|
||||
UNUSED(0);
|
||||
|
||||
private final int importance;
|
||||
private final int priority;
|
||||
|
||||
VariableUseState(int importance) {
|
||||
this.importance = importance;
|
||||
VariableUseState(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
private VariableUseState merge(@Nullable VariableUseState variableUseState) {
|
||||
if (variableUseState == null || importance > variableUseState.importance) return this;
|
||||
if (variableUseState == null || priority > variableUseState.priority) return this;
|
||||
return variableUseState;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user