Get rid of 'class object' usages in code and builtins

Replace some comments and library usages as well
This commit is contained in:
Pavel V. Talanov
2015-03-25 15:09:18 +03:00
parent 67f84c0f76
commit ed218c473a
157 changed files with 187 additions and 187 deletions
@@ -76,7 +76,7 @@ class PlatformStaticGenerator(
)
}
class object {
companion object {
[platformStatic]
public fun createStaticFunctionDescriptor(descriptor: FunctionDescriptor): FunctionDescriptor {
val memberDescriptor = if (descriptor is PropertyAccessorDescriptor) descriptor.getCorrespondingProperty() else descriptor
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.JetNamedFunction
data public class SourceInfo(val source: String, val pathOrCleanFQN: String, val linesInFile: Int) {
class object {
companion object {
fun createInfo(element: JetElement?, internalClassName: String): SourceInfo {
assert(element != null) { "Couldn't create source mapper for null element " + internalClassName }
val lineNumbers = CodegenUtil.getLineNumberForElement(element!!.getContainingFile(), true)
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.*
public trait ExpressionCodegenExtension {
class object : ProjectExtensionDescriptor<ExpressionCodegenExtension>("org.jetbrains.kotlin.expressionCodegenExtension", javaClass<ExpressionCodegenExtension>())
companion object : ProjectExtensionDescriptor<ExpressionCodegenExtension>("org.jetbrains.kotlin.expressionCodegenExtension", javaClass<ExpressionCodegenExtension>())
public class Context(
public val typeMapper: JetTypeMapper,
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParameterMappings?) {
class object {
companion object {
public val NEW_ARRAY_MARKER_METHOD_NAME: String = "reifyNewArray"
public val CHECKCAST_MARKER_METHOD_NAME: String = "reifyCheckcast"
public val INSTANCEOF_MARKER_METHOD_NAME: String = "reifyInstanceof"
@@ -143,7 +143,7 @@ trait SourceMapper {
parent?.visitOrigin()
}
class object {
companion object {
fun flushToClassBuilder(mapper: SourceMapper, v: ClassBuilder) {
for (fileMapping in mapper.resultMappings) {
@@ -253,7 +253,7 @@ class SMAP(val fileMappings: List<FileMapping>) {
sourceInfo = SourceInfo(default.name, default.path, defaultMapping.source + defaultMapping.range - 1)
}
class object {
companion object {
val FILE_SECTION = "*F"
val LINE_SECTION = "*L"
@@ -30,7 +30,7 @@ import javax.inject.Inject
public class TraceBasedErrorReporter : ErrorReporter {
class object {
companion object {
private val LOG = Logger.getInstance(javaClass<TraceBasedErrorReporter>())
public val ABI_VERSION_ERRORS: WritableSlice<String, AbiVersionErrorData> = Slices.createCollectiveSlice()
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.name.Name
abstract class JavaAnnotationArgumentImpl(
override val name: Name?
) : JavaAnnotationArgument {
class object Factory {
companion object Factory {
fun create(argument: PsiAnnotationMemberValue, name: Name?): JavaAnnotationArgument {
val value = JavaPsiFacade.getInstance(argument.getProject()).getConstantEvaluationHelper().computeConstantExpression(argument)
if (value is Enum<*>) {
@@ -49,7 +49,7 @@ public class VirtualFileKotlinClass private(
override fun hashCode() = file.hashCode()
override fun toString() = "${javaClass.getSimpleName()}: $file"
class object Factory {
companion object Factory {
private val LOG = Logger.getInstance(javaClass<VirtualFileKotlinClass>())
deprecated("Use KotlinBinaryClassCache")
@@ -47,7 +47,7 @@ public class JvmDeclarationOrigin(
public val element: PsiElement?,
public val descriptor: DeclarationDescriptor?
) {
class object {
companion object {
public val NO_ORIGIN: JvmDeclarationOrigin = JvmDeclarationOrigin(OTHER, null, null)
}
}
@@ -39,7 +39,7 @@ public data open class AnalysisResult protected (
private class Error(bindingContext: BindingContext, val exception: Throwable) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule())
class object {
companion object {
public val EMPTY: AnalysisResult = success(BindingContext.EMPTY, ErrorUtils.getErrorModule())
platformStatic public fun success(bindingContext: BindingContext, module: ModuleDescriptor): AnalysisResult {
@@ -75,7 +75,7 @@ public class ReadValueInstruction private (
override fun createCopy(): InstructionImpl =
ReadValueInstruction(element, lexicalScope, target, receiverValues, outputValue)
class object Factory {
companion object Factory {
public fun create (
element: JetElement,
lexicalScope: LexicalScope,
@@ -79,7 +79,7 @@ public class CallInstruction private(
override fun toString() =
renderInstruction("call", "${render(element)}, ${resolvedCall.getResultingDescriptor()!!.getName()}")
class object Factory {
companion object Factory {
fun create (
element: JetElement,
lexicalScope: LexicalScope,
@@ -115,7 +115,7 @@ public class MagicInstruction(
override fun toString() = renderInstruction("magic[$kind]", render(element))
class object Factory {
companion object Factory {
fun create(
element: JetElement,
valueElement: JetElement?,
@@ -165,7 +165,7 @@ class MergeInstruction private(
override fun toString() = renderInstruction("merge", render(element))
class object Factory {
companion object Factory {
fun create(
element: JetElement,
lexicalScope: LexicalScope,
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.psi.JetFile
public trait ExternalDeclarationsProvider {
class object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>(
companion object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>(
"org.jetbrains.kotlin.externalDeclarationsProvider",
javaClass<ExternalDeclarationsProvider>()
)
@@ -29,7 +29,7 @@ import kotlin.platform.*
* Parses the contents of a Markdown link in KDoc. Uses the standard Kotlin lexer.
*/
class KDocLinkParser(): PsiParser {
class object {
companion object {
platformStatic public fun parseMarkdownLink(root: IElementType, chameleon: ASTNode): ASTNode {
val parentElement = chameleon.getTreeParent().getPsi()
val project = parentElement.getProject()
@@ -147,7 +147,7 @@ public abstract class JetCodeFragment(
}
}
class object {
companion object {
public val IMPORT_SEPARATOR: String = ","
public val RUNTIME_TYPE_EVALUATOR: Key<Function1<JetExpression, JetType?>> = Key.create("RUNTIME_TYPE_EVALUATOR")
}
@@ -50,7 +50,7 @@ abstract class JetSimpleNameExpressionImpl(node: ASTNode) : JetExpressionImpl(no
override fun getReferencedName() = getReferencedNameImpl()
//NOTE: an unfortunate way to share an implementation between stubbed and not stubbed tree
class object Helper {
companion object Helper {
fun JetSimpleNameExpression.getReferencedNameElementTypeImpl(): IElementType {
return this.getReferencedNameElement().getNode()!!.getElementType()!!
@@ -73,7 +73,7 @@ public open class KotlinStubBaseImpl<T : JetElementImplStub<*>>(parent: StubElem
return methodName
}
class object {
companion object {
private val LOGGER: Logger = Logger.getInstance(javaClass<KotlinStubBaseImpl<JetElementImplStub<*>>>())
private val BASE_STUB_INTERFACES = listOf(javaClass<KotlinStubWithFqName<*>>(), javaClass<KotlinClassOrObjectStub<*>>(), javaClass<NamedStub<*>>())
@@ -25,7 +25,7 @@ public trait CodeAnalyzerInitializer {
public fun initialize(trace: BindingTrace, module: ModuleDescriptor, codeAnalyzer: KotlinCodeAnalyzer?)
public fun createTrace(): BindingTrace
class object {
companion object {
public fun getInstance(project: Project): CodeAnalyzerInitializer =
ServiceManager.getService<CodeAnalyzerInitializer>(project, javaClass<CodeAnalyzerInitializer>())!!
}
@@ -28,7 +28,7 @@ public class CompositeBindingContext private (
private val delegates: List<BindingContext>
) : BindingContext {
class object {
companion object {
public fun create(delegates: List<BindingContext>): BindingContext {
if (delegates.isEmpty()) return BindingContext.EMPTY
if (delegates.size() == 1) return delegates.first()
@@ -25,7 +25,7 @@ public open class StatementFilter {
public open val filter: ((JetElement) -> Boolean)?
get() = null
class object {
companion object {
public val NONE: StatementFilter = StatementFilter()
}
}
@@ -310,7 +310,7 @@ public class TypeResolver(
return classifierDescriptor
}
class object {
companion object {
[platformStatic]
public fun resolveProjectionKind(projectionKind: JetProjectionKind): Variance {
return when (projectionKind) {
@@ -79,7 +79,7 @@ class VarianceChecker(private val trace: BindingTrace) {
val occurrencePosition: Variance
)
class object {
companion object {
platformStatic fun recordPrivateToThisIfNeeded(trace: BindingTrace, descriptor: CallableMemberDescriptor) {
if (isIrrelevant(descriptor) || descriptor.getVisibility() != Visibilities.PRIVATE) return
@@ -47,8 +47,8 @@ public class CallableDescriptorCollectors<D : CallableDescriptor>(val collectors
Iterable<CallableDescriptorCollector<D>> {
override fun iterator(): Iterator<CallableDescriptorCollector<D>> = collectors.iterator()
[suppress("UNCHECKED_CAST")]
class object {
[suppress("UNCHECKED_CAST")] companion
object {
public val FUNCTIONS_AND_VARIABLES: CallableDescriptorCollectors<CallableDescriptor> =
CallableDescriptorCollectors(listOf(
FUNCTIONS_COLLECTOR as CallableDescriptorCollector<CallableDescriptor>,
@@ -38,7 +38,7 @@ import kotlin.platform.platformStatic
public class ConstantExpressionEvaluator private (val trace: BindingTrace) : JetVisitor<CompileTimeConstant<*>, JetType>() {
class object {
companion object {
platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? {
val evaluator = ConstantExpressionEvaluator(trace)
return evaluator.evaluate(expression, expectedType)
@@ -36,7 +36,7 @@ public trait Diagnostics : Iterable<Diagnostic> {
override fun iterator() = all().iterator()
class object {
companion object {
public val EMPTY: Diagnostics = object : Diagnostics {
override fun noSuppression(): Diagnostics = this
override val modificationTracker: ModificationTracker = ModificationTracker.NEVER_CHANGED
@@ -55,7 +55,7 @@ class LazyFileScope private(
}
}
class object Factory {
companion object Factory {
public fun create(
resolveSession: ResolveSession,
file: JetFile,
@@ -35,7 +35,7 @@ public abstract class DeclarationProviderFactoryService {
filesScope: GlobalSearchScope
): DeclarationProviderFactory
class object {
companion object {
public platformStatic fun createDeclarationProviderFactory(
project: Project,
storageManager: StorageManager,
@@ -319,7 +319,7 @@ public open class LazyClassMemberScope(
// Do not add details here, they may compromise the laziness during debugging
override fun toString() = "lazy scope for class ${thisDescriptor.getName()}"
class object {
companion object {
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
override fun extract(extractFrom: JetType, name: Name): Collection<FunctionDescriptor> {
return extractFrom.getMemberScope().getFunctions(name)
@@ -46,7 +46,7 @@ public trait Qualifier: ReceiverValue {
public val name: Name
get() = classifier?.getName() ?: packageView!!.getName()
// package, classifier or class object descriptor
// package, classifier or companion object descriptor
public val resultingDescriptor: DeclarationDescriptor
public val scope: JetScope
@@ -87,7 +87,7 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
}
}
class object {
companion object {
private val LOG = Logger.getInstance("#org.jetbrains.kotlin.asJava.JetCodeBlockModificationListener")
private fun containsClassesInside(element: PsiElement?): Boolean {
@@ -65,7 +65,7 @@ public class KotlinLightClassForPackage private(
}
}
class object {
companion object {
public fun getInstance(project: Project): FileStubCache {
return ServiceManager.getService<FileStubCache>(project, javaClass<FileStubCache>())
}
@@ -214,7 +214,7 @@ public class KotlinLightClassForPackage private(
}
}
class object Factory {
companion object Factory {
public fun create(
manager: PsiManager,
qualifiedName: FqName,
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.config.CompilerConfigurationKey
import org.jetbrains.kotlin.config.CompilerConfiguration
public trait ComponentRegistrar {
class object {
companion object {
public val PLUGIN_COMPONENT_REGISTRARS: CompilerConfigurationKey<MutableList<ComponentRegistrar>> = CompilerConfigurationKey.create("plugin component registrars")
}
@@ -98,7 +98,7 @@ public trait AbstractSMAPBaseTest {
}
class SMAPAndFile(val smap: String?, val sourceFile: String) {
class object {
companion object {
fun SMAPAndFile(smap: String?, sourceFile: File) = SMAPAndFile(smap, getPath(sourceFile))
public fun getPath(file: File): String {
@@ -165,7 +165,7 @@ public class MultiModuleJavaAnalysisCustomTest : UsefulTestCase() {
)
}
class object {
companion object {
val PATH_TO_TEST_ROOT_DIR = "compiler/testData/multiModule/java/custom"
}
}
@@ -52,7 +52,7 @@ import java.net.URLClassLoader
import java.util.regex.Pattern
public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdir() {
class object {
companion object {
private val renderer = DescriptorRendererBuilder()
.setWithDefinedIn(false)
.setExcludedAnnotationClasses(listOf(
@@ -108,7 +108,7 @@ public abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescrip
}
}
class object {
companion object {
val pattern = Pattern.compile(".+(?=:)")
}
}
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.config
import java.util.HashMap
public class Services private(private val map: Map<Class<*>, Any>) {
class object {
companion object {
public val EMPTY: Services = Builder().build()
}
+1 -1
View File
@@ -22,7 +22,7 @@ package kotlin
* information on enum classes.
*/
public abstract class Enum<E : Enum<E>>(name: String, ordinal: Int): Comparable<E> {
class object Companion {}
companion object {}
/**
* Returns the name of this enum constant, exactly as declared in its enum declaration.
+7 -7
View File
@@ -23,7 +23,7 @@ package kotlin
* On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`.
*/
public class Byte private () : Number, Comparable<Byte> {
class object Companion {}
companion object {}
/**
* Compares this value with the specified value for order.
@@ -181,7 +181,7 @@ public class Byte private () : Number, Comparable<Byte> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/
public class Char private () : Comparable<Char> {
class object Companion {}
companion object {}
/**
* Compares the character code of this character with the specified value for order.
@@ -326,7 +326,7 @@ public class Char private () : Comparable<Char> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `short`.
*/
public class Short private () : Number, Comparable<Short> {
class object Companion {}
companion object {}
/**
* Compares this value with the specified value for order.
@@ -484,7 +484,7 @@ public class Short private () : Number, Comparable<Short> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `int`.
*/
public class Int private () : Number, Comparable<Int> {
class object Companion {}
companion object {}
/**
* Compares this value with the specified value for order.
@@ -657,7 +657,7 @@ public class Int private () : Number, Comparable<Int> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `long`.
*/
public class Long private () : Number, Comparable<Long> {
class object Companion {}
companion object {}
/**
* Compares this value with the specified value for order.
@@ -830,7 +830,7 @@ public class Long private () : Number, Comparable<Long> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `float`.
*/
public class Float private () : Number, Comparable<Float> {
class object Companion : FloatingPointConstants<Float> {}
companion object : FloatingPointConstants<Float> {}
/**
* Compares this value with the specified value for order.
@@ -988,7 +988,7 @@ public class Float private () : Number, Comparable<Float> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `double`.
*/
public class Double private () : Number, Comparable<Double> {
class object Companion : FloatingPointConstants<Double> {}
companion object : FloatingPointConstants<Double> {}
/**
* Compares this value with the specified value for order.
+1 -1
View File
@@ -21,7 +21,7 @@ package kotlin
* implemented as instances of this class.
*/
public class String : Comparable<String>, CharSequence {
class object Companion {}
companion object {}
/**
* Returns a string obtained by concatenating this string with the string representation of the given [other] object.
+7 -7
View File
@@ -38,7 +38,7 @@ public class ByteRange(override val start: Byte, override val end: Byte) : Range
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * start.toInt() + end)
class object Companion {
companion object {
/** An empty range of values of type Byte. */
public val EMPTY: ByteRange = ByteRange(1, 0)
}
@@ -64,7 +64,7 @@ public class CharRange(override val start: Char, override val end: Char) : Range
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * start.toInt() + end)
class object Companion {
companion object {
/** An empty range of values of type Char. */
public val EMPTY: CharRange = CharRange(1.toChar(), 0.toChar())
}
@@ -90,7 +90,7 @@ public class ShortRange(override val start: Short, override val end: Short) : Ra
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * start.toInt() + end)
class object Companion {
companion object {
/** An empty range of values of type Short. */
public val EMPTY: ShortRange = ShortRange(1, 0)
}
@@ -116,7 +116,7 @@ public class IntRange(override val start: Int, override val end: Int) : Range<In
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * start + end)
class object Companion {
companion object {
/** An empty range of values of type Int. */
public val EMPTY: IntRange = IntRange(1, 0)
}
@@ -142,7 +142,7 @@ public class LongRange(override val start: Long, override val end: Long) : Range
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))).toInt()
class object Companion {
companion object {
/** An empty range of values of type Long. */
public val EMPTY: LongRange = LongRange(1, 0)
}
@@ -168,7 +168,7 @@ public class FloatRange(override val start: Float, override val end: Float) : Ra
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end))
class object Companion {
companion object {
/** An empty range of values of type Float. */
public val EMPTY: FloatRange = FloatRange(1.0f, 0.0f)
}
@@ -199,7 +199,7 @@ public class DoubleRange(override val start: Double, override val end: Double) :
return (31 * result + (temp xor (temp ushr 32))).toInt()
}
class object Companion {
companion object {
/** An empty range of values of type Double. */
public val EMPTY: DoubleRange = DoubleRange(1.0, 0.0)
}
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.types.JetType
public trait SamConversionResolver {
public class object EMPTY : SamConversionResolver {
public companion object EMPTY : SamConversionResolver {
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D) = null
override fun resolveSamConstructor(name: Name, scope: JetScope) = null
override fun resolveFunctionTypeIfSamInterface(
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.name.Name
// The purpose of this class is to hold a unique signature of either a method or a field, so that annotations on a member can be put
// into a map indexed by these signatures
data class MemberSignature private(private val signature: String) {
class object {
companion object {
platformStatic public fun fromMethodNameAndDesc(nameAndDesc: String): MemberSignature {
return MemberSignature(nameAndDesc)
}
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.name.Name
abstract class ReflectJavaAnnotationArgument(
override val name: Name?
) : JavaAnnotationArgument {
class object Factory {
companion object Factory {
fun create(value: Any, name: Name?): ReflectJavaAnnotationArgument {
return when {
value.javaClass.isEnumClassOrSpecializedEnumEntryClass() -> ReflectJavaEnumValueAnnotationArgument(name, value as Enum<*>)
@@ -27,7 +27,7 @@ public abstract class ReflectJavaType : JavaType {
override fun createArrayType(): JavaArrayType = throw UnsupportedOperationException()
class object Factory {
companion object Factory {
fun create(type: Type): ReflectJavaType {
return when {
type is Class<*> && type.isPrimitive() -> ReflectJavaPrimitiveType(type)
@@ -44,7 +44,7 @@ public class ReflectKotlinClass private(
private val classHeader: KotlinClassHeader
) : KotlinJvmBinaryClass {
class object Factory {
companion object Factory {
public fun create(klass: Class<*>): ReflectKotlinClass? {
val headerReader = ReadKotlinClassHeaderAnnotationVisitor()
@@ -29,7 +29,7 @@ public class RuntimeModuleData private(private val injector: InjectorForRuntimeD
public val localClassResolver: LocalClassResolver get() = injector.getDeserializationComponentsForJava().components.localClassResolver
class object {
companion object {
public fun create(classLoader: ClassLoader): RuntimeModuleData {
val module = ModuleDescriptorImpl(Name.special("<runtime module for $classLoader>"), listOf(), JavaToKotlinClassMap.INSTANCE)
module.addDependencyOnModule(module)
@@ -26,7 +26,7 @@ public trait Annotations : Iterable<AnnotationDescriptor> {
public fun findAnnotation(fqName: FqName): AnnotationDescriptor?
class object {
companion object {
public val EMPTY: Annotations = object : Annotations {
override fun isEmpty() = true
@@ -76,7 +76,7 @@ public trait JetScope {
}
}
class object {
companion object {
public val ALL_NAME_FILTER: (Name) -> Boolean = { true }
}
}
@@ -141,7 +141,7 @@ public class DescriptorKindFilter(
}
}
class object {
companion object {
public val NON_SINGLETON_CLASSIFIERS_MASK: Int = 0x01
public val SINGLETON_CLASSIFIERS_MASK: Int = 0x02
public val PACKAGES_MASK: Int = 0x04
@@ -33,7 +33,7 @@ public trait FlexibleTypeCapabilities {
}
public trait Flexibility : TypeCapability, SubtypingRepresentatives {
class object {
companion object {
// This is a "magic" classifier: when type resolver sees it in the code, e.g. ft<Foo, Foo?>, instead of creating a normal type,
// it creates a flexible type, e.g. (Foo..Foo?).
// This is used in tests and Evaluate Expression to have flexible types in the code,
@@ -145,7 +145,7 @@ public open class DelegatingFlexibleType protected (
override val upperBound: JetType,
override val extraCapabilities: FlexibleTypeCapabilities
) : DelegatingType(), NullAwareness, Flexibility, FlexibleTypeDelegation, Approximation {
class object {
companion object {
platformStatic fun create(lowerBound: JetType, upperBound: JetType, extraCapabilities: FlexibleTypeCapabilities): JetType {
if (lowerBound == upperBound) return lowerBound
return DelegatingFlexibleType(lowerBound, upperBound, extraCapabilities)
@@ -30,7 +30,7 @@ enum class PrimitiveType {
BOOLEAN
val capitalized: String get() = name().toLowerCase().capitalize()
class object {
companion object {
val exceptBoolean: Iterable<PrimitiveType> by Delegates.lazy { PrimitiveType.values().filterNot { it == BOOLEAN } }
}
}
@@ -61,7 +61,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
}
out.println("Comparable<$className> {")
out.print(" class object Companion")
out.print(" companion object")
if (kind == PrimitiveType.FLOAT || kind == PrimitiveType.DOUBLE) {
out.print(" : FloatingPointConstants<$className>")
}
@@ -82,7 +82,7 @@ public class $range(override val start: $t, override val end: $t) : Range<$t>, P
override fun hashCode(): Int $hashCode
class object Companion {
companion object {
/** An empty range of values of type $t. */
public val EMPTY: $range = $range($emptyBounds)
}
@@ -48,7 +48,7 @@ public class ReferenceVariantsHelper(
public val receivers: Collection<ReceiverValue>,
public val callType: CallType
) {
class object {
companion object {
val Empty = ReceiversData(listOf(), CallType.NORMAL)
}
}
@@ -216,7 +216,7 @@ public class ReferenceVariantsHelper(
return resolutionScope.getDescriptorsFiltered(DescriptorKindFilter.PACKAGES, nameFilter).filter(visibilityFilter)
}
class object {
companion object {
public fun getExplicitReceiverData(expression: JetSimpleNameExpression): Pair<JetExpression, CallType>? {
val receiverExpression = expression.getReceiverExpression() ?: return null
val parent = expression.getParent()
@@ -469,7 +469,7 @@ class PartialBodyResolveFilter(
NEED_COMPLETION
}
class object {
companion object {
private fun JetElement.blocks(): Collection<JetBlockExpression> {
val result = ArrayList<JetBlockExpression>(1)
this.accept(object : JetVisitorVoid() {
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.actions.internal
import com.intellij.ide.util.PropertiesComponent
public class KotlinInternalMode {
public class object Instance {
public companion object Instance {
val INTERNAL_MODE_PROPERTY = "kotlin.internal.mode.enabled"
public var enabled: Boolean
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.idea.stubindex.JetFunctionShortNameIndex
// used in Upsource, what's why in idea-analysis module
public class JetShortNamesCache(private val project: com.intellij.openapi.project.Project) : com.intellij.psi.search.PsiShortNamesCache() {
class object {
companion object {
public fun getKotlinInstance(project: com.intellij.openapi.project.Project): org.jetbrains.kotlin.idea.caches.JetShortNamesCache
= com.intellij.openapi.extensions.Extensions.getArea(project).getExtensionPoint<com.intellij.psi.search.PsiShortNamesCache>(com.intellij.psi.search.PsiShortNamesCache.EP_NAME).getExtensions()
.firstIsInstance<JetShortNamesCache>()
@@ -45,7 +45,7 @@ import kotlin.platform.platformStatic
private val LOG = Logger.getInstance(javaClass<KotlinCacheService>())
public class KotlinCacheService(val project: Project) {
class object {
companion object {
platformStatic public fun getInstance(project: Project): KotlinCacheService = ServiceManager.getService(project, javaClass<KotlinCacheService>())!!
}
@@ -31,7 +31,7 @@ import com.intellij.codeInsight.ExternalAnnotationsListener
import com.intellij.psi.PsiModifierListOwner
class LibraryModificationTracker(project: Project) : SimpleModificationTracker() {
class object {
companion object {
platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<LibraryModificationTracker>())!!
}
@@ -43,7 +43,7 @@ private class ExceptionTrackerWithProcessCanceledReport() : ExceptionTracker() {
}
class object {
companion object {
val LOG = Logger.getInstance(javaClass<ExceptionTrackerWithProcessCanceledReport>())
}
}
@@ -32,7 +32,7 @@ import com.intellij.openapi.util.SimpleModificationTracker
import kotlin.platform.platformStatic
class ModuleTypeCacheManager private (project: Project) {
class object {
companion object {
platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<ModuleTypeCacheManager>())
}
@@ -94,7 +94,7 @@ private fun getLibraryName(module: ModuleDescriptor): String? {
class JsMetaFileVirtualFileHolder private(val myProject: Project) {
class object {
companion object {
public val MODULE_DESCRIPTOR_KEY: Key<ModuleDescriptorImpl> = Key.create("MODULE_DESCRIPTOR")
public val PACKAGE_FQNAME_KEY: Key<FqName> = Key.create("PACKAGE_FQNAME_KEY")
private val JS_META_FILE_HOLDER_KEY: Key<JsMetaFileVirtualFileHolder> = Key.create("JS_META_FILE_HOLDER_KEY")
@@ -87,7 +87,7 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() {
return ClsStubBuilderComponents(classDataFinder, annotationLoader)
}
class object {
companion object {
val LOG = Logger.getInstance(javaClass<KotlinClsStubBuilder>())
}
}
@@ -113,7 +113,7 @@ public class DeserializerForDecompiler(val packageDirectory: VirtualFile, val di
return MutablePackageFragmentDescriptor(moduleDescriptor, fqName)
}
class object {
companion object {
private val LOG = Logger.getInstance(javaClass<DeserializerForDecompiler>())
}
}
@@ -222,7 +222,7 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension {
}
}
class object {
companion object {
var namesHighlightingEnabled = true
[TestOnly] set
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.idea.caches.resolve.analyze
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>("operator.to.function", javaClass()) {
class object {
companion object {
private fun isApplicablePrefix(element: JetPrefixExpression): Boolean {
return when (element.getOperationReference().getReferencedNameElementType()) {
JetTokens.PLUS, JetTokens.MINUS, JetTokens.PLUSPLUS, JetTokens.MINUSMINUS, JetTokens.EXCL -> true
@@ -41,7 +41,7 @@ public class JetForLoopInReference(element: JetForExpression) : JetMultiReferenc
return LOOP_RANGE_KEYS.map { key -> context.get(key, loopRange)?.getCandidateDescriptor() }.filterNotNull()
}
class object {
companion object {
private val LOOP_RANGE_KEYS = array(
BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL,
BindingContext.LOOP_RANGE_NEXT_RESOLVED_CALL,
@@ -57,7 +57,7 @@ public data class UsagesSearchLocation(
val inStrings: Boolean = false,
val inPlainText: Boolean = true
) {
class object {
companion object {
public val DEFAULT: UsagesSearchLocation = UsagesSearchLocation()
public val EVERYWHERE: UsagesSearchLocation = UsagesSearchLocation(true, true, true, true)
}
@@ -78,7 +78,7 @@ public class SubpackagesIndexService(private val project: Project) {
}
}
class object {
companion object {
public fun getInstance(project: Project): SubpackagesIndex {
return ServiceManager.getService(project, javaClass<SubpackagesIndexService>())!!.cachedValue.getValue()!!
}
@@ -44,7 +44,7 @@ public abstract class ImportInsertHelper {
public abstract fun importDescriptor(file: JetFile, descriptor: DeclarationDescriptor): ImportDescriptorResult
class object {
companion object {
[platformStatic]
public fun getInstance(project: Project): ImportInsertHelper
= ServiceManager.getService<ImportInsertHelper>(project, javaClass<ImportInsertHelper>())
@@ -46,12 +46,12 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
val removeThisLabels: Boolean = false,
val removeThis: Boolean = false
) {
class object {
companion object {
val DEFAULT = Options()
}
}
class object {
companion object {
val DEFAULT = ShortenReferences()
private fun DeclarationDescriptor.asString()
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.JetPsiFactory
public trait SimpleNameReferenceExtension {
class object {
companion object {
public val EP_NAME: ExtensionPointName<SimpleNameReferenceExtension> = ExtensionPointName.create("org.jetbrains.kotlin.simpleNameReferenceExtension")!!
}
@@ -21,7 +21,7 @@ public class CompilerSettings {
public var copyJsLibraryFiles: Boolean = true
public var outputDirectoryForJsLibraryFiles: String = DEFAULT_OUTPUT_DIRECTORY
class object {
companion object {
private val DEFAULT_ADDITIONAL_ARGUMENTS = "-version"
private val DEFAULT_OUTPUT_DIRECTORY = "lib"
}
@@ -154,7 +154,7 @@ public class JetAddImportAction(
JBPopupFactory.getInstance().createListPopup(getImportSelectionPopup()).showInBestPositionFor(editor)
}
class object {
companion object {
protected fun addImport(element: PsiElement, project: Project, selectedVariant: Variant) {
PsiDocumentManager.getInstance(project).commitAllDocuments()
@@ -73,7 +73,7 @@ public class KotlinReferenceData(
}
}
class object {
companion object {
public val dataFlavor: DataFlavor? by Delegates.lazy {
try {
DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + javaClass<KotlinReferenceData>().getName(), "KotlinReferenceData")
@@ -52,7 +52,7 @@ public class DeclarationDescriptorLookupObject(
return descriptorsEqualWithSubstitution(descriptor, lookupObject.descriptor)
}
class object {
companion object {
private val LOG = Logger.getInstance("#" + javaClass<DeclarationDescriptorLookupObject>().getName())
}
}
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetFunctionLiteral
public class KotlinCompletionCharFilter() : CharFilter() {
class object {
companion object {
public val ACCEPT_OPENING_BRACE: Key<Boolean> = Key("KotlinCompletionCharFilter.ACCEPT_OPENNING_BRACE")
public val JUST_TYPING_PREFIX: Key<String> = Key("KotlinCompletionCharFilter.JUST_TYPING_PREFIX")
@@ -30,7 +30,7 @@ public class LeafElementFilter(private val elementType: IElementType) : ElementF
override fun isClassAcceptable(hintClass: Class<*>)
= LEAF_CLASS_FILTER.isClassAcceptable(hintClass)
class object {
companion object {
private val LEAF_CLASS_FILTER = ClassFilter(javaClass<LeafPsiElement>())
}
}
@@ -255,7 +255,7 @@ public class LookupElementFactory(
}
}
class object {
companion object {
public fun getDefaultInsertHandler(descriptor: DeclarationDescriptor): InsertHandler<LookupElement> {
return when (descriptor) {
is FunctionDescriptor -> {
@@ -217,7 +217,7 @@ public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val
return caretPosition == CaretPosition.IN_BRACKETS
}
class object {
companion object {
public val NO_PARAMETERS_HANDLER: KotlinFunctionInsertHandler = KotlinFunctionInsertHandler(CaretPosition.AFTER_BRACKETS, null)
public val WITH_PARAMETERS_HANDLER: KotlinFunctionInsertHandler = KotlinFunctionInsertHandler(CaretPosition.IN_BRACKETS, null)
@@ -85,7 +85,7 @@ class WithTailInsertHandler(val tailText: String,
}
}
class object {
companion object {
fun commaTail() = WithTailInsertHandler(",", spaceBefore = false, spaceAfter = true /*TODO: use code style option*/)
fun rparenthTail() = WithTailInsertHandler(")", spaceBefore = false, spaceAfter = false)
fun elseTail() = WithTailInsertHandler("else", spaceBefore = true, spaceAfter = true)
@@ -473,7 +473,7 @@ class SmartCompletion(
}
}
class object {
companion object {
public val OLD_ARGUMENTS_REPLACEMENT_OFFSET: OffsetKey = OffsetKey.create("nonFunctionReplacementOffset")
public val MULTIPLE_ARGUMENTS_REPLACEMENT_OFFSET: OffsetKey = OffsetKey.create("multipleArgumentsReplacementOffset")
@@ -104,7 +104,7 @@ fun LookupElement.addTailAndNameSimilarity(matchedExpectedInfos: Collection<Expe
}
class ExpectedInfoClassification private(val substitutor: TypeSubstitutor?, val makeNotNullable: Boolean) {
class object {
companion object {
val notMatches = ExpectedInfoClassification(null, false)
fun matches(substitutor: TypeSubstitutor) = ExpectedInfoClassification(substitutor, false)
fun matchesIfNotNullable(substitutor: TypeSubstitutor) = ExpectedInfoClassification(substitutor, true)
@@ -180,7 +180,7 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
return dialog.isOK()
}
class object {
companion object {
private val LOG = Logger.getInstance("#org.jetbrains.kotlin.idea.conversion.copy.ConvertJavaCopyPastePostProcessor")
}
}
@@ -28,7 +28,7 @@ class CopiedCode(val fileName: String, val fileText: String, val startOffsets: I
public override fun getOffsets(offsets: IntArray?, index: Int) = index
public override fun setOffsets(offsets: IntArray?, index: Int) = index
class object {
companion object {
val DATA_FLAVOR: DataFlavor = DataFlavor(javaClass<ConvertJavaCopyPastePostProcessor>(), "class: ConvertJavaCopyPastePostProcessor")
}
}
@@ -116,7 +116,7 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() {
return false
}
class object {
companion object {
private val LOG = Logger.getInstance(javaClass<KotlinCoverageExtension>())
fun collectGeneratedClassQualifiedNames(outputRoot: VirtualFile?, file: JetFile): List<String>? {
@@ -273,7 +273,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult
myTypeMappers.put(key, value)
}
class object {
companion object {
public fun createTypeMapper(file: JetFile): JetTypeMapper {
val project = file.getProject()
@@ -34,7 +34,7 @@ public class KotlinDebuggerSettings : XDebuggerSettings<KotlinDebuggerSettings>(
public var DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES: Boolean = true
public var DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED: Boolean = false
class object {
companion object {
public fun getInstance(): KotlinDebuggerSettings {
return XDebuggerUtil.getInstance()?.getDebuggerSettings(javaClass<KotlinDebuggerSettings>())!!
}
@@ -42,7 +42,7 @@ class KotlinEditorTextProvider : EditorTextProvider {
return Pair(expression, expressionRange)
}
class object {
companion object {
fun <T> getElementInfo(expr: JetExpression, f: (PsiElement) -> T): T {
var expressionText = f(expr)
@@ -95,7 +95,7 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
override fun getEvaluatorBuilder() = KotlinEvaluationBuilder
class object {
companion object {
fun getContextElement(elementAt: PsiElement?): PsiElement? {
if (elementAt == null) return null
@@ -40,7 +40,7 @@ class KotlinEvaluateExpressionCache(val project: Project) {
MultiMap.create(), PsiModificationTracker.MODIFICATION_COUNT)
}, false)
class object {
companion object {
private val LOG = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<KotlinEvaluateExpressionCache>())!!
@@ -157,7 +157,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
return null
}
class object {
companion object {
private fun extractAndCompile(codeFragment: JetCodeFragment, sourcePosition: SourcePosition, context: EvaluationContextImpl): CompiledDataDescriptor {
codeFragment.checkForErrors()
@@ -79,7 +79,7 @@ public abstract class KotlinRuntimeTypeEvaluator(
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.surrounded.expression.null"))
}
class object {
companion object {
private fun getCastableRuntimeType(project: Project, value: Value): JetType? {
val myValue = value.asValue()
var psiClass = myValue.asmType.getClassDescriptor(project)
@@ -36,7 +36,7 @@ import com.intellij.psi.tree.TokenSet
import com.intellij.psi.PsiWhiteSpace
public class KotlinEnterHandler: EnterHandlerDelegateAdapter() {
class object {
companion object {
private val LOG = Logger.getInstance(javaClass<KotlinEnterHandler>())
private val FORCE_INDENT_IN_LAMBDA_AFTER = TokenSet.create(JetTokens.ARROW, JetTokens.LBRACE)
}
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.lexer.JetTokens
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase
public class KotlinListSelectioner : ExtendWordSelectionHandlerBase() {
class object {
companion object {
fun canSelect(e: PsiElement)
= e is JetParameterList || e is JetValueArgumentList || e is JetTypeParameterList || e is JetTypeArgumentList
}
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.JetIcons
import org.jetbrains.kotlin.idea.project.TargetPlatform
public class KotlinTemplatesFactory : ProjectTemplatesFactory() {
class object {
companion object {
public val KOTLIN_GROUP_NAME: String = "Kotlin"
}
@@ -51,7 +51,7 @@ import javax.swing.JComponent
import javax.swing.JPanel
public class UnusedSymbolInspection : AbstractKotlinInspection() {
class object {
companion object {
private val javaInspection = UnusedDeclarationInspection()
public fun isEntryPoint(declaration: JetNamedDeclaration): Boolean {
@@ -64,7 +64,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences
public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention<JetNamedFunction>(
"convert.function.to.property.intention", javaClass()
) {
class object {
companion object {
private var JetNamedFunction.typeFqNameToAdd: String? by UserDataProperty(Key.create("TYPE_FQ_NAME_TO_ADD"))
}
@@ -37,7 +37,7 @@ public class ConvertToBlockBodyAction : PsiElementBaseIntentionAction() {
convert(findDeclaration(element)!!)
}
class object {
companion object {
fun convert(declaration: JetDeclarationWithBody): JetDeclarationWithBody {
val body = declaration.getBodyExpression()!!
@@ -59,7 +59,7 @@ public class InsertExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpr
ShortenReferences.DEFAULT.process(element.getTypeArgumentList()!!)
}
class object {
companion object {
fun createTypeArguments(element: JetCallExpression): JetTypeArgumentList? {
val context = element.analyze()
val resolvedCall = element.getResolvedCall(context)

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