Refactoring: Rename copyable property delegates for PsiElement
This commit is contained in:
@@ -35,13 +35,13 @@ class NotNullableUserDataProperty<in R : UserDataHolder, T : Any>(val key: Key<T
|
||||
}
|
||||
}
|
||||
|
||||
class CopyableUserDataProperty<in R : PsiElement, T : Any>(val key: Key<T>) {
|
||||
class CopyablePsiUserDataProperty<in R : PsiElement, T : Any>(val key: Key<T>) {
|
||||
operator fun getValue(thisRef: R, property: KProperty<*>) = thisRef.getCopyableUserData(key)
|
||||
|
||||
operator fun setValue(thisRef: R, property: KProperty<*>, value: T?) = thisRef.putCopyableUserData(key, value)
|
||||
}
|
||||
|
||||
class NotNullableCopyableUserDataProperty<in R : PsiElement, T : Any>(val key: Key<T>, val defaultValue: T) {
|
||||
class NotNullablePsiCopyableUserDataProperty<in R : PsiElement, T : Any>(val key: Key<T>, val defaultValue: T) {
|
||||
operator fun getValue(thisRef: R, property: KProperty<*>) = thisRef.getCopyableUserData(key) ?: defaultValue
|
||||
|
||||
operator fun setValue(thisRef: R, property: KProperty<*>, value: T) {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ fun prepareDelayedRequests(project: Project) {
|
||||
}
|
||||
}
|
||||
|
||||
var KtElement.isToBeShortened: Boolean? by CopyableUserDataProperty(Key.create("IS_TO_BE_SHORTENED"))
|
||||
var KtElement.isToBeShortened: Boolean? by CopyablePsiUserDataProperty(Key.create("IS_TO_BE_SHORTENED"))
|
||||
|
||||
fun KtElement.addToBeShortenedDescendantsToWaitingSet() {
|
||||
forEachDescendantOfType<KtElement> {
|
||||
|
||||
@@ -421,7 +421,7 @@ fun OffsetMap.tryGetOffset(key: OffsetKey): Int? {
|
||||
}
|
||||
}
|
||||
|
||||
var KtCodeFragment.extraCompletionFilter: ((LookupElement) -> Boolean)? by CopyableUserDataProperty(Key.create("EXTRA_COMPLETION_FILTER"))
|
||||
var KtCodeFragment.extraCompletionFilter: ((LookupElement) -> Boolean)? by CopyablePsiUserDataProperty(Key.create("EXTRA_COMPLETION_FILTER"))
|
||||
|
||||
val DeclarationDescriptor.isArtificialImportAliasedDescriptor: Boolean
|
||||
get() = original.name != name
|
||||
+2
-2
@@ -137,7 +137,7 @@ fun addDebugExpressionIntoTmpFileForExtractFunction(originalFile: KtFile, codeFr
|
||||
return contentElementsInTmpFile
|
||||
}
|
||||
|
||||
private var PsiElement.IS_CONTEXT_ELEMENT: Boolean by NotNullableCopyableUserDataProperty(Key.create("IS_CONTEXT_ELEMENT"), false)
|
||||
private var PsiElement.IS_CONTEXT_ELEMENT: Boolean by NotNullablePsiCopyableUserDataProperty(Key.create("IS_CONTEXT_ELEMENT"), false)
|
||||
|
||||
private fun KtCodeFragment.markContextElement() {
|
||||
getOriginalContext()?.IS_CONTEXT_ELEMENT = true
|
||||
@@ -151,7 +151,7 @@ private fun KtFile.findContextElement(): KtElement? {
|
||||
return this.findDescendantOfType { it.IS_CONTEXT_ELEMENT == true }
|
||||
}
|
||||
|
||||
private var PsiElement.DEBUG_SMART_CAST: PsiElement? by CopyableUserDataProperty(Key.create("DEBUG_SMART_CAST"))
|
||||
private var PsiElement.DEBUG_SMART_CAST: PsiElement? by CopyablePsiUserDataProperty(Key.create("DEBUG_SMART_CAST"))
|
||||
|
||||
private fun KtCodeFragment.markSmartCasts() {
|
||||
val bindingContext = runInReadActionWithWriteActionPriorityWithPCE { analyzeFully() }
|
||||
|
||||
@@ -27,10 +27,10 @@ import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.psi.formatter.FormattingDocumentModelImpl
|
||||
import org.jetbrains.kotlin.idea.formatter.FormattingChange.ReplaceWhiteSpace
|
||||
import org.jetbrains.kotlin.idea.formatter.FormattingChange.ShiftIndentInsideRange
|
||||
import org.jetbrains.kotlin.psi.NotNullableCopyableUserDataProperty
|
||||
import org.jetbrains.kotlin.psi.NotNullablePsiCopyableUserDataProperty
|
||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||
|
||||
private var PsiFile.collectFormattingChanges: Boolean by NotNullableCopyableUserDataProperty(Key.create("COLLECT_FORMATTING_CHANGES"), false)
|
||||
private var PsiFile.collectFormattingChanges: Boolean by NotNullablePsiCopyableUserDataProperty(Key.create("COLLECT_FORMATTING_CHANGES"), false)
|
||||
private var PsiFile.collectChangesFormattingModel: CollectChangesWithoutApplyModel? by UserDataProperty(Key.create("COLLECT_CHANGES_FORMATTING_MODEL"))
|
||||
|
||||
fun createCollectFormattingChangesModel(file: PsiFile, block: Block): FormattingModel? {
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ class KotlinFunctionCallUsage(
|
||||
}
|
||||
|
||||
private var KtValueArgument.generatedArgumentValue: Boolean
|
||||
by NotNullableCopyableUserDataProperty(Key.create("GENERATED_ARGUMENT_VALUE"), false)
|
||||
by NotNullablePsiCopyableUserDataProperty(Key.create("GENERATED_ARGUMENT_VALUE"), false)
|
||||
|
||||
private fun ArgumentInfo.getArgumentByDefaultValue(
|
||||
element: KtCallElement,
|
||||
|
||||
@@ -86,7 +86,7 @@ fun showDialog(
|
||||
}
|
||||
|
||||
internal var KtSimpleNameExpression.internalUsageInfos: MutableMap<FqName, (KtSimpleNameExpression) -> UsageInfo?>?
|
||||
by CopyableUserDataProperty(Key.create("INTERNAL_USAGE_INFOS"))
|
||||
by CopyablePsiUserDataProperty(Key.create("INTERNAL_USAGE_INFOS"))
|
||||
|
||||
internal fun preProcessInternalUsages(element: KtElement, usages: Collection<KtElement>) {
|
||||
val mainFile = element.containingKtFile
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ data class ResolvedReferenceInfo(
|
||||
val shouldSkipPrimaryReceiver: Boolean
|
||||
)
|
||||
|
||||
internal var KtSimpleNameExpression.resolveResult: ResolveResult? by CopyableUserDataProperty(Key.create("RESOLVE_RESULT"))
|
||||
internal var KtSimpleNameExpression.resolveResult: ResolveResult? by CopyablePsiUserDataProperty(Key.create("RESOLVE_RESULT"))
|
||||
|
||||
data class ExtractionData(
|
||||
val originalFile: KtFile,
|
||||
|
||||
+2
-2
@@ -404,10 +404,10 @@ private fun makeCall(
|
||||
}
|
||||
|
||||
private var KtExpression.isJumpElementToReplace: Boolean
|
||||
by NotNullableCopyableUserDataProperty(Key.create("IS_JUMP_ELEMENT_TO_REPLACE"), false)
|
||||
by NotNullablePsiCopyableUserDataProperty(Key.create("IS_JUMP_ELEMENT_TO_REPLACE"), false)
|
||||
|
||||
private var KtReturnExpression.isReturnForLabelRemoval: Boolean
|
||||
by NotNullableCopyableUserDataProperty(Key.create("IS_RETURN_FOR_LABEL_REMOVAL"), false)
|
||||
by NotNullablePsiCopyableUserDataProperty(Key.create("IS_RETURN_FOR_LABEL_REMOVAL"), false)
|
||||
|
||||
fun ExtractionGeneratorConfiguration.generateDeclaration(
|
||||
declarationToReplace: KtNamedDeclaration? = null
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class TypeReferenceInfo(val reference: KtTypeReference, val type: KotlinType)
|
||||
|
||||
internal var KtTypeReference.resolveInfo : TypeReferenceInfo? by CopyableUserDataProperty(Key.create("RESOLVE_INFO"))
|
||||
internal var KtTypeReference.resolveInfo : TypeReferenceInfo? by CopyablePsiUserDataProperty(Key.create("RESOLVE_INFO"))
|
||||
|
||||
class IntroduceTypeAliasData(
|
||||
val originalTypeElement: KtElement,
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ fun findDuplicates(typeAlias: KtTypeAlias): Map<KotlinPsiRange, () -> Unit> {
|
||||
return rangesWithReplacers.toMap()
|
||||
}
|
||||
|
||||
private var KtTypeReference.typeParameterInfo : TypeParameter? by CopyableUserDataProperty(Key.create("TYPE_PARAMETER_INFO"))
|
||||
private var KtTypeReference.typeParameterInfo : TypeParameter? by CopyablePsiUserDataProperty(Key.create("TYPE_PARAMETER_INFO"))
|
||||
|
||||
fun IntroduceTypeAliasDescriptor.generateTypeAlias(previewOnly: Boolean = false): KtTypeAlias {
|
||||
val originalElement = originalData.originalTypeElement
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
|
||||
private val REPLACE_KEY = Key.create<Boolean>("REPLACE_KEY")
|
||||
private val COMMON_PARENT_KEY = Key.create<Boolean>("COMMON_PARENT_KEY")
|
||||
|
||||
private var KtExpression.isOccurrence: Boolean by NotNullableCopyableUserDataProperty(Key.create("OCCURRENCE"), false)
|
||||
private var KtExpression.isOccurrence: Boolean by NotNullablePsiCopyableUserDataProperty(Key.create("OCCURRENCE"), false)
|
||||
|
||||
private class IntroduceVariableContext(
|
||||
private val expression: KtExpression,
|
||||
|
||||
@@ -197,7 +197,7 @@ fun KtElement.processInternalReferencesToUpdateOnPackageNameChange(
|
||||
}
|
||||
}
|
||||
|
||||
internal var KtSimpleNameExpression.internalUsageInfo: UsageInfo? by CopyableUserDataProperty(Key.create("INTERNAL_USAGE_INFO"))
|
||||
internal var KtSimpleNameExpression.internalUsageInfo: UsageInfo? by CopyablePsiUserDataProperty(Key.create("INTERNAL_USAGE_INFO"))
|
||||
|
||||
internal fun markInternalUsages(usages: Collection<UsageInfo>) {
|
||||
usages.forEach { (it.element as? KtSimpleNameExpression)?.internalUsageInfo = it }
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class JavaToKotlinPreconversionPullUpHelper(
|
||||
private val jvmStaticAnnotation = KtPsiFactory(data.sourceClass.project).createAnnotationEntry("@kotlin.jvm.JvmStatic")
|
||||
|
||||
companion object {
|
||||
private var PsiMember.originalMember: PsiMember? by CopyableUserDataProperty(Key.create("ORIGINAL_MEMBER"))
|
||||
private var PsiMember.originalMember: PsiMember? by CopyablePsiUserDataProperty(Key.create("ORIGINAL_MEMBER"))
|
||||
}
|
||||
|
||||
private fun collectFieldReferencesToEncapsulate(member: PsiField) {
|
||||
|
||||
@@ -36,14 +36,13 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import java.util.*
|
||||
|
||||
private var KtElement.newFqName: FqName? by CopyableUserDataProperty(Key.create("NEW_FQ_NAME"))
|
||||
private var KtElement.replaceWithTargetThis: Boolean? by CopyableUserDataProperty(Key.create("REPLACE_WITH_TARGET_THIS"))
|
||||
private var KtElement.newTypeText: ((TypeSubstitutor) -> String?)? by CopyableUserDataProperty(Key.create("NEW_TYPE_TEXT"))
|
||||
private var KtElement.newFqName: FqName? by CopyablePsiUserDataProperty(Key.create("NEW_FQ_NAME"))
|
||||
private var KtElement.replaceWithTargetThis: Boolean? by CopyablePsiUserDataProperty(Key.create("REPLACE_WITH_TARGET_THIS"))
|
||||
private var KtElement.newTypeText: ((TypeSubstitutor) -> String?)? by CopyablePsiUserDataProperty(Key.create("NEW_TYPE_TEXT"))
|
||||
|
||||
fun markElements(
|
||||
declaration: KtNamedDeclaration,
|
||||
|
||||
Reference in New Issue
Block a user