private -> internal where it's necessary

This commit is contained in:
Zalim Bashorov
2015-09-25 14:18:23 +03:00
parent 0d2196e226
commit 8cb87b3e49
39 changed files with 145 additions and 148 deletions
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiWhiteSpace
import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.psi.psiUtil.siblings
private object EditCommaSeparatedListHelper { internal object EditCommaSeparatedListHelper {
public fun <TItem: JetElement> addItem(list: JetElement, allItems: List<TItem>, item: TItem): TItem { public fun <TItem: JetElement> addItem(list: JetElement, allItems: List<TItem>, item: TItem): TItem {
return addItemBefore(list, allItems, item, null) return addItemBefore(list, allItems, item, null)
} }
@@ -839,19 +839,19 @@ private fun getCompileTimeType(c: JetType): CompileTimeType<out Any>? {
private class CompileTimeType<T> private class CompileTimeType<T>
private val BYTE = CompileTimeType<Byte>() internal val BYTE = CompileTimeType<Byte>()
private val SHORT = CompileTimeType<Short>() internal val SHORT = CompileTimeType<Short>()
private val INT = CompileTimeType<Int>() internal val INT = CompileTimeType<Int>()
private val LONG = CompileTimeType<Long>() internal val LONG = CompileTimeType<Long>()
private val DOUBLE = CompileTimeType<Double>() internal val DOUBLE = CompileTimeType<Double>()
private val FLOAT = CompileTimeType<Float>() internal val FLOAT = CompileTimeType<Float>()
private val CHAR = CompileTimeType<Char>() internal val CHAR = CompileTimeType<Char>()
private val BOOLEAN = CompileTimeType<Boolean>() internal val BOOLEAN = CompileTimeType<Boolean>()
private val STRING = CompileTimeType<String>() internal val STRING = CompileTimeType<String>()
private val ANY = CompileTimeType<Any>() internal val ANY = CompileTimeType<Any>()
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private fun <A, B> binaryOperation( internal fun <A, B> binaryOperation(
a: CompileTimeType<A>, a: CompileTimeType<A>,
b: CompileTimeType<B>, b: CompileTimeType<B>,
functionName: String, functionName: String,
@@ -860,12 +860,12 @@ private fun <A, B> binaryOperation(
) = BinaryOperationKey(a, b, functionName) to Pair(operation, checker) as Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>> ) = BinaryOperationKey(a, b, functionName) to Pair(operation, checker) as Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private fun <A> unaryOperation( internal fun <A> unaryOperation(
a: CompileTimeType<A>, a: CompileTimeType<A>,
functionName: String, functionName: String,
operation: Function1<A, Any>, operation: Function1<A, Any>,
checker: Function1<Long, Long> checker: Function1<Long, Long>
) = UnaryOperationKey(a, functionName) to Pair(operation, checker) as Pair<Function1<Any?, Any>, Function1<Long, Long>> ) = UnaryOperationKey(a, functionName) to Pair(operation, checker) as Pair<Function1<Any?, Any>, Function1<Long, Long>>
private data class BinaryOperationKey<A, B>(val f: CompileTimeType<out A>, val s: CompileTimeType<out B>, val functionName: String) internal data class BinaryOperationKey<A, B>(val f: CompileTimeType<out A>, val s: CompileTimeType<out B>, val functionName: String)
private data class UnaryOperationKey<A>(val f: CompileTimeType<out A>, val functionName: String) internal data class UnaryOperationKey<A>(val f: CompileTimeType<out A>, val functionName: String)
@@ -17,14 +17,14 @@
package org.jetbrains.kotlin.resolve.constants.evaluate package org.jetbrains.kotlin.resolve.constants.evaluate
import java.math.BigInteger import java.math.BigInteger
import java.util.HashMap import java.util.*
/** This file is generated by org.jetbrains.kotlin.generators.evaluate:generate(). DO NOT MODIFY MANUALLY */ /** This file is generated by org.jetbrains.kotlin.generators.evaluate:generate(). DO NOT MODIFY MANUALLY */
private val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger("0") } internal val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger("0") }
private val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() } internal val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }
private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>> internal val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>
= hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>( = hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(
unaryOperation(BOOLEAN, "not", { a -> a.not() }, emptyUnaryFun), unaryOperation(BOOLEAN, "not", { a -> a.not() }, emptyUnaryFun),
unaryOperation(BOOLEAN, "toString", { a -> a.toString() }, emptyUnaryFun), unaryOperation(BOOLEAN, "toString", { a -> a.toString() }, emptyUnaryFun),
@@ -102,7 +102,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun) unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun)
) )
private val binaryOperations: HashMap<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>> internal val binaryOperations: HashMap<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>>
= hashMapOf<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>>( = hashMapOf<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>>(
binaryOperation(BOOLEAN, BOOLEAN, "and", { a, b -> a.and(b) }, emptyBinaryFun), binaryOperation(BOOLEAN, BOOLEAN, "and", { a, b -> a.and(b) }, emptyBinaryFun),
binaryOperation(BOOLEAN, BOOLEAN, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BOOLEAN, BOOLEAN, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.Variance.INVARIANT import org.jetbrains.kotlin.types.Variance.INVARIANT
import org.jetbrains.kotlin.types.Variance.IN_VARIANCE import org.jetbrains.kotlin.types.Variance.IN_VARIANCE
@@ -44,7 +43,7 @@ import org.jetbrains.kotlin.types.checker.JetTypeChecker
import org.jetbrains.kotlin.types.typeUtil.createProjection import org.jetbrains.kotlin.types.typeUtil.createProjection
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
import org.jetbrains.kotlin.utils.sure import org.jetbrains.kotlin.utils.sure
import java.util.HashSet import java.util.*
private val JAVA_LANG_CLASS_FQ_NAME: FqName = FqName("java.lang.Class") private val JAVA_LANG_CLASS_FQ_NAME: FqName = FqName("java.lang.Class")
@@ -337,7 +336,7 @@ class LazyJavaTypeResolver(
} }
private fun makeStarProjection( internal fun makeStarProjection(
typeParameter: TypeParameterDescriptor, typeParameter: TypeParameterDescriptor,
attr: JavaTypeAttributes attr: JavaTypeAttributes
): TypeProjection { ): TypeProjection {
@@ -418,7 +417,7 @@ fun JavaTypeAttributes.toFlexible(flexibility: JavaTypeFlexibility) =
// ErasedUpperBound(T : G<t>) = G<*> // UpperBound(T) is a type G<t> with arguments // ErasedUpperBound(T : G<t>) = G<*> // UpperBound(T) is a type G<t> with arguments
// ErasedUpperBound(T : A) = A // UpperBound(T) is a type A without arguments // ErasedUpperBound(T : A) = A // UpperBound(T) is a type A without arguments
// ErasedUpperBound(T : F) = UpperBound(F) // UB(T) is another type parameter F // ErasedUpperBound(T : F) = UpperBound(F) // UB(T) is another type parameter F
private fun TypeParameterDescriptor.getErasedUpperBound( internal fun TypeParameterDescriptor.getErasedUpperBound(
// Calculation of `potentiallyRecursiveTypeParameter.upperBounds` may recursively depend on `this.getErasedUpperBound` // Calculation of `potentiallyRecursiveTypeParameter.upperBounds` may recursively depend on `this.getErasedUpperBound`
// E.g. `class A<T extends A, F extends A>` // E.g. `class A<T extends A, F extends A>`
// To prevent recursive calls return defaultValue() instead // To prevent recursive calls return defaultValue() instead
@@ -80,7 +80,7 @@ public object RawTypeCapabilities : TypeCapabilities {
} }
} }
private object RawSubstitution : TypeSubstitution() { internal object RawSubstitution : TypeSubstitution() {
override fun get(key: JetType) = TypeProjectionImpl(eraseType(key)) override fun get(key: JetType) = TypeProjectionImpl(eraseType(key))
private val lowerTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND) private val lowerTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND)
@@ -68,10 +68,10 @@ fun generate(): String {
} }
} }
p.println("private val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger(\"0\") }") p.println("internal val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger(\"0\") }")
p.println("private val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }") p.println("internal val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }")
p.println() p.println()
p.println("private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>") p.println("internal val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>")
p.println(" = hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(") p.println(" = hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(")
p.pushIndent() p.pushIndent()
@@ -29,7 +29,7 @@ import com.intellij.psi.util.CachedValuesManager
import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.emptyOrSingletonList import org.jetbrains.kotlin.utils.emptyOrSingletonList
import java.util.LinkedHashSet import java.util.*
public val LIBRARY_NAME_PREFIX: String = "library " public val LIBRARY_NAME_PREFIX: String = "library "
@@ -111,7 +111,7 @@ public data class ModuleTestSourceInfo(override val module: Module) : ModuleSour
}) })
} }
private fun ModuleSourceInfo.isTests() = this is ModuleTestSourceInfo internal fun ModuleSourceInfo.isTests() = this is ModuleTestSourceInfo
public fun Module.productionSourceInfo(): ModuleProductionSourceInfo = ModuleProductionSourceInfo(this) public fun Module.productionSourceInfo(): ModuleProductionSourceInfo = ModuleProductionSourceInfo(this)
public fun Module.testSourceInfo(): ModuleTestSourceInfo = ModuleTestSourceInfo(this) public fun Module.testSourceInfo(): ModuleTestSourceInfo = ModuleTestSourceInfo(this)
@@ -160,7 +160,7 @@ public data class LibraryInfo(val project: Project, val library: Library) : Idea
override fun toString() = "LibraryInfo(libraryName=${library.getName()})" override fun toString() = "LibraryInfo(libraryName=${library.getName()})"
} }
private data class LibrarySourceInfo(val project: Project, val library: Library) : IdeaModuleInfo() { internal data class LibrarySourceInfo(val project: Project, val library: Library) : IdeaModuleInfo() {
override val name: Name = Name.special("<sources for library ${library.getName()}>") override val name: Name = Name.special("<sources for library ${library.getName()}>")
override fun contentScope() = GlobalSearchScope.EMPTY_SCOPE override fun contentScope() = GlobalSearchScope.EMPTY_SCOPE
@@ -184,7 +184,7 @@ public data class SdkInfo(val project: Project, val sdk: Sdk) : IdeaModuleInfo()
override fun dependencies(): List<IdeaModuleInfo> = listOf(this) override fun dependencies(): List<IdeaModuleInfo> = listOf(this)
} }
private object NotUnderContentRootModuleInfo : IdeaModuleInfo() { internal object NotUnderContentRootModuleInfo : IdeaModuleInfo() {
override val name: Name = Name.special("<special module for files not under source root>") override val name: Name = Name.special("<special module for files not under source root>")
override fun contentScope() = GlobalSearchScope.EMPTY_SCOPE override fun contentScope() = GlobalSearchScope.EMPTY_SCOPE
@@ -201,4 +201,4 @@ private data class LibraryWithoutSourceScope(project: Project, private val libra
private data class SdkScope(project: Project, private val sdk: Sdk) : private data class SdkScope(project: Project, private val sdk: Sdk) :
LibraryScopeBase(project, sdk.getRootProvider().getFiles(OrderRootType.CLASSES), arrayOf<VirtualFile>()) LibraryScopeBase(project, sdk.getRootProvider().getFiles(OrderRootType.CLASSES), arrayOf<VirtualFile>())
private fun IdeaModuleInfo.isLibraryClasses() = this is SdkInfo || this is LibraryInfo internal fun IdeaModuleInfo.isLibraryClasses() = this is SdkInfo || this is LibraryInfo
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
import org.jetbrains.kotlin.utils.keysToMap import org.jetbrains.kotlin.utils.keysToMap
private val LOG = Logger.getInstance(javaClass<KotlinCacheService>()) internal val LOG = Logger.getInstance(javaClass<KotlinCacheService>())
public class KotlinCacheService(val project: Project) { public class KotlinCacheService(val project: Project) {
companion object { companion object {
@@ -38,9 +38,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.ResolveSession
import java.util.HashMap import java.util.*
private class PerFileAnalysisCache(val file: JetFile, val componentProvider: ComponentProvider) { internal class PerFileAnalysisCache(val file: JetFile, val componentProvider: ComponentProvider) {
private val cache = HashMap<PsiElement, AnalysisResult>() private val cache = HashMap<PsiElement, AnalysisResult>()
private fun lookUp(analyzableElement: JetElement): AnalysisResult? { private fun lookUp(analyzableElement: JetElement): AnalysisResult? {
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.CompositeBindingContext
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.ResolveSession
private class ProjectResolutionFacade( internal class ProjectResolutionFacade(
val project: Project, val project: Project,
computeModuleResolverProvider: () -> CachedValueProvider.Result<ModuleResolverProvider> computeModuleResolverProvider: () -> CachedValueProvider.Result<ModuleResolverProvider>
) { ) {
@@ -85,7 +85,7 @@ private class ProjectResolutionFacade(
} }
} }
private class ResolutionFacadeImpl( internal class ResolutionFacadeImpl(
private val projectFacade: ProjectResolutionFacade, private val projectFacade: ProjectResolutionFacade,
private val moduleInfo: IdeaModuleInfo private val moduleInfo: IdeaModuleInfo
) : ResolutionFacade { ) : ResolutionFacade {
@@ -74,7 +74,7 @@ class ClsStubBuilderContext(
val typeParameters: TypeParameters val typeParameters: TypeParameters
) )
private fun ClsStubBuilderContext.child(typeParameterList: List<ProtoBuf.TypeParameter>, name: Name? = null): ClsStubBuilderContext { internal fun ClsStubBuilderContext.child(typeParameterList: List<ProtoBuf.TypeParameter>, name: Name? = null): ClsStubBuilderContext {
return ClsStubBuilderContext( return ClsStubBuilderContext(
this.components, this.components,
this.nameResolver, this.nameResolver,
@@ -21,11 +21,11 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.types.ErrorUtils.createErrorType import org.jetbrains.kotlin.types.ErrorUtils.createErrorType
import org.jetbrains.kotlin.types.TypeProjection import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.TypeSubstitution import org.jetbrains.kotlin.types.TypeSubstitution
@@ -54,7 +54,7 @@ private class ScopeWithMissingDependencies(val fqName: FqName, val containing: D
} }
} }
private class PackageFragmentProviderForMissingDependencies(val moduleDescriptor: ModuleDescriptor) : PackageFragmentProvider { internal class PackageFragmentProviderForMissingDependencies(val moduleDescriptor: ModuleDescriptor) : PackageFragmentProvider {
override fun getPackageFragments(fqName: FqName): List<PackageFragmentDescriptor> { override fun getPackageFragments(fqName: FqName): List<PackageFragmentDescriptor> {
return listOf(PackageFragmentWithMissingDependencies(fqName, moduleDescriptor)) return listOf(PackageFragmentWithMissingDependencies(fqName, moduleDescriptor))
} }
@@ -82,8 +82,8 @@ import org.jetbrains.org.objectweb.asm.Opcodes.ASM5
import org.jetbrains.org.objectweb.asm.tree.MethodNode import org.jetbrains.org.objectweb.asm.tree.MethodNode
import java.util.* import java.util.*
private val RECEIVER_NAME = "\$receiver" internal val RECEIVER_NAME = "\$receiver"
private val THIS_NAME = "this" internal val THIS_NAME = "this"
object KotlinEvaluationBuilder: EvaluatorBuilder { object KotlinEvaluationBuilder: EvaluatorBuilder {
override fun build(codeFragment: PsiElement, position: SourcePosition?): ExpressionEvaluator { override fun build(codeFragment: PsiElement, position: SourcePosition?): ExpressionEvaluator {
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.JetClass
import org.jetbrains.kotlin.psi.JetFunction import org.jetbrains.kotlin.psi.JetFunction
import org.jetbrains.kotlin.psi.JetNamedFunction import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.psi.JetSecondaryConstructor import org.jetbrains.kotlin.psi.JetSecondaryConstructor
import java.util.HashSet import java.util.*
fun collectContainingClasses(methods: Collection<PsiMethod>): Set<PsiClass> { fun collectContainingClasses(methods: Collection<PsiMethod>): Set<PsiClass> {
val classes = HashSet<PsiClass>() val classes = HashSet<PsiClass>()
@@ -41,7 +41,7 @@ fun collectContainingClasses(methods: Collection<PsiMethod>): Set<PsiClass> {
return classes return classes
} }
private fun getPsiClass(element: PsiElement?): PsiClass? { internal fun getPsiClass(element: PsiElement?): PsiClass? {
return when { return when {
element == null -> null element == null -> null
element is PsiClass -> element element is PsiClass -> element
@@ -51,7 +51,7 @@ private fun getPsiClass(element: PsiElement?): PsiClass? {
} }
} }
private fun getPsiMethod(element: PsiElement?): PsiMethod? { internal fun getPsiMethod(element: PsiElement?): PsiMethod? {
val parent = element?.getParent() val parent = element?.getParent()
return when { return when {
element == null -> null element == null -> null
@@ -16,34 +16,34 @@
package org.jetbrains.kotlin.idea.highlighter.markers package org.jetbrains.kotlin.idea.highlighter.markers
import com.intellij.psi.PsiMethod
import com.intellij.psi.search.PsiElementProcessor
import com.intellij.psi.search.searches.OverridingMethodsSearch
import com.intellij.psi.PsiModifier
import com.intellij.codeInsight.daemon.DaemonBundle import com.intellij.codeInsight.daemon.DaemonBundle
import com.intellij.ide.util.MethodCellRenderer
import com.intellij.codeInsight.daemon.impl.GutterIconTooltipHelper import com.intellij.codeInsight.daemon.impl.GutterIconTooltipHelper
import java.awt.event.MouseEvent
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.progress.ProgressManager
import javax.swing.JComponent
import com.intellij.psi.util.PsiUtil
import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator
import com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask import com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask
import com.intellij.ide.util.MethodCellRenderer
import com.intellij.ide.util.PsiElementListCellRenderer import com.intellij.ide.util.PsiElementListCellRenderer
import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.util.CommonProcessors import com.intellij.openapi.progress.ProgressManager
import com.intellij.psi.search.PsiElementProcessorAdapter import com.intellij.openapi.project.DumbService
import com.intellij.psi.PsiElement
import gnu.trove.THashSet
import com.intellij.psi.PsiClass
import com.intellij.psi.search.searches.AllOverridingMethodsSearch
import com.intellij.openapi.util.Pair import com.intellij.openapi.util.Pair
import java.util.HashSet import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import com.intellij.psi.PsiModifier
import com.intellij.psi.search.PsiElementProcessor
import com.intellij.psi.search.PsiElementProcessorAdapter
import com.intellij.psi.search.searches.AllOverridingMethodsSearch
import com.intellij.psi.search.searches.OverridingMethodsSearch
import com.intellij.psi.util.PsiUtil
import com.intellij.util.CommonProcessors
import com.intellij.util.Processor import com.intellij.util.Processor
import gnu.trove.THashSet
import org.jetbrains.kotlin.asJava.KotlinLightMethodForTraitFakeOverride import org.jetbrains.kotlin.asJava.KotlinLightMethodForTraitFakeOverride
import java.awt.event.MouseEvent
import java.util.*
import javax.swing.JComponent
private fun <T> getOverriddenDeclarations(mappingToJava: MutableMap<PsiMethod, T>, classes: Set<PsiClass>): Set<T> { internal fun <T> getOverriddenDeclarations(mappingToJava: MutableMap<PsiMethod, T>, classes: Set<PsiClass>): Set<T> {
val overridden = HashSet<T>() val overridden = HashSet<T>()
for (aClass in classes) { for (aClass in classes) {
AllOverridingMethodsSearch.search(aClass)!!.forEach(object : Processor<Pair<PsiMethod, PsiMethod>> { AllOverridingMethodsSearch.search(aClass)!!.forEach(object : Processor<Pair<PsiMethod, PsiMethod>> {
@@ -1069,7 +1069,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
} }
} }
private fun JetNamedDeclaration.getReturnTypeReference(): JetTypeReference? { internal fun JetNamedDeclaration.getReturnTypeReference(): JetTypeReference? {
return when (this) { return when (this) {
is JetCallableDeclaration -> getTypeReference() is JetCallableDeclaration -> getTypeReference()
is JetClassOrObject -> getDelegationSpecifiers().firstOrNull()?.getTypeReference() is JetClassOrObject -> getDelegationSpecifiers().firstOrNull()?.getTypeReference()
@@ -39,7 +39,7 @@ import java.util.LinkedHashSet
/** /**
* Special <code>Expression</code> for parameter names based on its type. * Special <code>Expression</code> for parameter names based on its type.
*/ */
private class ParameterNameExpression( internal class ParameterNameExpression(
private val names: Array<String>, private val names: Array<String>,
private val parameterTypeToNamesMap: Map<String, Array<String>>) : Expression() { private val parameterTypeToNamesMap: Map<String, Array<String>>) : Expression() {
init { init {
@@ -102,7 +102,7 @@ private class ParameterNameExpression(
/** /**
* An <code>Expression</code> for type references and delegation specifiers. * An <code>Expression</code> for type references and delegation specifiers.
*/ */
private abstract class TypeExpression(public val typeCandidates: List<TypeCandidate>) : Expression() { internal abstract class TypeExpression(public val typeCandidates: List<TypeCandidate>) : Expression() {
class ForTypeReference(typeCandidates: List<TypeCandidate>) : TypeExpression(typeCandidates) { class ForTypeReference(typeCandidates: List<TypeCandidate>) : TypeExpression(typeCandidates) {
override val cachedLookupElements: Array<LookupElement> = override val cachedLookupElements: Array<LookupElement> =
typeCandidates.map { LookupElementBuilder.create(it, it.renderedType!!) }.toTypedArray() typeCandidates.map { LookupElementBuilder.create(it, it.renderedType!!) }.toTypedArray()
@@ -132,7 +132,7 @@ private abstract class TypeExpression(public val typeCandidates: List<TypeCandid
/** /**
* A sort-of dummy <code>Expression</code> for parameter lists, to allow us to update the parameter list as the user makes selections. * A sort-of dummy <code>Expression</code> for parameter lists, to allow us to update the parameter list as the user makes selections.
*/ */
private class TypeParameterListExpression(private val mandatoryTypeParameters: List<RenderedTypeParameter>, internal class TypeParameterListExpression(private val mandatoryTypeParameters: List<RenderedTypeParameter>,
private val parameterTypeToTypeParameterNamesMap: Map<String, List<RenderedTypeParameter>>, private val parameterTypeToTypeParameterNamesMap: Map<String, List<RenderedTypeParameter>>,
insertLeadingSpace: Boolean) : Expression() { insertLeadingSpace: Boolean) : Expression() {
private val prefix = if (insertLeadingSpace) " <" else "<" private val prefix = if (insertLeadingSpace) " <" else "<"
@@ -185,7 +185,7 @@ private class TypeParameterListExpression(private val mandatoryTypeParameters: L
override fun calculateLookupItems(context: ExpressionContext?) = arrayOf<LookupElement>() override fun calculateLookupItems(context: ExpressionContext?) = arrayOf<LookupElement>()
} }
private object ValVarExpression: Expression() { internal object ValVarExpression: Expression() {
private val cachedLookupElements = listOf("val", "var").map { LookupElementBuilder.create(it) }.toTypedArray<LookupElement>() private val cachedLookupElements = listOf("val", "var").map { LookupElementBuilder.create(it) }.toTypedArray<LookupElement>()
override fun calculateResult(context: ExpressionContext?): Result? = TextResult("val") override fun calculateResult(context: ExpressionContext?): Result? = TextResult("val")
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.types.checker.JetTypeChecker
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import java.util.* import java.util.*
private fun JetType.contains(inner: JetType): Boolean { internal fun JetType.contains(inner: JetType): Boolean {
return JetTypeChecker.DEFAULT.equalTypes(this, inner) || getArguments().any { inner in it.getType() } return JetTypeChecker.DEFAULT.equalTypes(this, inner) || getArguments().any { inner in it.getType() }
} }
@@ -61,10 +61,10 @@ private fun JetType.render(typeParameterNameMap: Map<TypeParameterDescriptor, St
return "$typeString$typeArgumentString$nullifier" return "$typeString$typeArgumentString$nullifier"
} }
private fun JetType.renderShort(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, false) internal fun JetType.renderShort(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, false)
private fun JetType.renderLong(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, true) internal fun JetType.renderLong(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, true)
private fun getTypeParameterNamesNotInScope(typeParameters: Collection<TypeParameterDescriptor>, scope: JetScope): List<TypeParameterDescriptor> { internal fun getTypeParameterNamesNotInScope(typeParameters: Collection<TypeParameterDescriptor>, scope: JetScope): List<TypeParameterDescriptor> {
return typeParameters.filter { typeParameter -> return typeParameters.filter { typeParameter ->
val classifier = scope.getClassifier(typeParameter.name, NoLookupLocation.FROM_IDE) val classifier = scope.getClassifier(typeParameter.name, NoLookupLocation.FROM_IDE)
classifier == null || classifier != typeParameter classifier == null || classifier != typeParameter
@@ -215,9 +215,9 @@ private fun JetNamedDeclaration.guessType(context: BindingContext): Array<JetTyp
/** /**
* Encapsulates a single type substitution of a <code>JetType</code> by another <code>JetType</code>. * Encapsulates a single type substitution of a <code>JetType</code> by another <code>JetType</code>.
*/ */
private class JetTypeSubstitution(public val forType: JetType, public val byType: JetType) internal class JetTypeSubstitution(public val forType: JetType, public val byType: JetType)
private fun JetType.substitute(substitution: JetTypeSubstitution, variance: Variance): JetType { internal fun JetType.substitute(substitution: JetTypeSubstitution, variance: Variance): JetType {
val nullable = isMarkedNullable() val nullable = isMarkedNullable()
val currentType = makeNotNullable() val currentType = makeNotNullable()
@@ -43,11 +43,11 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.descriptors.ClassKind as ClassDescriptorKind import org.jetbrains.kotlin.descriptors.ClassKind as ClassDescriptorKind
private fun String.checkClassName(): Boolean = isNotEmpty() && Character.isUpperCase(first()) internal fun String.checkClassName(): Boolean = isNotEmpty() && Character.isUpperCase(first())
private fun String.checkPackageName(): Boolean = isNotEmpty() && Character.isLowerCase(first()) private fun String.checkPackageName(): Boolean = isNotEmpty() && Character.isLowerCase(first())
private fun getTargetParentByQualifier( internal fun getTargetParentByQualifier(
file: JetFile, file: JetFile,
isQualified: Boolean, isQualified: Boolean,
qualifierDescriptor: DeclarationDescriptor?): PsiElement? { qualifierDescriptor: DeclarationDescriptor?): PsiElement? {
@@ -68,7 +68,7 @@ private fun getTargetParentByQualifier(
return if (targetParent.canRefactor()) return targetParent else null return if (targetParent.canRefactor()) return targetParent else null
} }
private fun getTargetParentByCall(call: Call, file: JetFile): PsiElement? { internal fun getTargetParentByCall(call: Call, file: JetFile): PsiElement? {
val receiver = call.getExplicitReceiver() val receiver = call.getExplicitReceiver()
return when (receiver) { return when (receiver) {
ReceiverValue.NO_RECEIVER -> getTargetParentByQualifier(file, false, null) ReceiverValue.NO_RECEIVER -> getTargetParentByQualifier(file, false, null)
@@ -77,12 +77,12 @@ private fun getTargetParentByCall(call: Call, file: JetFile): PsiElement? {
} }
} }
private fun isInnerClassExpected(call: Call): Boolean { internal fun isInnerClassExpected(call: Call): Boolean {
val receiver = call.getExplicitReceiver() val receiver = call.getExplicitReceiver()
return receiver != ReceiverValue.NO_RECEIVER && receiver !is Qualifier return receiver != ReceiverValue.NO_RECEIVER && receiver !is Qualifier
} }
private fun JetExpression.getInheritableTypeInfo( internal fun JetExpression.getInheritableTypeInfo(
context: BindingContext, context: BindingContext,
moduleDescriptor: ModuleDescriptor, moduleDescriptor: ModuleDescriptor,
containingDeclaration: PsiElement): Pair<TypeInfo, (ClassKind) -> Boolean> { containingDeclaration: PsiElement): Pair<TypeInfo, (ClassKind) -> Boolean> {
@@ -108,7 +108,7 @@ private fun JetExpression.getInheritableTypeInfo(
} }
} }
private fun JetSimpleNameExpression.getCreatePackageFixIfApplicable(targetParent: PsiElement): IntentionAction? { internal fun JetSimpleNameExpression.getCreatePackageFixIfApplicable(targetParent: PsiElement): IntentionAction? {
val name = getReferencedName() val name = getReferencedName()
if (!name.checkPackageName()) return null if (!name.checkPackageName()) return null
@@ -257,7 +257,7 @@ data class ExtractionData(
// Hack: // Hack:
// we can't get first element offset through getStatement()/getChildren() since they skip comments and whitespaces // we can't get first element offset through getStatement()/getChildren() since they skip comments and whitespaces
// So we take offset of the left brace instead and increase it by 2 (which is length of "{\n" separating block start and its first element) // So we take offset of the left brace instead and increase it by 2 (which is length of "{\n" separating block start and its first element)
private fun JetExpression.getBlockContentOffset(): Int { internal fun JetExpression.getBlockContentOffset(): Int {
(this as? JetBlockExpression)?.getLBrace()?.let { (this as? JetBlockExpression)?.getLBrace()?.let {
return it.getTextRange()!!.getStartOffset() + 2 return it.getTextRange()!!.getStartOffset() + 2
} }
@@ -89,7 +89,7 @@ import org.jetbrains.kotlin.utils.DFS.Neighbors
import org.jetbrains.kotlin.utils.DFS.VisitedWithSet import org.jetbrains.kotlin.utils.DFS.VisitedWithSet
import java.util.* import java.util.*
private val DEFAULT_RETURN_TYPE = KotlinBuiltIns.getInstance().getUnitType() internal val DEFAULT_RETURN_TYPE = KotlinBuiltIns.getInstance().getUnitType()
private val DEFAULT_PARAMETER_TYPE = KotlinBuiltIns.getInstance().getNullableAnyType() private val DEFAULT_PARAMETER_TYPE = KotlinBuiltIns.getInstance().getNullableAnyType()
private fun DeclarationDescriptor.renderForMessage(): String = private fun DeclarationDescriptor.renderForMessage(): String =
@@ -104,7 +104,7 @@ private fun JetType.renderForMessage(): String = TYPE_RENDERER.renderType(this)
private fun JetDeclaration.renderForMessage(bindingContext: BindingContext): String? = private fun JetDeclaration.renderForMessage(bindingContext: BindingContext): String? =
bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this]?.renderForMessage() bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this]?.renderForMessage()
private fun JetType.isDefault(): Boolean = KotlinBuiltIns.isUnit(this) internal fun JetType.isDefault(): Boolean = KotlinBuiltIns.isUnit(this)
private fun List<Instruction>.getModifiedVarDescriptors(bindingContext: BindingContext): Map<VariableDescriptor, List<JetExpression>> { private fun List<Instruction>.getModifiedVarDescriptors(bindingContext: BindingContext): Map<VariableDescriptor, List<JetExpression>> {
val result = HashMap<VariableDescriptor, MutableList<JetExpression>>() val result = HashMap<VariableDescriptor, MutableList<JetExpression>>()
@@ -968,7 +968,7 @@ private fun ExtractionData.suggestFunctionNames(returnType: JetType): List<Strin
return functionNames.toList() return functionNames.toList()
} }
private fun JetNamedDeclaration.getGeneratedBody() = internal fun JetNamedDeclaration.getGeneratedBody() =
when (this) { when (this) {
is JetNamedFunction -> getBodyExpression() is JetNamedFunction -> getBodyExpression()
else -> { else -> {
@@ -83,7 +83,7 @@ fun DeclarationDescriptor.renderForConflicts(): String {
} }
} }
private fun KotlinPullUpData.getClashingMemberInTargetClass(memberDescriptor: CallableMemberDescriptor): CallableMemberDescriptor? { internal fun KotlinPullUpData.getClashingMemberInTargetClass(memberDescriptor: CallableMemberDescriptor): CallableMemberDescriptor? {
val memberInSuper = memberDescriptor.substitute(sourceToTargetClassSubstitutor) ?: return null val memberInSuper = memberDescriptor.substitute(sourceToTargetClassSubstitutor) ?: return null
return targetClassDescriptor.findCallableMemberBySignature(memberInSuper as CallableMemberDescriptor) return targetClassDescriptor.findCallableMemberBySignature(memberInSuper as CallableMemberDescriptor)
} }
@@ -16,22 +16,22 @@
package org.jetbrains.kotlin.idea.decompiler.stubBuilder package org.jetbrains.kotlin.idea.decompiler.stubBuilder
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.google.common.io.Files
import org.jetbrains.kotlin.psi.stubs.elements.JetFileStubBuilder
import org.jetbrains.kotlin.test.JetTestUtils
import java.io.File
import org.jetbrains.kotlin.test.MockLibraryUtil
import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.util.indexing.FileContentImpl import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.stubs.StubElement import com.intellij.psi.stubs.StubElement
import com.google.common.io.Files import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import com.intellij.openapi.vfs.VirtualFile import com.intellij.util.indexing.FileContentImpl
import org.junit.Assert
import org.jetbrains.kotlin.idea.stubs.AbstractStubBuilderTest import org.jetbrains.kotlin.idea.stubs.AbstractStubBuilderTest
import java.util.LinkedHashSet import org.jetbrains.kotlin.psi.stubs.elements.JetFileStubBuilder
import com.intellij.openapi.vfs.VfsUtilCore import org.jetbrains.kotlin.test.JetTestUtils
import org.jetbrains.kotlin.test.MockLibraryUtil
import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addIfNotNull
import org.junit.Assert
import java.io.File
import java.util.*
public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCase() { public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCase() {
fun doTest(sourcePath: String) { fun doTest(sourcePath: String) {
@@ -64,7 +64,7 @@ public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCa
} }
} }
private fun StubElement<out PsiElement>.serializeToString(): String { internal fun StubElement<out PsiElement>.serializeToString(): String {
return AbstractStubBuilderTest.serializeStubToString(this) return AbstractStubBuilderTest.serializeStubToString(this)
} }
@@ -16,7 +16,7 @@
package com.google.dart.compiler.backend.js.ast.metadata package com.google.dart.compiler.backend.js.ast.metadata
private class MetadataProperty<in T : HasMetadata, R>(val default: R) { internal class MetadataProperty<in T : HasMetadata, R>(val default: R) {
fun get(thisRef: T, desc: PropertyMetadata): R { fun get(thisRef: T, desc: PropertyMetadata): R {
if (!thisRef.hasData(desc.name)) return default if (!thisRef.hasData(desc.name)) return default
return thisRef.getData<R>(desc.name) return thisRef.getData<R>(desc.name)
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.js.inline.clean package org.jetbrains.kotlin.js.inline.clean
import com.google.dart.compiler.backend.js.ast.JsVisitorWithContextImpl
import com.google.dart.compiler.backend.js.ast.JsNode
import com.google.dart.compiler.backend.js.ast.JsContext import com.google.dart.compiler.backend.js.ast.JsContext
import com.google.dart.compiler.backend.js.ast.JsNode
import com.google.dart.compiler.backend.js.ast.JsVisitorWithContextImpl
private class NodeRemover<T>(val klass: Class<T>, val predicate: (T) -> Boolean): JsVisitorWithContextImpl() { internal class NodeRemover<T>(val klass: Class<T>, val predicate: (T) -> Boolean): JsVisitorWithContextImpl() {
override fun <T : JsNode> doTraverse(node: T, ctx: JsContext<*>) { override fun <T : JsNode> doTraverse(node: T, ctx: JsContext<*>) {
if (klass.isInstance(node)) { if (klass.isInstance(node)) {
@@ -16,12 +16,11 @@
package org.jetbrains.kotlin.js.inline.clean package org.jetbrains.kotlin.js.inline.clean
import com.google.dart.compiler.backend.js.ast.* import com.google.dart.compiler.backend.js.ast.JsNode
import org.jetbrains.kotlin.js.inline.util.IdentitySet import org.jetbrains.kotlin.js.inline.util.IdentitySet
import java.util.*
import java.util.IdentityHashMap internal class ReferenceTracker<Reference, RemoveCandidate : JsNode> {
private class ReferenceTracker<Reference, RemoveCandidate : JsNode> {
private val reachable = IdentityHashMap<Reference, Boolean>() private val reachable = IdentityHashMap<Reference, Boolean>()
private val removableCandidates = IdentityHashMap<Reference, RemoveCandidate>() private val removableCandidates = IdentityHashMap<Reference, RemoveCandidate>()
private val referenceFromTo = IdentityHashMap<Reference, MutableSet<Reference>>() private val referenceFromTo = IdentityHashMap<Reference, MutableSet<Reference>>()
+3 -3
View File
@@ -70,11 +70,11 @@ public fun lazy<T>(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
public fun lazy<T>(lock: Any?, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer) public fun lazy<T>(lock: Any?, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
private fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<T> { internal fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<T> {
return arrayOfNulls<Any>(size) as Array<T> return arrayOfNulls<Any>(size) as Array<T>
} }
private fun arrayCopyResize(source: dynamic, newSize: Int, defaultValue: Any?): dynamic { internal fun arrayCopyResize(source: dynamic, newSize: Int, defaultValue: Any?): dynamic {
val result = source.slice(0, newSize) val result = source.slice(0, newSize)
var index: Int = source.length var index: Int = source.length
if (newSize > index) { if (newSize > index) {
@@ -84,7 +84,7 @@ private fun arrayCopyResize(source: dynamic, newSize: Int, defaultValue: Any?):
return result return result
} }
private fun <T> arrayPlusCollection(array: dynamic, collection: Collection<T>): dynamic { internal fun <T> arrayPlusCollection(array: dynamic, collection: Collection<T>): dynamic {
val result = array.slice(0) val result = array.slice(0)
result.length += collection.size() result.length += collection.size()
var index: Int = array.length var index: Int = array.length
+1 -1
View File
@@ -16,7 +16,7 @@
package kotlin package kotlin
private class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> { internal class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> {
@Volatile private var sequenceRef: Sequence<T>? = sequence @Volatile private var sequenceRef: Sequence<T>? = sequence
//private val lock = Any() //private val lock = Any()
@@ -5,7 +5,6 @@ package kotlin
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.nio.charset.Charset import java.nio.charset.Charset
import java.util.Arrays
import kotlin.jvm.internal.Intrinsic import kotlin.jvm.internal.Intrinsic
// Array "constructor" // Array "constructor"
@@ -104,6 +103,6 @@ public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>() public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
/** Internal unsafe construction of array based on reference array type */ /** Internal unsafe construction of array based on reference array type */
private fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<out T> { internal fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<out T> {
return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array<out T> return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array<out T>
} }
@@ -6,7 +6,7 @@ package kotlin
import java.io.Serializable import java.io.Serializable
import java.util.* import java.util.*
private object EmptyIterator : ListIterator<Nothing> { internal object EmptyIterator : ListIterator<Nothing> {
override fun hasNext(): Boolean = false override fun hasNext(): Boolean = false
override fun hasPrevious(): Boolean = false override fun hasPrevious(): Boolean = false
override fun nextIndex(): Int = 0 override fun nextIndex(): Int = 0
@@ -15,7 +15,7 @@ private object EmptyIterator : ListIterator<Nothing> {
override fun previous(): Nothing = throw NoSuchElementException() override fun previous(): Nothing = throw NoSuchElementException()
} }
private object EmptyList : List<Nothing>, Serializable { internal object EmptyList : List<Nothing>, Serializable {
override fun equals(other: Any?): Boolean = other is List<*> && other.isEmpty() override fun equals(other: Any?): Boolean = other is List<*> && other.isEmpty()
override fun hashCode(): Int = 1 override fun hashCode(): Int = 1
override fun toString(): String = "[]" override fun toString(): String = "[]"
@@ -125,7 +125,7 @@ public fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this
private fun <T> Collection<T>.safeToConvertToSet() = size() > 2 && this is ArrayList private fun <T> Collection<T>.safeToConvertToSet() = size() > 2 && this is ArrayList
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */ /** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
private fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>): Collection<T> = internal fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>): Collection<T> =
when(this) { when(this) {
is Set -> this is Set -> this
is Collection -> is Collection ->
@@ -137,7 +137,7 @@ private fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>)
} }
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */ /** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
private fun <T> Iterable<T>.convertToSetForSetOperation(): Collection<T> = internal fun <T> Iterable<T>.convertToSetForSetOperation(): Collection<T> =
when(this) { when(this) {
is Set -> this is Set -> this
is Collection -> if (this.safeToConvertToSet()) toHashSet() else this is Collection -> if (this.safeToConvertToSet()) toHashSet() else this
@@ -79,7 +79,7 @@ public fun <K, V> linkedMapOf(vararg values: Pair<K, V>): LinkedHashMap<K, V> {
private val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1 private val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
private fun mapCapacity(expectedSize: Int): Int { internal fun mapCapacity(expectedSize: Int): Int {
if (expectedSize < 3) { if (expectedSize < 3) {
return expectedSize + 1 return expectedSize + 1
} }
@@ -96,7 +96,7 @@ public fun <T, R> Sequence<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> {
* @param sendWhen If `true`, values for which the predicate returns `true` are returned. Otherwise, * @param sendWhen If `true`, values for which the predicate returns `true` are returned. Otherwise,
* values for which the predicate returns `false` are returned * values for which the predicate returns `false` are returned
*/ */
private class FilteringSequence<T>(private val sequence: Sequence<T>, internal class FilteringSequence<T>(private val sequence: Sequence<T>,
private val sendWhen: Boolean = true, private val sendWhen: Boolean = true,
private val predicate: (T) -> Boolean private val predicate: (T) -> Boolean
) : Sequence<T> { ) : Sequence<T> {
@@ -142,7 +142,7 @@ private class FilteringSequence<T>(private val sequence: Sequence<T>,
* in the underlying [sequence]. * in the underlying [sequence].
*/ */
private class TransformingSequence<T, R> internal class TransformingSequence<T, R>
constructor(private val sequence: Sequence<T>, private val transformer: (T) -> R) : Sequence<R> { constructor(private val sequence: Sequence<T>, private val transformer: (T) -> R) : Sequence<R> {
override fun iterator(): Iterator<R> = object : Iterator<R> { override fun iterator(): Iterator<R> = object : Iterator<R> {
val iterator = sequence.iterator() val iterator = sequence.iterator()
@@ -161,7 +161,7 @@ constructor(private val sequence: Sequence<T>, private val transformer: (T) -> R
* in the underlying [sequence], where the transformer function takes the index of the value in the underlying * in the underlying [sequence], where the transformer function takes the index of the value in the underlying
* sequence along with the value itself. * sequence along with the value itself.
*/ */
private class TransformingIndexedSequence<T, R> internal class TransformingIndexedSequence<T, R>
constructor(private val sequence: Sequence<T>, private val transformer: (Int, T) -> R) : Sequence<R> { constructor(private val sequence: Sequence<T>, private val transformer: (Int, T) -> R) : Sequence<R> {
override fun iterator(): Iterator<R> = object : Iterator<R> { override fun iterator(): Iterator<R> = object : Iterator<R> {
val iterator = sequence.iterator() val iterator = sequence.iterator()
@@ -180,7 +180,7 @@ constructor(private val sequence: Sequence<T>, private val transformer: (Int, T)
* A sequence which combines values from the underlying [sequence] with their indices and returns them as * A sequence which combines values from the underlying [sequence] with their indices and returns them as
* [IndexedValue] objects. * [IndexedValue] objects.
*/ */
private class IndexingSequence<T> internal class IndexingSequence<T>
constructor(private val sequence: Sequence<T>) : Sequence<IndexedValue<T>> { constructor(private val sequence: Sequence<T>) : Sequence<IndexedValue<T>> {
override fun iterator(): Iterator<IndexedValue<T>> = object : Iterator<IndexedValue<T>> { override fun iterator(): Iterator<IndexedValue<T>> = object : Iterator<IndexedValue<T>> {
val iterator = sequence.iterator() val iterator = sequence.iterator()
@@ -200,7 +200,7 @@ constructor(private val sequence: Sequence<T>) : Sequence<IndexedValue<T>> {
* [transform] function and returns the values returned by that function. The sequence stops returning * [transform] function and returns the values returned by that function. The sequence stops returning
* values as soon as one of the underlying sequences stops returning values. * values as soon as one of the underlying sequences stops returning values.
*/ */
private class MergingSequence<T1, T2, V> internal class MergingSequence<T1, T2, V>
constructor(private val sequence1: Sequence<T1>, constructor(private val sequence1: Sequence<T1>,
private val sequence2: Sequence<T2>, private val sequence2: Sequence<T2>,
private val transform: (T1, T2) -> V private val transform: (T1, T2) -> V
@@ -218,7 +218,7 @@ private class MergingSequence<T1, T2, V>
} }
} }
private class FlatteningSequence<T, R> internal class FlatteningSequence<T, R>
constructor(private val sequence: Sequence<T>, constructor(private val sequence: Sequence<T>,
private val transformer: (T) -> Sequence<R> private val transformer: (T) -> Sequence<R>
) : Sequence<R> { ) : Sequence<R> {
@@ -257,7 +257,7 @@ private class FlatteningSequence<T, R>
} }
} }
private class MultiSequence<T> internal class MultiSequence<T>
constructor(private val sequence: Sequence<Sequence<T>>) : Sequence<T> { constructor(private val sequence: Sequence<Sequence<T>>) : Sequence<T> {
override fun iterator(): Iterator<T> = object : Iterator<T> { override fun iterator(): Iterator<T> = object : Iterator<T> {
val iterator = sequence.iterator() val iterator = sequence.iterator()
@@ -298,7 +298,7 @@ constructor(private val sequence: Sequence<Sequence<T>>) : Sequence<T> {
* A sequence that returns at most [count] values from the underlying [sequence], and stops returning values * A sequence that returns at most [count] values from the underlying [sequence], and stops returning values
* as soon as that count is reached. * as soon as that count is reached.
*/ */
private class TakeSequence<T> internal class TakeSequence<T>
constructor(private val sequence: Sequence<T>, constructor(private val sequence: Sequence<T>,
private val count: Int private val count: Int
) : Sequence<T> { ) : Sequence<T> {
@@ -327,7 +327,7 @@ private class TakeSequence<T>
* A sequence that returns values from the underlying [sequence] while the [predicate] function returns * A sequence that returns values from the underlying [sequence] while the [predicate] function returns
* `true`, and stops returning values once the function returns `false` for the next element. * `true`, and stops returning values once the function returns `false` for the next element.
*/ */
private class TakeWhileSequence<T> internal class TakeWhileSequence<T>
constructor(private val sequence: Sequence<T>, constructor(private val sequence: Sequence<T>,
private val predicate: (T) -> Boolean private val predicate: (T) -> Boolean
) : Sequence<T> { ) : Sequence<T> {
@@ -373,7 +373,7 @@ private class TakeWhileSequence<T>
* A sequence that skips the specified number of values from the underlying [sequence] and returns * A sequence that skips the specified number of values from the underlying [sequence] and returns
* all values after that. * all values after that.
*/ */
private class DropSequence<T> internal class DropSequence<T>
constructor(private val sequence: Sequence<T>, constructor(private val sequence: Sequence<T>,
private val count: Int private val count: Int
) : Sequence<T> { ) : Sequence<T> {
@@ -409,7 +409,7 @@ private class DropSequence<T>
* A sequence that skips the values from the underlying [sequence] while the given [predicate] returns `true` and returns * A sequence that skips the values from the underlying [sequence] while the given [predicate] returns `true` and returns
* all values after that. * all values after that.
*/ */
private class DropWhileSequence<T> internal class DropWhileSequence<T>
constructor(private val sequence: Sequence<T>, constructor(private val sequence: Sequence<T>,
private val predicate: (T) -> Boolean private val predicate: (T) -> Boolean
) : Sequence<T> { ) : Sequence<T> {
@@ -452,7 +452,7 @@ private class DropWhileSequence<T>
} }
} }
private class DistinctSequence<T, K>(private val source : Sequence<T>, private val keySelector : (T) -> K) : Sequence<T> { internal class DistinctSequence<T, K>(private val source : Sequence<T>, private val keySelector : (T) -> K) : Sequence<T> {
override fun iterator(): Iterator<T> = DistinctIterator(source.iterator(), keySelector) override fun iterator(): Iterator<T> = DistinctIterator(source.iterator(), keySelector)
} }
@@ -6,7 +6,7 @@ package kotlin
import java.util.concurrent.atomic.AtomicReference import java.util.concurrent.atomic.AtomicReference
private class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> { internal class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> {
private val sequenceRef = AtomicReference(sequence) private val sequenceRef = AtomicReference(sequence)
override fun iterator(): Iterator<T> { override fun iterator(): Iterator<T> {
@@ -7,7 +7,7 @@ import java.io.Serializable
import java.util.* import java.util.*
private object EmptySet : Set<Nothing>, Serializable { internal object EmptySet : Set<Nothing>, Serializable {
override fun equals(other: Any?): Boolean = other is Set<*> && other.isEmpty() override fun equals(other: Any?): Boolean = other is Set<*> && other.isEmpty()
override fun hashCode(): Int = 0 override fun hashCode(): Int = 0
override fun toString(): String = "[]" override fun toString(): String = "[]"
@@ -14,22 +14,22 @@ import kotlin.text.Regex
/** /**
* Returns the index within this string of the first occurrence of the specified character, starting from the specified offset. * Returns the index within this string of the first occurrence of the specified character, starting from the specified offset.
*/ */
private fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex) internal fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex)
/** /**
* Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset. * Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset.
*/ */
private fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex) internal fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex)
/** /**
* Returns the index within this string of the last occurrence of the specified character. * Returns the index within this string of the last occurrence of the specified character.
*/ */
private fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex) internal fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex)
/** /**
* Returns the index within this string of the last occurrence of the specified character, starting from the specified offset. * Returns the index within this string of the last occurrence of the specified character, starting from the specified offset.
*/ */
private fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex) internal fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex)
/** /**
+3 -3
View File
@@ -54,7 +54,7 @@ public enum class LazyThreadSafetyMode {
private object UNINITIALIZED_VALUE private object UNINITIALIZED_VALUE
private open class LazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable { internal open class LazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable {
private var initializer: (() -> T)? = initializer private var initializer: (() -> T)? = initializer
@Volatile private var _value: Any? = UNINITIALIZED_VALUE @Volatile private var _value: Any? = UNINITIALIZED_VALUE
protected open val lock: Any protected open val lock: Any
@@ -88,9 +88,9 @@ private open class LazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializab
private fun writeReplace(): Any = InitializedLazyImpl(value) private fun writeReplace(): Any = InitializedLazyImpl(value)
} }
private class ExternallySynchronizedLazyImpl<out T>(override val lock: Any, initializer: () -> T): LazyImpl<T>(initializer) internal class ExternallySynchronizedLazyImpl<out T>(override val lock: Any, initializer: () -> T): LazyImpl<T>(initializer)
private class UnsafeLazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable { internal class UnsafeLazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable {
private var initializer: (() -> T)? = initializer private var initializer: (() -> T)? = initializer
private var _value: Any? = UNINITIALIZED_VALUE private var _value: Any? = UNINITIALIZED_VALUE
+1 -1
View File
@@ -32,6 +32,6 @@ public fun <T: Comparable<T>> T.rangeTo(that: T): ComparableRange<T> {
} }
private fun checkStepIsPositive(isPositive: Boolean, step: Number) { internal fun checkStepIsPositive(isPositive: Boolean, step: Number) {
if (!isPositive) throw IllegalArgumentException("Step must be positive, was: $step") if (!isPositive) throw IllegalArgumentException("Step must be positive, was: $step")
} }
@@ -9,7 +9,7 @@ import javax.lang.model.element.TypeElement
import javax.lang.model.type.NoType import javax.lang.model.type.NoType
import javax.lang.model.type.TypeVisitor import javax.lang.model.type.TypeVisitor
private class RoundEnvironmentWrapper( internal class RoundEnvironmentWrapper(
val processingEnv: ProcessingEnvironment, val processingEnv: ProcessingEnvironment,
val parent: RoundEnvironment, val parent: RoundEnvironment,
val roundNumber: Int, val roundNumber: Int,
@@ -20,7 +20,7 @@ import org.gradle.api.logging.Logger
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.util.* import java.util.*
private fun Any.loadKotlinVersionFromResource(log: Logger): String { internal fun Any.loadKotlinVersionFromResource(log: Logger): String {
log.kotlinDebug("Loading version information") log.kotlinDebug("Loading version information")
val props = Properties() val props = Properties()
val propFileName = "project.properties" val propFileName = "project.properties"