default -> companion: replace all mentions of default and default object
This commit is contained in:
+1
-1
@@ -88,7 +88,7 @@ public class ReferenceVariantsHelper(
|
||||
|
||||
val qualifier = context[BindingContext.QUALIFIER, receiverExpression]
|
||||
if (qualifier != null) {
|
||||
// It's impossible to add extension function for package or class (if it's default object, expression type is not null)
|
||||
// It's impossible to add extension function for package or class (if it's companion object, expression type is not null)
|
||||
qualifier.scope.getDescriptorsFiltered(kindFilter exclude DescriptorKindExclude.Extensions, nameFilter).filterTo(descriptors) { callType.canCall(it) }
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.HashSet
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
public fun JetScope.getImplicitReceiversWithInstance(): List<ReceiverParameterDescriptor> {
|
||||
// we use a set to workaround a bug with receiver for default object present twice in the result of getImplicitReceiversHierarchy()
|
||||
// we use a set to workaround a bug with receiver for companion object present twice in the result of getImplicitReceiversHierarchy()
|
||||
val receivers = LinkedHashSet(getImplicitReceiversHierarchy())
|
||||
|
||||
val withInstance = HashSet<DeclarationDescriptor>()
|
||||
|
||||
@@ -389,7 +389,7 @@ usageType.type.definition = Type definition
|
||||
usageType.is = Target type of 'is' operation
|
||||
usageType.as = Target type of 'as' operation
|
||||
usageType.class.object = Nested class/object
|
||||
usageType.default.object = Default object
|
||||
usageType.companion.object = Companion object
|
||||
usageType.instantiation = Instantiation
|
||||
usageType.function.call = Function call
|
||||
usageType.implicit.get = Implicit 'get'
|
||||
|
||||
+10
-10
@@ -66,7 +66,7 @@ private class ClassClsStubBuilder(
|
||||
supertypeIds
|
||||
}
|
||||
}
|
||||
private val defaultObjectName = if (classProto.hasDefaultObjectName()) c.nameResolver.getName(classProto.getDefaultObjectName()) else null
|
||||
private val companionObjectName = if (classProto.hasCompanionObjectName()) c.nameResolver.getName(classProto.getCompanionObjectName()) else null
|
||||
|
||||
private val classOrObjectStub = createClassOrObjectStubAndModifierListStub()
|
||||
|
||||
@@ -94,14 +94,14 @@ private class ClassClsStubBuilder(
|
||||
val additionalModifiers = when (classKind) {
|
||||
ProtoBuf.Class.Kind.ENUM_CLASS -> listOf(JetTokens.ENUM_KEYWORD)
|
||||
ProtoBuf.Class.Kind.ANNOTATION_CLASS -> listOf(JetTokens.ANNOTATION_KEYWORD)
|
||||
ProtoBuf.Class.Kind.CLASS_OBJECT -> listOf(JetTokens.DEFAULT_KEYWORD)
|
||||
ProtoBuf.Class.Kind.CLASS_OBJECT -> listOf(JetTokens.COMPANION_KEYWORD)
|
||||
else -> listOf<JetModifierKeywordToken>()
|
||||
}
|
||||
return createModifierListStubForDeclaration(parent, classProto.getFlags(), relevantFlags, additionalModifiers)
|
||||
}
|
||||
|
||||
private fun doCreateClassOrObjectStub(): StubElement<out PsiElement> {
|
||||
val isDefaultObject = classKind == ProtoBuf.Class.Kind.CLASS_OBJECT
|
||||
val isCompanionObject = classKind == ProtoBuf.Class.Kind.CLASS_OBJECT
|
||||
val fqName = outerContext.containerFqName.child(classId.getRelativeClassName().shortName())
|
||||
val shortName = fqName.shortName()?.ref()
|
||||
val superTypeRefs = supertypeIds.filter {
|
||||
@@ -113,7 +113,7 @@ private class ClassClsStubBuilder(
|
||||
KotlinObjectStubImpl(
|
||||
parentStub, shortName, fqName, superTypeRefs,
|
||||
isTopLevel = !classId.isNestedClass(),
|
||||
isDefault = isDefaultObject,
|
||||
isDefault = isCompanionObject,
|
||||
isLocal = false,
|
||||
isObjectLiteral = false
|
||||
)
|
||||
@@ -164,19 +164,19 @@ private class ClassClsStubBuilder(
|
||||
|
||||
private fun createClassBodyAndMemberStubs() {
|
||||
val classBody = KotlinPlaceHolderStubImpl<JetClassBody>(classOrObjectStub, JetStubElementTypes.CLASS_BODY)
|
||||
createDefaultObjectStub(classBody)
|
||||
createCompanionObjectStub(classBody)
|
||||
createEnumEntryStubs(classBody)
|
||||
createCallableMemberStubs(classBody)
|
||||
createInnerAndNestedClasses(classBody)
|
||||
}
|
||||
|
||||
private fun createDefaultObjectStub(classBody: KotlinPlaceHolderStubImpl<JetClassBody>) {
|
||||
if (defaultObjectName == null) {
|
||||
private fun createCompanionObjectStub(classBody: KotlinPlaceHolderStubImpl<JetClassBody>) {
|
||||
if (companionObjectName == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val defaultObjectId = classId.createNestedClassId(defaultObjectName)
|
||||
createNestedClassStub(classBody, defaultObjectId)
|
||||
val companionObjectId = classId.createNestedClassId(companionObjectName)
|
||||
createNestedClassStub(classBody, companionObjectId)
|
||||
}
|
||||
|
||||
private fun createEnumEntryStubs(classBody: KotlinPlaceHolderStubImpl<JetClassBody>) {
|
||||
@@ -213,7 +213,7 @@ private class ClassClsStubBuilder(
|
||||
private fun createInnerAndNestedClasses(classBody: KotlinPlaceHolderStubImpl<JetClassBody>) {
|
||||
classProto.getNestedClassNameList().forEach { id ->
|
||||
val nestedClassName = c.nameResolver.getName(id)
|
||||
if (nestedClassName != defaultObjectName) {
|
||||
if (nestedClassName != companionObjectName) {
|
||||
val nestedClassId = classId.createNestedClassId(nestedClassName)
|
||||
createNestedClassStub(classBody, nestedClassId)
|
||||
}
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
}
|
||||
val typeConstraintListStub = KotlinPlaceHolderStubImpl<JetTypeConstraintList>(parent, JetStubElementTypes.TYPE_CONSTRAINT_LIST)
|
||||
for ((name, type) in protosForTypeConstraintList) {
|
||||
val typeConstraintStub = KotlinTypeConstraintStubImpl(typeConstraintListStub, isDefaultObjectConstraint = false)
|
||||
val typeConstraintStub = KotlinTypeConstraintStubImpl(typeConstraintListStub, isCompanionObjectConstraint = false)
|
||||
KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref())
|
||||
createTypeReferenceStub(typeConstraintStub, type)
|
||||
}
|
||||
|
||||
+4
-4
@@ -149,18 +149,18 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
||||
builder.append(" {\n")
|
||||
var firstPassed = false
|
||||
val subindent = indent + " "
|
||||
val defaultObject = descriptor.getDefaultObjectDescriptor()
|
||||
if (defaultObject != null) {
|
||||
val companionObject = descriptor.getCompanionObjectDescriptor()
|
||||
if (companionObject != null) {
|
||||
firstPassed = true
|
||||
builder.append(subindent)
|
||||
appendDescriptor(defaultObject, subindent)
|
||||
appendDescriptor(companionObject, subindent)
|
||||
}
|
||||
val allDescriptors = descriptor.secondaryConstructors + descriptor.getDefaultType().getMemberScope().getDescriptors()
|
||||
for (member in allDescriptors) {
|
||||
if (member.getContainingDeclaration() != descriptor) {
|
||||
continue
|
||||
}
|
||||
if (member == defaultObject) {
|
||||
if (member == companionObject) {
|
||||
continue
|
||||
}
|
||||
if (member is CallableMemberDescriptor
|
||||
|
||||
@@ -209,8 +209,8 @@ public object UsageTypeUtils {
|
||||
return when (descriptor) {
|
||||
is ClassifierDescriptor -> when {
|
||||
// Treat object accesses as variables to simulate the old behaviour (when variables were created for objects)
|
||||
DescriptorUtils.isNonDefaultObject(descriptor), DescriptorUtils.isEnumEntry(descriptor) -> getVariableUsageType()
|
||||
DescriptorUtils.isDefaultObject(descriptor) -> DEFAULT_OBJECT_ACCESS
|
||||
DescriptorUtils.isNonCompanionObject(descriptor), DescriptorUtils.isEnumEntry(descriptor) -> getVariableUsageType()
|
||||
DescriptorUtils.isCompanionObject(descriptor) -> COMPANION_OBJECT_ACCESS
|
||||
else -> getClassUsageType()
|
||||
}
|
||||
is PackageViewDescriptor -> {
|
||||
@@ -232,7 +232,7 @@ enum class UsageTypeEnum {
|
||||
TYPE_DEFINITION
|
||||
IS
|
||||
CLASS_OBJECT_ACCESS
|
||||
DEFAULT_OBJECT_ACCESS
|
||||
COMPANION_OBJECT_ACCESS
|
||||
EXTENSION_RECEIVER_TYPE
|
||||
SUPER_TYPE_QUALIFIER
|
||||
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ private object DeclarationKindDetector : JetVisitor<AnnotationHostKind?, Unit?>(
|
||||
override fun visitParameter(d: JetParameter, _: Unit?) = detect(d, "parameter", newLineNeeded = false)
|
||||
|
||||
override fun visitObjectDeclaration(d: JetObjectDeclaration, _: Unit?): AnnotationHostKind? {
|
||||
if (d.isDefault()) return detect(d, "default object", name = "${d.getName()} of ${d.getStrictParentOfType<JetClass>()?.getName()}")
|
||||
if (d.isCompanion()) return detect(d, "companion object", name = "${d.getName()} of ${d.getStrictParentOfType<JetClass>()?.getName()}")
|
||||
if (d.getParent() is JetObjectLiteralExpression) return null
|
||||
return detect(d, "object")
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
|
||||
if (this is JetReference) {
|
||||
return targets.any {
|
||||
it is PsiMethod && it.isConstructor() && it.getContainingClass() == unwrappedCandidate
|
||||
|| it is JetObjectDeclaration && it.isDefault() && it.getNonStrictParentOfType<JetClass>() == unwrappedCandidate
|
||||
|| it is JetObjectDeclaration && it.isCompanion() && it.getNonStrictParentOfType<JetClass>() == unwrappedCandidate
|
||||
}
|
||||
}
|
||||
if (this is PsiReferenceExpression && candidateTarget is JetObjectDeclaration && unwrappedTargets.size() == 1) {
|
||||
val referredClass = unwrappedTargets.first()
|
||||
if (referredClass is JetClass && candidateTarget in referredClass.getDefaultObjects()) {
|
||||
if (referredClass is JetClass && candidateTarget in referredClass.getCompanionObjects()) {
|
||||
val parentReference = getParent().getReference()
|
||||
if (parentReference != null) {
|
||||
return parentReference.unwrappedTargets.any {
|
||||
|
||||
+5
-5
@@ -45,15 +45,15 @@ public class KotlinReferencesSearcher extends QueryExecutorBase<PsiReference, Re
|
||||
if (lightClass != null) {
|
||||
searchNamedElement(queryParameters, lightClass, className);
|
||||
|
||||
if (element instanceof JetObjectDeclaration && ((JetObjectDeclaration) element).isDefault()) {
|
||||
PsiField fieldForDefaultObject = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() {
|
||||
if (element instanceof JetObjectDeclaration && ((JetObjectDeclaration) element).isCompanion()) {
|
||||
PsiField fieldForCompanionObject = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() {
|
||||
@Override
|
||||
public PsiField compute() {
|
||||
return LightClassUtil.getLightFieldForDefaultObject(element);
|
||||
return LightClassUtil.getLightFieldForCompanionObject(element);
|
||||
}
|
||||
});
|
||||
if (fieldForDefaultObject != null) {
|
||||
searchNamedElement(queryParameters, fieldForDefaultObject);
|
||||
if (fieldForCompanionObject != null) {
|
||||
searchNamedElement(queryParameters, fieldForCompanionObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ fun PsiNamedElement.getAccessorNames(readable: Boolean = true, writable: Boolean
|
||||
return Collections.emptyList()
|
||||
}
|
||||
|
||||
public fun PsiNamedElement.getClassNameForDefaultObject(): String? {
|
||||
public fun PsiNamedElement.getClassNameForCompanionObject(): String? {
|
||||
return if (this is JetObjectDeclaration) {
|
||||
getNonStrictParentOfType<JetClass>()?.getName()
|
||||
} else {
|
||||
@@ -105,7 +105,7 @@ public abstract class UsagesSearchHelper<T : PsiNamedElement> {
|
||||
|
||||
protected open fun makeWordList(target: UsagesSearchTarget<T>): List<String> {
|
||||
return with(target.element) {
|
||||
getName().singletonOrEmptyList() + getAccessorNames() + getClassNameForDefaultObject().singletonOrEmptyList() + getSpecialNamesToSearch()
|
||||
getName().singletonOrEmptyList() + getAccessorNames() + getClassNameForCompanionObject().singletonOrEmptyList() + getSpecialNamesToSearch()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ public fun JetType.canBeReferencedViaImport(): Boolean {
|
||||
return descriptor != null && descriptor.canBeReferencedViaImport()
|
||||
}
|
||||
|
||||
// for cases when class qualifier refers default object treats it like reference to class itself
|
||||
// for cases when class qualifier refers companion object treats it like reference to class itself
|
||||
public fun JetReferenceExpression.getImportableTargets(bindingContext: BindingContext): Collection<DeclarationDescriptor> {
|
||||
val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_DEFAULT_OBJECT, this]?.let { listOf(it) }
|
||||
val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, this]?.let { listOf(it) }
|
||||
?: bindingContext[BindingContext.REFERENCE_TARGET, this]?.let { listOf(it) }
|
||||
?: bindingContext[BindingContext.AMBIGUOUS_REFERENCE_TARGET, this]
|
||||
?: listOf()
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
||||
ShortenTypesVisitor(file, elementFilter, failedToImportDescriptors),
|
||||
ShortenThisExpressionsVisitor(file, elementFilter, failedToImportDescriptors),
|
||||
ShortenQualifiedExpressionsVisitor(file, elementFilter, failedToImportDescriptors),
|
||||
RemoveExplicitDefaultObjectReferenceVisitor(file, elementFilter, failedToImportDescriptors)
|
||||
RemoveExplicitCompanionObjectReferenceVisitor(file, elementFilter, failedToImportDescriptors)
|
||||
)
|
||||
val descriptorsToImport = visitors.flatMap { analyzeReferences(elementsToUse, it) }.toSet()
|
||||
visitors.forEach { it.shortenElements(elementsToUse) }
|
||||
@@ -409,7 +409,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
||||
}
|
||||
}
|
||||
|
||||
private class RemoveExplicitDefaultObjectReferenceVisitor(
|
||||
private class RemoveExplicitCompanionObjectReferenceVisitor(
|
||||
file: JetFile,
|
||||
elementFilter: (PsiElement) -> FilterResult,
|
||||
failedToImportDescriptors: Set<DeclarationDescriptor>
|
||||
@@ -434,7 +434,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
||||
val selectorExpression = qualifiedExpression.getSelectorExpression() ?: return false
|
||||
val selectorTarget = selectorExpression.singleTarget(bindingContext) ?: return false
|
||||
|
||||
if (receiverTarget.getDefaultObjectDescriptor() != selectorTarget) return false
|
||||
if (receiverTarget.getCompanionObjectDescriptor() != selectorTarget) return false
|
||||
|
||||
val selectorsSelector = (qualifiedExpression.getParent() as? JetDotQualifiedExpression)?.getSelectorExpression()
|
||||
if (selectorsSelector == null) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class JetDeclarationMover extends AbstractJetUpDownMover {
|
||||
|
||||
@Override
|
||||
public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) {
|
||||
if (declaration.isDefault()) {
|
||||
if (declaration.isCompanion()) {
|
||||
memberSuspects.add(declaration.getClassKeyword());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ private class JetDeclarationRemotenessWeigher(private val file: JetFile) : Looku
|
||||
}
|
||||
|
||||
val qualifiedName = qualifiedName(o)
|
||||
// Invalid name can be met for default object descriptor: Test.MyTest.A.<no name provided>.testOther
|
||||
// Invalid name can be met for companion object descriptor: Test.MyTest.A.<no name provided>.testOther
|
||||
if (qualifiedName != null && isValidJavaFqName(qualifiedName)) {
|
||||
val importPath = ImportPath(qualifiedName)
|
||||
val fqName = importPath.fqnPart()
|
||||
|
||||
@@ -231,7 +231,7 @@ class SmartCompletion(
|
||||
val typeParameter = type.type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor ?: return false
|
||||
if (!type.freeParameters.contains(typeParameter)) return false
|
||||
return KotlinBuiltIns.isAnyOrNullableAny(typeParameter.getUpperBoundsAsType())
|
||||
//TODO: check for default object constraint when they are supported
|
||||
//TODO: check for companion object constraint when they are supported
|
||||
}
|
||||
|
||||
private fun calcExpectedInfos(expression: JetExpression): Collection<ExpectedInfo>? {
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.kotlin.idea.completion.isVisible
|
||||
import org.jetbrains.kotlin.idea.completion.ExpectedInfo
|
||||
|
||||
// adds java static members, enum members and members from default object
|
||||
// adds java static members, enum members and members from companion object
|
||||
class StaticMembers(
|
||||
val bindingContext: BindingContext,
|
||||
val resolutionFacade: ResolutionFacade,
|
||||
@@ -85,16 +85,16 @@ class StaticMembers(
|
||||
|
||||
classDescriptor.getStaticScope().getAllDescriptors().forEach(::processMember)
|
||||
|
||||
val defaultObject = classDescriptor.getDefaultObjectDescriptor()
|
||||
if (defaultObject != null) {
|
||||
defaultObject.getDefaultType().getMemberScope().getAllDescriptors()
|
||||
val companionObject = classDescriptor.getCompanionObjectDescriptor()
|
||||
if (companionObject != null) {
|
||||
companionObject.getDefaultType().getMemberScope().getAllDescriptors()
|
||||
.filter { !it.isExtension }
|
||||
.forEach(::processMember)
|
||||
}
|
||||
|
||||
var members = classDescriptor.getDefaultType().getMemberScope().getAllDescriptors()
|
||||
if (classDescriptor.getKind() != ClassKind.ENUM_CLASS) {
|
||||
members = members.filter { DescriptorUtils.isNonDefaultObject(it) }
|
||||
members = members.filter { DescriptorUtils.isNonCompanionObject(it) }
|
||||
}
|
||||
members.forEach(::processMember)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class TypeInstantiationItems(
|
||||
): LookupElement? {
|
||||
var lookupElement = lookupElementFactory.createLookupElement(classifier, resolutionFacade, bindingContext, false)
|
||||
|
||||
if (DescriptorUtils.isNonDefaultObject(classifier)) {
|
||||
if (DescriptorUtils.isNonCompanionObject(classifier)) {
|
||||
return lookupElement.addTail(tail)
|
||||
}
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult
|
||||
element is JetClassInitializer -> {
|
||||
val parent = getElementToCalculateClassName(element.getParent())
|
||||
// Class-object initializer
|
||||
if (parent is JetObjectDeclaration && parent.isDefault()) {
|
||||
if (parent is JetObjectDeclaration && parent.isCompanion()) {
|
||||
return PositionedElement(getInternalClassNameForElement(parent.getParent(), typeMapper, file, isInLibrary).className, parent)
|
||||
}
|
||||
return getInternalClassNameForElement(element, typeMapper, file, isInLibrary)
|
||||
|
||||
@@ -44,7 +44,7 @@ public object JetUsageTypeProvider : UsageTypeProviderEx {
|
||||
TYPE_DEFINITION -> JetUsageTypes.TYPE_DEFINITION
|
||||
IS -> JetUsageTypes.IS
|
||||
CLASS_OBJECT_ACCESS -> JetUsageTypes.CLASS_OBJECT_ACCESS
|
||||
DEFAULT_OBJECT_ACCESS -> JetUsageTypes.DEFAULT_OBJECT_ACCESS
|
||||
COMPANION_OBJECT_ACCESS -> JetUsageTypes.COMPANION_OBJECT_ACCESS
|
||||
EXTENSION_RECEIVER_TYPE -> JetUsageTypes.EXTENSION_RECEIVER_TYPE
|
||||
SUPER_TYPE_QUALIFIER -> JetUsageTypes.SUPER_TYPE_QUALIFIER
|
||||
|
||||
@@ -85,7 +85,7 @@ object JetUsageTypes {
|
||||
val TYPE_DEFINITION = UsageType(JetBundle.message("usageType.type.definition"))
|
||||
val IS = UsageType(JetBundle.message("usageType.is"))
|
||||
val CLASS_OBJECT_ACCESS = UsageType(JetBundle.message("usageType.class.object"))
|
||||
val DEFAULT_OBJECT_ACCESS = UsageType(JetBundle.message("usageType.default.object"))
|
||||
val COMPANION_OBJECT_ACCESS = UsageType(JetBundle.message("usageType.companion.object"))
|
||||
val EXTENSION_RECEIVER_TYPE = UsageType(JetBundle.message("usageType.extension.receiver.type"))
|
||||
val SUPER_TYPE_QUALIFIER = UsageType(JetBundle.message("usageType.super.type.qualifier"))
|
||||
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
|
||||
if (descriptor == null) return null;
|
||||
|
||||
if (element instanceof JetClassOrObject) {
|
||||
if (element instanceof JetObjectDeclaration && ((JetObjectDeclaration) element).isDefault()) {
|
||||
if (element instanceof JetObjectDeclaration && ((JetObjectDeclaration) element).isCompanion()) {
|
||||
descriptor = descriptor.getContainingDeclaration();
|
||||
if (!(descriptor instanceof ClassDescriptor)) return null;
|
||||
|
||||
|
||||
@@ -183,8 +183,8 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
}
|
||||
|
||||
|
||||
private fun JetElement.classForDefaultObjectReference(): ClassDescriptor? {
|
||||
return analyze()[BindingContext.SHORT_REFERENCE_TO_DEFAULT_OBJECT, this as? JetReferenceExpression]
|
||||
private fun JetElement.classForCompanionObjectReference(): ClassDescriptor? {
|
||||
return analyze()[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, this as? JetReferenceExpression]
|
||||
}
|
||||
|
||||
override fun visitJetElement(element: JetElement) {
|
||||
@@ -192,8 +192,8 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
if (reference is JetReference) {
|
||||
val referencedName = (element as? JetNameReferenceExpression)?.getReferencedNameAsName() //TODO: other types of references
|
||||
|
||||
//class qualifiers that refer to default objects should be considered (containing) class references
|
||||
val targets = element.classForDefaultObjectReference()?.let { listOf(it) }
|
||||
//class qualifiers that refer to companion objects should be considered (containing) class references
|
||||
val targets = element.classForCompanionObjectReference()?.let { listOf(it) }
|
||||
?: reference.resolveToDescriptors()
|
||||
for (target in targets) {
|
||||
if (!target.canBeReferencedViaImport()) continue
|
||||
@@ -223,7 +223,7 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
private fun isAccessibleAsMember(target: DeclarationDescriptor, place: JetElement): Boolean {
|
||||
val container = target.getContainingDeclaration()
|
||||
if (container !is ClassDescriptor) return false
|
||||
val scope = if (DescriptorUtils.isDefaultObject(container))
|
||||
val scope = if (DescriptorUtils.isCompanionObject(container))
|
||||
container.getContainingDeclaration() as? ClassDescriptor ?: return false
|
||||
else
|
||||
container
|
||||
|
||||
@@ -101,8 +101,8 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
if (!ProjectRootsUtil.isInProjectSource(declaration)) return
|
||||
|
||||
// Simple PSI-based checks
|
||||
val isDefaultObject = declaration is JetObjectDeclaration && declaration.isDefault()
|
||||
if (declaration.getNameIdentifier() == null && !isDefaultObject) return
|
||||
val isCompanionObject = declaration is JetObjectDeclaration && declaration.isCompanion()
|
||||
if (declaration.getNameIdentifier() == null && !isCompanionObject) return
|
||||
if (declaration is JetEnumEntry) return
|
||||
if (declaration.hasModifier(JetTokens.OVERRIDE_KEYWORD)) return
|
||||
if (declaration is JetProperty && declaration.isLocal()) return
|
||||
@@ -118,7 +118,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
if (hasNonTrivialUsages(declaration)) return
|
||||
if (declaration is JetClassOrObject && classOrObjectHasTextUsages(declaration)) return
|
||||
|
||||
val (inspectionTarget, textRange) = if (isDefaultObject && declaration.getNameIdentifier() == null) {
|
||||
val (inspectionTarget, textRange) = if (isCompanionObject && declaration.getNameIdentifier() == null) {
|
||||
val objectKeyword = (declaration as JetObjectDeclaration).getObjectKeyword()
|
||||
Pair(declaration, TextRange(0, objectKeyword.getStartOffsetInParent() + objectKeyword.getTextLength()))
|
||||
} else {
|
||||
@@ -167,7 +167,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
if (useScope is GlobalSearchScope) {
|
||||
var zeroOccurrences = true
|
||||
|
||||
for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForDefaultObject().singletonOrEmptyList()) {
|
||||
for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) {
|
||||
when (psiSearchHelper.isCheapEnoughToSearch(name, useScope, null, null)) {
|
||||
ZERO_OCCURRENCES -> {} // go on, check other names
|
||||
FEW_OCCURRENCES -> zeroOccurrences = false
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
public class ClassObjectToDefaultObjectFix(private val elem: JetObjectDeclaration) : JetIntentionAction<JetObjectDeclaration>(elem) {
|
||||
public class ClassObjectToCompanionObjectFix(private val elem: JetObjectDeclaration) : JetIntentionAction<JetObjectDeclaration>(elem) {
|
||||
override fun getText(): String = JetBundle.message("migrate.class.object.to.default")
|
||||
|
||||
override fun getFamilyName(): String = JetBundle.message("migrate.class.object.to.default.family")
|
||||
@@ -35,18 +35,18 @@ public class ClassObjectToDefaultObjectFix(private val elem: JetObjectDeclaratio
|
||||
|
||||
class object Factory : JetSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic) =
|
||||
(diagnostic.getPsiElement() as? JetObjectDeclaration)?.let { ClassObjectToDefaultObjectFix(it) }
|
||||
(diagnostic.getPsiElement() as? JetObjectDeclaration)?.let { ClassObjectToCompanionObjectFix(it) }
|
||||
|
||||
fun classKeywordToDefaultModifier(objectDeclaration: JetObjectDeclaration) {
|
||||
objectDeclaration.getClassKeyword()?.delete()
|
||||
if (!objectDeclaration.hasModifier(JetTokens.DEFAULT_KEYWORD)) {
|
||||
objectDeclaration.addModifier(JetTokens.DEFAULT_KEYWORD)
|
||||
if (!objectDeclaration.hasModifier(JetTokens.COMPANION_KEYWORD)) {
|
||||
objectDeclaration.addModifier(JetTokens.COMPANION_KEYWORD)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ClassObjectToDefaultObjectInWholeProjectFix(private val elem: JetObjectDeclaration) : JetIntentionAction<JetObjectDeclaration>(elem) {
|
||||
public class ClassObjectToCompanionObjectInWholeProjectFix(private val elem: JetObjectDeclaration) : JetIntentionAction<JetObjectDeclaration>(elem) {
|
||||
override fun getText(): String = JetBundle.message("migrate.class.object.to.default.in.whole.project")
|
||||
|
||||
override fun getFamilyName(): String = JetBundle.message("migrate.class.object.to.default.in.whole.project.family")
|
||||
@@ -54,20 +54,20 @@ public class ClassObjectToDefaultObjectInWholeProjectFix(private val elem: JetOb
|
||||
override fun invoke(project: Project, editor: Editor, file: JetFile) {
|
||||
val files = PluginJetFilesProvider.allFilesInProject(file.getProject())
|
||||
|
||||
files.forEach { it.accept(ClassObjectToDefaultObjectVisitor) }
|
||||
files.forEach { it.accept(ClassObjectToCompanionObjectVisitor) }
|
||||
}
|
||||
|
||||
private object ClassObjectToDefaultObjectVisitor : JetTreeVisitorVoid() {
|
||||
private object ClassObjectToCompanionObjectVisitor : JetTreeVisitorVoid() {
|
||||
override fun visitObjectDeclaration(objectDeclaration: JetObjectDeclaration) {
|
||||
objectDeclaration.acceptChildren(this)
|
||||
if (objectDeclaration.getClassKeyword() != null) {
|
||||
ClassObjectToDefaultObjectFix.classKeywordToDefaultModifier(objectDeclaration)
|
||||
ClassObjectToCompanionObjectFix.classKeywordToDefaultModifier(objectDeclaration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class object Factory : JetSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic) =
|
||||
(diagnostic.getPsiElement() as? JetObjectDeclaration)?.let { ClassObjectToDefaultObjectInWholeProjectFix(it) }
|
||||
(diagnostic.getPsiElement() as? JetObjectDeclaration)?.let { ClassObjectToCompanionObjectInWholeProjectFix(it) }
|
||||
}
|
||||
}
|
||||
@@ -296,8 +296,8 @@ public class QuickFixRegistrar {
|
||||
QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromReferenceExpressionActionFactory.INSTANCE$);
|
||||
QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromCallWithConstructorCalleeActionFactory.INSTANCE$);
|
||||
|
||||
QuickFixes.factories.put(DEPRECATED_CLASS_OBJECT_SYNTAX, ClassObjectToDefaultObjectFix.Factory);
|
||||
QuickFixes.factories.put(DEPRECATED_CLASS_OBJECT_SYNTAX, ClassObjectToDefaultObjectInWholeProjectFix.Factory);
|
||||
QuickFixes.factories.put(DEPRECATED_CLASS_OBJECT_SYNTAX, ClassObjectToCompanionObjectFix.Factory);
|
||||
QuickFixes.factories.put(DEPRECATED_CLASS_OBJECT_SYNTAX, ClassObjectToCompanionObjectInWholeProjectFix.Factory);
|
||||
QuickFixes.factories.put(INIT_KEYWORD_BEFORE_CLASS_INITIALIZER_EXPECTED, AddInitKeywordFix.OBJECT$);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class CreateCallableFromUsageFix(
|
||||
val receiverInfo = callableInfo.receiverTypeInfo
|
||||
|
||||
if (receiverInfo is TypeInfo.Empty) return !isExtension
|
||||
// TODO: Remove after default object extensions are supported
|
||||
// TODO: Remove after companion object extensions are supported
|
||||
if (isExtension && receiverInfo.staticContextRequired) return false
|
||||
|
||||
val file = element.getContainingFile() as JetFile
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ data class ExtractionData(
|
||||
if (parent is JetQualifiedExpression && parent.getSelectorExpression() == ref) {
|
||||
val receiverDescriptor =
|
||||
(originalResolveResult.resolvedCall?.getDispatchReceiver() as? ThisReceiver)?.getDeclarationDescriptor()
|
||||
if (!DescriptorUtils.isDefaultObject(receiverDescriptor) && parent.getReceiverExpression() !is JetSuperExpression) continue
|
||||
if (!DescriptorUtils.isCompanionObject(receiverDescriptor) && parent.getReceiverExpression() !is JetSuperExpression) continue
|
||||
}
|
||||
// Skip P in type references like 'P.Q'
|
||||
if (parent is JetUserType && (parent.getParent() as? JetUserType)?.getQualifier() == parent) continue
|
||||
|
||||
@@ -330,8 +330,8 @@ public fun chooseContainerElement<T>(
|
||||
if (this is JetPropertyAccessor) {
|
||||
return (getParent() as JetProperty).renderName() + if (isGetter()) ".get" else ".set"
|
||||
}
|
||||
if (this is JetObjectDeclaration && this.isDefault()) {
|
||||
return "Default object of ${getStrictParentOfType<JetClassOrObject>()?.renderName() ?: "<anonymous>"}"
|
||||
if (this is JetObjectDeclaration && this.isCompanion()) {
|
||||
return "Companion object of ${getStrictParentOfType<JetClassOrObject>()?.renderName() ?: "<anonymous>"}"
|
||||
}
|
||||
return (this as? PsiNamedElement)?.getName() ?: "<anonymous>"
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
@@ -81,7 +80,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
if (container instanceof JetFile) return PackageClassUtils.getPackageClassFqName(((JetFile) container).getPackageFqName());
|
||||
if (container instanceof JetClassOrObject) {
|
||||
JetClassOrObject classOrObject = (JetClassOrObject) container;
|
||||
if (classOrObject instanceof JetObjectDeclaration && ((JetObjectDeclaration) classOrObject).isDefault()) {
|
||||
if (classOrObject instanceof JetObjectDeclaration && ((JetObjectDeclaration) classOrObject).isCompanion()) {
|
||||
classOrObject = PsiTreeUtil.getParentOfType(classOrObject, JetClass.class);
|
||||
}
|
||||
return classOrObject != null ? classOrObject.getFqName() : null;
|
||||
@@ -120,7 +119,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
currentElement = PsiTreeUtil.getParentOfType((PsiElement) currentElement, JetClassOrObject.class, JetFile.class)) {
|
||||
JetDeclarationContainer entryPointContainer = currentElement;
|
||||
if (entryPointContainer instanceof JetClass) {
|
||||
entryPointContainer = singleOrNull(((JetClass) currentElement).getDefaultObjects());
|
||||
entryPointContainer = singleOrNull(((JetClass) currentElement).getCompanionObjects());
|
||||
}
|
||||
if (entryPointContainer != null && mainFunctionDetector.hasMain(entryPointContainer.getDeclarations())) return entryPointContainer;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dependency
|
||||
|
||||
class Date {
|
||||
default object {
|
||||
companion object {
|
||||
val VALUE = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.*
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
default object : Factory<HTML> {
|
||||
companion object : Factory<HTML> {
|
||||
override fun create() = HTML()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.util.*
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
default object : Factory<Head> {
|
||||
companion object : Factory<Head> {
|
||||
override fun create() = Head()
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.*
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body") {
|
||||
default object : Factory<Body> {
|
||||
companion object : Factory<Body> {
|
||||
override fun create() = Body()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
enum class E {
|
||||
ENTRY
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun foo(): E = ENTRY
|
||||
fun bar(): Array<E> = values()
|
||||
fun baz(): E = valueOf("ENTRY")
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package Jet86
|
||||
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
val x = 1
|
||||
}
|
||||
<error descr="[MANY_DEFAULT_OBJECTS] Only one default object is allowed per class">default</error> object Another { // error
|
||||
<error descr="[MANY_COMPANION_OBJECTS] Only one companion object is allowed per class">companion</error> object Another { // error
|
||||
val x = 1
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class B() {
|
||||
}
|
||||
|
||||
object b {
|
||||
<error descr="[DEFAULT_OBJECT_NOT_ALLOWED] A default object is not allowed here">default</error> object {
|
||||
<error descr="[COMPANION_OBJECT_NOT_ALLOWED] A companion object is not allowed here">companion</error> object {
|
||||
val x = 1
|
||||
}
|
||||
// error
|
||||
|
||||
@@ -11,7 +11,7 @@ class B {
|
||||
}
|
||||
|
||||
class C {
|
||||
default <warning textAttributesKey="DEPRECATED_ATTRIBUTES">class object G</warning> {
|
||||
companion <warning textAttributesKey="DEPRECATED_ATTRIBUTES">class object G</warning> {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ trait B {
|
||||
class C() : A(), B
|
||||
|
||||
class D() {
|
||||
default object : A(), B {}
|
||||
companion object : A(), B {}
|
||||
}
|
||||
|
||||
class Test1<T : A>()
|
||||
|
||||
@@ -3,7 +3,7 @@ import kotlin.platform.platformStatic
|
||||
platformStatic
|
||||
class <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">A</error> {
|
||||
platformStatic
|
||||
default <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">object</error> {
|
||||
companion <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">object</error> {
|
||||
platformStatic fun a1() {
|
||||
|
||||
}
|
||||
@@ -18,21 +18,21 @@ class <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not su
|
||||
|
||||
fun test() {
|
||||
val <warning descr="[UNUSED_VARIABLE] Variable 's' is never used">s</warning> = object {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and default objects of classes can be annotated with 'platformStatic'">platformStatic fun a3()</error> {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'">platformStatic fun a3()</error> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and default objects of classes can be annotated with 'platformStatic'">platformStatic fun a4()</error> {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'">platformStatic fun a4()</error> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
platformStatic
|
||||
trait <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">B</error> {
|
||||
default object {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and default objects of classes can be annotated with 'platformStatic'">platformStatic fun a1()</error> {
|
||||
companion object {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'">platformStatic fun a1()</error> {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -45,13 +45,13 @@ trait <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not su
|
||||
|
||||
fun test() {
|
||||
val <warning descr="[UNUSED_VARIABLE] Variable 's' is never used">s</warning> = object {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and default objects of classes can be annotated with 'platformStatic'">platformStatic fun a3()</error> {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'">platformStatic fun a3()</error> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and default objects of classes can be annotated with 'platformStatic'">platformStatic fun a4()</error> {
|
||||
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'">platformStatic fun a4()</error> {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
class B {
|
||||
default object <error>A</error> {
|
||||
companion object <error>A</error> {
|
||||
}
|
||||
|
||||
val <error>A</error> = this
|
||||
}
|
||||
|
||||
class C {
|
||||
default <error>object A</error> {
|
||||
companion <error>object A</error> {
|
||||
<error>val A</error> = this
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class D {
|
||||
default <error>object A</error> {
|
||||
companion <error>object A</error> {
|
||||
<error>val `OBJECT$`</error> = this
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
default object {
|
||||
companion object {
|
||||
<error>val x</error> = 1
|
||||
<error>fun getX()</error> = 1
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ trait Bar {
|
||||
}
|
||||
|
||||
class A {
|
||||
default object : Bar
|
||||
companion object : Bar
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -4,7 +4,7 @@ trait <lineMarker></lineMarker>TestTrait {
|
||||
|
||||
class A {
|
||||
class B {
|
||||
default object : TestTrait { // TODO: No line marker
|
||||
companion object : TestTrait { // TODO: No line marker
|
||||
override fun <lineMarker descr="Implements function in 'TestTrait'"></lineMarker>test() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package p
|
||||
class B
|
||||
|
||||
class R {
|
||||
default object {
|
||||
companion object {
|
||||
fun B.f() {
|
||||
this.<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EXIST: { itemText: "f", tailText: "() for B in R.Default" }
|
||||
// EXIST: { itemText: "f", tailText: "() for B in R.Companion" }
|
||||
|
||||
@@ -4,7 +4,7 @@ class C {
|
||||
inner class InnerClass
|
||||
object AnObject
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
val classObjectField = 0
|
||||
class ClassObjectClass
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class C {
|
||||
}
|
||||
}
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun fromClassObject(){}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ class A {
|
||||
class Nested
|
||||
inner class Inner
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
class Nested2
|
||||
val c: Int = 1
|
||||
object Obj2
|
||||
@@ -19,7 +19,7 @@ fun some() {
|
||||
}
|
||||
|
||||
// EXIST: Nested
|
||||
// EXIST: Default
|
||||
// EXIST: Companion
|
||||
// EXIST: c
|
||||
// EXIST: foo
|
||||
// EXIST: Obj
|
||||
|
||||
@@ -2,7 +2,7 @@ class A {
|
||||
class Nested
|
||||
inner class Inner
|
||||
|
||||
default object Named {
|
||||
companion object Named {
|
||||
class Nested2
|
||||
val c: Int = 1
|
||||
object Obj2
|
||||
|
||||
@@ -2,7 +2,7 @@ class A {
|
||||
class Nested
|
||||
inner class Inner
|
||||
|
||||
default object Named {
|
||||
companion object Named {
|
||||
class Nested2
|
||||
val c: Int = 1
|
||||
object Obj2
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Test.MyTest
|
||||
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
public fun testOther() {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Some {
|
||||
default object {
|
||||
companion object {
|
||||
val coProp = 12
|
||||
|
||||
fun coFun = 12
|
||||
|
||||
@@ -2,11 +2,11 @@ package foo
|
||||
|
||||
class A {
|
||||
class B {
|
||||
default object
|
||||
companion object
|
||||
}
|
||||
}
|
||||
|
||||
fun A.B.Default.foo() {}
|
||||
fun A.B.Companion.foo() {}
|
||||
|
||||
fun some() {
|
||||
A.B.<caret>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C {
|
||||
fun String.memberExtForString(){}
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun foo() {
|
||||
"".<caret>
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ fun some() {
|
||||
}
|
||||
|
||||
class Some {
|
||||
default object {
|
||||
companion object {
|
||||
object NamedObjectInClassObject
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class Test {
|
||||
default object {
|
||||
companion object {
|
||||
class Some
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Test.Default.S<caret>
|
||||
Test.Companion.S<caret>
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
class Test {
|
||||
default object {
|
||||
companion object {
|
||||
class Some
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Test.Default.Some
|
||||
Test.Companion.Some
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package a
|
||||
|
||||
class Test {
|
||||
default object {
|
||||
companion object {
|
||||
class Some
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
a.Test.Default.S<caret>
|
||||
a.Test.Companion.S<caret>
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package a
|
||||
|
||||
class Test {
|
||||
default object {
|
||||
companion object {
|
||||
class Some
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
a.Test.Default.Some<caret>
|
||||
a.Test.Companion.Some<caret>
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package Test.MyTest
|
||||
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
public fun testOther(a: Int) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Test.MyTest
|
||||
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
public fun testOther(a: Int) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Test.MyTest
|
||||
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
public fun testOther(a: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Test.MyTest
|
||||
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
public fun testOther(a: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AClass {
|
||||
default object {}
|
||||
companion object {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AClass {
|
||||
default object {}
|
||||
companion object {}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package pack
|
||||
class KtClass {
|
||||
fun foo(){}
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun staticFoo(){}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
class Inner {}
|
||||
}
|
||||
}
|
||||
|
||||
val v: A.Default.Inner = <caret>
|
||||
val v: A.Companion.Inner = <caret>
|
||||
|
||||
// ELEMENT: Inner
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class A {
|
||||
default object {
|
||||
companion object {
|
||||
class Inner {}
|
||||
}
|
||||
}
|
||||
|
||||
val v: A.Default.Inner = A.Default.Inner()
|
||||
val v: A.Companion.Inner = A.Companion.Inner()
|
||||
|
||||
// ELEMENT: Inner
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package `package`
|
||||
|
||||
class `class` {
|
||||
default object {
|
||||
companion object {
|
||||
val `val` = `class`()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package `package`
|
||||
|
||||
class `class` {
|
||||
default object {
|
||||
companion object {
|
||||
val `val` = `class`()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(p: Int): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(p: Int): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(p: () -> Unit): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(p: () -> Unit): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(p: (Int, String) -> Unit): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(p: (Int, String) -> Unit): K = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
default object {
|
||||
companion object {
|
||||
fun f1(): C = C()
|
||||
fun f2(): C = C()
|
||||
fun f3(): C? = C()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
default object {
|
||||
companion object {
|
||||
fun f1(): C = C()
|
||||
fun f2(): C = C()
|
||||
fun f3(): C? = C()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
default object {
|
||||
companion object {
|
||||
fun f1(): C = C()
|
||||
fun f2(): C = C()
|
||||
fun f3(): C? = C()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
default object {
|
||||
companion object {
|
||||
fun f1(): C = C()
|
||||
fun f2(): C = C()
|
||||
fun f3(): C? = C()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(): K? = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
fun bar(): K? = K()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
public class Testing {
|
||||
public static void test() {
|
||||
mockLib.foo.LibClass.Default.<caret>
|
||||
mockLib.foo.LibClass.Companion.<caret>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ public class Testing {
|
||||
}
|
||||
}
|
||||
|
||||
// EXIST: Default
|
||||
// EXIST: Companion
|
||||
// EXIST: OBJECT$
|
||||
@@ -1,6 +1,6 @@
|
||||
public class Testing {
|
||||
public static void test() {
|
||||
mockLib.foo.LibClass.Default.NestedObject.<caret>
|
||||
mockLib.foo.LibClass.Companion.NestedObject.<caret>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public class Testing {
|
||||
public static void test(mockLib.foo.F.Default.F.Default.<caret>) {
|
||||
public static void test(mockLib.foo.F.Companion.F.Companion.<caret>) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ public class LibClass {
|
||||
public fun foo() {
|
||||
}
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun classObjectFun() {
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public fun String.topLevelExtFunction(): String = ""
|
||||
public var topLevelVar: String = ""
|
||||
|
||||
class F() {
|
||||
default object {
|
||||
companion object {
|
||||
class F {
|
||||
default object {
|
||||
companion object {
|
||||
object F {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
val foo: K = K()
|
||||
fun bar(): K = K()
|
||||
val x: String = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class K {
|
||||
default object {
|
||||
companion object {
|
||||
val foo: K = K()
|
||||
fun bar(): K = K()
|
||||
val x: String = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package sample
|
||||
|
||||
class Kool {
|
||||
default object {
|
||||
companion object {
|
||||
val foo: Kool = Kool()
|
||||
fun bar(): Kool = Kool()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
default object {
|
||||
companion object {
|
||||
fun foo(): C {
|
||||
return <caret>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class X {
|
||||
default object {
|
||||
companion object {
|
||||
fun String.f(): X = X()
|
||||
fun g(): X = X()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class C {
|
||||
listOf("a").filter(<caret>)
|
||||
}
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun staticFoo(s: String): Boolean = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C<T> {
|
||||
default object {
|
||||
companion object {
|
||||
fun<T> create(t: T): C<T>{}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Name {
|
||||
default object {
|
||||
companion object {
|
||||
fun create(): Name = Name()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var global: C = C()
|
||||
|
||||
abstract class C {
|
||||
default object {
|
||||
companion object {
|
||||
val INSTANCE = C()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ var nullableX: C? = null
|
||||
var nullableFoo: C? = null
|
||||
|
||||
abstract class C {
|
||||
default object {
|
||||
companion object {
|
||||
val INSTANCE_X = C()
|
||||
val INSTANCE_FOO = C()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Outer {
|
||||
}
|
||||
|
||||
class ClassObject {
|
||||
default object {
|
||||
companion object {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ fun g(t: T): Int {
|
||||
B.f()
|
||||
A
|
||||
B
|
||||
A.Default
|
||||
B.Default
|
||||
A.Companion
|
||||
B.Companion
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package a
|
||||
trait T
|
||||
|
||||
class A {
|
||||
default object: T {
|
||||
companion object: T {
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
default object {
|
||||
companion object {
|
||||
fun f(): Int
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@ class B {
|
||||
B.f()
|
||||
A
|
||||
B
|
||||
A.Default
|
||||
B.Default
|
||||
A.Companion
|
||||
B.Companion
|
||||
}</selection>
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class A {
|
||||
f()
|
||||
}</selection>
|
||||
|
||||
default object {
|
||||
companion object {
|
||||
fun f()
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package to
|
||||
|
||||
import a.Outer
|
||||
|
||||
fun f(n: Outer.Default.Nested, e: Outer.Default.NestedEnum, o: Outer.Default.NestedObj, t: Outer.Default.NestedTrait, a: Outer.Default.NestedAnnotation) {
|
||||
fun f(n: Outer.Companion.Nested, e: Outer.Companion.NestedEnum, o: Outer.Companion.NestedObj, t: Outer.Companion.NestedTrait, a: Outer.Companion.NestedAnnotation) {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user