Use OperatorNameConventions constants instead of hardcoded literals

This commit is contained in:
Alexander Udalov
2016-11-02 13:18:47 +03:00
parent 61767bb0ea
commit 0d4bd2a673
8 changed files with 23 additions and 15 deletions
@@ -57,6 +57,7 @@ import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils.*
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
import org.jetbrains.kotlin.util.OperatorNameConventions
import java.util.*
class ControlFlowInformationProvider private constructor(
@@ -647,13 +648,13 @@ class ControlFlowInformationProvider private constructor(
val functionDescriptor =
trace.get(DECLARATION_TO_DESCRIPTOR, owner) as? FunctionDescriptor
?: throw AssertionError(owner.text)
val functionName = functionDescriptor.name.asString()
val functionName = functionDescriptor.name
if (isMain
|| functionDescriptor.isOverridableOrOverrides
|| owner.hasModifier(KtTokens.OVERRIDE_KEYWORD)
|| "getValue" == functionName
|| "setValue" == functionName
|| "propertyDelegated" == functionName) {
|| OperatorNameConventions.GET_VALUE == functionName
|| OperatorNameConventions.SET_VALUE == functionName
|| OperatorNameConventions.PROPERTY_DELEGATED == functionName) {
return
}
report(UNUSED_PARAMETER.on(element, variableDescriptor), ctxt)
@@ -257,7 +257,7 @@ public class CallResolver {
Call.CallType callType = context.call.getCallType();
if (callType == Call.CallType.ARRAY_GET_METHOD || callType == Call.CallType.ARRAY_SET_METHOD) {
Name name = Name.identifier(callType == Call.CallType.ARRAY_GET_METHOD ? "get" : "set");
Name name = callType == Call.CallType.ARRAY_GET_METHOD ? OperatorNameConventions.GET : OperatorNameConventions.SET;
KtArrayAccessExpression arrayAccessExpression = (KtArrayAccessExpression) context.call.getCallElement();
return computeTasksAndResolveCall(
context, name, arrayAccessExpression,
@@ -1691,7 +1691,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
? CallMaker.makeArrayGetCall(receiver, arrayAccessExpression, Call.CallType.ARRAY_GET_METHOD)
: CallMaker.makeArraySetCall(receiver, arrayAccessExpression, rightHandSide, Call.CallType.ARRAY_SET_METHOD);
OverloadResolutionResults<FunctionDescriptor> functionResults = components.callResolver.resolveCallWithGivenName(
context, call, arrayAccessExpression, Name.identifier(isGet ? "get" : "set"));
context, call, arrayAccessExpression, isGet ? OperatorNameConventions.GET : OperatorNameConventions.SET);
List<KtExpression> indices = arrayAccessExpression.getIndexExpressions();
// The accumulated data flow info of all index expressions is saved on the last index