Use OperatorNameConventions constants instead of hardcoded literals
This commit is contained in:
@@ -94,6 +94,7 @@ import org.jetbrains.kotlin.types.TypeUtils;
|
|||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS;
|
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS;
|
||||||
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
|
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.org.objectweb.asm.Label;
|
import org.jetbrains.org.objectweb.asm.Label;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||||
@@ -4152,7 +4153,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
ResolvedCall<FunctionDescriptor> resolvedSetCall = bindingContext.get(INDEXED_LVALUE_SET, expression);
|
ResolvedCall<FunctionDescriptor> resolvedSetCall = bindingContext.get(INDEXED_LVALUE_SET, expression);
|
||||||
ResolvedCall<FunctionDescriptor> resolvedGetCall = bindingContext.get(INDEXED_LVALUE_GET, expression);
|
ResolvedCall<FunctionDescriptor> resolvedGetCall = bindingContext.get(INDEXED_LVALUE_GET, expression);
|
||||||
|
|
||||||
boolean isGetter = "get".equals(operationDescriptor.getName().asString());
|
boolean isGetter = OperatorNameConventions.GET.equals(operationDescriptor.getName());
|
||||||
|
|
||||||
Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall);
|
Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall);
|
||||||
Callable callableMethod = resolveToCallableMethod(operationDescriptor, false);
|
Callable callableMethod = resolveToCallableMethod(operationDescriptor, false);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore
|
|||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils.*
|
import org.jetbrains.kotlin.types.TypeUtils.*
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ControlFlowInformationProvider private constructor(
|
class ControlFlowInformationProvider private constructor(
|
||||||
@@ -647,13 +648,13 @@ class ControlFlowInformationProvider private constructor(
|
|||||||
val functionDescriptor =
|
val functionDescriptor =
|
||||||
trace.get(DECLARATION_TO_DESCRIPTOR, owner) as? FunctionDescriptor
|
trace.get(DECLARATION_TO_DESCRIPTOR, owner) as? FunctionDescriptor
|
||||||
?: throw AssertionError(owner.text)
|
?: throw AssertionError(owner.text)
|
||||||
val functionName = functionDescriptor.name.asString()
|
val functionName = functionDescriptor.name
|
||||||
if (isMain
|
if (isMain
|
||||||
|| functionDescriptor.isOverridableOrOverrides
|
|| functionDescriptor.isOverridableOrOverrides
|
||||||
|| owner.hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|| owner.hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
||||||
|| "getValue" == functionName
|
|| OperatorNameConventions.GET_VALUE == functionName
|
||||||
|| "setValue" == functionName
|
|| OperatorNameConventions.SET_VALUE == functionName
|
||||||
|| "propertyDelegated" == functionName) {
|
|| OperatorNameConventions.PROPERTY_DELEGATED == functionName) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
report(UNUSED_PARAMETER.on(element, variableDescriptor), ctxt)
|
report(UNUSED_PARAMETER.on(element, variableDescriptor), ctxt)
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public class CallResolver {
|
|||||||
|
|
||||||
Call.CallType callType = context.call.getCallType();
|
Call.CallType callType = context.call.getCallType();
|
||||||
if (callType == Call.CallType.ARRAY_GET_METHOD || callType == Call.CallType.ARRAY_SET_METHOD) {
|
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();
|
KtArrayAccessExpression arrayAccessExpression = (KtArrayAccessExpression) context.call.getCallElement();
|
||||||
return computeTasksAndResolveCall(
|
return computeTasksAndResolveCall(
|
||||||
context, name, arrayAccessExpression,
|
context, name, arrayAccessExpression,
|
||||||
|
|||||||
+1
-1
@@ -1691,7 +1691,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
? CallMaker.makeArrayGetCall(receiver, arrayAccessExpression, Call.CallType.ARRAY_GET_METHOD)
|
? CallMaker.makeArrayGetCall(receiver, arrayAccessExpression, Call.CallType.ARRAY_GET_METHOD)
|
||||||
: CallMaker.makeArraySetCall(receiver, arrayAccessExpression, rightHandSide, Call.CallType.ARRAY_SET_METHOD);
|
: CallMaker.makeArraySetCall(receiver, arrayAccessExpression, rightHandSide, Call.CallType.ARRAY_SET_METHOD);
|
||||||
OverloadResolutionResults<FunctionDescriptor> functionResults = components.callResolver.resolveCallWithGivenName(
|
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();
|
List<KtExpression> indices = arrayAccessExpression.getIndexExpressions();
|
||||||
// The accumulated data flow info of all index expressions is saved on the last index
|
// The accumulated data flow info of all index expressions is saved on the last index
|
||||||
|
|||||||
+2
-3
@@ -33,13 +33,12 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.HashSet
|
import java.util.*
|
||||||
|
|
||||||
class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider {
|
class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider {
|
||||||
override fun getLineMarkerInfo(element: PsiElement) = null
|
override fun getLineMarkerInfo(element: PsiElement) = null
|
||||||
@@ -159,7 +158,7 @@ private fun getCallNameFromPsi(element: KtElement): Name? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is KtArrayAccessExpression ->
|
is KtArrayAccessExpression ->
|
||||||
return Name.identifier("get")
|
return OperatorNameConventions.GET
|
||||||
is KtThisExpression ->
|
is KtThisExpression ->
|
||||||
if (element.getParent() is KtCallExpression) {
|
if (element.getParent() is KtCallExpression) {
|
||||||
return OperatorNameConventions.INVOKE
|
return OperatorNameConventions.INVOKE
|
||||||
|
|||||||
+4
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.Parame
|
|||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
|
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object CreateGetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet = true) {
|
object CreateGetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet = true) {
|
||||||
@@ -32,6 +33,8 @@ object CreateGetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet
|
|||||||
val arrayType = TypeInfo(arrayExpr, Variance.IN_VARIANCE)
|
val arrayType = TypeInfo(arrayExpr, Variance.IN_VARIANCE)
|
||||||
val parameters = element.indexExpressions.map { ParameterInfo(TypeInfo(it, Variance.IN_VARIANCE)) }
|
val parameters = element.indexExpressions.map { ParameterInfo(TypeInfo(it, Variance.IN_VARIANCE)) }
|
||||||
val returnType = TypeInfo(element, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(element, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo("get", arrayType, returnType, Collections.emptyList(), parameters, isOperator = true)
|
return FunctionInfo(
|
||||||
|
OperatorNameConventions.GET.asString(), arrayType, returnType, Collections.emptyList(), parameters, isOperator = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUsageFactory<KtExpression>() {
|
object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUsageFactory<KtExpression>() {
|
||||||
override fun getElementOfInterest(diagnostic: Diagnostic): KtExpression? {
|
override fun getElementOfInterest(diagnostic: Diagnostic): KtExpression? {
|
||||||
@@ -62,7 +63,7 @@ object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUs
|
|||||||
|
|
||||||
if (isApplicableForAccessor(propertyDescriptor.getter)) {
|
if (isApplicableForAccessor(propertyDescriptor.getter)) {
|
||||||
val getterInfo = FunctionInfo(
|
val getterInfo = FunctionInfo(
|
||||||
name = "getValue",
|
name = OperatorNameConventions.GET_VALUE.asString(),
|
||||||
receiverTypeInfo = accessorReceiverType,
|
receiverTypeInfo = accessorReceiverType,
|
||||||
returnTypeInfo = TypeInfo(propertyType, Variance.OUT_VARIANCE),
|
returnTypeInfo = TypeInfo(propertyType, Variance.OUT_VARIANCE),
|
||||||
parameterInfos = listOf(thisRefParam, metadataParam),
|
parameterInfos = listOf(thisRefParam, metadataParam),
|
||||||
@@ -74,7 +75,7 @@ object CreatePropertyDelegateAccessorsActionFactory : CreateCallableMemberFromUs
|
|||||||
if (propertyDescriptor.isVar && isApplicableForAccessor(propertyDescriptor.setter)) {
|
if (propertyDescriptor.isVar && isApplicableForAccessor(propertyDescriptor.setter)) {
|
||||||
val newValueParam = ParameterInfo(TypeInfo(propertyType, Variance.IN_VARIANCE))
|
val newValueParam = ParameterInfo(TypeInfo(propertyType, Variance.IN_VARIANCE))
|
||||||
val setterInfo = FunctionInfo(
|
val setterInfo = FunctionInfo(
|
||||||
name = "setValue",
|
name = OperatorNameConventions.SET_VALUE.asString(),
|
||||||
receiverTypeInfo = accessorReceiverType,
|
receiverTypeInfo = accessorReceiverType,
|
||||||
returnTypeInfo = TypeInfo(builtIns.unitType, Variance.OUT_VARIANCE),
|
returnTypeInfo = TypeInfo(builtIns.unitType, Variance.OUT_VARIANCE),
|
||||||
parameterInfos = listOf(thisRefParam, metadataParam, newValueParam),
|
parameterInfos = listOf(thisRefParam, metadataParam, newValueParam),
|
||||||
|
|||||||
+4
-1
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
|||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object CreateSetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet = false) {
|
object CreateSetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet = false) {
|
||||||
@@ -61,6 +62,8 @@ object CreateSetFunctionActionFactory : CreateGetSetFunctionActionFactory(isGet
|
|||||||
parameters.add(ParameterInfo(valType, "value"))
|
parameters.add(ParameterInfo(valType, "value"))
|
||||||
|
|
||||||
val returnType = TypeInfo(builtIns.unitType, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(builtIns.unitType, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo("set", arrayType, returnType, Collections.emptyList(), parameters, isOperator = true)
|
return FunctionInfo(
|
||||||
|
OperatorNameConventions.SET.asString(), arrayType, returnType, Collections.emptyList(), parameters, isOperator = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user