default -> companion: default object -> class object in project code, builtins and libs code

This commit is contained in:
Pavel V. Talanov
2015-03-16 14:51:11 +03:00
parent 444b461ba7
commit 2a6facaef6
151 changed files with 205 additions and 205 deletions
@@ -1908,7 +1908,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (descriptor instanceof PropertyDescriptor) {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.Default.getInstances(state.getProject());
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.OBJECT$.getInstances(state.getProject());
if (!codegenExtensions.isEmpty() && resolvedCall != null) {
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
JetType returnType = propertyDescriptor.getReturnType();
@@ -2348,7 +2348,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (!(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor)) { // otherwise already
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod);
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.Default.getInstances(state.getProject());
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.OBJECT$.getInstances(state.getProject());
if (!codegenExtensions.isEmpty()) {
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
for (ExpressionCodegenExtension extension : codegenExtensions) {
@@ -388,7 +388,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
genClosureFields(context.closure, v, typeMapper);
for (ExpressionCodegenExtension extension : ExpressionCodegenExtension.Default.getInstances(state.getProject())) {
for (ExpressionCodegenExtension extension : ExpressionCodegenExtension.OBJECT$.getInstances(state.getProject())) {
extension.generateClassSyntheticParts(v, state, myClass, descriptor);
}
}
@@ -76,7 +76,7 @@ class PlatformStaticGenerator(
)
}
default object {
class object {
[platformStatic]
public fun createStaticFunctionDescriptor(descriptor: FunctionDescriptor): FunctionDescriptor {
val memberDescriptor = if (descriptor is PropertyAccessorDescriptor) descriptor.getCorrespondingProperty() else descriptor
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.*
public trait ExpressionCodegenExtension {
default object : ProjectExtensionDescriptor<ExpressionCodegenExtension>("org.jetbrains.kotlin.expressionCodegenExtension", javaClass<ExpressionCodegenExtension>())
class 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?) {
default object {
class 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"
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.name.Name
abstract class JavaAnnotationArgumentImpl(
override val name: Name?
) : JavaAnnotationArgument {
default object Factory {
class 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"
default object Factory {
class 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?
) {
default object {
class 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())
default object {
class 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)
default object Factory {
class 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()}")
default object Factory {
class object Factory {
fun create (
element: JetElement,
lexicalScope: LexicalScope,
@@ -115,7 +115,7 @@ public class MagicInstruction(
override fun toString() = renderInstruction("magic[$kind]", render(element))
default object Factory {
class object Factory {
fun create(
element: JetElement,
valueElement: JetElement?,
@@ -165,7 +165,7 @@ class MergeInstruction private(
override fun toString() = renderInstruction("merge", render(element))
default object Factory {
class 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 {
default object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>(
class 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 {
default object {
class 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(
}
}
default object {
class 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
default object Helper {
class 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
}
default object {
class 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
default object {
class 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 {
default object {
class 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
default object {
class object {
public val NONE: StatementFilter = StatementFilter()
}
}
@@ -306,7 +306,7 @@ public class TypeResolver(
return classifierDescriptor
}
default object {
class object {
[platformStatic]
public fun resolveProjectionKind(projectionKind: JetProjectionKind): Variance {
return when (projectionKind) {
@@ -79,7 +79,7 @@ class VarianceChecker(private val trace: BindingTrace) {
val occurrencePosition: Variance
)
default object {
class 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")] default
object {
[suppress("UNCHECKED_CAST")]
class 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>() {
default object {
class 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()
default object {
class 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(
}
}
default object Factory {
class object Factory {
public fun create(
resolveSession: ResolveSession,
file: JetFile,
@@ -35,7 +35,7 @@ public abstract class DeclarationProviderFactoryService {
filesScope: GlobalSearchScope
): DeclarationProviderFactory
default object {
class 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()}"
default object {
class object {
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
override fun extract(extractFrom: JetType, name: Name): Collection<FunctionDescriptor> {
return extractFrom.getMemberScope().getFunctions(name)
@@ -87,7 +87,7 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
}
}
default object {
class 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(
}
}
default object {
class object {
public fun getInstance(project: Project): FileStubCache {
return ServiceManager.getService<FileStubCache>(project, javaClass<FileStubCache>())
}
@@ -214,7 +214,7 @@ public class KotlinLightClassForPackage private(
}
}
default object Factory {
class 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 {
default object {
class object {
public val PLUGIN_COMPONENT_REGISTRARS: CompilerConfigurationKey<MutableList<ComponentRegistrar>> = CompilerConfigurationKey.create("plugin component registrars")
}
@@ -93,7 +93,7 @@ public trait AbstractSMAPBaseTest {
}
class SMAPAndFile(val smap: String?, val sourceFile: String) {
default object {
class 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() {
)
}
default object {
class object {
val PATH_TO_TEST_ROOT_DIR = "compiler/testData/multiModule/java/custom"
}
}
@@ -108,7 +108,7 @@ public abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescrip
}
}
default object {
class 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>) {
default object {
class object {
public val EMPTY: Services = Builder().build()
}