Clean up: rename Jet* to Kt*
This commit is contained in:
+1
-1
@@ -181,7 +181,7 @@ abstract class KtLightClassForFacadeBase constructor(
|
||||
equals(another) ||
|
||||
(another is KtLightClassForFacade && another.facadeClassFqName == facadeClassFqName)
|
||||
|
||||
override fun getElementIcon(flags: Int): Icon? = throw UnsupportedOperationException("This should be done by JetIconProvider")
|
||||
override fun getElementIcon(flags: Int): Icon? = throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
||||
|
||||
override fun isInheritor(baseClass: PsiClass, checkDeep: Boolean): Boolean {
|
||||
return baseClass.qualifiedName == CommonClassNames.JAVA_LANG_OBJECT
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ abstract class KtLightClassForScript(val script: KtScript) : KtLightClassBase(sc
|
||||
(another is KtLightClassForScript && fqName == another.fqName)
|
||||
|
||||
override fun getElementIcon(flags: Int): Icon? =
|
||||
throw UnsupportedOperationException("This should be done by JetIconProvider")
|
||||
throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
||||
|
||||
override val originKind: LightClassOriginKind get() = LightClassOriginKind.SOURCE
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ abstract class KtLightClassForSourceDeclaration(
|
||||
(qualifiedName != null && another is KtLightClassForSourceDeclaration && qualifiedName == another.qualifiedName)
|
||||
|
||||
override fun getElementIcon(flags: Int): Icon? =
|
||||
throw UnsupportedOperationException("This should be done by JetIconProvider")
|
||||
throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
|
||||
@@ -1626,7 +1626,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
BlockStackElement topOfStack = blockStackElements.pop();
|
||||
assert topOfStack == tryWithFinallyBlockStackElement : "Top element of stack doesn't equals processing finally block";
|
||||
|
||||
KtTryExpression jetTryExpression = tryWithFinallyBlockStackElement.expression;
|
||||
KtTryExpression ktTryExpression = tryWithFinallyBlockStackElement.expression;
|
||||
Label finallyStart = linkedLabel();
|
||||
v.mark(finallyStart);
|
||||
tryWithFinallyBlockStackElement.addGapLabel(finallyStart);
|
||||
@@ -1635,7 +1635,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
generateFinallyMarker(v, finallyDepth, true);
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
gen(jetTryExpression.getFinallyBlock().getFinalExpression(), Type.VOID_TYPE);
|
||||
gen(ktTryExpression.getFinallyBlock().getFinalExpression(), Type.VOID_TYPE);
|
||||
|
||||
if (isFinallyMarkerRequired(context)) {
|
||||
generateFinallyMarker(v, finallyDepth, false);
|
||||
@@ -4849,9 +4849,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
public void newArrayInstruction(@NotNull KotlinType arrayType) {
|
||||
if (KotlinBuiltIns.isArray(arrayType)) {
|
||||
KotlinType elementJetType = arrayType.getArguments().get(0).getType();
|
||||
putReifiedOperationMarkerIfTypeIsReifiedParameter(this, elementJetType, ReifiedTypeInliner.OperationKind.NEW_ARRAY);
|
||||
v.newarray(boxType(typeMapper.mapTypeAsDeclaration(elementJetType)));
|
||||
KotlinType elementKotlinType = arrayType.getArguments().get(0).getType();
|
||||
putReifiedOperationMarkerIfTypeIsReifiedParameter(this, elementKotlinType, ReifiedTypeInliner.OperationKind.NEW_ARRAY);
|
||||
v.newarray(boxType(typeMapper.mapTypeAsDeclaration(elementKotlinType)));
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(arrayType);
|
||||
|
||||
@@ -603,8 +603,8 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
if (initializerValue == null) return state.getClassBuilderMode().generateBodies;
|
||||
|
||||
//TODO: OPTIMIZATION: don't initialize static final fields
|
||||
KotlinType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
|
||||
Type type = typeMapper.mapType(jetType);
|
||||
KotlinType kotlinType = getPropertyOrDelegateType(property, propertyDescriptor);
|
||||
Type type = typeMapper.mapType(kotlinType);
|
||||
return !skipDefaultValue(propertyDescriptor, initializerValue.getValue(), type);
|
||||
}
|
||||
|
||||
|
||||
@@ -560,9 +560,9 @@ public class PropertyCodegen {
|
||||
PropertyDescriptor propertyDescriptor = propertyAccessorDescriptor.getCorrespondingProperty();
|
||||
StackValue property = codegen.intermediateValueForProperty(propertyDescriptor, true, null, StackValue.LOCAL_0);
|
||||
|
||||
PsiElement jetProperty = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
|
||||
if (jetProperty instanceof KtProperty || jetProperty instanceof KtParameter) {
|
||||
codegen.markLineNumber((KtElement) jetProperty, false);
|
||||
PsiElement ktProperty = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
|
||||
if (ktProperty instanceof KtProperty || ktProperty instanceof KtParameter) {
|
||||
codegen.markLineNumber((KtElement) ktProperty, false);
|
||||
}
|
||||
|
||||
if (propertyAccessorDescriptor instanceof PropertyGetterDescriptor) {
|
||||
|
||||
@@ -245,9 +245,9 @@ public class CodegenBinding {
|
||||
answer.addAll(files);
|
||||
|
||||
for (FqName name : names) {
|
||||
Collection<KtFile> jetFiles = bindingContext.get(PACKAGE_TO_FILES, name);
|
||||
if (jetFiles != null) {
|
||||
answer.addAll(jetFiles);
|
||||
Collection<KtFile> ktFiles = bindingContext.get(PACKAGE_TO_FILES, name);
|
||||
if (ktFiles != null) {
|
||||
answer.addAll(ktFiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
class Increment(private val myDelta: Int) : IntrinsicMethod() {
|
||||
override fun toCallable(method: CallableMethod, isSuper: Boolean, resolvedCall: ResolvedCall<*>): Callable =
|
||||
createIntrinsicCallable(method) {
|
||||
val jetExpression = resolvedCall.call.calleeExpression
|
||||
assert(jetExpression !is KtPrefixExpression) { "There should be postfix increment ${jetExpression!!.text}" }
|
||||
val ktExpression = resolvedCall.call.calleeExpression
|
||||
assert(ktExpression !is KtPrefixExpression) { "There should be postfix increment ${ktExpression!!.text}" }
|
||||
genIncrement(returnType, myDelta, it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
class NewArray : IntrinsicMethod() {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val jetType = resolvedCall.resultingDescriptor.returnType!!
|
||||
val type = codegen.state.typeMapper.mapType(jetType)
|
||||
val kotlinType = resolvedCall.resultingDescriptor.returnType!!
|
||||
val type = codegen.state.typeMapper.mapType(kotlinType)
|
||||
return object : IntrinsicCallable(type, listOf(Type.INT_TYPE), null, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
codegen.newArrayInstruction(jetType)
|
||||
codegen.newArrayInstruction(kotlinType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
|
||||
object TypeIntrinsics {
|
||||
@JvmStatic
|
||||
fun instanceOf(v: InstructionAdapter, jetType: KotlinType, boxedAsmType: Type) {
|
||||
val functionTypeArity = getFunctionTypeArity(jetType)
|
||||
fun instanceOf(v: InstructionAdapter, kotlinType: KotlinType, boxedAsmType: Type) {
|
||||
val functionTypeArity = getFunctionTypeArity(kotlinType)
|
||||
if (functionTypeArity >= 0) {
|
||||
v.iconst(functionTypeArity)
|
||||
v.typeIntrinsic(IS_FUNCTON_OF_ARITY_METHOD_NAME, IS_FUNCTON_OF_ARITY_DESCRIPTOR)
|
||||
return
|
||||
}
|
||||
|
||||
val suspendFunctionTypeArity = getSuspendFunctionTypeArity(jetType)
|
||||
val suspendFunctionTypeArity = getSuspendFunctionTypeArity(kotlinType)
|
||||
if (suspendFunctionTypeArity >= 0) {
|
||||
val notSuspendLambda = Label()
|
||||
val end = Label()
|
||||
@@ -49,7 +49,7 @@ object TypeIntrinsics {
|
||||
return
|
||||
}
|
||||
|
||||
val isMutableCollectionMethodName = getIsMutableCollectionMethodName(jetType)
|
||||
val isMutableCollectionMethodName = getIsMutableCollectionMethodName(kotlinType)
|
||||
if (isMutableCollectionMethodName != null) {
|
||||
v.typeIntrinsic(isMutableCollectionMethodName, IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR)
|
||||
return
|
||||
@@ -72,8 +72,8 @@ object TypeIntrinsics {
|
||||
LdcInsnNode(Integer(value))
|
||||
}
|
||||
|
||||
@JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type) {
|
||||
val functionTypeArity = getFunctionTypeArity(jetType)
|
||||
@JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, kotlinType: KotlinType, asmType: Type) {
|
||||
val functionTypeArity = getFunctionTypeArity(kotlinType)
|
||||
if (functionTypeArity >= 0) {
|
||||
instructions.insertBefore(instanceofInsn, iconstNode(functionTypeArity))
|
||||
instructions.insertBefore(instanceofInsn,
|
||||
@@ -82,7 +82,7 @@ object TypeIntrinsics {
|
||||
return
|
||||
}
|
||||
|
||||
val isMutableCollectionMethodName = getIsMutableCollectionMethodName(jetType)
|
||||
val isMutableCollectionMethodName = getIsMutableCollectionMethodName(kotlinType)
|
||||
if (isMutableCollectionMethodName != null) {
|
||||
instructions.insertBefore(instanceofInsn,
|
||||
typeIntrinsicNode(isMutableCollectionMethodName, IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR))
|
||||
@@ -141,22 +141,22 @@ object TypeIntrinsics {
|
||||
FqNames.mutableMapEntry
|
||||
)
|
||||
|
||||
private fun getMutableCollectionMethodName(prefix: String, jetType: KotlinType): String? {
|
||||
val fqName = getClassFqName(jetType)
|
||||
private fun getMutableCollectionMethodName(prefix: String, kotlinType: KotlinType): String? {
|
||||
val fqName = getClassFqName(kotlinType)
|
||||
if (fqName == null || fqName !in MUTABLE_COLLECTION_TYPE_FQ_NAMES) return null
|
||||
val baseName = if (fqName == FqNames.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString()
|
||||
return prefix + baseName
|
||||
}
|
||||
|
||||
private fun getIsMutableCollectionMethodName(jetType: KotlinType): String? = getMutableCollectionMethodName("is", jetType)
|
||||
private fun getIsMutableCollectionMethodName(kotlinType: KotlinType): String? = getMutableCollectionMethodName("is", kotlinType)
|
||||
|
||||
private fun getAsMutableCollectionMethodName(jetType: KotlinType): String? = getMutableCollectionMethodName("as", jetType)
|
||||
private fun getAsMutableCollectionMethodName(kotlinType: KotlinType): String? = getMutableCollectionMethodName("as", kotlinType)
|
||||
|
||||
private val IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR =
|
||||
Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getObjectType("java/lang/Object"))
|
||||
|
||||
private fun getClassFqName(jetType: KotlinType): FqName? {
|
||||
val classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null
|
||||
private fun getClassFqName(kotlinType: KotlinType): FqName? {
|
||||
val classDescriptor = TypeUtils.getClassDescriptor(kotlinType) ?: return null
|
||||
return DescriptorUtils.getFqName(classDescriptor).toSafe()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
/**
|
||||
* This class solves the problem of interdependency between analyzing Kotlin code and generating JetLightClasses
|
||||
* This class solves the problem of interdependency between analyzing Kotlin code and generating KotlinLightClasses
|
||||
|
||||
* Consider the following example:
|
||||
|
||||
|
||||
+3
-3
@@ -249,9 +249,9 @@ object PositioningStrategies {
|
||||
val TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE: PositioningStrategy<KtDeclaration> = object : PositioningStrategy<KtDeclaration>() {
|
||||
override fun mark(element: KtDeclaration): List<TextRange> {
|
||||
if (element is KtTypeParameterListOwner) {
|
||||
val jetTypeParameterList = element.typeParameterList
|
||||
if (jetTypeParameterList != null) {
|
||||
return markElement(jetTypeParameterList)
|
||||
val ktTypeParameterList = element.typeParameterList
|
||||
if (ktTypeParameterList != null) {
|
||||
return markElement(ktTypeParameterList)
|
||||
}
|
||||
}
|
||||
return DECLARATION_SIGNATURE.mark(element)
|
||||
|
||||
@@ -71,7 +71,7 @@ fun getExpectedTypePredicate(
|
||||
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
||||
val typePredicates = LinkedHashSet<TypePredicate?>()
|
||||
|
||||
fun addSubtypesOf(jetType: KotlinType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
fun addSubtypesOf(kotlinType: KotlinType?) = typePredicates.add(kotlinType?.getSubtypesPredicate())
|
||||
|
||||
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
||||
val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue()
|
||||
|
||||
@@ -25,16 +25,16 @@ import org.jetbrains.kotlin.psi.doNotAnalyze
|
||||
|
||||
class KotlinLookupLocation(val element: KtElement) : LookupLocation {
|
||||
val cachedLocation : LocationInfo? by lazy {
|
||||
val containingJetFile = element.containingKtFile
|
||||
val containingKtFile = element.containingKtFile
|
||||
|
||||
if (containingJetFile.doNotAnalyze != null)
|
||||
if (containingKtFile.doNotAnalyze != null)
|
||||
null
|
||||
else
|
||||
object : LocationInfo {
|
||||
override val filePath = containingJetFile.virtualFilePath
|
||||
override val filePath = containingKtFile.virtualFilePath
|
||||
|
||||
override val position: Position
|
||||
get() = getLineAndColumnInPsiFile(containingJetFile, element.textRange).let { Position(it.line, it.column) }
|
||||
get() = getLineAndColumnInPsiFile(containingKtFile, element.textRange).let { Position(it.line, it.column) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class AnnotationChecker(
|
||||
}
|
||||
}
|
||||
if (annotated is KtDeclarationWithBody) {
|
||||
// JetFunction or JetPropertyAccessor
|
||||
// KtFunction or KtPropertyAccessor
|
||||
for (parameter in annotated.valueParameters) {
|
||||
if (!parameter.hasValOrVar()) {
|
||||
check(parameter, trace)
|
||||
@@ -276,7 +276,7 @@ class AnnotationChecker(
|
||||
}
|
||||
|
||||
fun checkUselessFunctionLiteralAnnotation() {
|
||||
// TODO: tests on different JetAnnotatedExpression (?!)
|
||||
// TODO: tests on different KtAnnotatedExpression (?!)
|
||||
if (KotlinTarget.FUNCTION !in applicableTargets) return
|
||||
val annotatedExpression = entry.parent as? KtAnnotatedExpression ?: return
|
||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: return
|
||||
|
||||
@@ -176,11 +176,11 @@ public class AnnotationResolverImpl extends AnnotationResolver {
|
||||
}
|
||||
|
||||
public static void reportUnsupportedAnnotationForTypeParameter(
|
||||
@NotNull KtTypeParameter jetTypeParameter,
|
||||
@NotNull KtTypeParameter ktTypeParameter,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LanguageVersionSettings languageVersionSettings
|
||||
) {
|
||||
KtModifierList modifierList = jetTypeParameter.getModifierList();
|
||||
KtModifierList modifierList = ktTypeParameter.getModifierList();
|
||||
if (modifierList == null) return;
|
||||
|
||||
for (KtAnnotationEntry annotationEntry : modifierList.getAnnotationEntries()) {
|
||||
|
||||
@@ -205,8 +205,8 @@ public interface BindingContext {
|
||||
}
|
||||
PsiElement declarationPsiElement = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
|
||||
if (declarationPsiElement instanceof KtParameter) {
|
||||
KtParameter jetParameter = (KtParameter) declarationPsiElement;
|
||||
return jetParameter.hasValOrVar() ||
|
||||
KtParameter ktParameter = (KtParameter) declarationPsiElement;
|
||||
return ktParameter.hasValOrVar() ||
|
||||
backingFieldRequired; // this part is unused because we do not allow access to constructor parameters in member bodies
|
||||
}
|
||||
if (propertyDescriptor.getModality() == Modality.ABSTRACT) return false;
|
||||
|
||||
@@ -515,12 +515,12 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
private fun checkTypeParameters(typeParameterListOwner: KtTypeParameterListOwner) {
|
||||
for (jetTypeParameter in typeParameterListOwner.typeParameters) {
|
||||
for (ktTypeParameter in typeParameterListOwner.typeParameters) {
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.ClassTypeParameterAnnotations)) {
|
||||
AnnotationResolverImpl.reportUnsupportedAnnotationForTypeParameter(jetTypeParameter, trace, languageVersionSettings)
|
||||
AnnotationResolverImpl.reportUnsupportedAnnotationForTypeParameter(ktTypeParameter, trace, languageVersionSettings)
|
||||
}
|
||||
|
||||
trace.get(TYPE_PARAMETER, jetTypeParameter)?.let { DescriptorResolver.checkConflictingUpperBounds(trace, it, jetTypeParameter) }
|
||||
trace.get(TYPE_PARAMETER, ktTypeParameter)?.let { DescriptorResolver.checkConflictingUpperBounds(trace, it, ktTypeParameter) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ class LazyTopDownAnalyzer(
|
||||
var visitor: KtVisitorVoid? = null
|
||||
visitor = ExceptionWrappingKtVisitorVoid(object : KtVisitorVoid() {
|
||||
private fun registerDeclarations(declarations: List<KtDeclaration>) {
|
||||
for (jetDeclaration in declarations) {
|
||||
jetDeclaration.accept(visitor!!)
|
||||
for (ktDeclaration in declarations) {
|
||||
ktDeclaration.accept(visitor!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,17 +128,17 @@ class LazyTopDownAnalyzer(
|
||||
|
||||
private fun checkClassOrObjectDeclarations(classOrObject: KtClassOrObject, classDescriptor: ClassDescriptor) {
|
||||
var companionObjectAlreadyFound = false
|
||||
for (jetDeclaration in classOrObject.declarations) {
|
||||
if (jetDeclaration is KtObjectDeclaration && jetDeclaration.isCompanion()) {
|
||||
for (ktDeclaration in classOrObject.declarations) {
|
||||
if (ktDeclaration is KtObjectDeclaration && ktDeclaration.isCompanion()) {
|
||||
if (companionObjectAlreadyFound) {
|
||||
trace.report(MANY_COMPANION_OBJECTS.on(jetDeclaration))
|
||||
trace.report(MANY_COMPANION_OBJECTS.on(ktDeclaration))
|
||||
}
|
||||
companionObjectAlreadyFound = true
|
||||
} else if (jetDeclaration is KtSecondaryConstructor) {
|
||||
} else if (ktDeclaration is KtSecondaryConstructor) {
|
||||
if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) {
|
||||
trace.report(CONSTRUCTOR_IN_OBJECT.on(jetDeclaration))
|
||||
trace.report(CONSTRUCTOR_IN_OBJECT.on(ktDeclaration))
|
||||
} else if (classDescriptor.kind == ClassKind.INTERFACE) {
|
||||
trace.report(CONSTRUCTOR_IN_INTERFACE.on(jetDeclaration))
|
||||
trace.report(CONSTRUCTOR_IN_INTERFACE.on(ktDeclaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,11 +150,11 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
|
||||
private fun registerPrimaryConstructorParameters(klass: KtClass) {
|
||||
for (jetParameter in klass.primaryConstructorParameters) {
|
||||
if (jetParameter.hasValOrVar()) {
|
||||
for (ktParameter in klass.primaryConstructorParameters) {
|
||||
if (ktParameter.hasValOrVar()) {
|
||||
c.primaryConstructorParameterProperties.put(
|
||||
jetParameter,
|
||||
lazyDeclarationResolver.resolveToDescriptor(jetParameter) as PropertyDescriptor
|
||||
ktParameter,
|
||||
lazyDeclarationResolver.resolveToDescriptor(ktParameter) as PropertyDescriptor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ object ModifierCheckerCore {
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
if (listOwner is KtDeclarationWithBody) {
|
||||
// JetFunction or JetPropertyAccessor
|
||||
// KtFunction or KtPropertyAccessor
|
||||
for (parameter in listOwner.valueParameters) {
|
||||
if (!parameter.hasValOrVar()) {
|
||||
check(parameter, trace, trace[BindingContext.VALUE_PARAMETER, parameter], languageVersionSettings)
|
||||
|
||||
@@ -63,8 +63,8 @@ private fun createTypeBindingFromPsi(
|
||||
}
|
||||
|
||||
fun KtCallableDeclaration.createTypeBindingForReturnType(trace: BindingContext): TypeBinding<PsiElement>? {
|
||||
val jetTypeReference = typeReference
|
||||
if (jetTypeReference != null) return jetTypeReference.createTypeBinding(trace)
|
||||
val ktTypeReference = typeReference
|
||||
if (ktTypeReference != null) return ktTypeReference.createTypeBinding(trace)
|
||||
|
||||
val descriptor = trace[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
|
||||
if (descriptor !is CallableDescriptor) return null
|
||||
|
||||
@@ -336,7 +336,7 @@ public class CallResolver {
|
||||
else if (calleeExpression instanceof KtConstructorDelegationReferenceExpression) {
|
||||
KtConstructorDelegationCall delegationCall = (KtConstructorDelegationCall) context.call.getCallElement();
|
||||
DeclarationDescriptor container = context.scope.getOwnerDescriptor();
|
||||
assert container instanceof ConstructorDescriptor : "Trying to resolve JetConstructorDelegationCall not in constructor. scope.ownerDescriptor = " + container;
|
||||
assert container instanceof ConstructorDescriptor : "Trying to resolve KtConstructorDelegationCall not in constructor. scope.ownerDescriptor = " + container;
|
||||
return (OverloadResolutionResults) resolveConstructorDelegationCall(
|
||||
context,
|
||||
delegationCall,
|
||||
|
||||
@@ -277,7 +277,7 @@ class CandidateResolver(
|
||||
val expression = candidateCall.call.calleeExpression
|
||||
|
||||
if (expression is KtSimpleNameExpression) {
|
||||
// 'B' in 'class A: B()' is JetConstructorCalleeExpression
|
||||
// 'B' in 'class A: B()' is KtConstructorCalleeExpression
|
||||
if (descriptor is ConstructorDescriptor) {
|
||||
val modality = descriptor.constructedClass.modality
|
||||
if (modality == Modality.ABSTRACT) {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class ReifiedTypeParameterAnnotationChecker : DeclarationChecker {
|
||||
) {
|
||||
for (reifiedTypeParameterDescriptor in typeParameterDescriptors.filter { it.isReified }) {
|
||||
val typeParameterDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(reifiedTypeParameterDescriptor)
|
||||
if (typeParameterDeclaration !is KtTypeParameter) throw AssertionError("JetTypeParameter expected")
|
||||
if (typeParameterDeclaration !is KtTypeParameter) throw AssertionError("KtTypeParameter expected")
|
||||
|
||||
diagnosticHolder.report(
|
||||
Errors.REIFIED_TYPE_PARAMETER_NO_INLINE.on(
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class DeclarationScopeProviderImpl implements DeclarationScopeProvider {
|
||||
KtDeclaration ktDeclaration = KtStubbedPsiUtil.getPsiOrStubParent(elementOfDeclaration, KtDeclaration.class, false);
|
||||
|
||||
assert !(elementOfDeclaration instanceof KtDeclaration) || ktDeclaration == elementOfDeclaration :
|
||||
"For JetDeclaration element getParentOfType() should return itself.";
|
||||
"For KtDeclaration element getParentOfType() should return itself.";
|
||||
assert ktDeclaration != null : "Should be contained inside declaration.";
|
||||
|
||||
KtDeclaration parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(ktDeclaration);
|
||||
|
||||
@@ -130,9 +130,9 @@ open class LazyDeclarationResolver constructor(
|
||||
val grandFather = parameter.parent.parent
|
||||
when (grandFather) {
|
||||
is KtPrimaryConstructor -> {
|
||||
val jetClass = grandFather.getContainingClassOrObject()
|
||||
val ktClassOrObject = grandFather.getContainingClassOrObject()
|
||||
// This is a primary constructor parameter
|
||||
val classDescriptor = getClassDescriptorIfAny(jetClass, lookupLocationFor(jetClass, false))
|
||||
val classDescriptor = getClassDescriptorIfAny(ktClassOrObject, lookupLocationFor(ktClassOrObject, false))
|
||||
return when {
|
||||
classDescriptor == null -> null
|
||||
parameter.hasValOrVar() -> {
|
||||
|
||||
+2
-2
@@ -78,8 +78,8 @@ public abstract class KtClassOrObjectInfo<E extends KtClassOrObject> implements
|
||||
public FqName getContainingPackageFqName() {
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (file instanceof KtFile) {
|
||||
KtFile jetFile = (KtFile) file;
|
||||
return jetFile.getPackageFqName();
|
||||
KtFile ktFile = (KtFile) file;
|
||||
return ktFile.getPackageFqName();
|
||||
}
|
||||
throw new IllegalArgumentException("Not in a KtFile: " + element);
|
||||
}
|
||||
|
||||
+3
-3
@@ -196,8 +196,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
this.annotations = Annotations.Companion.getEMPTY();
|
||||
}
|
||||
|
||||
List<KtAnnotationEntry> jetDanglingAnnotations = classLikeInfo.getDanglingAnnotations();
|
||||
if (jetDanglingAnnotations.isEmpty()) {
|
||||
List<KtAnnotationEntry> ktDanglingAnnotations = classLikeInfo.getDanglingAnnotations();
|
||||
if (ktDanglingAnnotations.isEmpty()) {
|
||||
this.danglingAnnotations = Annotations.Companion.getEMPTY();
|
||||
}
|
||||
else {
|
||||
@@ -213,7 +213,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return getScopeForMemberDeclarationResolution();
|
||||
}
|
||||
},
|
||||
jetDanglingAnnotations
|
||||
ktDanglingAnnotations
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ interface KtElement : NavigatablePsiElement, KtPureElement {
|
||||
|
||||
fun <R, D> accept(visitor: KtVisitor<R, D>, data: D): R
|
||||
|
||||
@Deprecated("Don't use getReference() on JetElement for the choice is unpredictable")
|
||||
@Deprecated("Don't use getReference() on KtElement for the choice is unpredictable")
|
||||
override fun getReference(): PsiReference?
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ public class KtFunctionType extends KtElementImplStub<KotlinPlaceHolderStub<KtFu
|
||||
if (receiverTypeRef != null) {
|
||||
result.add(receiverTypeRef);
|
||||
}
|
||||
for (KtParameter jetParameter : getParameters()) {
|
||||
result.add(jetParameter.getTypeReference());
|
||||
for (KtParameter ktParameter : getParameters()) {
|
||||
result.add(ktParameter.getTypeReference());
|
||||
}
|
||||
KtTypeReference returnTypeRef = getReturnTypeReference();
|
||||
if (returnTypeRef != null) {
|
||||
|
||||
@@ -336,9 +336,9 @@ public class KtPsiUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtClassOrObject getClassIfParameterIsProperty(@NotNull KtParameter jetParameter) {
|
||||
if (jetParameter.hasValOrVar()) {
|
||||
PsiElement grandParent = jetParameter.getParent().getParent();
|
||||
public static KtClassOrObject getClassIfParameterIsProperty(@NotNull KtParameter ktParameter) {
|
||||
if (ktParameter.hasValOrVar()) {
|
||||
PsiElement grandParent = ktParameter.getParent().getParent();
|
||||
if (grandParent instanceof KtPrimaryConstructor) {
|
||||
return ((KtPrimaryConstructor) grandParent).getContainingClassOrObject();
|
||||
}
|
||||
@@ -883,7 +883,7 @@ public class KtPsiUtil {
|
||||
KtSimpleNameExpression operationExpression = expression.getOperationReference();
|
||||
IElementType elementType = operationExpression.getReferencedNameElementType();
|
||||
assert elementType == null || elementType instanceof KtToken :
|
||||
"JetOperationExpression should have operation token of type KtToken: " +
|
||||
"KtOperationExpression should have operation token of type KtToken: " +
|
||||
expression;
|
||||
return (KtToken) elementType;
|
||||
}
|
||||
|
||||
@@ -418,8 +418,8 @@ public class KtVisitor<R, D> extends PsiElementVisitor {
|
||||
return visitKtElement(typeProjection, data);
|
||||
}
|
||||
|
||||
public R visitWhenEntry(@NotNull KtWhenEntry jetWhenEntry, D data) {
|
||||
return visitKtElement(jetWhenEntry, data);
|
||||
public R visitWhenEntry(@NotNull KtWhenEntry ktWhenEntry, D data) {
|
||||
return visitKtElement(ktWhenEntry, data);
|
||||
}
|
||||
|
||||
public R visitIsExpression(@NotNull KtIsExpression expression, D data) {
|
||||
|
||||
@@ -397,8 +397,8 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
|
||||
super.visitTypeProjection(typeProjection, null);
|
||||
}
|
||||
|
||||
public void visitWhenEntry(@NotNull KtWhenEntry jetWhenEntry) {
|
||||
super.visitWhenEntry(jetWhenEntry, null);
|
||||
public void visitWhenEntry(@NotNull KtWhenEntry ktWhenEntry) {
|
||||
super.visitWhenEntry(ktWhenEntry, null);
|
||||
}
|
||||
|
||||
public void visitIsExpression(@NotNull KtIsExpression expression) {
|
||||
@@ -993,8 +993,8 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Void visitWhenEntry(@NotNull KtWhenEntry jetWhenEntry, Void data) {
|
||||
visitWhenEntry(jetWhenEntry);
|
||||
public final Void visitWhenEntry(@NotNull KtWhenEntry ktWhenEntry, Void data) {
|
||||
visitWhenEntry(ktWhenEntry);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
|
||||
|
||||
// methods with parameter
|
||||
|
||||
public void visitJetElementVoid(@NotNull KtElement element, P data) {
|
||||
public void visitKtElementVoid(@NotNull KtElement element, P data) {
|
||||
super.visitKtElement(element, data);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
|
||||
super.visitDestructuringDeclarationEntry(multiDeclarationEntry, data);
|
||||
}
|
||||
|
||||
public void visitJetFileVoid(@NotNull KtFile file, P data) {
|
||||
public void visitKtFileVoid(@NotNull KtFile file, P data) {
|
||||
super.visitKtFile(file, data);
|
||||
}
|
||||
|
||||
@@ -370,8 +370,8 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
|
||||
super.visitTypeProjection(typeProjection, data);
|
||||
}
|
||||
|
||||
public void visitWhenEntryVoid(@NotNull KtWhenEntry jetWhenEntry, P data) {
|
||||
super.visitWhenEntry(jetWhenEntry, data);
|
||||
public void visitWhenEntryVoid(@NotNull KtWhenEntry ktWhenEntry, P data) {
|
||||
super.visitWhenEntry(ktWhenEntry, data);
|
||||
}
|
||||
|
||||
public void visitCollectionLiteralExpressionVoid(@NotNull KtCollectionLiteralExpression expression, P data) {
|
||||
@@ -425,7 +425,7 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
|
||||
// hidden methods
|
||||
@Override
|
||||
public final Void visitKtElement(@NotNull KtElement element, P data) {
|
||||
visitJetElementVoid(element, data);
|
||||
visitKtElementVoid(element, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
|
||||
|
||||
@Override
|
||||
public final Void visitKtFile(@NotNull KtFile file, P data) {
|
||||
visitJetFileVoid(file, data);
|
||||
visitKtFileVoid(file, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -936,8 +936,8 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Void visitWhenEntry(@NotNull KtWhenEntry jetWhenEntry, P data) {
|
||||
visitWhenEntryVoid(jetWhenEntry, data);
|
||||
public final Void visitWhenEntry(@NotNull KtWhenEntry ktWhenEntry, P data) {
|
||||
visitWhenEntryVoid(ktWhenEntry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class KtWhenConditionInRange extends KtWhenCondition {
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public KtExpression getRangeExpression() {
|
||||
// Copied from JetBinaryExpression
|
||||
// Copied from KtBinaryExpression
|
||||
ASTNode node = getOperationReference().getNode().getTreeNext();
|
||||
while (node != null) {
|
||||
PsiElement psi = node.getPsi();
|
||||
|
||||
@@ -40,8 +40,8 @@ class KotlinFileStubImpl(
|
||||
val facadePartSimpleNames: List<String>?,
|
||||
) : PsiFileStubImpl<KtFile>(ktFile), KotlinFileStub, PsiClassHolderFileStub<KtFile> {
|
||||
|
||||
constructor(jetFile: KtFile?, packageName: String, isScript: Boolean) : this(
|
||||
jetFile,
|
||||
constructor(ktFile: KtFile?, packageName: String, isScript: Boolean) : this(
|
||||
ktFile,
|
||||
packageName,
|
||||
isScript,
|
||||
facadeFqNameString = null,
|
||||
|
||||
@@ -43,7 +43,7 @@ object ModifierMaskUtils {
|
||||
@JvmStatic
|
||||
fun maskHasModifier(mask: Long, modifierToken: KtModifierKeywordToken): Boolean {
|
||||
val index = MODIFIER_KEYWORDS_ARRAY.indexOf(modifierToken)
|
||||
assert(index >= 0) { "All JetModifierKeywordTokens should be present in MODIFIER_KEYWORDS_ARRAY" }
|
||||
assert(index >= 0) { "All KtModifierKeywordTokens should be present in MODIFIER_KEYWORDS_ARRAY" }
|
||||
return (mask and (1L shl index)) != 0L
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironmentMa
|
||||
|
||||
CompilerTestLanguageVersionSettingsKt.setupLanguageVersionSettingsForCompilerTests(FileUtil.loadFile(file, true), environment);
|
||||
|
||||
KtFile ktFile = KotlinTestUtils.loadJetFile(environment.getProject(), file);
|
||||
KtFile ktFile = KotlinTestUtils.loadKtFile(environment.getProject(), file);
|
||||
|
||||
SetMultimap<KtElement, Pseudocode> data = LinkedHashMultimap.create();
|
||||
AnalysisResult analysisResult = KotlinTestUtils.analyzeFile(ktFile, environment);
|
||||
|
||||
@@ -68,7 +68,7 @@ fun getExpectedTypePredicate(
|
||||
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
||||
val typePredicates = LinkedHashSet<TypePredicate?>()
|
||||
|
||||
fun addSubtypesOf(jetType: KotlinType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
fun addSubtypesOf(kotlinType: KotlinType?) = typePredicates.add(kotlinType?.getSubtypesPredicate())
|
||||
|
||||
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
||||
val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue()
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ abstract public class AbstractGenerateNotNullAssertionsTest extends CodegenTestC
|
||||
}
|
||||
|
||||
private void assertNoIntrinsicsMethodIsCalledInMyClasses(boolean noClassFileIsAnError) {
|
||||
for (KtFile jetFile : myFiles.getPsiFiles()) {
|
||||
String fileClassName = JvmFileClassUtil.getFileClassInfoNoResolve(jetFile).getFileClassFqName().asString();
|
||||
for (KtFile ktFile : myFiles.getPsiFiles()) {
|
||||
String fileClassName = JvmFileClassUtil.getFileClassInfoNoResolve(ktFile).getFileClassFqName().asString();
|
||||
assertNoIntrinsicsMethodIsCalled(fileClassName, noClassFileIsAnError);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ abstract class AbstractCompileJavaAgainstKotlinTest : TestCaseWithTmpdir() {
|
||||
updateConfiguration(environment.configuration)
|
||||
environment.registerJavac(
|
||||
javaFiles = javaFiles,
|
||||
kotlinFiles = listOf(KotlinTestUtils.loadJetFile(environment.project, ktFiles.first()))
|
||||
kotlinFiles = listOf(KotlinTestUtils.loadKtFile(environment.project, ktFiles.first()))
|
||||
)
|
||||
if (!ktFiles.isEmpty()) {
|
||||
LoadDescriptorUtil.compileKotlinToDirAndGetModule(ktFiles, outDir, environment)
|
||||
|
||||
+2
-2
@@ -97,9 +97,9 @@ abstract class AbstractResolvedCallsTest : KotlinTestWithEnvironment() {
|
||||
}
|
||||
|
||||
protected open fun buildCachedCallAtIndex(
|
||||
bindingContext: BindingContext, jetFile: KtFile, index: Int
|
||||
bindingContext: BindingContext, ktFile: KtFile, index: Int
|
||||
): Pair<PsiElement?, ResolvedCall<out CallableDescriptor>?> {
|
||||
val element = jetFile.findElementAt(index)!!
|
||||
val element = ktFile.findElementAt(index)!!
|
||||
val expression = element.getStrictParentOfType<KtExpression>()
|
||||
|
||||
val cachedCall = expression?.getParentResolvedCall(bindingContext, strict = false)
|
||||
|
||||
+2
-2
@@ -28,9 +28,9 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
|
||||
abstract class AbstractResolvedConstructorDelegationCallsTests : AbstractResolvedCallsTest() {
|
||||
override fun buildCachedCallAtIndex(
|
||||
bindingContext: BindingContext, jetFile: KtFile, index: Int
|
||||
bindingContext: BindingContext, ktFile: KtFile, index: Int
|
||||
): Pair<PsiElement?, ResolvedCall<out CallableDescriptor>?> {
|
||||
val element = jetFile.findElementAt(index)
|
||||
val element = ktFile.findElementAt(index)
|
||||
val constructor = element?.getNonStrictParentOfType<KtSecondaryConstructor>()!!
|
||||
val delegationCall = constructor.getDelegationCall()
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.regex.Pattern
|
||||
|
||||
object BuiltinsTestUtils {
|
||||
fun compileBuiltinsModule(environment: KotlinCoreEnvironment): ModuleDescriptor {
|
||||
val files = KotlinTestUtils.loadToJetFiles(
|
||||
val files = KotlinTestUtils.loadToKtFiles(
|
||||
environment, ContainerUtil.concat<File>(
|
||||
allFilesUnder("core/builtins/native"),
|
||||
allFilesUnder("core/builtins/src"),
|
||||
|
||||
@@ -224,13 +224,13 @@ public class KotlinTestUtils {
|
||||
for (KotlinSourceRoot root : roots) {
|
||||
File file = new File(root.getPath());
|
||||
if (file.isFile()) {
|
||||
ktFiles.add(loadJetFile(environment.getProject(), file));
|
||||
ktFiles.add(loadKtFile(environment.getProject(), file));
|
||||
}
|
||||
else {
|
||||
//noinspection ConstantConditions
|
||||
for (File childFile : file.listFiles()) {
|
||||
if (childFile.getName().endsWith(".kt") || childFile.getName().endsWith(".kts")) {
|
||||
ktFiles.add(loadJetFile(environment.getProject(), childFile));
|
||||
ktFiles.add(loadKtFile(environment.getProject(), childFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,18 +597,18 @@ public class KotlinTestUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtFile loadJetFile(@NotNull Project project, @NotNull File ioFile) throws IOException {
|
||||
public static KtFile loadKtFile(@NotNull Project project, @NotNull File ioFile) throws IOException {
|
||||
String text = FileUtil.loadFile(ioFile, true);
|
||||
return new KtPsiFactory(project).createPhysicalFile(ioFile.getName(), text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<KtFile> loadToJetFiles(@NotNull KotlinCoreEnvironment environment, @NotNull List<File> files) throws IOException {
|
||||
List<KtFile> jetFiles = Lists.newArrayList();
|
||||
public static List<KtFile> loadToKtFiles(@NotNull KotlinCoreEnvironment environment, @NotNull List<File> files) throws IOException {
|
||||
List<KtFile> ktFiles = Lists.newArrayList();
|
||||
for (File file : files) {
|
||||
jetFiles.add(loadJetFile(environment.getProject(), file));
|
||||
ktFiles.add(loadKtFile(environment.getProject(), file));
|
||||
}
|
||||
return jetFiles;
|
||||
return ktFiles;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
private fun analyzeFileToPackageView(vararg extraClassPath: File): PackageViewDescriptor {
|
||||
val environment = createEnvironment(extraClassPath.toList())
|
||||
|
||||
val ktFile = KotlinTestUtils.loadJetFile(environment.project, getTestDataFileWithExtension("kt"))
|
||||
val ktFile = KotlinTestUtils.loadKtFile(environment.project, getTestDataFileWithExtension("kt"))
|
||||
val result = JvmResolveUtil.analyzeAndCheckForErrors(ktFile, environment)
|
||||
|
||||
return result.moduleDescriptor.getPackage(LoadDescriptorUtil.TEST_PACKAGE_FQNAME).also {
|
||||
@@ -197,7 +197,7 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
val library = compileLibrary("library")
|
||||
val environment = createEnvironment(listOf(library))
|
||||
|
||||
val ktFile = KotlinTestUtils.loadJetFile(environment.project, getTestDataFileWithExtension("kt"))
|
||||
val ktFile = KotlinTestUtils.loadKtFile(environment.project, getTestDataFileWithExtension("kt"))
|
||||
val result = JvmResolveUtil.analyze(ktFile, environment)
|
||||
result.throwIfError()
|
||||
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
|
||||
val modules = HashMap<String, TestModule>()
|
||||
for (dir in moduleDirs) {
|
||||
val name = dir.name
|
||||
val kotlinFiles = KotlinTestUtils.loadToJetFiles(environment, dir.listFiles { it -> it.extension == "kt" }?.toList().orEmpty())
|
||||
val kotlinFiles = KotlinTestUtils.loadToKtFiles(environment, dir.listFiles { it -> it.extension == "kt" }?.toList().orEmpty())
|
||||
val javaFilesScope = object : DelegatingGlobalSearchScope(GlobalSearchScope.allScope(project)) {
|
||||
override fun contains(file: VirtualFile): Boolean {
|
||||
if (file !in myBaseScope!!) return false
|
||||
|
||||
@@ -40,11 +40,11 @@ public class RecursiveDescriptorProcessorTest extends KotlinTestWithEnvironment
|
||||
}
|
||||
|
||||
public void testRecursive() throws Exception {
|
||||
File ktFile = new File("compiler/testData/recursiveProcessor/declarations.kt");
|
||||
File file = new File("compiler/testData/recursiveProcessor/declarations.kt");
|
||||
File txtFile = new File("compiler/testData/recursiveProcessor/declarations.txt");
|
||||
String text = FileUtil.loadFile(ktFile, true);
|
||||
KtFile jetFile = KtTestUtil.createFile("declarations.kt", text, getEnvironment().getProject());
|
||||
AnalysisResult result = KotlinTestUtils.analyzeFile(jetFile, getEnvironment());
|
||||
String text = FileUtil.loadFile(file, true);
|
||||
KtFile ktFile = KtTestUtil.createFile("declarations.kt", text, getEnvironment().getProject());
|
||||
AnalysisResult result = KotlinTestUtils.analyzeFile(ktFile, getEnvironment());
|
||||
PackageViewDescriptor testPackage = result.getModuleDescriptor().getPackage(FqName.topLevel(Name.identifier("test")));
|
||||
|
||||
List<String> descriptors = recursivelyCollectDescriptors(testPackage);
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.typeBinding.TypeBinding
|
||||
import org.jetbrains.kotlin.resolve.typeBinding.createTypeBindingForReturnType
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils.assertEqualsToFile
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils.loadJetFile
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils.loadKtFile
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import java.io.File
|
||||
@@ -36,7 +36,7 @@ abstract class AbstractTypeBindingTest : KotlinTestWithEnvironment() {
|
||||
|
||||
protected fun doTest(path: String) {
|
||||
val testFile = File(path)
|
||||
val testKtFile = loadJetFile(project, testFile)
|
||||
val testKtFile = loadKtFile(project, testFile)
|
||||
|
||||
val analyzeResult = JvmResolveUtil.analyze(testKtFile, environment)
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
|
||||
@NotNull
|
||||
private LexicalScope getDeclarationsScope() throws IOException {
|
||||
KtFile ktFile = KotlinTestUtils.loadJetFile(getProject(), new File("compiler/testData/type-checker-test.kt"));
|
||||
KtFile ktFile = KotlinTestUtils.loadKtFile(getProject(), new File("compiler/testData/type-checker-test.kt"));
|
||||
AnalysisResult result = JvmResolveUtil.analyze(ktFile, getEnvironment());
|
||||
//noinspection ConstantConditions
|
||||
return result.getBindingContext().get(BindingContext.LEXICAL_SCOPE, ktFile);
|
||||
|
||||
@@ -145,10 +145,10 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
|
||||
}
|
||||
|
||||
private KotlinType resolveType(String typeStr) {
|
||||
KtTypeReference jetTypeReference = new KtPsiFactory(getProject()).createType(typeStr);
|
||||
AnalyzingUtils.checkForSyntacticErrors(jetTypeReference);
|
||||
KtTypeReference ktTypeReference = new KtPsiFactory(getProject()).createType(typeStr);
|
||||
AnalyzingUtils.checkForSyntacticErrors(ktTypeReference);
|
||||
BindingTrace trace = new BindingTraceContext();
|
||||
KotlinType type = container.getTypeResolver().resolveType(scope, jetTypeReference, trace, true);
|
||||
KotlinType type = container.getTypeResolver().resolveType(scope, ktTypeReference, trace, true);
|
||||
if (!trace.getBindingContext().getDiagnostics().isEmpty()) {
|
||||
fail("Errors:\n" + StringUtil.join(trace.getBindingContext().getDiagnostics(), DefaultErrorMessages::render, "\n"));
|
||||
}
|
||||
|
||||
+3
-3
@@ -306,9 +306,9 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitWhenEntry(jetWhenEntry: KtWhenEntry) {
|
||||
jetWhenEntry.firstOfTypeWithRender<FirWhenBranch>(jetWhenEntry.expression) { this.result.typeRef }
|
||||
super.visitWhenEntry(jetWhenEntry)
|
||||
override fun visitWhenEntry(ktWhenEntry: KtWhenEntry) {
|
||||
ktWhenEntry.firstOfTypeWithRender<FirWhenBranch>(ktWhenEntry.expression) { this.result.typeRef }
|
||||
super.visitWhenEntry(ktWhenEntry)
|
||||
}
|
||||
|
||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression) {
|
||||
|
||||
+3
-4
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.compiler.visualizer.Annotator.annotate
|
||||
import org.jetbrains.kotlin.contracts.parsing.isEqualsDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
@@ -227,9 +226,9 @@ class PsiVisualizer(private val file: KtFile, analysisResult: AnalysisResult) :
|
||||
super.visitWhenExpression(expression)
|
||||
}
|
||||
|
||||
override fun visitWhenEntry(jetWhenEntry: KtWhenEntry) {
|
||||
addAnnotation(renderType(jetWhenEntry.expression), jetWhenEntry.expression!!)
|
||||
super.visitWhenEntry(jetWhenEntry)
|
||||
override fun visitWhenEntry(ktWhenEntry: KtWhenEntry) {
|
||||
addAnnotation(renderType(ktWhenEntry.expression), ktWhenEntry.expression!!)
|
||||
super.visitWhenEntry(ktWhenEntry)
|
||||
}
|
||||
|
||||
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
|
||||
|
||||
@@ -19,17 +19,20 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
val KotlinType.nameIfStandardType: Name?
|
||||
get() = constructor.declarationDescriptor?.takeIf(KotlinBuiltIns::isBuiltIn)?.name
|
||||
|
||||
fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String {
|
||||
@Deprecated(message = "Use getKotlinTypeFqName(Boolean) instead")
|
||||
fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String = getKotlinTypeFqName(printTypeArguments)
|
||||
|
||||
fun KotlinType.getKotlinTypeFqName(printTypeArguments: Boolean): String {
|
||||
val declaration = requireNotNull(constructor.declarationDescriptor) {
|
||||
"declarationDescriptor is null for constructor = $constructor with ${constructor.javaClass}"
|
||||
}
|
||||
if (declaration is TypeParameterDescriptor) {
|
||||
return StringUtil.join(declaration.upperBounds, { type -> type.getJetTypeFqName(printTypeArguments) }, "&")
|
||||
return StringUtil.join(declaration.upperBounds, { type -> type.getKotlinTypeFqName(printTypeArguments) }, "&")
|
||||
}
|
||||
|
||||
val typeArguments = arguments
|
||||
val typeArgumentsAsString = if (printTypeArguments && !typeArguments.isEmpty()) {
|
||||
val joinedTypeArguments = StringUtil.join(typeArguments, { projection -> projection.type.getJetTypeFqName(false) }, ", ")
|
||||
val joinedTypeArguments = StringUtil.join(typeArguments, { projection -> projection.type.getKotlinTypeFqName(false) }, ", ")
|
||||
|
||||
"<$joinedTypeArguments>"
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public final class PatternBuilder {
|
||||
if (actualReceiver != null) {
|
||||
if (receiverFqName == null) return false;
|
||||
|
||||
String actualReceiverFqName = DescriptorUtilsKt.getJetTypeFqName(actualReceiver.getType(), false);
|
||||
String actualReceiverFqName = DescriptorUtilsKt.getKotlinTypeFqName(actualReceiver.getType(), false);
|
||||
|
||||
if (!actualReceiverFqName.equals(receiverFqName)) return false;
|
||||
}
|
||||
|
||||
+13
-13
@@ -111,8 +111,8 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JsNode visitBlockExpression(@NotNull KtBlockExpression jetBlock, @NotNull TranslationContext context) {
|
||||
List<KtExpression> statements = jetBlock.getStatements();
|
||||
public JsNode visitBlockExpression(@NotNull KtBlockExpression ktBlockExpression, @NotNull TranslationContext context) {
|
||||
List<KtExpression> statements = ktBlockExpression.getStatements();
|
||||
JsBlock jsBlock = new JsBlock();
|
||||
for (KtExpression statement : statements) {
|
||||
JsNode jsNode = Translation.translateExpression(statement, context, jsBlock);
|
||||
@@ -131,9 +131,9 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
|
||||
@Override
|
||||
public JsNode visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration, @NotNull TranslationContext context) {
|
||||
KtExpression jetInitializer = multiDeclaration.getInitializer();
|
||||
assert jetInitializer != null : "Initializer for multi declaration must be not null";
|
||||
JsExpression initializer = Translation.translateAsExpression(jetInitializer, context);
|
||||
KtExpression ktInitializer = multiDeclaration.getInitializer();
|
||||
assert ktInitializer != null : "Initializer for multi declaration must be not null";
|
||||
JsExpression initializer = Translation.translateAsExpression(ktInitializer, context);
|
||||
JsName parameterName = JsScope.declareTemporary();
|
||||
JsVars tempVarDeclaration = JsAstUtils.newVar(parameterName, initializer);
|
||||
MetadataProperties.setSynthetic(tempVarDeclaration, true);
|
||||
@@ -143,20 +143,20 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JsNode visitReturnExpression(@NotNull KtReturnExpression jetReturnExpression, @NotNull TranslationContext context) {
|
||||
KtExpression returned = jetReturnExpression.getReturnedExpression();
|
||||
public JsNode visitReturnExpression(@NotNull KtReturnExpression ktReturnExpression, @NotNull TranslationContext context) {
|
||||
KtExpression returned = ktReturnExpression.getReturnedExpression();
|
||||
|
||||
// TODO: add related descriptor to context and use it here
|
||||
KtDeclarationWithBody parent = PsiTreeUtil.getParentOfType(jetReturnExpression, KtDeclarationWithBody.class);
|
||||
KtDeclarationWithBody parent = PsiTreeUtil.getParentOfType(ktReturnExpression, KtDeclarationWithBody.class);
|
||||
if (parent instanceof KtSecondaryConstructor) {
|
||||
ClassDescriptor classDescriptor = context.getClassDescriptor();
|
||||
assert classDescriptor != null : "Missing class descriptor in context while translating constructor: " +
|
||||
PsiUtilsKt.getTextWithLocation(jetReturnExpression);
|
||||
PsiUtilsKt.getTextWithLocation(ktReturnExpression);
|
||||
JsExpression ref = ReferenceTranslator.translateAsValueReference(classDescriptor.getThisAsReceiverParameter(), context);
|
||||
return new JsReturn(ref.source(jetReturnExpression));
|
||||
return new JsReturn(ref.source(ktReturnExpression));
|
||||
}
|
||||
|
||||
FunctionDescriptor returnTarget = getNonLocalReturnTarget(jetReturnExpression, context);
|
||||
FunctionDescriptor returnTarget = getNonLocalReturnTarget(ktReturnExpression, context);
|
||||
|
||||
JsReturn jsReturn;
|
||||
if (returned == null) {
|
||||
@@ -172,7 +172,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
|
||||
KotlinType returnedType = context.bindingContext().getType(returned);
|
||||
assert returnedType != null : "Resolved return expression is expected to have type: " +
|
||||
PsiUtilsKt.getTextWithLocation(jetReturnExpression);
|
||||
PsiUtilsKt.getTextWithLocation(ktReturnExpression);
|
||||
|
||||
CallableDescriptor returnTargetOrCurrentFunction = returnTarget;
|
||||
if (returnTargetOrCurrentFunction == null) {
|
||||
@@ -188,7 +188,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
|
||||
MetadataProperties.setReturnTarget(jsReturn, returnTarget);
|
||||
|
||||
return jsReturn.source(jetReturnExpression);
|
||||
return jsReturn.source(ktReturnExpression);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public final class StringTemplateTranslator extends AbstractTranslator {
|
||||
public void visitStringTemplateEntryWithExpression(@NotNull KtStringTemplateEntryWithExpression entry) {
|
||||
KtExpression entryExpression = entry.getExpression();
|
||||
assert entryExpression != null :
|
||||
"JetStringTemplateEntryWithExpression must have not null entry expression.";
|
||||
"KtStringTemplateEntryWithExpression must have not null entry expression.";
|
||||
JsExpression translatedExpression = Translation.translateAsExpression(entryExpression, context());
|
||||
|
||||
KotlinType type = context().bindingContext().getType(entryExpression);
|
||||
|
||||
+2
-2
@@ -37,9 +37,9 @@ public abstract class TranslatorVisitor<T> extends KtVisitor<T, TranslationConte
|
||||
return emptyResult(context);
|
||||
}
|
||||
|
||||
public final void traverseContainer(@NotNull KtDeclarationContainer jetClass,
|
||||
public final void traverseContainer(@NotNull KtDeclarationContainer ktClass,
|
||||
@NotNull TranslationContext context) {
|
||||
for (KtDeclaration declaration : jetClass.getDeclarations()) {
|
||||
for (KtDeclaration declaration : ktClass.getDeclarations()) {
|
||||
declaration.accept(this, context);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -358,18 +358,18 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
|
||||
private List<JsParameter> translatePrimaryConstructorParameters() {
|
||||
List<KtParameter> parameterList = getPrimaryConstructorParameters(classDeclaration);
|
||||
List<JsParameter> result = new ArrayList<>();
|
||||
for (KtParameter jetParameter : parameterList) {
|
||||
result.add(translateParameter(jetParameter));
|
||||
for (KtParameter ktParameter : parameterList) {
|
||||
result.add(translateParameter(ktParameter));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JsParameter translateParameter(@NotNull KtParameter jetParameter) {
|
||||
DeclarationDescriptor parameterDescriptor = getDescriptorForElement(bindingContext(), jetParameter);
|
||||
private JsParameter translateParameter(@NotNull KtParameter ktParameter) {
|
||||
DeclarationDescriptor parameterDescriptor = getDescriptorForElement(bindingContext(), ktParameter);
|
||||
JsName parameterName = context().getNameForDescriptor(parameterDescriptor);
|
||||
JsParameter jsParameter = new JsParameter(parameterName);
|
||||
mayBeAddInitializerStatementForProperty(jsParameter, jetParameter);
|
||||
mayBeAddInitializerStatementForProperty(jsParameter, ktParameter);
|
||||
return jsParameter;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class CompanionObjectIntrinsicAccessTranslator extends AbstractTranslator
|
||||
@NotNull TranslationContext context
|
||||
) {
|
||||
DeclarationDescriptor referenceDescriptor = getDescriptorForReferenceExpression(context.bindingContext(), expression);
|
||||
assert referenceDescriptor != null : "JetSimpleName expression must reference a descriptor " + expression.getText();
|
||||
assert referenceDescriptor != null : "KtSimpleName expression must reference a descriptor " + expression.getText();
|
||||
return new CompanionObjectIntrinsicAccessTranslator(referenceDescriptor, context);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public final class ReferenceAccessTranslator extends AbstractTranslator implemen
|
||||
/*package*/ static ReferenceAccessTranslator newInstance(@NotNull KtSimpleNameExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
DeclarationDescriptor referenceDescriptor = getDescriptorForReferenceExpression(context.bindingContext(), expression);
|
||||
assert referenceDescriptor != null : "JetSimpleName expression must reference a descriptor " + expression.getText();
|
||||
assert referenceDescriptor != null : "KtSimpleName expression must reference a descriptor " + expression.getText();
|
||||
return new ReferenceAccessTranslator(referenceDescriptor, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public final class BindingUtils {
|
||||
@NotNull
|
||||
private static KtParameter getParameterForDescriptor(@NotNull ValueParameterDescriptor descriptor) {
|
||||
PsiElement result = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
assert result instanceof KtParameter : message(descriptor, "ValueParameterDescriptor should have corresponding JetParameter");
|
||||
assert result instanceof KtParameter : message(descriptor, "ValueParameterDescriptor should have corresponding KtParameter");
|
||||
return (KtParameter) result;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -132,15 +132,15 @@ public final class FunctionBodyTranslator extends AbstractTranslator {
|
||||
|
||||
@NotNull
|
||||
private JsBlock translate() {
|
||||
KtExpression jetBodyExpression = declaration.getBodyExpression();
|
||||
assert jetBodyExpression != null : "Cannot translate a body of an abstract function.";
|
||||
KtExpression ktExpression = declaration.getBodyExpression();
|
||||
assert ktExpression != null : "Cannot translate a body of an abstract function.";
|
||||
JsBlock jsBlock = new JsBlock();
|
||||
|
||||
|
||||
JsNode jsBody = Translation.translateExpression(jetBodyExpression, context(), jsBlock);
|
||||
JsNode jsBody = Translation.translateExpression(ktExpression, context(), jsBlock);
|
||||
jsBlock.getStatements().addAll(mayBeWrapWithReturn(jsBody).getStatements());
|
||||
|
||||
if (jetBodyExpression instanceof KtBlockExpression &&
|
||||
if (ktExpression instanceof KtBlockExpression &&
|
||||
descriptor.getReturnType() != null && KotlinBuiltIns.isUnit(descriptor.getReturnType()) &&
|
||||
!KotlinBuiltIns.isUnit(TranslationUtils.getReturnTypeForCoercion(descriptor))) {
|
||||
ClassDescriptor unit = context().getCurrentModule().getBuiltIns().getUnit();
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.backend.common.CompilationException
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
|
||||
import org.jetbrains.kotlin.js.descriptorUtils.getKotlinTypeFqName
|
||||
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -59,7 +59,7 @@ fun AbstractSerialGenerator.getSerialTypeInfo(property: SerializableProperty): S
|
||||
T.isTypeParameter() -> SerialTypeInfo(property, if (property.type.isMarkedNullable) "Nullable" else "", null)
|
||||
T.isPrimitiveNumberType() or T.isBoolean() -> SerialTypeInfo(
|
||||
property,
|
||||
T.getJetTypeFqName(false).removePrefix("kotlin.") // i don't feel so good about it...
|
||||
T.getKotlinTypeFqName(false).removePrefix("kotlin.") // i don't feel so good about it...
|
||||
// alternative: KotlinBuiltIns.getPrimitiveType(T)!!.typeName.identifier
|
||||
)
|
||||
KotlinBuiltIns.isString(T) -> SerialTypeInfo(property, "String")
|
||||
@@ -162,7 +162,7 @@ fun findTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDescri
|
||||
}
|
||||
|
||||
fun findStandardKotlinTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDescriptor? {
|
||||
val typeName = kType.getJetTypeFqName(false)
|
||||
val typeName = kType.getKotlinTypeFqName(false)
|
||||
val name = when (typeName) {
|
||||
"Z" -> if (kType.isBoolean()) PrimitiveBuiltins.booleanSerializer else null
|
||||
"B" -> if (kType.isByte()) PrimitiveBuiltins.byteSerializer else null
|
||||
|
||||
+2
-2
@@ -182,7 +182,7 @@ sealed class CallTypeAndReceiver<TReceiver : KtElement?, out TCallType : CallTyp
|
||||
|
||||
is KtUnaryExpression -> OPERATOR(receiverExpression)
|
||||
|
||||
else -> error("Unknown parent for JetOperationReferenceExpression: $parent with text '${parent.text}'")
|
||||
else -> error("Unknown parent for KtOperationReferenceExpression: $parent with text '${parent.text}'")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ sealed class CallTypeAndReceiver<TReceiver : KtElement?, out TCallType : CallTyp
|
||||
DOT(receiverExpression)
|
||||
}
|
||||
|
||||
else -> error("Unknown parent for JetNameReferenceExpression with receiver: $parent")
|
||||
else -> error("Unknown parent for KtNameReferenceExpression with receiver: $parent")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user