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