Remove deprecated declarations from project code, cleanup usages
This commit is contained in:
@@ -323,7 +323,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
Type[] myParameterTypes = bridge.getArgumentTypes();
|
||||
|
||||
List<ParameterDescriptor> calleeParameters = CollectionsKt.plus(
|
||||
org.jetbrains.kotlin.utils.CollectionsKt.<ParameterDescriptor>singletonOrEmptyList(funDescriptor.getExtensionReceiverParameter()),
|
||||
CollectionsKt.listOfNotNull(funDescriptor.getExtensionReceiverParameter()),
|
||||
funDescriptor.getValueParameters()
|
||||
);
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class KotlinBinaryClassCache : Disposable {
|
||||
}
|
||||
|
||||
val aClass = ApplicationManager.getApplication().runReadAction(Computable {
|
||||
//noinspection deprecation
|
||||
@Suppress("DEPRECATION")
|
||||
VirtualFileKotlinClass.create(file, fileContent)
|
||||
})
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ fun ModuleContext(module: ModuleDescriptor, project: Project): ModuleContext =
|
||||
fun GlobalContext.withProject(project: Project): ProjectContext = ProjectContextImpl(project, this)
|
||||
fun ProjectContext.withModule(module: ModuleDescriptor): ModuleContext = ModuleContextImpl(module, this)
|
||||
|
||||
@JvmOverloads
|
||||
fun ContextForNewModule(
|
||||
projectContext: ProjectContext,
|
||||
moduleName: Name,
|
||||
|
||||
@@ -21,13 +21,13 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.FileContentUtilCore;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import kotlin.collections.ArraysKt;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -39,7 +39,6 @@ import org.jetbrains.kotlin.parsing.KotlinParserDefinition;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinFileStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtPlaceHolderStubElementType;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
import org.jetbrains.kotlin.utils.CollectionsKt;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -279,7 +278,7 @@ public class KtFile extends PsiFileBase implements KtDeclarationContainer, KtAnn
|
||||
PsiElement result = super.setName(name);
|
||||
boolean willBeScript = name.endsWith(KotlinParserDefinition.STD_SCRIPT_EXT);
|
||||
if (isScript() != willBeScript) {
|
||||
FileContentUtilCore.reparseFiles(CollectionsKt.<VirtualFile>singletonOrEmptyList(getVirtualFile()));
|
||||
FileContentUtilCore.reparseFiles(CollectionsKt.listOfNotNull(getVirtualFile()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
|
||||
|
||||
operator fun <K, V: Any> BindingContext.get(slice: ReadOnlySlice<K, V>, key: K): V? = get(slice, key)
|
||||
|
||||
fun KtReturnExpression.getTargetFunctionDescriptor(context: BindingContext): FunctionDescriptor? {
|
||||
val targetLabel = getTargetLabel()
|
||||
if (targetLabel != null) return context[LABEL_TARGET, targetLabel]?.let { context[FUNCTION, it] }
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
|
||||
}
|
||||
|
||||
fun makeScriptContents() = BasicScriptContents(file, getAnnotations = {
|
||||
val classLoader = (template as Any)::class.java.classLoader
|
||||
val classLoader = template::class.java.classLoader
|
||||
try {
|
||||
getAnnotationEntries(file, project)
|
||||
.mapNotNull { psiAnn ->
|
||||
|
||||
@@ -102,13 +102,8 @@ class LoggingStorageManager(
|
||||
return CallData(outerInstance, containingField, enclosingEntity, arguments, result)
|
||||
}
|
||||
|
||||
private fun enclosingEntity(_class: Class<out Any>): GenericDeclaration? {
|
||||
val result = _class.enclosingConstructor
|
||||
?: _class.enclosingMethod
|
||||
?: _class.enclosingClass
|
||||
|
||||
return result as GenericDeclaration?
|
||||
}
|
||||
private fun enclosingEntity(klass: Class<out Any>): GenericDeclaration? =
|
||||
klass.enclosingConstructor ?: klass.enclosingMethod ?: klass.enclosingClass
|
||||
|
||||
private fun Class<*>.getAllDeclaredFields(): List<Field> {
|
||||
val result = arrayListOf<Field>()
|
||||
|
||||
+2
-2
@@ -144,7 +144,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.isImpl = isImpl;
|
||||
}
|
||||
|
||||
public void setHiddenToOvercomeSignatureClash(boolean hiddenToOvercomeSignatureClash) {
|
||||
private void setHiddenToOvercomeSignatureClash(boolean hiddenToOvercomeSignatureClash) {
|
||||
isHiddenToOvercomeSignatureClash = hiddenToOvercomeSignatureClash;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected KotlinType getExtensionReceiverParameterType() {
|
||||
private KotlinType getExtensionReceiverParameterType() {
|
||||
if (extensionReceiverParameter == null) return null;
|
||||
return extensionReceiverParameter.getType();
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class TypeUtils {
|
||||
for (TypeParameterDescriptor parameterDescriptor : parameters) {
|
||||
result.add(new TypeProjectionImpl(parameterDescriptor.getDefaultType()));
|
||||
}
|
||||
return org.jetbrains.kotlin.utils.CollectionsKt.toReadOnlyList(result);
|
||||
return CollectionsKt.toList(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -20,15 +20,6 @@ import java.lang.reflect.Modifier
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@Deprecated("Use listOfNotNull(this) or this.let(::listOfNotNull) instead", ReplaceWith("listOfNotNull(this)"))
|
||||
fun <T: Any> T?.singletonOrEmptyList(): List<T> = if (this != null) Collections.singletonList(this) else Collections.emptyList()
|
||||
|
||||
@Deprecated("Use listOf(this) or this.let(::listOf) instead", ReplaceWith("listOf(this)"))
|
||||
fun <T> T.singletonList(): List<T> = Collections.singletonList(this)
|
||||
|
||||
@Deprecated("Use this?.let(::setOf).orEmpty() instead", ReplaceWith("this?.let(::setOf).orEmpty()"))
|
||||
fun <T: Any> T?.singletonOrEmptySet(): Set<T> = if (this != null) Collections.singleton(this) else Collections.emptySet()
|
||||
|
||||
inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? {
|
||||
for (element in this) if (element is T) return element
|
||||
return null
|
||||
@@ -79,9 +70,6 @@ fun <T> sequenceOfLazyValues(vararg elements: () -> T): Sequence<T> = elements.a
|
||||
|
||||
fun <T1, T2> Pair<T1, T2>.swap(): Pair<T2, T1> = Pair(second, first)
|
||||
|
||||
@Deprecated("Use takeIf() instead.", ReplaceWith("this.takeIf(predicate)"))
|
||||
fun <T: Any> T.check(predicate: (T) -> Boolean): T? = if (predicate(this)) this else null
|
||||
|
||||
inline fun <reified T : Any> Any?.safeAs(): T? = this as? T
|
||||
inline fun <reified T : Any> Any?.cast(): T = this as T
|
||||
inline fun <reified T : Any> Any?.assertedCast(message: () -> String): T = this as? T ?: throw AssertionError(message())
|
||||
|
||||
@@ -57,14 +57,11 @@ inline fun <T, C: Collection<T>> C.ifEmpty(body: () -> C): C = if (isEmpty()) bo
|
||||
|
||||
inline fun <T> Array<out T>.ifEmpty(body: () -> Array<out T>): Array<out T> = if (isEmpty()) body() else this
|
||||
|
||||
@Deprecated("Use listOfNotNull instead", ReplaceWith("listOfNotNull(item)"))
|
||||
fun <T: Any> emptyOrSingletonList(item: T?): List<T> = listOfNotNull(item)
|
||||
|
||||
fun <T: Any> MutableCollection<T>.addIfNotNull(t: T?) {
|
||||
if (t != null) add(t)
|
||||
}
|
||||
|
||||
suspend fun <T: Any> SequenceBuilder<in T>.yieldIfNotNull(t: T?) = if (t != null) yield(t) else Unit
|
||||
suspend fun <T: Any> SequenceBuilder<T>.yieldIfNotNull(t: T?) = if (t != null) yield(t) else Unit
|
||||
|
||||
fun <K, V> newHashMapWithExpectedSize(expectedSize: Int): HashMap<K, V> =
|
||||
HashMap(capacity(expectedSize))
|
||||
@@ -81,14 +78,6 @@ fun <E> newLinkedHashSetWithExpectedSize(expectedSize: Int): LinkedHashSet<E> =
|
||||
private fun capacity(expectedSize: Int): Int =
|
||||
if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1
|
||||
|
||||
@Deprecated("Use toList(), it provides the same behavior for Collection", ReplaceWith("this.toList()"))
|
||||
fun <T> Collection<T>.toReadOnlyList(): List<T> =
|
||||
when (size) {
|
||||
0 -> emptyList()
|
||||
1 -> listOf(first())
|
||||
else -> ArrayList(this)
|
||||
}
|
||||
|
||||
fun <T> ArrayList<T>.compactIfPossible(): List<T> =
|
||||
when (size) {
|
||||
0 -> emptyList()
|
||||
@@ -96,10 +85,6 @@ fun <T> ArrayList<T>.compactIfPossible(): List<T> =
|
||||
else -> apply { trimToSize() }
|
||||
}
|
||||
|
||||
@Deprecated("Use listOfNotNull(this) or this.let(::listOfNotNull) instead", ReplaceWith("listOfNotNull(this)"))
|
||||
fun <T: Any> T?.singletonOrEmptyList(): List<T> =
|
||||
if (this != null) listOf(this) else emptyList()
|
||||
|
||||
fun <T> List<T>.indexOfFirst(startFrom: Int, predicate: (T) -> Boolean): Int {
|
||||
for (index in startFrom..lastIndex) {
|
||||
if (predicate(this[index])) return index
|
||||
|
||||
@@ -127,7 +127,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
generateBitwiseOperators(className, since = if (kind == PrimitiveType.BYTE || kind == PrimitiveType.SHORT) "1.1" else null)
|
||||
}
|
||||
|
||||
generateConversions(kind)
|
||||
generateConversions()
|
||||
|
||||
out.println("}\n")
|
||||
}
|
||||
@@ -220,7 +220,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
out.println()
|
||||
}
|
||||
|
||||
private fun generateConversions(kind: PrimitiveType) {
|
||||
private fun generateConversions() {
|
||||
for (otherKind in PrimitiveType.exceptBoolean) {
|
||||
val name = otherKind.capitalized
|
||||
out.println(" public override fun to$name(): $name")
|
||||
|
||||
-3
@@ -19,8 +19,6 @@ package org.jetbrains.kotlin.idea.decompiler.stubBuilder
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.getFunctionalClassKind
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionClass
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -41,7 +39,6 @@ import org.jetbrains.kotlin.serialization.ProtoBuf.Type.Argument.Projection
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.TypeParameter.Variance
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||
import java.util.*
|
||||
|
||||
// TODO: see DescriptorRendererOptions.excludedTypeAnnotationClasses for decompiler
|
||||
|
||||
+1
-2
@@ -45,7 +45,6 @@ import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.isBooleanOrNullableBoolean
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptySet
|
||||
import java.util.*
|
||||
|
||||
interface InheritanceItemsSearcher {
|
||||
@@ -118,7 +117,7 @@ class SmartCompletion(
|
||||
if (operationToken == KtTokens.EQ || operationToken in COMPARISON_TOKENS) {
|
||||
val left = parent.left
|
||||
if (left is KtReferenceExpression) {
|
||||
return@lazy bindingContext[BindingContext.REFERENCE_TARGET, left].singletonOrEmptySet()
|
||||
return@lazy bindingContext[BindingContext.REFERENCE_TARGET, left]?.let(::setOf).orEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptySet
|
||||
|
||||
class KotlinMemberInfo @JvmOverloads constructor(
|
||||
member: KtNamedDeclaration,
|
||||
@@ -44,7 +43,7 @@ class KotlinMemberInfo @JvmOverloads constructor(
|
||||
) : MemberInfoBase<KtNamedDeclaration>(member) {
|
||||
companion object {
|
||||
private val RENDERER = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.withOptions {
|
||||
modifiers = DescriptorRendererModifier.INNER.singletonOrEmptySet()
|
||||
modifiers = setOf(DescriptorRendererModifier.INNER)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,4 +104,4 @@ fun MemberInfo.toKotlinMemberInfo(): KotlinMemberInfo? {
|
||||
return KotlinMemberInfo(declaration, declaration is KtClass && overrides != null).apply {
|
||||
this.isToAbstract = this@toKotlinMemberInfo.isToAbstract
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.sun.jdi.Location;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import kotlin.Unit;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.io.FilesKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.sequences.SequencesKt;
|
||||
@@ -54,7 +55,6 @@ import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||
import org.jetbrains.kotlin.utils.CollectionsKt;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
|
||||
import java.io.File;
|
||||
@@ -280,7 +280,7 @@ public abstract class AbstractPositionManagerTest extends KotlinLightCodeInsight
|
||||
|
||||
@Override
|
||||
public List<ReferenceType> classesByName(String name) {
|
||||
return CollectionsKt.emptyOrSingletonList(referencesByName.get(name));
|
||||
return CollectionsKt.listOfNotNull(referencesByName.get(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user