Partial code cleanup: can be private and some others applied

This commit is contained in:
Mikhail Glukhikh
2017-07-27 14:38:01 +03:00
parent 42f8a3e65b
commit c5a81691fb
126 changed files with 270 additions and 258 deletions
@@ -39,9 +39,7 @@ class KotlinCompilerAdapter : Javac13() {
return argument
}
override fun getSupportedFileExtensions(): Array<String> {
return super.getSupportedFileExtensions() + KOTLIN_EXTENSIONS
}
override fun getSupportedFileExtensions(): Array<String> = super.getSupportedFileExtensions() + KOTLIN_EXTENSIONS
@Throws(BuildException::class)
override fun execute(): Boolean {
@@ -22,7 +22,7 @@ import java.util.*
class DefaultCallArgs(val size: Int) {
val bits: BitSet = BitSet(size)
private val bits: BitSet = BitSet(size)
fun mark(index: Int) {
assert (index < size) {
@@ -39,7 +39,7 @@ class DefaultCallArgs(val size: Int) {
val masks = ArrayList<Int>(1)
var mask = 0
for (i in 0..size - 1) {
for (i in 0 until size) {
if (i != 0 && i % Integer.SIZE == 0) {
masks.add(mask)
mask = 0
@@ -23,9 +23,9 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
class InlineCycleReporter(val diagnostics: DiagnosticSink) {
class InlineCycleReporter(private val diagnostics: DiagnosticSink) {
val processingFunctions = linkedMapOf<PsiElement, CallableDescriptor>()
private val processingFunctions = linkedMapOf<PsiElement, CallableDescriptor>()
fun enterIntoInlining(call: ResolvedCall<*>?): Boolean {
//null call for default method inlining
@@ -25,9 +25,9 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
class JvmStaticInCompanionObjectGenerator(
val descriptor: FunctionDescriptor,
val declarationOrigin: JvmDeclarationOrigin,
val state: GenerationState,
private val descriptor: FunctionDescriptor,
private val declarationOrigin: JvmDeclarationOrigin,
private val state: GenerationState,
parentBodyCodegen: ImplementationBodyCodegen
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
private val typeMapper = state.typeMapper
@@ -62,7 +62,7 @@ class PropertyReferenceCodegen(
private val isLocalDelegatedProperty = target is LocalVariableDescriptor
val getFunction =
private val getFunction =
if (isLocalDelegatedProperty)
(localVariableDescriptorForReference as VariableDescriptorWithAccessors).getter!!
else
@@ -250,13 +250,13 @@ class PropertyReferenceCodegen(
class PropertyReferenceGenerationStrategy(
val isGetter: Boolean,
val originalFunctionDesc: FunctionDescriptor,
private val originalFunctionDesc: FunctionDescriptor,
val target: VariableDescriptor,
val asmType: Type,
val receiverType: Type?,
val expression: KtElement,
state: GenerationState,
val isInliningStrategy: Boolean
private val isInliningStrategy: Boolean
) :
FunctionGenerationStrategy.CodegenBased(state) {
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
@@ -21,7 +21,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
class CoercionValue(
val value: StackValue,
val castType: Type
private val castType: Type
) : StackValue(castType, value.canHaveSideEffects()) {
override fun putSelector(type: Type, v: InstructionAdapter) {
@@ -28,12 +28,10 @@ class DefaultImplsClassContext(
contextKind: OwnerKind,
parentContext: CodegenContext<*>?,
localLookup: ((DeclarationDescriptor) -> Boolean)?,
val interfaceContext: ClassContext
private val interfaceContext: ClassContext
) : ClassContext(typeMapper, contextDescriptor, contextKind, parentContext, localLookup) {
override fun getCompanionObjectContext(): CodegenContext<*>? {
return interfaceContext.companionObjectContext
}
override fun getCompanionObjectContext(): CodegenContext<*>? = interfaceContext.companionObjectContext
override fun getAccessors(): Collection<AccessorForCallableDescriptor<*>> {
val accessors = super.getAccessors()
@@ -25,8 +25,8 @@ class InlineLambdaContext(
contextKind: OwnerKind,
parentContext: CodegenContext<*>,
closure: MutableClosure?,
val isCrossInline: Boolean,
val isPropertyReference: Boolean
private val isCrossInline: Boolean,
private val isPropertyReference: Boolean
) : MethodContext(functionDescriptor, contextKind, parentContext, closure, false) {
override fun getFirstCrossInlineOrNonInlineContext(): CodegenContext<*> {
@@ -141,7 +141,7 @@ class IntervalMetaInfo<T : SplittableInterval<T>> {
return splitPair
}
fun getInterval(curIns: LabelNode, isOpen: Boolean) =
private fun getInterval(curIns: LabelNode, isOpen: Boolean) =
if (isOpen) intervalStarts.get(curIns) else intervalEnds.get(curIns)
}
@@ -21,7 +21,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
class DeferredMethodVisitor(
val intermediate: MethodNode,
val resultNode: () -> MethodVisitor
private val resultNode: () -> MethodVisitor
) : MethodVisitor(API, intermediate) {
override fun visitEnd() {
@@ -24,7 +24,7 @@ class InlinedLambdaRemapper(
originalLambdaInternalName: String,
parent: FieldRemapper,
methodParams: Parameters,
val isDefaultBoundCallableReference: Boolean
private val isDefaultBoundCallableReference: Boolean
) : FieldRemapper(originalLambdaInternalName, parent, methodParams) {
public override fun canProcess(fieldOwner: String, fieldName: String, isFolding: Boolean) =
@@ -84,7 +84,7 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : LabelOwner {
class DefaultLambda(
override val lambdaClassType: Type,
val capturedArgs: Array<Type>,
private val capturedArgs: Array<Type>,
val parameterDescriptor: ValueParameterDescriptor,
val offset: Int,
val needReification: Boolean
@@ -53,7 +53,7 @@ abstract class ObjectTransformer<out T : TransformationInfo>(@JvmField val trans
class WhenMappingTransformer(
whenObjectRegenerationInfo: WhenMappingTransformationInfo,
val inliningContext: InliningContext
private val inliningContext: InliningContext
) : ObjectTransformer<WhenMappingTransformationInfo>(whenObjectRegenerationInfo, inliningContext.state) {
override fun doTransform(parentRemapper: FieldRemapper): InlineResult {
@@ -16,13 +16,11 @@
package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.context.MethodContext
import org.jetbrains.kotlin.codegen.generateAsCast
import org.jetbrains.kotlin.codegen.generateIsCheck
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
import org.jetbrains.kotlin.codegen.optimization.common.intConstant
import org.jetbrains.kotlin.codegen.optimization.removeNodeGetNext
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.Variance
@@ -34,7 +32,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.tree.*
class ReificationArgument(
val parameterName: String, val nullable: Boolean, val arrayDepth: Int
val parameterName: String, val nullable: Boolean, private val arrayDepth: Int
) {
fun asString() = "[".repeat(arrayDepth) + parameterName + (if (nullable) "?" else "")
fun combine(replacement: ReificationArgument) =
@@ -302,7 +300,7 @@ class TypeParameterMapping(
)
class ReifiedTypeParametersUsages {
val usedTypeParameters: MutableSet<String> = hashSetOf()
private val usedTypeParameters: MutableSet<String> = hashSetOf()
fun wereUsedReifiedParameters(): Boolean = usedTypeParameters.isNotEmpty()
@@ -28,7 +28,7 @@ val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug"
class SMAPBuilder(
val source: String,
val path: String,
val fileMappings: List<FileMapping>
private val fileMappings: List<FileMapping>
) {
private val header = "SMAP\n$source\nKotlin"
@@ -91,9 +91,9 @@ open class NestedSourceMapper(
override val parent: SourceMapper, val ranges: List<RangeMapping>, sourceInfo: SourceInfo
) : DefaultSourceMapper(sourceInfo) {
val visitedLines = TIntIntHashMap()
private val visitedLines = TIntIntHashMap()
var lastVisitedRange: RangeMapping? = null
private var lastVisitedRange: RangeMapping? = null
override fun mapLineNumber(lineNumber: Int): Int {
val mappedLineNumber = visitedLines.get(lineNumber)
@@ -115,7 +115,7 @@ open class NestedSourceMapper(
}
}
fun findMappingIfExists(lineNumber: Int): RangeMapping? {
private fun findMappingIfExists(lineNumber: Int): RangeMapping? {
val index = ranges.binarySearch(RangeMapping(lineNumber, lineNumber, 1), Comparator {
value, key ->
if (key.dest in value) 0 else RangeMapping.Comparator.compare(value, key)
@@ -40,7 +40,7 @@ interface TransformationInfo {
class WhenMappingTransformationInfo(
override val oldClassName: String,
parentNameGenerator: NameGenerator,
val alreadyRegenerated: Boolean,
private val alreadyRegenerated: Boolean,
val fieldNode: FieldInsnNode
) : TransformationInfo {
@@ -24,7 +24,7 @@ class TypeParameter(val oldName: String, val newName: String?, val isReified: Bo
class TypeRemapper private constructor(
private val typeMapping: MutableMap<String, String>,
val parent: TypeRemapper? = null,
val isRootInlineLambda: Boolean = false
private val isRootInlineLambda: Boolean = false
) {
private val additionalMappings = hashMapOf<String, String>()
private val typeParametersMapping = hashMapOf<String, TypeParameter>()
@@ -88,7 +88,7 @@ class DeadCodeEliminationMethodTransformer : MethodTransformer() {
return true
}
class Result(val removedNodes: Set<AbstractInsnNode>) {
class Result(private val removedNodes: Set<AbstractInsnNode>) {
fun hasRemovedAnything() = removedNodes.isNotEmpty()
fun isRemoved(node: AbstractInsnNode) = removedNodes.contains(node)
fun isAlive(node: AbstractInsnNode) = !isRemoved(node)
@@ -45,7 +45,7 @@ class CleanBoxedValue(
}
class TaintedBoxedValue(val boxedBasicValue: CleanBoxedValue) : BoxedBasicValue(boxedBasicValue.type) {
class TaintedBoxedValue(private val boxedBasicValue: CleanBoxedValue) : BoxedBasicValue(boxedBasicValue.type) {
override val descriptor get() = boxedBasicValue.descriptor
override fun taint(): BoxedBasicValue = this
@@ -53,7 +53,7 @@ class TaintedBoxedValue(val boxedBasicValue: CleanBoxedValue) : BoxedBasicValue(
class BoxedValueDescriptor(
val boxedType: Type,
private val boxedType: Type,
val boxingInsn: AbstractInsnNode,
val progressionIterator: ProgressionIteratorBasicValue?
) {
@@ -67,7 +67,7 @@ open class MethodAnalyzer<V : Value>(
protected val interpreter: Interpreter<V>
) {
val instructions: InsnList = method.instructions
val nInsns: Int = instructions.size()
private val nInsns: Int = instructions.size()
val frames: Array<Frame<V>?> = arrayOfNulls(nInsns)
@@ -57,7 +57,7 @@ class SavedStackDescriptor(
val savedValues: List<BasicValue>,
val firstLocalVarIndex: Int
) {
val savedValuesSize = savedValues.fold(0, { size, value -> size + value.size })
private val savedValuesSize = savedValues.fold(0, { size, value -> size + value.size })
val firstUnusedLocalVarIndex = firstLocalVarIndex + savedValuesSize
override fun toString(): String =
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen.optimization.transformer
import org.jetbrains.org.objectweb.asm.tree.MethodNode
open class CompositeMethodTransformer(vararg val transformers: MethodTransformer) : MethodTransformer() {
open class CompositeMethodTransformer(private vararg val transformers: MethodTransformer) : MethodTransformer() {
override fun transform(internalClassName: String, methodNode: MethodNode) {
transformers.forEach { it.transform(internalClassName, methodNode) }
}
@@ -20,8 +20,11 @@ import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.read
import kotlin.concurrent.write
open class AggregatedReplStateHistory<T1, T2>(val history1: IReplStageHistory<T1>, val history2: IReplStageHistory<T2>, override val lock: ReentrantReadWriteLock = ReentrantReadWriteLock())
: IReplStageHistory<Pair<T1, T2>>, AbstractList<ReplHistoryRecord<Pair<T1, T2>>>()
open class AggregatedReplStateHistory<T1, T2>(
private val history1: IReplStageHistory<T1>,
private val history2: IReplStageHistory<T2>,
override val lock: ReentrantReadWriteLock = ReentrantReadWriteLock()
) : IReplStageHistory<Pair<T1, T2>>, AbstractList<ReplHistoryRecord<Pair<T1, T2>>>()
{
override val size: Int
get() = minOf(history1.size, history2.size)
@@ -26,7 +26,7 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
private val fallbackScriptArgs: ScriptArgsWithTypes? = null,
repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
) : ReplFullEvaluator {
val evaluator = GenericReplEvaluator(baseClasspath, baseClassloader, fallbackScriptArgs, repeatingMode)
private val evaluator = GenericReplEvaluator(baseClasspath, baseClassloader, fallbackScriptArgs, repeatingMode)
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = AggregatedReplStageState(compiler.createState(lock), evaluator.createState(lock), lock)
@@ -22,10 +22,11 @@ import java.lang.reflect.InvocationTargetException
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.write
open class GenericReplEvaluator(val baseClasspath: Iterable<File>,
val baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
protected val fallbackScriptArgs: ScriptArgsWithTypes? = null,
protected val repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
open class GenericReplEvaluator(
val baseClasspath: Iterable<File>,
val baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
protected val fallbackScriptArgs: ScriptArgsWithTypes? = null,
protected val repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
) : ReplEvaluator {
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = GenericReplEvaluatorState(baseClasspath, baseClassloader, lock)
@@ -43,7 +43,7 @@ class StorageComponentContainer(id: String, parent: StorageComponentContainer? =
val parentContext = parent?.let { ComponentResolveContext(it, DynamicComponentDescriptor) }
ComponentResolveContext(this, DynamicComponentDescriptor, parentContext)
}
val componentStorage: ComponentStorage = ComponentStorage(id, parent?.componentStorage)
private val componentStorage: ComponentStorage = ComponentStorage(id, parent?.componentStorage)
override fun createResolveContext(requestingDescriptor: ValueDescriptor): ValueResolveContext {
if (requestingDescriptor == DynamicComponentDescriptor) // cache unknown component descriptor
@@ -42,7 +42,7 @@ class ComponentResolveContext(
class ConstructorBinding(val constructor: Constructor<*>, val argumentDescriptors: List<ValueDescriptor>)
class MethodBinding(val method: Method, val argumentDescriptors: List<ValueDescriptor>) {
class MethodBinding(val method: Method, private val argumentDescriptors: List<ValueDescriptor>) {
fun invoke(instance: Any) {
val arguments = computeArguments(argumentDescriptors).toTypedArray()
method.invoke(instance, *arguments)
@@ -35,7 +35,7 @@ enum class ComponentStorageState {
internal class InvalidCardinalityException(message: String, val descriptors: Collection<ComponentDescriptor>) : Exception(message)
class ComponentStorage(val myId: String, parent: ComponentStorage?) : ValueResolver {
class ComponentStorage(private val myId: String, parent: ComponentStorage?) : ValueResolver {
var state = ComponentStorageState.Initial
private val registry = ComponentRegistry()
init {
@@ -39,7 +39,7 @@ class BinaryJavaClass(
override val outerClass: JavaClass?,
classContent: ByteArray? = null
) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MapBasedJavaAnnotationOwner {
lateinit var myInternalName: String
private lateinit var myInternalName: String
override val annotations: MutableCollection<JavaAnnotation> = ContainerUtil.newSmartList()
override lateinit var typeParameters: List<JavaTypeParameter>
@@ -47,7 +47,7 @@ class IncrementalPackageFragmentProvider(
val target: TargetId,
private val kotlinClassFinder: KotlinClassFinder
) : PackageFragmentProvider {
val fqNameToPackageFragment =
private val fqNameToPackageFragment =
PackagePartClassUtils.getFilesWithCallables(sourceFiles)
.mapTo(hashSetOf()) { it.packageFqName }
.keysToMap(this::IncrementalPackageFragment)
@@ -47,7 +47,7 @@ object JvmSimpleNameBacktickChecker : IdentifierChecker {
}
}
fun checkNamed(declaration: KtNamedDeclaration, diagnosticHolder: DiagnosticSink) {
private fun checkNamed(declaration: KtNamedDeclaration, diagnosticHolder: DiagnosticSink) {
val name = declaration.name ?: return
val element = declaration.nameIdentifier ?: declaration
@@ -93,7 +93,7 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
}
}
val samWithReceiverAnnotations: List<String>? by lazy {
private val samWithReceiverAnnotations: List<String>? by lazy {
takeUnlessError { template.annotations.firstIsInstanceOrNull<kotlin.script.extensions.SamWithReceiverAnnotations>()?.annotations?.toList() }
?: takeUnlessError { template.annotations.firstIsInstanceOrNull<org.jetbrains.kotlin.script.SamWithReceiverAnnotations>()?.annotations?.toList() }
}
@@ -75,8 +75,8 @@ class EmptyResolverForProject<M : ModuleInfo> : ResolverForProject<M>() {
class ResolverForProjectImpl<M : ModuleInfo>(
private val debugName: String,
val descriptorByModule: Map<M, ModuleDescriptorImpl>,
val delegateResolver: ResolverForProject<M> = EmptyResolverForProject()
private val descriptorByModule: Map<M, ModuleDescriptorImpl>,
private val delegateResolver: ResolverForProject<M> = EmptyResolverForProject()
) : ResolverForProject<M>() {
override fun tryGetResolverForModule(moduleInfo: M): ResolverForModule? {
if (!isCorrectModuleInfo(moduleInfo)) {
@@ -36,7 +36,7 @@ class NondeterministicJumpInstruction(
private val _resolvedTargets: MutableMap<Label, Instruction> = linkedMapOf()
val targetLabels: List<Label> = ArrayList(targetLabels)
val resolvedTargets: Map<Label, Instruction>
private val resolvedTargets: Map<Label, Instruction>
get() = _resolvedTargets
fun setResolvedTarget(label: Label, resolvedTarget: Instruction) {
@@ -28,7 +28,7 @@ class ThrowExceptionInstruction(
expression: KtThrowExpression,
blockScope: BlockScope,
errorLabel: Label,
val thrownValue: PseudoValue
private val thrownValue: PseudoValue
) : AbstractJumpInstruction(expression, errorLabel, blockScope) {
override val inputValues: List<PseudoValue> get() = Collections.singletonList(thrownValue)
@@ -150,7 +150,7 @@ open class KDocTag(node: ASTNode) : KDocElementImpl(node) {
return processedLines.joinToString("\n")
}
fun String.calcIndent() = indexOfFirst { !it.isWhitespace() }
private fun String.calcIndent() = indexOfFirst { !it.isWhitespace() }
companion object {
val indentationWhiteSpaces = " ".repeat(4)
@@ -49,8 +49,10 @@ class NotNullableCopyableUserDataProperty<in R : PsiElement, T : Any>(val key: K
}
}
class NotNullableCopyableUserDataPropertyWithLazyDefault<in R : PsiElement, T : Any>(val key: Key<T>,
val computeDefaultValue: () -> T) {
class NotNullableCopyableUserDataPropertyWithLazyDefault<in R : PsiElement, T : Any>(
val key: Key<T>,
val computeDefaultValue: () -> T
) {
private val delegate by lazy { NotNullableCopyableUserDataProperty<R, T>(key, computeDefaultValue()) }
operator fun getValue(thisRef: R, property: KProperty<*>) = delegate.getValue(thisRef, property)
@@ -249,7 +249,7 @@ class AnnotationChecker(private val additionalCheckers: Iterable<AdditionalAnnot
val T_DESTRUCTURING_DECLARATION = targetList(DESTRUCTURING_DECLARATION)
fun TargetListBuilder.propertyTargets(backingField: Boolean, delegate: Boolean) {
private fun TargetListBuilder.propertyTargets(backingField: Boolean, delegate: Boolean) {
if (backingField) extraTargets(FIELD)
if (delegate) {
onlyWithUseSiteTarget(VALUE_PARAMETER, PROPERTY_GETTER, PROPERTY_SETTER, FIELD)
@@ -90,14 +90,14 @@ object ModifierCheckerCore {
IMPL_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, MEMBER_FUNCTION, TOP_LEVEL_PROPERTY, MEMBER_PROPERTY, CONSTRUCTOR, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS, TYPEALIAS)
)
val featureDependencies = mapOf(
private val featureDependencies = mapOf(
SUSPEND_KEYWORD to LanguageFeature.Coroutines,
INLINE_KEYWORD to LanguageFeature.InlineProperties,
HEADER_KEYWORD to LanguageFeature.MultiPlatformProjects,
IMPL_KEYWORD to LanguageFeature.MultiPlatformProjects
)
val featureDependenciesTargets = mapOf(
private val featureDependenciesTargets = mapOf(
LanguageFeature.InlineProperties to setOf(PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER)
)
@@ -285,7 +285,7 @@ class CallExpressionResolver(
}
}
fun resolveSimpleName(
private fun resolveSimpleName(
context: ExpressionTypingContext, expression: KtSimpleNameExpression
): OverloadResolutionResults<VariableDescriptor> {
val temporaryForVariable = TemporaryTraceAndCache.create(context, "trace to resolve as local variable or property", expression)
@@ -167,7 +167,7 @@ class GenericCandidateResolver(
})
}
fun addConstraintForValueArgument(
private fun addConstraintForValueArgument(
valueArgument: ValueArgument,
valueParameterDescriptor: ValueParameterDescriptor,
substitutor: TypeSubstitutor,
@@ -57,7 +57,7 @@ object UnderscoreUsageChecker : CallChecker {
}
}
fun String.isUnderscoreOnlyName() =
private fun String.isUnderscoreOnlyName() =
isNotEmpty() && all { it == '_' }
}
@@ -37,12 +37,11 @@ import java.util.*
class SmartCastManager {
fun getSmartCastVariants(
private fun getSmartCastVariants(
receiverToCast: ReceiverValue,
context: ResolutionContext<*>
): List<KotlinType> {
return getSmartCastVariants(receiverToCast, context.trace.bindingContext, context.scope.ownerDescriptor, context.dataFlowInfo)
}
): List<KotlinType> =
getSmartCastVariants(receiverToCast, context.trace.bindingContext, context.scope.ownerDescriptor, context.dataFlowInfo)
fun getSmartCastVariants(
receiverToCast: ReceiverValue,
@@ -73,7 +72,7 @@ class SmartCastManager {
/**
* @return variants @param receiverToCast may be cast to according to @param dataFlowInfo, @param receiverToCast itself is NOT included
*/
fun getSmartCastVariantsExcludingReceiver(
private fun getSmartCastVariantsExcludingReceiver(
bindingContext: BindingContext,
containingDeclarationOrModule: DeclarationDescriptor,
dataFlowInfo: DataFlowInfo,
@@ -177,7 +177,7 @@ class ConstantExpressionEvaluator(
return getArgumentExpressionsForArrayLikeCall(resolvedCall)
}
fun getArgumentExpressionsForCollectionLiteralCall(
private fun getArgumentExpressionsForCollectionLiteralCall(
expression: KtCollectionLiteralExpression,
trace: BindingTrace): Pair<List<KtExpression>, KotlinType?>? {
val resolvedCall = trace[COLLECTION_LITERAL_CALL, expression] ?: return null
@@ -166,7 +166,7 @@ class InlineAnalyzerExtension(
trace.report(Errors.NOTHING_TO_INLINE.on(reportOn, functionDescriptor))
}
fun checkInlinableParameter(
private fun checkInlinableParameter(
parameter: ParameterDescriptor,
expression: KtElement,
functionDescriptor: CallableDescriptor,
@@ -20,7 +20,9 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtDestructuringDeclarationEntry
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
class CombinedPackageMemberDeclarationProvider(val providers: Collection<PackageMemberDeclarationProvider>) : PackageMemberDeclarationProvider {
class CombinedPackageMemberDeclarationProvider(
val providers: Collection<PackageMemberDeclarationProvider>
) : PackageMemberDeclarationProvider {
override fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean) = providers.flatMap { it.getAllDeclaredSubPackages(nameFilter) }
override fun getPackageFiles() = providers.flatMap { it.getPackageFiles() }
@@ -118,7 +118,7 @@ protected constructor(
return propertyDescriptors(name)
}
fun doGetProperties(name: Name): Collection<PropertyDescriptor> {
private fun doGetProperties(name: Name): Collection<PropertyDescriptor> {
val result = LinkedHashSet<PropertyDescriptor>()
val declarations = declarationProvider.getPropertyDeclarations(name)
@@ -92,7 +92,7 @@ class IncrementalJvmCompilerRunner(
private val artifactChangesProvider: ArtifactChangesProvider? = null,
private val changesRegistry: ChangesRegistry? = null
) {
var anyClassesCompiled: Boolean = false
private var anyClassesCompiled: Boolean = false
private set
private val cacheDirectory = File(workingDir, CACHES_DIR_NAME)
private val dirtySourcesSinceLastTimeFile = File(workingDir, DIRTY_SOURCES_FILE_NAME)
@@ -39,7 +39,11 @@ import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import java.lang.RuntimeException
class ClassCodegen private constructor(val irClass: IrClass, val context: JvmBackendContext, val parentClassCodegen: ClassCodegen? = null) : InnerClassConsumer {
class ClassCodegen private constructor(
private val irClass: IrClass,
val context: JvmBackendContext,
private val parentClassCodegen: ClassCodegen? = null
) : InnerClassConsumer {
private val innerClasses = mutableListOf<ClassDescriptor>()
@@ -49,7 +53,7 @@ class ClassCodegen private constructor(val irClass: IrClass, val context: JvmBac
val descriptor = irClass.descriptor
val isAnonymous = DescriptorUtils.isAnonymousObject(irClass.descriptor)
private val isAnonymous = DescriptorUtils.isAnonymousObject(irClass.descriptor)
val type: Type = if (isAnonymous) CodegenBinding.asmTypeForAnonymousClass(state.bindingContext, descriptor.source.getPsi() as KtElement) else typeMapper.mapType(descriptor)
@@ -120,7 +124,7 @@ class ClassCodegen private constructor(val irClass: IrClass, val context: JvmBac
}
fun generateField(field: IrField) {
private fun generateField(field: IrField) {
val fieldType = typeMapper.mapType(field.descriptor)
val fieldSignature = typeMapper.mapFieldSignature(field.descriptor.type, field.descriptor)
val fv = visitor.newField(field.OtherOrigin, field.descriptor.calculateCommonFlags(), field.descriptor.name.asString(), fieldType.descriptor,
@@ -134,7 +138,7 @@ class ClassCodegen private constructor(val irClass: IrClass, val context: JvmBac
}
}
fun generateMethod(method: IrFunction) {
private fun generateMethod(method: IrFunction) {
if (method.origin == IrDeclarationOrigin.FAKE_OVERRIDE) return
FunctionCodegen(method, this).generate()
}
@@ -36,7 +36,7 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
class FunctionCodegen(val irFunction: IrFunction, val classCodegen: ClassCodegen) {
class FunctionCodegen(private val irFunction: IrFunction, private val classCodegen: ClassCodegen) {
val state = classCodegen.state
@@ -77,7 +77,7 @@ open class KnownClassDescriptor(
initialize(emptyList(), supertypes)
}
inline fun createClassWithTypeParameters(
private inline fun createClassWithTypeParameters(
name: Name,
containingDeclaration: DeclarationDescriptor,
supertypes: List<KotlinType>,
@@ -33,8 +33,8 @@ import org.jetbrains.org.objectweb.asm.Opcodes
import java.util.*
class SpecialDescriptorsFactory(
val psiSourceManager: PsiSourceManager,
val builtIns: KotlinBuiltIns
private val psiSourceManager: PsiSourceManager,
private val builtIns: KotlinBuiltIns
) {
private val singletonFieldDescriptors = HashMap<ClassDescriptor, PropertyDescriptor>()
private val outerThisDescriptors = HashMap<ClassDescriptor, PropertyDescriptor>()
@@ -108,7 +108,7 @@ class BridgeLowering(val state: GenerationState) : ClassLoweringPass {
}
fun generateBridges(descriptor: FunctionDescriptor, irClass: IrClass) {
private fun generateBridges(descriptor: FunctionDescriptor, irClass: IrClass) {
// equals(Any?), hashCode(), toString() never need bridges
if (isMethodOfAny(descriptor)) {
return
@@ -103,7 +103,7 @@ class SyntheticAccessorLowering(val state: GenerationState) : FileLoweringPass,
private val IrClassContext.codegenContext: CodegenContext<*>
get() = contextAnnotator.context2Codegen[this]!!
var contextAnnotator by Delegates.notNull<ContextAnnotator>()
private lateinit var contextAnnotator: ContextAnnotator
private val ClassDescriptor.codegenContext: CodegenContext<*>
get() = contextAnnotator.class2Codegen[this]!!
@@ -45,7 +45,7 @@ class FunctionGenerator(val function: IrFunction) {
inner class FunctionVisitor : IrElementVisitor<IrStatement?, Boolean> {
inline fun <reified IE : IrElement> IE.process(includeSelf: Boolean = true) = this.accept(this@FunctionVisitor, includeSelf)
private inline fun <reified IE : IrElement> IE.process(includeSelf: Boolean = true) = this.accept(this@FunctionVisitor, includeSelf)
override fun visitFunction(declaration: IrFunction, data: Boolean): IrStatement? {
if (data) {
@@ -63,7 +63,7 @@ class PsiSourceManager : SourceManager {
endColumnNumber = getColumnNumber(endOffset)
)
fun getRecognizableName(): String = psiFileName
private fun getRecognizableName(): String = psiFileName
override val name: String get() = getRecognizableName()
@@ -74,7 +74,7 @@ class PsiSourceManager : SourceManager {
private val fileEntriesByIrFile = HashMap<IrFile, PsiFileEntry>()
private val ktFileByFileEntry = HashMap<PsiFileEntry, KtFile>()
fun createFileEntry(ktFile: KtFile): PsiFileEntry {
private fun createFileEntry(ktFile: KtFile): PsiFileEntry {
if (ktFile in fileEntriesByKtFile) error("PsiFileEntry is already created for $ktFile")
val newEntry = PsiFileEntry(ktFile)
fileEntriesByKtFile[ktFile] = newEntry
@@ -219,7 +219,7 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
generateValueParameterDeclarations(irFunction, null, null, withDefaultValues = false)
}
fun generateValueParameterDeclarations(
private fun generateValueParameterDeclarations(
irFunction: IrFunction,
ktParameterOwner: KtElement?,
ktReceiverParameterElement: KtElement?,
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
open class DeepCopySymbolsRemapper(
val descriptorsRemapper: DescriptorsRemapper = DescriptorsRemapper.DEFAULT
private val descriptorsRemapper: DescriptorsRemapper = DescriptorsRemapper.DEFAULT
) : IrElementVisitorVoid, SymbolRemapper {
private val classes = hashMapOf<IrClassSymbol, IrClassSymbol>()
private val constructors = hashMapOf<IrConstructorSymbol, IrConstructorSymbol>()
@@ -40,8 +40,8 @@ fun IrFile.dumpTreesFromLineNumber(lineNumber: Int): String {
}
class DumpIrTreeVisitor(out: Appendable): IrElementVisitor<Unit, String> {
val printer = Printer(out, " ")
val elementRenderer = RenderIrElementVisitor()
private val printer = Printer(out, " ")
private val elementRenderer = RenderIrElementVisitor()
companion object {
val ANNOTATIONS_RENDERER = DescriptorRenderer.withOptions {
@@ -223,10 +223,10 @@ class DumpIrTreeVisitor(out: Appendable): IrElementVisitor<Unit, String> {
class DumpTreeFromSourceLineVisitor(
val fileEntry: SourceManager.FileEntry,
val lineNumber: Int,
private val lineNumber: Int,
out: Appendable
): IrElementVisitorVoid {
val dumper = DumpIrTreeVisitor(out)
private val dumper = DumpIrTreeVisitor(out)
override fun visitElement(element: IrElement) {
if (fileEntry.getLineNumber(element.startOffset) == lineNumber) {
@@ -39,7 +39,10 @@ interface DeclaredMemberIndex {
}
}
open class ClassDeclaredMemberIndex(val jClass: JavaClass, val memberFilter: (JavaMember) -> Boolean) : DeclaredMemberIndex {
open class ClassDeclaredMemberIndex(
val jClass: JavaClass,
private val memberFilter: (JavaMember) -> Boolean
) : DeclaredMemberIndex {
private val methodFilter = {
m: JavaMethod ->
memberFilter(m) && !DescriptorResolverUtils.isObjectMethodInInterface(m)
@@ -262,7 +262,7 @@ enum class RelationToType(val description: String) {
override fun toString() = description
}
data class DescriptorWithRelation(val descriptor: ClassifierDescriptor, val relation: RelationToType) {
data class DescriptorWithRelation(val descriptor: ClassifierDescriptor, private val relation: RelationToType) {
fun effectiveVisibility() =
(descriptor as? ClassDescriptor)?.visibility?.effectiveVisibility(descriptor, false) ?: Public
@@ -50,11 +50,10 @@ interface ClassifierNamePolicy {
// for local declarations qualified up to function scope
object SOURCE_CODE_QUALIFIED : ClassifierNamePolicy {
override fun renderClassifier(classifier: ClassifierDescriptor, renderer: DescriptorRenderer): String {
return qualifiedNameForSourceCode(classifier)
}
override fun renderClassifier(classifier: ClassifierDescriptor, renderer: DescriptorRenderer): String =
qualifiedNameForSourceCode(classifier)
fun qualifiedNameForSourceCode(descriptor: ClassifierDescriptor): String {
private fun qualifiedNameForSourceCode(descriptor: ClassifierDescriptor): String {
val nameString = descriptor.name.render()
if (descriptor is TypeParameterDescriptor) {
return nameString
@@ -106,7 +106,7 @@ class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache()
return getMethodSequenceByName(name, scope).toList().toTypedArray()
}
fun getMethodSequenceByName(name: String, scope: GlobalSearchScope): Sequence<PsiMethod> {
private fun getMethodSequenceByName(name: String, scope: GlobalSearchScope): Sequence<PsiMethod> {
val propertiesIndex = KotlinPropertyShortNameIndex.getInstance()
val functionIndex = KotlinFunctionShortNameIndex.getInstance()
@@ -160,7 +160,7 @@ class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache()
set.addAll(allMethodNames)
}
fun getFieldSequenceByName(name: String, scope: GlobalSearchScope): Sequence<PsiField> {
private fun getFieldSequenceByName(name: String, scope: GlobalSearchScope): Sequence<PsiField> {
return KotlinPropertyShortNameIndex.getInstance().get(name, project, scope).asSequence()
.map { LightClassUtil.getLightClassBackingField(it) }
.filterNotNull()
@@ -276,7 +276,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
return getClassRelativeName(parent).child(name)
}
fun createLightClassForDecompiledKotlinFile(file: KtClsFile): KtLightClassForDecompiledDeclaration? {
private fun createLightClassForDecompiledKotlinFile(file: KtClsFile): KtLightClassForDecompiledDeclaration? {
val virtualFile = file.virtualFile ?: return null
val classOrObject = file.declarations.filterIsInstance<KtClassOrObject>().singleOrNull()
@@ -37,8 +37,11 @@ class ScriptModuleSearchScope(val scriptFile: VirtualFile, baseScope: GlobalSear
override fun hashCode() = scriptFile.hashCode() * 73 * super.hashCode()
}
data class ScriptModuleInfo(val project: Project, val scriptFile: VirtualFile,
val scriptDefinition: KotlinScriptDefinition) : IdeaModuleInfo {
data class ScriptModuleInfo(
val project: Project,
val scriptFile: VirtualFile,
val scriptDefinition: KotlinScriptDefinition
) : IdeaModuleInfo {
override val moduleOrigin: ModuleOrigin
get() = ModuleOrigin.OTHER
@@ -51,7 +51,7 @@ open class KotlinClsStubBuilder : ClsStubBuilder() {
return doBuildFileStub(file, content.content)
}
fun doBuildFileStub(file: VirtualFile, fileContent: ByteArray): PsiFileStub<KtFile>? {
private fun doBuildFileStub(file: VirtualFile, fileContent: ByteArray): PsiFileStub<KtFile>? {
val kotlinClass = IDEKotlinBinaryClassCache.getKotlinBinaryClass(file, fileContent) ?: error("Can't find binary class for Kotlin file: $file")
val header = kotlinClass.classHeader
val classId = kotlinClass.classId
@@ -45,7 +45,7 @@ import kotlin.reflect.KClass
@Suppress("DEPRECATION")
@Deprecated("Please do not use for new inspections. Use AbstractKotlinInspection as base class for them")
abstract class IntentionBasedInspection<TElement : PsiElement>(
val intentionInfos: List<IntentionBasedInspection.IntentionData<TElement>>,
private val intentionInfos: List<IntentionBasedInspection.IntentionData<TElement>>,
protected open val problemText: String?
) : AbstractKotlinInspection() {
@@ -64,7 +64,7 @@ sealed class SyntheticPropertyAccessorReference(expression: KtNameReferenceExpre
override fun canRename() = true
fun renameByPropertyName(newName: String): PsiElement? {
private fun renameByPropertyName(newName: String): PsiElement? {
val nameIdentifier = KtPsiFactory(expression).createNameIdentifier(newName)
expression.getReferencedNameElement().replace(nameIdentifier)
return expression
@@ -225,7 +225,7 @@ class PsiBasedClassResolver @TestOnly constructor(private val targetClassFqName:
Ambiguity(UNSURE)
}
fun Result.changeTo(newResult: Result): Result {
private fun Result.changeTo(newResult: Result): Result {
if (this == Result.NothingFound || this.returnValue == newResult.returnValue) {
return newResult
}
@@ -52,12 +52,12 @@ class IllegalIdentifierInspection : AbstractKotlinInspection() {
}
}
fun checkAndroidFacet(element: PsiElement): Boolean {
private fun checkAndroidFacet(element: PsiElement): Boolean {
return element.getAndroidFacetForFile() != null || ApplicationManager.getApplication().isUnitTestMode
}
// https://source.android.com/devices/tech/dalvik/dex-format.html#string-syntax
fun isValidDalvikCharacter(c: Char) = when (c) {
private fun isValidDalvikCharacter(c: Char) = when (c) {
in 'A'..'Z' -> true
in 'a'..'z' -> true
in '0'..'9' -> true
@@ -290,15 +290,13 @@ object KeywordCompletion {
return buildFilterWithReducedContext("", null, position)
}
fun computeKeywordApplications(prefixText: String, keyword: KtKeywordToken): Sequence<String> {
return when (keyword) {
SUSPEND_KEYWORD -> sequenceOf("suspend () -> Unit>", "suspend X")
else -> {
if (prefixText.endsWith("@"))
sequenceOf(keyword.value + ":X Y.Z")
else
sequenceOf(keyword.value + " X")
}
private fun computeKeywordApplications(prefixText: String, keyword: KtKeywordToken): Sequence<String> = when (keyword) {
SUSPEND_KEYWORD -> sequenceOf("suspend () -> Unit>", "suspend X")
else -> {
if (prefixText.endsWith("@"))
sequenceOf(keyword.value + ":X Y.Z")
else
sequenceOf(keyword.value + " X")
}
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions.SET
object OperatorNameCompletion {
val additionalOperatorPresentation = mapOf(
private val additionalOperatorPresentation = mapOf(
SET to "[...] = ...",
GET to "[...]",
CONTAINS to "in !in",
@@ -153,7 +153,7 @@ class ReferenceVariantsCollector(
return ReferenceVariants(filterConfiguration.filterVariants(basicVariants).toHashSet(), emptyList())
}
fun doCollectExtensionVariants(filterConfiguration: FilterConfiguration, basicVariants: ReferenceVariants): ReferenceVariants {
private fun doCollectExtensionVariants(filterConfiguration: FilterConfiguration, basicVariants: ReferenceVariants): ReferenceVariants {
val (_, additionalPropertyNameFilter, shadowedDeclarationsFilter, completeExtensionsFromIndices) = filterConfiguration
if (completeExtensionsFromIndices) {
@@ -184,7 +184,7 @@ class ReferenceVariantsCollector(
return ReferenceVariants(emptyList(), emptyList())
}
fun <TDescriptor : DeclarationDescriptor> FilterConfiguration.filterVariants(_variants: Collection<TDescriptor>): Collection<TDescriptor> {
private fun <TDescriptor : DeclarationDescriptor> FilterConfiguration.filterVariants(_variants: Collection<TDescriptor>): Collection<TDescriptor> {
var variants = _variants
if (shadowedDeclarationsFilter != null)
@@ -56,20 +56,16 @@ class ToFromOriginalFileMapper private constructor(
shift = syntheticLength - originalLength
}
fun toOriginalFile(offset: Int): Int? {
return when {
offset <= completionOffset -> offset
offset >= syntheticLength - tailLength -> offset - shift
else -> null
}
private fun toOriginalFile(offset: Int): Int? = when {
offset <= completionOffset -> offset
offset >= syntheticLength - tailLength -> offset - shift
else -> null
}
fun toSyntheticFile(offset: Int): Int? {
return when {
offset <= completionOffset -> offset
offset >= originalLength - tailLength -> offset + shift
else -> null
}
private fun toSyntheticFile(offset: Int): Int? = when {
offset <= completionOffset -> offset
offset >= originalLength - tailLength -> offset + shift
else -> null
}
fun <TElement : PsiElement> toOriginalFile(element: TElement): TElement? {
@@ -45,7 +45,10 @@ import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution
import java.util.*
class ArtificialElementInsertHandler(
val textBeforeCaret: String, val textAfterCaret: String, val shortenRefs: Boolean) : InsertHandler<LookupElement>{
private val textBeforeCaret: String,
private val textAfterCaret: String,
private val shortenRefs: Boolean
) : InsertHandler<LookupElement>{
override fun handleInsert(context: InsertionContext, item: LookupElement) {
val offset = context.editor.caretModel.offset
val startOffset = offset - item.lookupString.length
@@ -73,7 +73,7 @@ class KotlinJsr223JvmScriptEngine4Idea(
override fun overrideScriptArgs(context: ScriptContext): ScriptArgsWithTypes? =
getScriptArgs(getContext(), scriptArgsTypes)
val localEvaluator: ReplFullEvaluator by lazy { GenericReplCompilingEvaluator(replCompiler, templateClasspath, Thread.currentThread().contextClassLoader) }
private val localEvaluator: ReplFullEvaluator by lazy { GenericReplCompilingEvaluator(replCompiler, templateClasspath, Thread.currentThread().contextClassLoader) }
override val replEvaluator: ReplFullEvaluator get() = localEvaluator
@@ -329,7 +329,7 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
}
}
fun String.htmlEscape(): String = HtmlEscapers.htmlEscaper().escape(this)
private fun String.htmlEscape(): String = HtmlEscapers.htmlEscaper().escape(this)
private inline fun StringBuilder.wrap(prefix: String, postfix: String, crossinline body: () -> Unit) {
this.append(prefix)
@@ -64,7 +64,7 @@ class SearchNotPropertyCandidatesAction : AnAction() {
}
fun processAllDescriptors(desc: DeclarationDescriptor, project: Project) {
private fun processAllDescriptors(desc: DeclarationDescriptor, project: Project) {
val processed = mutableSetOf<DeclarationDescriptor>()
var pFunctions = 0
val matchedDescriptors = mutableSetOf<FunctionDescriptor>()
@@ -50,9 +50,9 @@ class PlainTextPasteImportResolver(val dataForConversion: DataForConversion, val
private val shortNameCache = PsiShortNamesCache.getInstance(project)
private val scope = file.resolveScope
val failedToResolveReferenceNames = HashSet<String>()
var ambiguityInResolution = false
var couldNotResolve = false
private val failedToResolveReferenceNames = HashSet<String>()
private var ambiguityInResolution = false
private var couldNotResolve = false
val addedImports = ArrayList<PsiImportStatementBase>()
@@ -72,7 +72,7 @@ class DebuggerClassNameProvider(
}
}
val inlineUsagesSearcher = InlineCallableUsagesSearcher(debugProcess, scopes)
private val inlineUsagesSearcher = InlineCallableUsagesSearcher(debugProcess, scopes)
/**
* Returns classes in which the given line number *is* present.
@@ -37,7 +37,10 @@ import org.jetbrains.kotlin.idea.debugger.DebuggerClassNameProvider.Companion.ge
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches.ComputedClassNames
class InlineCallableUsagesSearcher(val myDebugProcess: DebugProcess, val scopes: List<GlobalSearchScope>) {
class InlineCallableUsagesSearcher(
private val myDebugProcess: DebugProcess,
val scopes: List<GlobalSearchScope>
) {
fun findInlinedCalls(
declaration: KtDeclaration,
bindingContext: BindingContext = KotlinDebuggerCaches.getOrCreateTypeMapper(declaration).bindingContext,
@@ -230,7 +230,7 @@ class KotlinFieldBreakpoint(
}
}
inline fun <reified T : EventRequest> findRequest(debugProcess: DebugProcessImpl, requestClass: Class<T>, requestor: Requestor): T? {
inline private fun <reified T : EventRequest> findRequest(debugProcess: DebugProcessImpl, requestClass: Class<T>, requestor: Requestor): T? {
val requests = debugProcess.requestsManager.findRequests(requestor)
for (eventRequest in requests) {
if (eventRequest::class.java == requestClass) {
@@ -33,7 +33,7 @@ class DelegatedPropertyFieldDescriptor(
project: Project,
objectRef: ObjectReference,
val delegate: Field,
val renderDelegatedProperty: Boolean
private val renderDelegatedProperty: Boolean
) : FieldDescriptorImpl(project, objectRef, delegate) {
override fun calcValue(evaluationContext: EvaluationContextImpl?): Value? {
@@ -41,7 +41,7 @@ private val LOG = Logger.getInstance(KotlinClassWithDelegatedPropertyRenderer::c
private fun notPreparedClassMessage(referenceType: ReferenceType) =
"$referenceType ${referenceType.isPrepared} ${referenceType.sourceName()}"
class KotlinClassWithDelegatedPropertyRenderer(val rendererSettings: NodeRendererSettings) : ClassRenderer() {
class KotlinClassWithDelegatedPropertyRenderer(private val rendererSettings: NodeRendererSettings) : ClassRenderer() {
override fun isApplicable(jdiType: Type?): Boolean {
if (!super.isApplicable(jdiType)) return false
@@ -247,9 +247,9 @@ class KotlinMultilineStringEnterHandler : EnterHandlerDelegateAdapter() {
private val kotlinIndentOptions =
CodeStyleSettingsManager.getInstance(project).currentSettings.getIndentOptions(KotlinFileType.INSTANCE)
val useTabs = kotlinIndentOptions.USE_TAB_CHARACTER
val tabSize = kotlinIndentOptions.TAB_SIZE
val regularIndent = kotlinIndentOptions.INDENT_SIZE
private val useTabs = kotlinIndentOptions.USE_TAB_CHARACTER
private val tabSize = kotlinIndentOptions.TAB_SIZE
private val regularIndent = kotlinIndentOptions.INDENT_SIZE
val marginIndent = regularIndent
fun getSmartSpaces(count: Int): String = when {
@@ -301,7 +301,7 @@ class KotlinMultilineStringEnterHandler : EnterHandlerDelegateAdapter() {
}
fun getLiteralCalls(str: KtStringTemplateExpression): Sequence<KtCallExpression> {
private fun getLiteralCalls(str: KtStringTemplateExpression): Sequence<KtCallExpression> {
var previous: PsiElement = str
return str.parents
.takeWhile { parent ->
@@ -44,6 +44,6 @@ class KotlinMissingForOrWhileBodyFixer : SmartEnterProcessorWithFixers.Fixer<Kot
doc.insertString(rParen.range.end, "{}")
}
fun KtLoopExpression.isValidLoopCondition() = leftParenthesis != null && rightParenthesis != null
private fun KtLoopExpression.isValidLoopCondition() = leftParenthesis != null && rightParenthesis != null
}
@@ -39,7 +39,7 @@ class KotlinMissingWhenBodyFixer : SmartEnterProcessorWithFixers.Fixer<KotlinSma
}
}
fun KtWhenExpression.insertOpenBraceAfter(): PsiElement? = when {
private fun KtWhenExpression.insertOpenBraceAfter(): PsiElement? = when {
rightParenthesis != null -> rightParenthesis
subjectExpression != null -> null
leftParenthesis != null -> null
@@ -48,10 +48,10 @@ class KotlinFacetEditorGeneralTab(
) : JPanel(BorderLayout()) {
private val isMultiEditor = configuration == null
var editableCommonArguments: CommonCompilerArguments
var editableJvmArguments: K2JVMCompilerArguments
var editableJsArguments: K2JSCompilerArguments
var editableCompilerSettings: CompilerSettings
private var editableCommonArguments: CommonCompilerArguments
private var editableJvmArguments: K2JVMCompilerArguments
private var editableJsArguments: K2JSCompilerArguments
private var editableCompilerSettings: CompilerSettings
val compilerConfigurable: KotlinCompilerConfigurableTab
@@ -146,7 +146,7 @@ class KotlinFacetEditorGeneralTab(
compilerConfigurable.reset()
}
val chosenPlatform: TargetPlatformKind<*>?
private val chosenPlatform: TargetPlatformKind<*>?
get() = targetPlatformComboBox.selectedItem as TargetPlatformKind<*>?
}
@@ -24,57 +24,52 @@ import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.findUsages.UsageTypeEnum.*
object KotlinUsageTypeProvider : UsageTypeProviderEx {
override fun getUsageType(element: PsiElement?): UsageType? {
return getUsageType(element, UsageTarget.EMPTY_ARRAY)
}
override fun getUsageType(element: PsiElement?): UsageType? = getUsageType(element, UsageTarget.EMPTY_ARRAY)
override fun getUsageType(element: PsiElement?, targets: Array<out UsageTarget>): UsageType? {
val usageType = UsageTypeUtils.getUsageType(element)
if (usageType == null) return null
val usageType = UsageTypeUtils.getUsageType(element) ?: return null
return convertEnumToUsageType(usageType)
}
fun convertEnumToUsageType(usageType: UsageTypeEnum): UsageType {
return when (usageType) {
TYPE_CONSTRAINT -> KotlinUsageTypes.TYPE_CONSTRAINT
VALUE_PARAMETER_TYPE -> KotlinUsageTypes.VALUE_PARAMETER_TYPE
NON_LOCAL_PROPERTY_TYPE -> KotlinUsageTypes.NON_LOCAL_PROPERTY_TYPE
FUNCTION_RETURN_TYPE -> KotlinUsageTypes.FUNCTION_RETURN_TYPE
SUPER_TYPE -> KotlinUsageTypes.SUPER_TYPE
IS -> KotlinUsageTypes.IS
CLASS_OBJECT_ACCESS -> KotlinUsageTypes.CLASS_OBJECT_ACCESS
COMPANION_OBJECT_ACCESS -> KotlinUsageTypes.COMPANION_OBJECT_ACCESS
EXTENSION_RECEIVER_TYPE -> KotlinUsageTypes.EXTENSION_RECEIVER_TYPE
SUPER_TYPE_QUALIFIER -> KotlinUsageTypes.SUPER_TYPE_QUALIFIER
TYPE_ALIAS -> KotlinUsageTypes.TYPE_ALIAS
fun convertEnumToUsageType(usageType: UsageTypeEnum): UsageType = when (usageType) {
TYPE_CONSTRAINT -> KotlinUsageTypes.TYPE_CONSTRAINT
VALUE_PARAMETER_TYPE -> KotlinUsageTypes.VALUE_PARAMETER_TYPE
NON_LOCAL_PROPERTY_TYPE -> KotlinUsageTypes.NON_LOCAL_PROPERTY_TYPE
FUNCTION_RETURN_TYPE -> KotlinUsageTypes.FUNCTION_RETURN_TYPE
SUPER_TYPE -> KotlinUsageTypes.SUPER_TYPE
IS -> KotlinUsageTypes.IS
CLASS_OBJECT_ACCESS -> KotlinUsageTypes.CLASS_OBJECT_ACCESS
COMPANION_OBJECT_ACCESS -> KotlinUsageTypes.COMPANION_OBJECT_ACCESS
EXTENSION_RECEIVER_TYPE -> KotlinUsageTypes.EXTENSION_RECEIVER_TYPE
SUPER_TYPE_QUALIFIER -> KotlinUsageTypes.SUPER_TYPE_QUALIFIER
TYPE_ALIAS -> KotlinUsageTypes.TYPE_ALIAS
FUNCTION_CALL -> KotlinUsageTypes.FUNCTION_CALL
IMPLICIT_GET -> KotlinUsageTypes.IMPLICIT_GET
IMPLICIT_SET -> KotlinUsageTypes.IMPLICIT_SET
IMPLICIT_INVOKE -> KotlinUsageTypes.IMPLICIT_INVOKE
IMPLICIT_ITERATION -> KotlinUsageTypes.IMPLICIT_ITERATION
PROPERTY_DELEGATION -> KotlinUsageTypes.PROPERTY_DELEGATION
FUNCTION_CALL -> KotlinUsageTypes.FUNCTION_CALL
IMPLICIT_GET -> KotlinUsageTypes.IMPLICIT_GET
IMPLICIT_SET -> KotlinUsageTypes.IMPLICIT_SET
IMPLICIT_INVOKE -> KotlinUsageTypes.IMPLICIT_INVOKE
IMPLICIT_ITERATION -> KotlinUsageTypes.IMPLICIT_ITERATION
PROPERTY_DELEGATION -> KotlinUsageTypes.PROPERTY_DELEGATION
RECEIVER -> KotlinUsageTypes.RECEIVER
DELEGATE -> KotlinUsageTypes.DELEGATE
RECEIVER -> KotlinUsageTypes.RECEIVER
DELEGATE -> KotlinUsageTypes.DELEGATE
PACKAGE_DIRECTIVE -> KotlinUsageTypes.PACKAGE_DIRECTIVE
PACKAGE_MEMBER_ACCESS -> KotlinUsageTypes.PACKAGE_MEMBER_ACCESS
PACKAGE_DIRECTIVE -> KotlinUsageTypes.PACKAGE_DIRECTIVE
PACKAGE_MEMBER_ACCESS -> KotlinUsageTypes.PACKAGE_MEMBER_ACCESS
CALLABLE_REFERENCE -> KotlinUsageTypes.CALLABLE_REFERENCE
CALLABLE_REFERENCE -> KotlinUsageTypes.CALLABLE_REFERENCE
READ -> UsageType.READ
WRITE -> UsageType.WRITE
CLASS_IMPORT -> UsageType.CLASS_IMPORT
CLASS_LOCAL_VAR_DECLARATION -> UsageType.CLASS_LOCAL_VAR_DECLARATION
TYPE_PARAMETER -> UsageType.TYPE_PARAMETER
CLASS_CAST_TO -> UsageType.CLASS_CAST_TO
ANNOTATION -> UsageType.ANNOTATION
CLASS_NEW_OPERATOR -> UsageType.CLASS_NEW_OPERATOR
NAMED_ARGUMENT -> KotlinUsageTypes.NAMED_ARGUMENT
READ -> UsageType.READ
WRITE -> UsageType.WRITE
CLASS_IMPORT -> UsageType.CLASS_IMPORT
CLASS_LOCAL_VAR_DECLARATION -> UsageType.CLASS_LOCAL_VAR_DECLARATION
TYPE_PARAMETER -> UsageType.TYPE_PARAMETER
CLASS_CAST_TO -> UsageType.CLASS_CAST_TO
ANNOTATION -> UsageType.ANNOTATION
CLASS_NEW_OPERATOR -> UsageType.CLASS_NEW_OPERATOR
NAMED_ARGUMENT -> KotlinUsageTypes.NAMED_ARGUMENT
USAGE_IN_STRING_LITERAL -> UsageType.LITERAL_USAGE
}
USAGE_IN_STRING_LITERAL -> UsageType.LITERAL_USAGE
}
}
@@ -50,7 +50,8 @@ import kotlin.collections.ArrayList
class KotlinLanguageInjector(
val configuration: Configuration,
val project: Project,
val temporaryPlacesRegistry: TemporaryPlacesRegistry) : MultiHostInjector {
val temporaryPlacesRegistry: TemporaryPlacesRegistry
) : MultiHostInjector {
companion object {
private val STRING_LITERALS_REGEXP = "\"([^\"]*)\"".toRegex()
private val ABSENT_KOTLIN_INJECTION = BaseInjection("ABSENT_KOTLIN_BASE_INJECTION")
@@ -50,7 +50,7 @@ open class ConvertLambdaToReferenceIntention(text: String) :
open fun buildReferenceText(element: KtLambdaExpression) = buildReferenceText(lambdaExpression = element, shortTypes = false)
protected fun KtLambdaArgument.outerCalleeDescriptor(): FunctionDescriptor? {
private fun KtLambdaArgument.outerCalleeDescriptor(): FunctionDescriptor? {
val outerCallExpression = parent as? KtCallExpression ?: return null
val context = outerCallExpression.analyze()
val outerCallee = outerCallExpression.calleeExpression as? KtReferenceExpression ?: return null
@@ -143,7 +143,7 @@ class ConvertPrimaryConstructorToSecondaryIntention : SelfTargetingIntention<KtP
element.delete()
}
fun convertValueParametersToProperties(
private fun convertValueParametersToProperties(
element: KtPrimaryConstructor, klass: KtClass, factory: KtPsiFactory, anchorBefore: PsiElement?
) {
for (valueParameter in element.valueParameters.reversed()) {
@@ -39,7 +39,7 @@ class ConvertReferenceToLambdaInspection : IntentionBasedInspection<KtCallableRe
class ConvertReferenceToLambdaIntention : SelfTargetingOffsetIndependentIntention<KtCallableReferenceExpression>(
KtCallableReferenceExpression::class.java, "Convert reference to lambda"
) {
val SOURCE_RENDERER = IdeDescriptorRenderers.SOURCE_CODE
private val SOURCE_RENDERER = IdeDescriptorRenderers.SOURCE_CODE
override fun applyTo(element: KtCallableReferenceExpression, editor: Editor?) {
val context = element.analyze(BodyResolveMode.PARTIAL)
@@ -71,7 +71,7 @@ class MovePropertyToClassBodyIntention : SelfTargetingIntention<KtParameter>(KtP
if (hasVararg) element.addModifier(KtTokens.VARARG_KEYWORD)
}
fun KtAnnotationEntry.isAppliedToProperty(): Boolean {
private fun KtAnnotationEntry.isAppliedToProperty(): Boolean {
useSiteTarget?.getAnnotationUseSiteTarget()?.let {
return it == AnnotationUseSiteTarget.FIELD
|| it == AnnotationUseSiteTarget.PROPERTY
@@ -83,7 +83,7 @@ class MovePropertyToClassBodyIntention : SelfTargetingIntention<KtParameter>(KtP
return !isApplicableToConstructorParameter()
}
fun KtAnnotationEntry.isAppliedToConstructorParameter(): Boolean {
private fun KtAnnotationEntry.isAppliedToConstructorParameter(): Boolean {
useSiteTarget?.getAnnotationUseSiteTarget()?.let {
return it == AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
}
@@ -91,19 +91,19 @@ class MovePropertyToClassBodyIntention : SelfTargetingIntention<KtParameter>(KtP
return isApplicableToConstructorParameter()
}
fun KtAnnotationEntry.isApplicableToConstructorParameter(): Boolean {
private fun KtAnnotationEntry.isApplicableToConstructorParameter(): Boolean {
val context = analyze(BodyResolveMode.PARTIAL)
val descriptor = context[BindingContext.ANNOTATION, this] ?: return false
val applicableTargets = AnnotationChecker.applicableTargetSet(descriptor)
return applicableTargets.contains(KotlinTarget.VALUE_PARAMETER)
}
fun KtAnnotationEntry.textWithoutUseSite() = "@" + typeReference?.text.orEmpty() + valueArgumentList?.text.orEmpty()
private fun KtAnnotationEntry.textWithoutUseSite() = "@" + typeReference?.text.orEmpty() + valueArgumentList?.text.orEmpty()
fun KtAnnotationUseSiteTarget.removeWithColon() {
private fun KtAnnotationUseSiteTarget.removeWithColon() {
nextSibling?.delete() // ':' symbol after use site
delete()
}
fun KtPrimaryConstructor.isNotContainedInAnnotation() = !getContainingClassOrObject().isAnnotation()
private fun KtPrimaryConstructor.isNotContainedInAnnotation() = !getContainingClassOrObject().isAnnotation()
}
@@ -132,7 +132,7 @@ class MovePropertyToConstructorIntention :
return parameterDescriptor.source.getPsi() as? KtParameter
}
fun KtAnnotationEntry.isApplicableToConstructorParameter(): Boolean {
private fun KtAnnotationEntry.isApplicableToConstructorParameter(): Boolean {
val context = analyze(BodyResolveMode.PARTIAL)
val descriptor = context[BindingContext.ANNOTATION, this] ?: return false
val applicableTargets = AnnotationChecker.applicableTargetSet(descriptor)
@@ -69,7 +69,7 @@ class UsePropertyAccessSyntaxInspection : IntentionBasedInspection<KtCallExpress
val fqNameList = mutableListOf<FqNameUnsafe>()
var fqNameStrings: List<String>
private var fqNameStrings: List<String>
get() = fqNameList.map { it.asString() }
set(value) {
fqNameList.clear()
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.lastBlockStatementOrThis
import org.jetbrains.kotlin.types.typeUtil.isNothing
object BranchedFoldingUtils {
fun getFoldableBranchedAssignment(branch: KtExpression?): KtBinaryExpression? {
private fun getFoldableBranchedAssignment(branch: KtExpression?): KtBinaryExpression? {
fun checkAssignment(expression: KtBinaryExpression): Boolean {
if (expression.operationToken !in KtTokens.ALL_ASSIGNMENTS) return false
@@ -52,7 +52,7 @@ object BranchedFoldingUtils {
it.getTargetLabel() == null
}
fun checkAssignmentsMatch(a1: KtBinaryExpression, a2: KtBinaryExpression): Boolean =
private fun checkAssignmentsMatch(a1: KtBinaryExpression, a2: KtBinaryExpression): Boolean =
a1.left?.text == a2.left?.text && a1.operationToken == a2.operationToken
internal fun getFoldableAssignmentNumber(expression: KtExpression?): Int {
@@ -57,7 +57,7 @@ interface Condition {
}
}
class AtomicCondition(val expression: KtExpression, val isNegated: Boolean = false) : Condition {
class AtomicCondition(val expression: KtExpression, private val isNegated: Boolean = false) : Condition {
init {
assert(expression.isPhysical)
}
@@ -60,7 +60,7 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
return resultSaver.resultText
}
fun bytecodeMapForExistingClassfile(file: VirtualFile): Map<File, () -> ByteArray> {
private fun bytecodeMapForExistingClassfile(file: VirtualFile): Map<File, () -> ByteArray> {
val mask = "${file.nameWithoutExtension}$"
val files =
mapOf(file.path to file) +
@@ -73,7 +73,7 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
}
}
fun bytecodeMapForSourceFile(file: KtFile): Map<File, () -> ByteArray> {
private fun bytecodeMapForSourceFile(file: KtFile): Map<File, () -> ByteArray> {
val configuration = CompilerConfiguration().apply {
languageVersionSettings = file.languageVersionSettings
}
@@ -179,7 +179,7 @@ object KDocRenderer {
fun child(type: IElementType): MarkdownNode? = children.firstOrNull { it.type == type }
}
fun MarkdownNode.visit(action: (MarkdownNode, () -> Unit) -> Unit) {
private fun MarkdownNode.visit(action: (MarkdownNode, () -> Unit) -> Unit) {
action(this) {
for (child in children) {
child.visit(action)
@@ -187,7 +187,7 @@ object KDocRenderer {
}
}
fun MarkdownNode.toHtml(): String {
private fun MarkdownNode.toHtml(): String {
if (node.type == MarkdownTokenTypes.WHITE_SPACE) {
return text // do not trim trailing whitespace
}
@@ -311,11 +311,11 @@ object KDocRenderer {
return sb.toString().trimEnd()
}
fun StringBuilder.trimEnd() {
private fun StringBuilder.trimEnd() {
while (length > 0 && this[length - 1] == ' ') {
deleteCharAt(length - 1)
}
}
fun String.htmlEscape(): String = replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
private fun String.htmlEscape(): String = replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
}

Some files were not shown because too many files have changed in this diff Show More