Cleanup: apply "Convert lambda to reference"
This commit is contained in:
@@ -42,7 +42,7 @@ import java.util.*
|
||||
|
||||
|
||||
fun Iterable<File>.javaSourceRoots(roots: Iterable<File>): Iterable<File> =
|
||||
filter { it.isJavaFile() }
|
||||
filter(File::isJavaFile)
|
||||
.map { findSrcDirRoot(it, roots) }
|
||||
.filterNotNull()
|
||||
|
||||
|
||||
@@ -70,7 +70,5 @@ internal class Parameters(val parameters: List<ParameterInfo>) : Iterable<Parame
|
||||
}
|
||||
|
||||
val capturedTypes: List<Type>
|
||||
get() = captured.map {
|
||||
it.getType()
|
||||
}
|
||||
get() = captured.map(CapturedParamInfo::getType)
|
||||
}
|
||||
|
||||
@@ -52,9 +52,7 @@ fun MethodNode.prepareForEmitting() {
|
||||
|
||||
// local variables with live ranges starting after last meaningful instruction lead to VerifyError
|
||||
localVariables = localVariables.filter { lv ->
|
||||
InsnSequence(lv.start, lv.end).any { insn ->
|
||||
insn.isMeaningful
|
||||
}
|
||||
InsnSequence(lv.start, lv.end).any(AbstractInsnNode::isMeaningful)
|
||||
}
|
||||
|
||||
// We should remove linenumbers after last meaningful instruction
|
||||
@@ -73,9 +71,7 @@ fun MethodNode.prepareForEmitting() {
|
||||
|
||||
fun MethodNode.removeEmptyCatchBlocks() {
|
||||
tryCatchBlocks = tryCatchBlocks.filter { tcb ->
|
||||
InsnSequence(tcb.start, tcb.end).any { insn ->
|
||||
insn.isMeaningful
|
||||
}
|
||||
InsnSequence(tcb.start, tcb.end).any(AbstractInsnNode::isMeaningful)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ found top-level declarations to <destination dir> (*.kotlin_builtins files)"""
|
||||
|
||||
val destDir = File(args[0])
|
||||
|
||||
val srcDirs = args.drop(1).map { File(it) }
|
||||
val srcDirs = args.drop(1).map(::File)
|
||||
assert(srcDirs.isNotEmpty()) { "At least one source directory should be specified" }
|
||||
|
||||
val missing = srcDirs.filterNot { it.exists() }
|
||||
val missing = srcDirs.filterNot(File::exists)
|
||||
assert(missing.isEmpty()) { "These source directories are missing: $missing" }
|
||||
|
||||
try {
|
||||
|
||||
@@ -50,7 +50,7 @@ object PluginCliParser {
|
||||
configuration: CompilerConfiguration,
|
||||
classLoader: ClassLoader
|
||||
) {
|
||||
val optionValuesByPlugin = arguments.pluginOptions?.map { parsePluginOption(it) }?.groupBy {
|
||||
val optionValuesByPlugin = arguments.pluginOptions?.map(::parsePluginOption)?.groupBy {
|
||||
if (it == null) throw CliOptionProcessingException("Wrong plugin option format: $it, should be ${CommonCompilerArguments.PLUGIN_OPTION_FORMAT}")
|
||||
it.pluginId
|
||||
} ?: mapOf()
|
||||
|
||||
@@ -142,7 +142,7 @@ class ReplFromTerminal(
|
||||
|
||||
companion object {
|
||||
private fun splitCommand(command: String): List<String> {
|
||||
return Arrays.asList(*command.split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray())
|
||||
return Arrays.asList(*command.split(" ".toRegex()).dropLastWhile(String::isEmpty).toTypedArray())
|
||||
}
|
||||
|
||||
fun run(disposable: Disposable, configuration: CompilerConfiguration) {
|
||||
|
||||
+8
-8
@@ -89,8 +89,8 @@ class StringPropMapper<C, out P : KMutableProperty1<C, String>>(dest: C,
|
||||
prop: P,
|
||||
names: List<String> = listOf(),
|
||||
fromString: ((String) -> String) = { it },
|
||||
toString: ((String) -> String?) = { it.toString() },
|
||||
skipIf: ((String) -> Boolean) = { it.isEmpty() },
|
||||
toString: ((String) -> String?) = { it },
|
||||
skipIf: ((String) -> Boolean) = String::isEmpty,
|
||||
mergeDelimiter: String? = null)
|
||||
: PropMapper<C, String, P>(dest = dest, prop = prop, names = if (names.any()) names else listOf(prop.name),
|
||||
fromString = fromString, toString = toString, skipIf = skipIf, mergeDelimiter = mergeDelimiter)
|
||||
@@ -212,13 +212,13 @@ data class DaemonOptions(
|
||||
) : OptionsGroup {
|
||||
|
||||
override val mappers: List<PropMapper<*, *, *>>
|
||||
get() = listOf(PropMapper(this, DaemonOptions::runFilesPath, fromString = { it.trimQuotes() }),
|
||||
PropMapper(this, DaemonOptions::autoshutdownMemoryThreshold, fromString = { it.toLong() }, skipIf = { it == 0L }, mergeDelimiter = "="),
|
||||
get() = listOf(PropMapper(this, DaemonOptions::runFilesPath, fromString = String::trimQuotes),
|
||||
PropMapper(this, DaemonOptions::autoshutdownMemoryThreshold, fromString = String::toLong, skipIf = { it == 0L }, mergeDelimiter = "="),
|
||||
// TODO: implement "use default" value without specifying default, so if client and server uses different defaults, it should not lead to many params in the cmd line; use 0 for it and used different val for infinite
|
||||
PropMapper(this, DaemonOptions::autoshutdownIdleSeconds, fromString = { it.toInt() }, skipIf = { it == 0 }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::autoshutdownUnusedSeconds, fromString = { it.toInt() }, skipIf = { it == COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::shutdownDelayMilliseconds, fromString = { it.toLong() }, skipIf = { it == COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::forceShutdownTimeoutMilliseconds, fromString = { it.toLong() }, skipIf = { it == COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::autoshutdownIdleSeconds, fromString = String::toInt, skipIf = { it == 0 }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::autoshutdownUnusedSeconds, fromString = String::toInt, skipIf = { it == COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::shutdownDelayMilliseconds, fromString = String::toLong, skipIf = { it == COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS }, mergeDelimiter = "="),
|
||||
PropMapper(this, DaemonOptions::forceShutdownTimeoutMilliseconds, fromString = String::toLong, skipIf = { it == COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS }, mergeDelimiter = "="),
|
||||
BoolPropMapper(this, DaemonOptions::verbose),
|
||||
BoolPropMapper(this, DaemonOptions::reportPerf))
|
||||
}
|
||||
|
||||
+2
-3
@@ -73,10 +73,9 @@ object FileSystem {
|
||||
val base = File(runtimeStateFilesBasePath)
|
||||
// if base is not suitable, take home dir as a base and ensure the first name is prefixed with "." -
|
||||
// this will work ok as a fallback solution on most systems
|
||||
val dir = if (base.exists() && base.isDirectory) names.fold(base, { r, v -> File(r, v) })
|
||||
val dir = if (base.exists() && base.isDirectory) names.fold(base, ::File)
|
||||
else names.drop(1)
|
||||
.fold(File(userHomePath, names.first().let { if (it.startsWith(".")) it else ".$it" }),
|
||||
{ r, v -> File(r, v) })
|
||||
.fold(File(userHomePath, names.first().let { if (it.startsWith(".")) it else ".$it" }), ::File)
|
||||
return if ((dir.exists() && dir.isDirectory) || dir.mkdirs()) dir.absolutePath
|
||||
else tempPath
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
|
||||
thread(isDaemon = true, start = true) {
|
||||
try {
|
||||
fileIds = classpath
|
||||
.map { File(it) }
|
||||
.map(::File)
|
||||
.asSequence()
|
||||
.flatMap { it.walk().filter(::isClasspathFile) }
|
||||
.map { FileId(it, it.lastModified(), it.md5Digest()) }
|
||||
|
||||
@@ -1416,7 +1416,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
|
||||
private fun generateCallOrMarkUnresolved(call: KtCallElement) {
|
||||
if (!generateCall(call)) {
|
||||
val arguments = call.valueArguments.mapNotNull { valueArgument -> valueArgument.getArgumentExpression() }
|
||||
val arguments = call.valueArguments.mapNotNull(ValueArgument::getArgumentExpression)
|
||||
|
||||
for (argument in arguments) {
|
||||
generateInstructions(argument)
|
||||
|
||||
@@ -358,7 +358,7 @@ object Renderers {
|
||||
override fun get(key: TypeConstructor): TypeProjection? {
|
||||
val typeDescriptor = key.declarationDescriptor as? TypeParameterDescriptor ?: return null
|
||||
if (typeDescriptor.containingDeclaration != descriptor.typeAliasDescriptor) return null
|
||||
return inferredTypesForTypeParameters[typeDescriptor.index]?.let { TypeProjectionImpl(it) }
|
||||
return inferredTypesForTypeParameters[typeDescriptor.index]?.let(::TypeProjectionImpl)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ class DeclarationsChecker(
|
||||
) {
|
||||
val upperBounds = descriptor.upperBounds
|
||||
val (boundsWhichAreTypeParameters, otherBounds) = upperBounds
|
||||
.map { type -> type.constructor }
|
||||
.map(KotlinType::constructor)
|
||||
.partition { constructor -> constructor.declarationDescriptor is TypeParameterDescriptor }
|
||||
.let { pair -> pair.first.toSet() to pair.second.toSet() }
|
||||
if (boundsWhichAreTypeParameters.size > 1 || (boundsWhichAreTypeParameters.size == 1 && otherBounds.isNotEmpty())) {
|
||||
@@ -543,9 +543,7 @@ class DeclarationsChecker(
|
||||
val declarationDescriptor = it.constructor.declarationDescriptor
|
||||
if (declarationDescriptor is TypeParameterDescriptor && declarationDescriptor in allTypeParameters) {
|
||||
if (allAccessibleTypeParameters.add(declarationDescriptor)) {
|
||||
declarationDescriptor.upperBounds.forEach {
|
||||
addAccessibleTypeParametersFromType(it)
|
||||
}
|
||||
declarationDescriptor.upperBounds.forEach(::addAccessibleTypeParametersFromType)
|
||||
}
|
||||
}
|
||||
false
|
||||
|
||||
@@ -488,7 +488,7 @@ class QualifiedExpressionResolver {
|
||||
|
||||
return qualifiedExpressions
|
||||
.subList(nextExpressionIndexAfterQualifier, qualifiedExpressions.size)
|
||||
.map { CallExpressionElement(it) }
|
||||
.map(::CallExpressionElement)
|
||||
}
|
||||
|
||||
private fun mapToQualifierParts(qualifiedExpressions: List<KtQualifiedExpression>,
|
||||
|
||||
@@ -127,9 +127,7 @@ fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boolean {
|
||||
return true
|
||||
}
|
||||
if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return descriptor.overriddenDescriptors.all {
|
||||
isOrOverridesSynthesized(it)
|
||||
}
|
||||
return descriptor.overriddenDescriptors.all(::isOrOverridesSynthesized)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ abstract class SuppressDiagnosticsByAnnotations(
|
||||
) : SuppressStringProvider {
|
||||
|
||||
private val stringsToSuppress = diagnosticsToSuppress.map { it.name.toLowerCase() }
|
||||
private val expectedFqNames = annotationsFqName.map { it.toString() }
|
||||
private val expectedFqNames = annotationsFqName.map(FqName::toString)
|
||||
|
||||
override fun get(annotationDescriptor: AnnotationDescriptor): List<String> {
|
||||
val descriptor = DescriptorUtils.getClassDescriptorForType(annotationDescriptor.type)
|
||||
|
||||
@@ -71,7 +71,7 @@ class FileScopeFactory(
|
||||
|
||||
val extraImports = file.originalFile.virtualFile?.let { vFile ->
|
||||
val scriptExternalDependencies = getScriptExternalDependencies(vFile, file.project)
|
||||
ktImportsFactory.createImportDirectives(scriptExternalDependencies?.imports?.map { ImportPath(it) }.orEmpty())
|
||||
ktImportsFactory.createImportDirectives(scriptExternalDependencies?.imports?.map(::ImportPath).orEmpty())
|
||||
}
|
||||
|
||||
val allImplicitImports = defaultImports concat extraImports
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
interface PsiSourceElement : SourceElement {
|
||||
val psi: PsiElement?
|
||||
|
||||
override fun getContainingFile(): SourceFile = psi?.containingFile?.let { PsiSourceFile(it) } ?: SourceFile.NO_SOURCE_FILE
|
||||
override fun getContainingFile(): SourceFile = psi?.containingFile?.let(::PsiSourceFile) ?: SourceFile.NO_SOURCE_FILE
|
||||
}
|
||||
|
||||
class PsiSourceFile(val psiFile: PsiFile): SourceFile {
|
||||
|
||||
@@ -47,9 +47,7 @@ abstract class PerformanceCounter protected constructor(val name: String) {
|
||||
|
||||
fun resetAllCounters() {
|
||||
synchronized(allCounters) {
|
||||
allCounters.forEach {
|
||||
it.reset()
|
||||
}
|
||||
allCounters.forEach(PerformanceCounter::reset)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,9 +139,7 @@ val KtClassOrObject.hasInterfaceDefaultImpls: Boolean
|
||||
get() = this is KtClass && isInterface() && hasNonAbstractMembers(this)
|
||||
|
||||
private fun hasNonAbstractMembers(ktInterface: KtClass): Boolean {
|
||||
return ktInterface.declarations.any {
|
||||
isNonAbstractMember(it)
|
||||
}
|
||||
return ktInterface.declarations.any(::isNonAbstractMember)
|
||||
}
|
||||
|
||||
private fun isNonAbstractMember(member: KtDeclaration?): Boolean {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
fun getReceiverValueWithSmartCast(
|
||||
receiverArgument: ReceiverValue?,
|
||||
smartCastType: KotlinType?
|
||||
) = smartCastType?.let { SmartCastReceiverValue(it) } ?: receiverArgument
|
||||
) = smartCastType?.let(::SmartCastReceiverValue) ?: receiverArgument
|
||||
|
||||
private class SmartCastReceiverValue(private val type: KotlinType) : ReceiverValue {
|
||||
override fun getType() = type
|
||||
|
||||
+2
-2
@@ -182,7 +182,7 @@ object JavaAnnotationTargetMapper {
|
||||
val kotlinTargets = arguments.filterIsInstance<JavaEnumValueAnnotationArgument>()
|
||||
.flatMap { mapJavaTargetArgumentByName(it.resolve()?.name?.asString()) }
|
||||
.mapNotNull { builtIns.getAnnotationTargetEnumEntry(it) }
|
||||
.map { EnumValue(it) }
|
||||
.map(::EnumValue)
|
||||
val parameterDescriptor = DescriptorResolverUtils.getAnnotationParameterByName(
|
||||
JavaAnnotationMapper.TARGET_ANNOTATION_ALLOWED_TARGETS, builtIns.targetAnnotation
|
||||
)
|
||||
@@ -199,7 +199,7 @@ object JavaAnnotationTargetMapper {
|
||||
// Map argument: java.lang.annotation.Retention -> kotlin.annotation.annotation
|
||||
return (element as? JavaEnumValueAnnotationArgument)?.let {
|
||||
retentionNameList[it.resolve()?.name?.asString()]?.let {
|
||||
(builtIns.getAnnotationRetentionEnumEntry(it) as? ClassDescriptor)?.let { EnumValue(it) }
|
||||
(builtIns.getAnnotationRetentionEnumEntry(it) as? ClassDescriptor)?.let(::EnumValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ object BuiltinSpecialProperties {
|
||||
.groupBy({ it.second }, { it.first })
|
||||
|
||||
private val SPECIAL_FQ_NAMES = PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP.keys
|
||||
internal val SPECIAL_SHORT_NAMES = SPECIAL_FQ_NAMES.map { it.shortName() }.toSet()
|
||||
internal val SPECIAL_SHORT_NAMES = SPECIAL_FQ_NAMES.map(FqName::shortName).toSet()
|
||||
|
||||
fun hasBuiltinSpecialPropertyFqName(callableMemberDescriptor: CallableMemberDescriptor): Boolean {
|
||||
if (callableMemberDescriptor.name !in SPECIAL_SHORT_NAMES) return false
|
||||
|
||||
+2
-2
@@ -34,9 +34,9 @@ interface ReflectJavaAnnotationOwner : JavaAnnotationOwner {
|
||||
}
|
||||
|
||||
fun Array<Annotation>.getAnnotations(): List<ReflectJavaAnnotation> {
|
||||
return map { ReflectJavaAnnotation(it) }
|
||||
return map(::ReflectJavaAnnotation)
|
||||
}
|
||||
|
||||
fun Array<Annotation>.findAnnotation(fqName: FqName): ReflectJavaAnnotation? {
|
||||
return firstOrNull { it.annotationClass.java.classId.asSingleFqName() == fqName }?.let { ReflectJavaAnnotation(it) }
|
||||
return firstOrNull { it.annotationClass.java.classId.asSingleFqName() == fqName }?.let(::ReflectJavaAnnotation)
|
||||
}
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ class ReflectJavaClass(
|
||||
get() = Name.identifier(klass.simpleName)
|
||||
|
||||
override val typeParameters: List<ReflectJavaTypeParameter>
|
||||
get() = klass.typeParameters.map { ReflectJavaTypeParameter(it) }
|
||||
get() = klass.typeParameters.map(::ReflectJavaTypeParameter)
|
||||
|
||||
override val isInterface: Boolean
|
||||
get() = klass.isInterface
|
||||
|
||||
+1
-1
@@ -46,5 +46,5 @@ class ReflectJavaConstructor(override val member: Constructor<*>) : ReflectJavaM
|
||||
}
|
||||
|
||||
override val typeParameters: List<ReflectJavaTypeParameter>
|
||||
get() = member.typeParameters.map { ReflectJavaTypeParameter(it) }
|
||||
get() = member.typeParameters.map(::ReflectJavaTypeParameter)
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,5 +31,5 @@ class ReflectJavaMethod(override val member: Method) : ReflectJavaMember(), Java
|
||||
get() = member.defaultValue != null
|
||||
|
||||
override val typeParameters: List<ReflectJavaTypeParameter>
|
||||
get() = member.typeParameters.map { ReflectJavaTypeParameter(it) }
|
||||
get() = member.typeParameters.map(::ReflectJavaTypeParameter)
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ class ReflectJavaTypeParameter(
|
||||
) : ReflectJavaElement(), JavaTypeParameter, ReflectJavaAnnotationOwner {
|
||||
override val upperBounds: List<ReflectJavaClassifierType>
|
||||
get() {
|
||||
val bounds = typeVariable.bounds.map { bound -> ReflectJavaClassifierType(bound) }
|
||||
val bounds = typeVariable.bounds.map(::ReflectJavaClassifierType)
|
||||
if (bounds.singleOrNull()?.reflectType == Any::class.java) return emptyList()
|
||||
return bounds
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ fun KotlinTypeChecker.equalTypesOrNulls(type1: KotlinType?, type2: KotlinType?):
|
||||
|
||||
fun KotlinType.containsError() = ErrorUtils.containsErrorType(this)
|
||||
|
||||
fun List<KotlinType>.defaultProjections(): List<TypeProjection> = map { TypeProjectionImpl(it) }
|
||||
fun List<KotlinType>.defaultProjections(): List<TypeProjection> = map(::TypeProjectionImpl)
|
||||
|
||||
fun KotlinType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative())
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(
|
||||
return when (insn.opcode) {
|
||||
MULTIANEWARRAY -> {
|
||||
val node = insn as MultiANewArrayInsnNode
|
||||
eval.newMultiDimensionalArray(Type.getType(node.desc), values.map { v -> v.int })
|
||||
eval.newMultiDimensionalArray(Type.getType(node.desc), values.map(Value::int))
|
||||
}
|
||||
|
||||
INVOKEVIRTUAL, INVOKESPECIAL, INVOKEINTERFACE -> {
|
||||
|
||||
@@ -30,7 +30,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
var versionStr = args[0]
|
||||
|
||||
val incrementPartStr = versionStr.takeLastWhile { it.isDigit() }
|
||||
val incrementPartStr = versionStr.takeLastWhile(Char::isDigit)
|
||||
val versionPrefix = versionStr.take(versionStr.length - incrementPartStr.length)
|
||||
val incrementPart = incrementPartStr.toInt()
|
||||
|
||||
|
||||
+1
-3
@@ -176,9 +176,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
}
|
||||
|
||||
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
val filesByModule = findFilesForFacade(facadeFqName, scope).groupBy {
|
||||
it.getModuleInfo()
|
||||
}
|
||||
val filesByModule = findFilesForFacade(facadeFqName, scope).groupBy(KtFile::getModuleInfo)
|
||||
|
||||
return filesByModule.flatMap {
|
||||
createLightClassForFileFacade(facadeFqName, it.value, it.key)
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ class KotlinCacheServiceImpl(val project: Project) : KotlinCacheService {
|
||||
private fun createFacadeForSyntheticFiles(files: Set<KtFile>): ProjectResolutionFacade {
|
||||
// we assume that all files come from the same module
|
||||
val targetPlatform = files.map { TargetPlatformDetector.getPlatform(it) }.toSet().single()
|
||||
val syntheticFileModule = files.map { it.getModuleInfo() }.toSet().single()
|
||||
val syntheticFileModule = files.map(KtFile::getModuleInfo).toSet().single()
|
||||
val sdk = syntheticFileModule.sdk
|
||||
val filesModificationTracker = ModificationTracker {
|
||||
// TODO: Check getUserData(FILE_OUT_OF_BLOCK_MODIFICATION_COUNT) actually works
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class LibraryDependenciesCache(private val project: Project) {
|
||||
}, Unit)
|
||||
}
|
||||
|
||||
getLibraryUsageIndex().modulesLibraryIsUsedIn[library].forEach { module -> collectLibrariesAndSdksAcrossDependencies(module) }
|
||||
getLibraryUsageIndex().modulesLibraryIsUsedIn[library].forEach(::collectLibrariesAndSdksAcrossDependencies)
|
||||
|
||||
return Pair(libraries.toList(), sdks.toList())
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ fun createModuleResolverProvider(
|
||||
|
||||
val allModuleInfos = (allModules ?: collectAllModuleInfosFromIdeaModel(project)).toHashSet()
|
||||
|
||||
val syntheticFilesByModule = syntheticFiles.groupBy { it.getModuleInfo() }
|
||||
val syntheticFilesByModule = syntheticFiles.groupBy(KtFile::getModuleInfo)
|
||||
val syntheticFilesModules = syntheticFilesByModule.keys
|
||||
allModuleInfos.addAll(syntheticFilesModules)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.HashSet
|
||||
fun ModuleSourceInfo.getDependentModules(): Set<ModuleSourceInfo> {
|
||||
val dependents = getDependents(module)
|
||||
if (isTests()) {
|
||||
return dependents.mapTo(HashSet<ModuleSourceInfo>()) { it.testSourceInfo() }
|
||||
return dependents.mapTo(HashSet<ModuleSourceInfo>(), Module::testSourceInfo)
|
||||
}
|
||||
else {
|
||||
return dependents.flatMapTo(HashSet<ModuleSourceInfo>()) { listOf(it.productionSourceInfo(), it.testSourceInfo()) }
|
||||
|
||||
@@ -78,7 +78,7 @@ fun renderResolvedCall(resolvedCall: ResolvedCall<*>, context: RenderingContext)
|
||||
}
|
||||
|
||||
val typeParameters = resolvedCall.candidateDescriptor.typeParameters
|
||||
val (inferredTypeParameters, notInferredTypeParameters) = typeParameters.partition { parameter -> parameter.isInferred() }
|
||||
val (inferredTypeParameters, notInferredTypeParameters) = typeParameters.partition(TypeParameterDescriptor::isInferred)
|
||||
|
||||
append("<br/>$indent<i>where</i> ")
|
||||
if (!notInferredTypeParameters.isEmpty()) {
|
||||
@@ -103,7 +103,7 @@ fun renderResolvedCall(resolvedCall: ResolvedCall<*>, context: RenderingContext)
|
||||
append(typeRenderer.render(receiverParameter.type, context)).append(".")
|
||||
}
|
||||
append(HtmlEscapers.htmlEscaper().escape(resultingDescriptor.name.asString())).append("(")
|
||||
append(resultingDescriptor.valueParameters.map { parameter -> renderParameter(parameter) }.joinToString())
|
||||
append(resultingDescriptor.valueParameters.map(::renderParameter).joinToString())
|
||||
append(if (resolvedCall.hasUnmappedArguments()) renderError(")") else ")")
|
||||
|
||||
if (!resolvedCall.candidateDescriptor.typeParameters.isEmpty()) {
|
||||
|
||||
@@ -32,7 +32,7 @@ fun PsiElement.getKotlinFqName(): FqName? {
|
||||
val element = namedUnwrappedElement
|
||||
return when (element) {
|
||||
is PsiPackage -> FqName(element.qualifiedName)
|
||||
is PsiClass -> element.qualifiedName?.let { FqName(it) }
|
||||
is PsiClass -> element.qualifiedName?.let(::FqName)
|
||||
is PsiMember -> element.getName()?.let { name ->
|
||||
val prefix = element.containingClass?.qualifiedName
|
||||
FqName(if (prefix != null) "$prefix.$name" else name)
|
||||
|
||||
+1
-3
@@ -203,9 +203,7 @@ class ExpressionsOfTypeProcessor(
|
||||
}
|
||||
|
||||
private enum class ReferenceProcessor(val handler: (ExpressionsOfTypeProcessor, PsiReference) -> Boolean) {
|
||||
CallableOfOurType({ processor, reference ->
|
||||
processor.processReferenceToCallableOfOurType(reference)
|
||||
}),
|
||||
CallableOfOurType(ExpressionsOfTypeProcessor::processReferenceToCallableOfOurType),
|
||||
|
||||
ProcessLambdasInCalls({ processor, reference ->
|
||||
(reference.element as? KtReferenceExpression)?.let { processor.processLambdasForCallableReference(it) }
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class StubBasedPackageMemberDeclarationProvider(
|
||||
.mapTo(result) { KtClassInfoUtil.createClassLikeInfo(it) }
|
||||
|
||||
KotlinScriptFqnIndex.instance.get(childName(name), project, searchScope)
|
||||
.mapTo(result) { KtScriptInfo(it) }
|
||||
.mapTo(result, ::KtScriptInfo)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ abstract class DeclarationLookupObjectImpl(
|
||||
return if (descriptor != null)
|
||||
descriptor.importableFqName
|
||||
else
|
||||
(psiElement as? PsiClass)?.qualifiedName?.let { FqName(it) }
|
||||
(psiElement as? PsiClass)?.qualifiedName?.let(::FqName)
|
||||
}
|
||||
|
||||
override fun toString() = super.toString() + " " + (descriptor ?: psiElement)
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ class InsertHandlerProvider(
|
||||
}
|
||||
}
|
||||
|
||||
originalFunction.extensionReceiverParameter?.type?.let { addPotentiallyInferred(it) }
|
||||
originalFunction.extensionReceiverParameter?.type?.let(::addPotentiallyInferred)
|
||||
originalFunction.valueParameters.forEach { addPotentiallyInferred(it.type) }
|
||||
|
||||
fun allTypeParametersPotentiallyInferred() = originalFunction.typeParameters.all { it in potentiallyInferred }
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ fun createKeywordConstructLookupElement(
|
||||
private fun detectIndent(text: CharSequence, offset: Int): String {
|
||||
return text.substring(0, offset)
|
||||
.substringAfterLast('\n')
|
||||
.takeWhile { it.isWhitespace() }
|
||||
.takeWhile(Char::isWhitespace)
|
||||
}
|
||||
|
||||
private fun String.indentLinesAfterFirst(indent: String): String {
|
||||
|
||||
+1
-1
@@ -412,7 +412,7 @@ class SmartCompletion(
|
||||
if (descriptor.modality != Modality.ABSTRACT && !descriptor.isInner) {
|
||||
descriptor.constructors
|
||||
.filter(visibilityFilter)
|
||||
.mapNotNullTo(this) { toLookupElement(it) }
|
||||
.mapNotNullTo(this, ::toLookupElement)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class OverrideMembersHandler(private val preferConstructorParameters: Boolean =
|
||||
}
|
||||
}
|
||||
|
||||
val realSupers = byOriginalRealSupers.values.map { it.realSuper }
|
||||
val realSupers = byOriginalRealSupers.values.map(Data::realSuper)
|
||||
val nonAbstractRealSupers = realSupers.filter { it.modality != Modality.ABSTRACT }
|
||||
val realSupersToUse = if (nonAbstractRealSupers.isNotEmpty()) {
|
||||
nonAbstractRealSupers
|
||||
|
||||
@@ -27,7 +27,7 @@ fun PsiDirectory.getPackage(): PsiPackage? = JavaDirectoryService.getInstance()!
|
||||
|
||||
fun PsiFile.getFqNameByDirectory(): FqName {
|
||||
val qualifiedNameByDirectory = parent?.getPackage()?.qualifiedName
|
||||
return qualifiedNameByDirectory?.let { FqName(it) } ?: FqName.ROOT
|
||||
return qualifiedNameByDirectory?.let(::FqName) ?: FqName.ROOT
|
||||
}
|
||||
|
||||
fun KtFile.packageMatchesDirectory(): Boolean = packageFqName == getFqNameByDirectory()
|
||||
+7
-7
@@ -49,7 +49,7 @@ class GradleScriptTemplatesProvider(project: Project): ScriptTemplatesProvider {
|
||||
gradleExeSettings?.daemonVmOptions?.let { vmOptions ->
|
||||
CommandLineTokenizer(vmOptions).toList()
|
||||
.mapNotNull { it?.let { it as? String } }
|
||||
.filterNot { it.isBlank() }
|
||||
.filterNot(String::isBlank)
|
||||
.distinct()
|
||||
} ?: emptyList()
|
||||
}
|
||||
@@ -68,13 +68,13 @@ class GradleScriptTemplatesProvider(project: Project): ScriptTemplatesProvider {
|
||||
override val environment: Map<String, Any?>? by lazy {
|
||||
|
||||
mapOf(
|
||||
"gradleHome" to gradleExeSettings?.gradleHome?.let { File(it) },
|
||||
"projectRoot" to (project.basePath ?: project.baseDir.canonicalPath)?.let { File(it) },
|
||||
"gradleWithConnection" to { action: (ProjectConnection) -> Unit ->
|
||||
"gradleHome" to gradleExeSettings?.gradleHome?.let(::File),
|
||||
"projectRoot" to (project.basePath ?: project.baseDir.canonicalPath)?.let(::File),
|
||||
"gradleWithConnection" to { action: (ProjectConnection) -> Unit ->
|
||||
GradleExecutionHelper().execute(project.basePath!!, null) { action(it) } },
|
||||
"gradleJavaHome" to gradleExeSettings?.javaHome,
|
||||
"gradleJvmOptions" to gradleJvmOptions,
|
||||
"getScriptSectionTokens" to ::topLevelSectionCodeTextTokens)
|
||||
"gradleJavaHome" to gradleExeSettings?.javaHome,
|
||||
"gradleJvmOptions" to gradleJvmOptions,
|
||||
"getScriptSectionTokens" to ::topLevelSectionCodeTextTokens)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -544,7 +544,7 @@ class PomFile private constructor(val xmlFile: XmlFile, val domModel: MavenDomPr
|
||||
<profiles/>
|
||||
""".lines()
|
||||
.map { it.trim().removePrefix("<").removeSuffix("/>").trim() }
|
||||
.filter { it.isNotEmpty() }
|
||||
.filter(String::isNotEmpty)
|
||||
.toCollection(LinkedHashSet())
|
||||
|
||||
val recommendedOrderAsList = recommendedElementsOrder.toList()
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ class DifferentMavenStdlibVersionInspection : DomElementsInspection<MavenDomProj
|
||||
}
|
||||
|
||||
private fun createFixes(project: MavenProject, versionElement: GenericDomValue<*>, versions: List<String>): List<SetVersionQuickFix> {
|
||||
val bestVersion = versions.maxBy { MavenVersionComparable(it) }!!
|
||||
val bestVersion = versions.maxBy(::MavenVersionComparable)!!
|
||||
if (bestVersion == versionElement.stringValue) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ abstract class ConfigureKotlinInProjectAction : AnAction() {
|
||||
val project = e.project ?: return
|
||||
|
||||
val modules = getModulesWithKotlinFiles(project).ifEmpty { project.allModules() }
|
||||
if (modules.all { isModuleConfigured(it) }) {
|
||||
if (modules.all(::isModuleConfigured)) {
|
||||
Messages.showInfoMessage("All modules with Kotlin files are configured", e.presentation.text!!)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class KotlinCreateFromTemplateHandler : DefaultCreateFromTemplateHandler() {
|
||||
if (!packageName.isNullOrEmpty()) {
|
||||
props[FileTemplate.ATTRIBUTE_PACKAGE_NAME] = packageName!!
|
||||
.split('.')
|
||||
.map { it.quoteIfNeeded() }
|
||||
.map(String::quoteIfNeeded)
|
||||
.joinToString(".")
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: Li
|
||||
ApplicationManager.getApplication().executeOnPooledThread {
|
||||
val notificationString = DumbService.getInstance(project).runReadActionInSmartMode(Computable {
|
||||
val modules = getModulesWithKotlinFiles(project) - excludeModules
|
||||
if (modules.all { isModuleConfigured(it) }) null else ConfigureKotlinNotification.getNotificationString(project, excludeModules)
|
||||
if (modules.all(::isModuleConfigured)) null else ConfigureKotlinNotification.getNotificationString(project, excludeModules)
|
||||
})
|
||||
if (notificationString != null) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
|
||||
+1
-1
@@ -243,7 +243,7 @@ private fun addDebugExpressionBeforeContextElement(codeFragment: KtCodeFragment,
|
||||
|
||||
fun insertExpression(expr: KtElement?): List<KtExpression> {
|
||||
when (expr) {
|
||||
is KtBlockExpression -> return expr.statements.flatMap { insertExpression(it) }
|
||||
is KtBlockExpression -> return expr.statements.flatMap(::insertExpression)
|
||||
is KtExpression -> {
|
||||
val newDebugExpression = parent.addBefore(expr, elementBefore)
|
||||
if (newDebugExpression == null) {
|
||||
|
||||
@@ -59,7 +59,7 @@ class AddVarianceModifierInspection : AbstractKotlinInspection() {
|
||||
}
|
||||
if (variances.size == 1) {
|
||||
val suggested = variances.first()
|
||||
val fixes = variances.map { AddVarianceFix(it) }
|
||||
val fixes = variances.map(::AddVarianceFix)
|
||||
holder.registerProblem(
|
||||
typeParameter,
|
||||
"Type parameter can have $suggested variance",
|
||||
|
||||
@@ -39,7 +39,7 @@ class SuggestVariableNameMacro : Macro() {
|
||||
override fun getPresentableName() = "kotlinSuggestVariableName()"
|
||||
|
||||
override fun calculateResult(params: Array<out Expression>, context: ExpressionContext): Result? {
|
||||
return suggestNames(context).firstOrNull()?.let { TextResult(it) }
|
||||
return suggestNames(context).firstOrNull()?.let(::TextResult)
|
||||
}
|
||||
|
||||
override fun calculateLookupItems(params: Array<out Expression>, context: ExpressionContext): Array<out LookupElement>? {
|
||||
|
||||
@@ -209,7 +209,7 @@ open class KotlinChangeInfo(
|
||||
|
||||
for (caller in value) {
|
||||
add(caller)
|
||||
OverridingMethodsSearch.search(caller.getRepresentativeLightMethod() ?: continue).forEach { add(it) }
|
||||
OverridingMethodsSearch.search(caller.getRepresentativeLightMethod() ?: continue).forEach(::add)
|
||||
}
|
||||
|
||||
propagationTargetUsageInfos = result.toList()
|
||||
|
||||
+1
-1
@@ -260,7 +260,7 @@ data class ExtractionData(
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
expressions.forEach { unmarkReferencesInside(it) }
|
||||
expressions.forEach(::unmarkReferencesInside)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ open class IntroduceTypeAliasParameterTablePanel : AbstractParameterTablePanel<T
|
||||
}
|
||||
|
||||
fun init(parameters: List<TypeParameter>) {
|
||||
parameterInfos = parameters.mapTo(ArrayList()) { TypeParameterInfo(it) }
|
||||
parameterInfos = parameters.mapTo(ArrayList(), ::TypeParameterInfo)
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ class KotlinAwareMoveFilesOrDirectoriesDialog(
|
||||
this.helpID = helpID
|
||||
|
||||
with (updatePackageDirectiveCb) {
|
||||
val jetFiles = psiElements.filterIsInstance<KtFile>().filter { it.isInJavaSourceRoot() }
|
||||
val jetFiles = psiElements.filterIsInstance<KtFile>().filter(KtFile::isInJavaSourceRoot)
|
||||
if (jetFiles.isEmpty()) {
|
||||
parent.remove(updatePackageDirectiveCb)
|
||||
return
|
||||
|
||||
@@ -138,7 +138,7 @@ fun KtElement.lazilyProcessInternalReferencesToUpdateOnPackageNameChange(
|
||||
if (isExtension && containingDescriptor is ClassDescriptor) {
|
||||
val implicitClass = (refExpr.getResolvedCall(bindingContext)?.dispatchReceiver as? ImplicitClassReceiver)?.classDescriptor
|
||||
if (DescriptorUtils.isCompanionObject(implicitClass)) {
|
||||
return { ImplicitCompanionAsDispatchReceiverUsageInfo(it) }
|
||||
return ::ImplicitCompanionAsDispatchReceiverUsageInfo
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class JavaToKotlinPullUpHelperFactory : PullUpHelperFactory {
|
||||
return outerPsiClasses
|
||||
.drop(1)
|
||||
.plus(dummyTargetClass)
|
||||
.fold(dummyFile.add(outerPsiClasses.first())) { parent, child -> parent.add(child) } as PsiClass
|
||||
.fold(dummyFile.add(outerPsiClasses.first()), PsiElement::add) as PsiClass
|
||||
}
|
||||
|
||||
override fun createPullUpHelper(data: PullUpData): PullUpHelper<*> {
|
||||
|
||||
@@ -105,7 +105,7 @@ class KotlinPushDownProcessor(
|
||||
return HierarchySearchRequest(context.sourceClass, context.sourceClass.useScope, false)
|
||||
.searchInheritors()
|
||||
.mapNotNull { it.unwrapped }
|
||||
.map { SubclassUsage(it) }
|
||||
.map(::SubclassUsage)
|
||||
.toTypedArray()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
|
||||
|
||||
RenameUtil.doRenameGenericNamedElement(element, newName, simpleUsages.toTypedArray(), listener)
|
||||
|
||||
(element.unwrapped as? KtNamedDeclaration)?.let { dropOverrideKeywordIfNecessary(it) }
|
||||
(element.unwrapped as? KtNamedDeclaration)?.let(::dropOverrideKeywordIfNecessary)
|
||||
}
|
||||
|
||||
private fun wrapPsiMethod(element: PsiElement?): PsiMethod? = when (element) {
|
||||
|
||||
+1
-1
@@ -315,7 +315,7 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
|
||||
is KtProperty ->
|
||||
if (!element.isLocal) {
|
||||
element.toLightMethods().forEach { method -> method.cleanUpOverrides() }
|
||||
element.toLightMethods().forEach(PsiMethod::cleanUpOverrides)
|
||||
}
|
||||
|
||||
is KtTypeParameter ->
|
||||
|
||||
@@ -102,7 +102,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
|
||||
if (commentInfo.isComment) {
|
||||
// Original comment was first in line, but there's no line break before the current one
|
||||
if (!commentInfo.isPostInsert && commentInfo.isFirstNonWhitespaceElementInLine &&
|
||||
!builder.takeLastWhile { it.isWhitespace() }.contains('\n')) {
|
||||
!builder.takeLastWhile(Char::isWhitespace).contains('\n')) {
|
||||
builder.append('\n')
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ fun Converter.convertImport(anImport: PsiImportStatementBase, dumpConversion: Bo
|
||||
}
|
||||
else {
|
||||
convertImport(fqName, reference, onDemand, anImport is PsiImportStaticStatement)
|
||||
.map { Import(it) }
|
||||
.map(::Import)
|
||||
}
|
||||
return convertedImports.map { it.assignPrototype(anImport) }
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
if (IncrementalCompilation.isEnabled()) {
|
||||
for (target in chunk.targets) {
|
||||
val cache = incrementalCaches[target]!!
|
||||
val removedAndDirtyFiles = filesToCompile[target] + dirtyFilesHolder.getRemovedFiles(target).map { File(it) }
|
||||
val removedAndDirtyFiles = filesToCompile[target] + dirtyFilesHolder.getRemovedFiles(target).map(::File)
|
||||
cache.markOutputClassesDirty(removedAndDirtyFiles)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class JpsIncrementalCacheImpl(
|
||||
}
|
||||
}
|
||||
|
||||
return result.map { File(it) }
|
||||
return result.map(::File)
|
||||
}
|
||||
|
||||
fun cleanDirtyInlineFunctions() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.getNameForAnnotatedObject
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isNativeObject
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||
@@ -85,7 +86,7 @@ class NameSuggestion {
|
||||
|
||||
is PackageFragmentDescriptor -> {
|
||||
return if (!descriptor.fqName.isRoot) {
|
||||
SuggestedName(descriptor.fqName.pathSegments().map { it.asString() }, true, descriptor,
|
||||
SuggestedName(descriptor.fqName.pathSegments().map(Name::asString), true, descriptor,
|
||||
descriptor.containingDeclaration)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -66,7 +66,7 @@ class FunctionReader(private val context: TranslationContext) {
|
||||
|
||||
init {
|
||||
val config = context.config as LibrarySourcesConfig
|
||||
val libs = config.libraries.map { File(it) }
|
||||
val libs = config.libraries.map(::File)
|
||||
|
||||
JsLibraryUtils.traverseJsLibraries(libs) { fileContent, _ ->
|
||||
var current = 0
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ private fun moveCapturedLocalInside(capturingFunction: JsFunction, capturedName:
|
||||
val scope = capturingFunction.getInnerFunction()?.scope!!
|
||||
val freshNames = getTemporaryNamesInScope(scope, capturedArgs)
|
||||
|
||||
val aliasCallArguments = freshNames.map { it.makeRef() }
|
||||
val aliasCallArguments = freshNames.map(JsName::makeRef)
|
||||
val alias = JsInvocation(localFunAlias.qualifier, aliasCallArguments)
|
||||
declareAliasInsideFunction(capturingFunction, capturedName, alias)
|
||||
|
||||
|
||||
+2
-2
@@ -89,9 +89,9 @@ object LongOperationFIF : FunctionIntrinsicFactory {
|
||||
LONG_EQUALS_ANY.apply(descriptor) || LONG_BINARY_OPERATION_LONG.apply(descriptor) || LONG_BIT_SHIFTS.apply(descriptor) ->
|
||||
longBinaryIntrinsics[operationName]
|
||||
INTEGER_BINARY_OPERATION_LONG.apply(descriptor) ->
|
||||
wrapIntrinsicIfPresent(longBinaryIntrinsics[operationName], { longFromInt(it) }, ID())
|
||||
wrapIntrinsicIfPresent(longBinaryIntrinsics[operationName], ::longFromInt, ID())
|
||||
LONG_BINARY_OPERATION_INTEGER.apply(descriptor) ->
|
||||
wrapIntrinsicIfPresent(longBinaryIntrinsics[operationName], ID(), { longFromInt(it) })
|
||||
wrapIntrinsicIfPresent(longBinaryIntrinsics[operationName], ID(), ::longFromInt)
|
||||
FLOATING_POINT_BINARY_OPERATION_LONG.apply(descriptor) ->
|
||||
wrapIntrinsicIfPresent(floatBinaryIntrinsics[operationName], ID(), { invokeMethod(it, Namer.LONG_TO_NUMBER) })
|
||||
LONG_BINARY_OPERATION_FLOATING_POINT.apply(descriptor) ->
|
||||
|
||||
+7
-7
@@ -33,14 +33,14 @@ object NumberAndCharConversionFIF : CompositeFIF() {
|
||||
|
||||
private val convertOperations: Map<String, ConversionUnaryIntrinsic> =
|
||||
mapOf(
|
||||
"Float|Double.toInt" to ConversionUnaryIntrinsic { toInt32(it) },
|
||||
"Int|Float|Double.toShort" to ConversionUnaryIntrinsic { toShort(it) },
|
||||
"Short|Int|Float|Double.toByte" to ConversionUnaryIntrinsic { toByte(it) },
|
||||
"Float|Double.toInt" to ConversionUnaryIntrinsic(::toInt32),
|
||||
"Int|Float|Double.toShort" to ConversionUnaryIntrinsic(::toShort),
|
||||
"Short|Int|Float|Double.toByte" to ConversionUnaryIntrinsic(::toByte),
|
||||
|
||||
"Int|Short|Byte.toLong" to ConversionUnaryIntrinsic { longFromInt(it) },
|
||||
"Float|Double.toLong" to ConversionUnaryIntrinsic { longFromNumber(it) },
|
||||
"Int|Short|Byte.toLong" to ConversionUnaryIntrinsic(::longFromInt),
|
||||
"Float|Double.toLong" to ConversionUnaryIntrinsic(::longFromNumber),
|
||||
|
||||
"Char.toDouble|toFloat|toInt" to ConversionUnaryIntrinsic { charToInt(it) },
|
||||
"Char.toDouble|toFloat|toInt" to ConversionUnaryIntrinsic(::charToInt),
|
||||
"Char.toShort" to ConversionUnaryIntrinsic { toShort(charToInt(it)) },
|
||||
"Char.toByte" to ConversionUnaryIntrinsic { toByte(charToInt(it)) },
|
||||
"Char.toLong" to ConversionUnaryIntrinsic { longFromInt(charToInt(it)) },
|
||||
@@ -52,7 +52,7 @@ object NumberAndCharConversionFIF : CompositeFIF() {
|
||||
"Number.toFloat|toDouble" to ConversionUnaryIntrinsic { invokeKotlinFunction("numberToDouble", it) },
|
||||
"Number.toLong" to ConversionUnaryIntrinsic { invokeKotlinFunction("numberToLong", it) },
|
||||
|
||||
"Int|Short|Byte|Float|Double.toChar" to ConversionUnaryIntrinsic { toChar(it) },
|
||||
"Int|Short|Byte|Float|Double.toChar" to ConversionUnaryIntrinsic(::toChar),
|
||||
|
||||
"Long.toFloat|toDouble" to ConversionUnaryIntrinsic { invokeMethod(it, "toNumber") },
|
||||
"Long.toInt" to ConversionUnaryIntrinsic { invokeMethod(it, "toInt") },
|
||||
|
||||
+2
-2
@@ -64,9 +64,9 @@ object LongCompareToBOIF : BinaryOperationIntrinsicFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private val INTEGER_COMPARE_TO_LONG = CompareToBinaryIntrinsic( { longFromInt(it) }, ID())
|
||||
private val INTEGER_COMPARE_TO_LONG = CompareToBinaryIntrinsic(::longFromInt, ID())
|
||||
private val CHAR_COMPARE_TO_LONG = CompareToBinaryIntrinsic( { longFromInt(charToInt(it)) }, ID())
|
||||
private val LONG_COMPARE_TO_INTEGER = CompareToBinaryIntrinsic( ID(), { longFromInt(it) })
|
||||
private val LONG_COMPARE_TO_INTEGER = CompareToBinaryIntrinsic(ID(), ::longFromInt)
|
||||
private val LONG_COMPARE_TO_CHAR = CompareToBinaryIntrinsic( ID(), { longFromInt(charToInt(it)) })
|
||||
private val LONG_COMPARE_TO_LONG = CompareToBinaryIntrinsic( ID(), ID() )
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ internal fun File.toComponents(): FilePathComponents {
|
||||
val rootLength = path.getRootLength()
|
||||
val rootName = path.substring(0, rootLength)
|
||||
val subPath = path.substring(rootLength)
|
||||
val list = if (subPath.isEmpty()) listOf() else subPath.split(File.separatorChar).map { File(it) }
|
||||
val list = if (subPath.isEmpty()) listOf() else subPath.split(File.separatorChar).map(::File)
|
||||
return FilePathComponents(File(rootName), list)
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public fun File.relativeTo(base: File): File = File(this.toRelativeString(base))
|
||||
* @return File with relative path from [base] to this, or `this` if this and base paths have different roots.
|
||||
*/
|
||||
public fun File.relativeToOrSelf(base: File): File
|
||||
= toRelativeStringOrNull(base)?.let { File(it) } ?: this
|
||||
= toRelativeStringOrNull(base)?.let(::File) ?: this
|
||||
|
||||
/**
|
||||
* Calculates the relative path for this file from [base] file.
|
||||
@@ -105,7 +105,7 @@ public fun File.relativeToOrSelf(base: File): File
|
||||
* @return File with relative path from [base] to this, or `null` if this and base paths have different roots.
|
||||
*/
|
||||
public fun File.relativeToOrNull(base: File): File?
|
||||
= toRelativeStringOrNull(base)?.let { File(it) }
|
||||
= toRelativeStringOrNull(base)?.let(::File)
|
||||
|
||||
|
||||
private fun File.toRelativeStringOrNull(base: File): String? {
|
||||
|
||||
@@ -74,8 +74,8 @@ public fun String.replaceIndent(newIndent: String = ""): String {
|
||||
val lines = lines()
|
||||
|
||||
val minCommonIndent = lines
|
||||
.filter { it.isNotBlank() }
|
||||
.map { it.indentWidth() }
|
||||
.filter(String::isNotBlank)
|
||||
.map(String::indentWidth)
|
||||
.min() ?: 0
|
||||
|
||||
return lines.reindent(length + newIndent.length * lines.size, getIndentFunction(newIndent), { line -> line.drop(minCommonIndent) })
|
||||
|
||||
@@ -125,7 +125,7 @@ public fun String.trimEnd(vararg chars: Char): String = trimEnd { it in chars }
|
||||
/**
|
||||
* Returns a sub sequence of this char sequence having leading and trailing whitespace trimmed.
|
||||
*/
|
||||
public fun CharSequence.trim(): CharSequence = trim { it.isWhitespace() }
|
||||
public fun CharSequence.trim(): CharSequence = trim(Char::isWhitespace)
|
||||
|
||||
/**
|
||||
* Returns a string with leading and trailing whitespace trimmed.
|
||||
@@ -136,7 +136,7 @@ public inline fun String.trim(): String = (this as CharSequence).trim().toString
|
||||
/**
|
||||
* Returns a sub sequence of this char sequence having leading whitespace removed.
|
||||
*/
|
||||
public fun CharSequence.trimStart(): CharSequence = trimStart { it.isWhitespace() }
|
||||
public fun CharSequence.trimStart(): CharSequence = trimStart(Char::isWhitespace)
|
||||
|
||||
/**
|
||||
* Returns a string with leading whitespace removed.
|
||||
@@ -147,7 +147,7 @@ public inline fun String.trimStart(): String = (this as CharSequence).trimStart(
|
||||
/**
|
||||
* Returns a sub sequence of this char sequence having trailing whitespace removed.
|
||||
*/
|
||||
public fun CharSequence.trimEnd(): CharSequence = trimEnd { it.isWhitespace() }
|
||||
public fun CharSequence.trimEnd(): CharSequence = trimEnd(Char::isWhitespace)
|
||||
|
||||
/**
|
||||
* Returns a string with trailing whitespace removed.
|
||||
|
||||
@@ -132,7 +132,7 @@ internal constructor(private val nativePattern: Pattern) {
|
||||
/**
|
||||
* Returns a sequence of all occurrences of a regular expression within the [input] string, beginning at the specified [startIndex].
|
||||
*/
|
||||
public fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = generateSequence({ find(input, startIndex) }, { match -> match.next() })
|
||||
public fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = generateSequence({ find(input, startIndex) }, MatchResult::next)
|
||||
|
||||
/**
|
||||
* Attempts to match the entire [input] CharSequence against the pattern.
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ internal fun genPropertyForWidget(
|
||||
resolvedWidget: ResolvedWidget,
|
||||
context: SyntheticElementResolveContext
|
||||
): PropertyDescriptor {
|
||||
val sourceEl = resolvedWidget.widget.sourceElement?.let { XmlSourceElement(it) } ?: SourceElement.NO_SOURCE
|
||||
val sourceEl = resolvedWidget.widget.sourceElement?.let(::XmlSourceElement) ?: SourceElement.NO_SOURCE
|
||||
|
||||
val classDescriptor = resolvedWidget.viewClassDescriptor
|
||||
val type = classDescriptor?.let {
|
||||
@@ -65,7 +65,7 @@ internal fun genPropertyForWidget(
|
||||
defaultType
|
||||
else
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor,
|
||||
defaultType.constructor.parameters.map { StarProjectionImpl(it) })
|
||||
defaultType.constructor.parameters.map(::StarProjectionImpl))
|
||||
} ?: context.viewType
|
||||
|
||||
return genProperty(resolvedWidget.widget.id, receiverType, type, packageFragmentDescriptor, sourceEl, resolvedWidget.errorType)
|
||||
@@ -77,7 +77,7 @@ internal fun genPropertyForFragment(
|
||||
type: SimpleType,
|
||||
fragment: AndroidResource.Fragment
|
||||
): PropertyDescriptor {
|
||||
val sourceElement = fragment.sourceElement?.let { XmlSourceElement(it) } ?: SourceElement.NO_SOURCE
|
||||
val sourceElement = fragment.sourceElement?.let(::XmlSourceElement) ?: SourceElement.NO_SOURCE
|
||||
return genProperty(fragment.id, receiverType, type, packageFragmentDescriptor, sourceElement, null)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -339,7 +339,7 @@ abstract class AbstractAnnotationProcessingExtension(
|
||||
}
|
||||
|
||||
val applicableAnnotations = applicableAnnotationNames
|
||||
.map { javaPsiFacade().findClass(it, projectScope())?.let { JeTypeElement(it) } }
|
||||
.map { javaPsiFacade().findClass(it, projectScope())?.let(::JeTypeElement) }
|
||||
.filterNotNullTo(hashSetOf())
|
||||
|
||||
log {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.java.model
|
||||
|
||||
import javax.lang.model.element.Name
|
||||
|
||||
fun JeName(name: String?) = name?.let { JeName(it) } ?: JeName.EMPTY
|
||||
fun JeName(name: String?) = name?.let(::JeName) ?: JeName.EMPTY
|
||||
|
||||
class JeName(val name: String) : Name, CharSequence by name {
|
||||
override fun contentEquals(cs: CharSequence?) = cs?.toString() == name
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class JeClassInitializerExecutableElement(
|
||||
) : JeAbstractElement<PsiClassInitializer>(psi), ExecutableElement, JeNoAnnotations, JeModifierListOwner {
|
||||
val isStaticInitializer = psi.isStatic
|
||||
|
||||
override fun getEnclosingElement() = psi.containingClass?.let { JeTypeElement(it) }
|
||||
override fun getEnclosingElement() = psi.containingClass?.let(::JeTypeElement)
|
||||
|
||||
override fun getSimpleName() = if (isStaticInitializer) JeName.CLINIT else JeName.EMPTY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user