Run "Add 'init' keyword in whole project" quickfix

This commit is contained in:
Denis Zharkov
2015-03-31 12:22:34 +03:00
parent 99f1ab333e
commit a4018d9eae
65 changed files with 85 additions and 82 deletions
@@ -115,7 +115,7 @@ public abstract class CoveringTryCatchNodeProcessor<T: IntervalWithHandler>() {
public class DefaultProcessor(val node: MethodNode) : CoveringTryCatchNodeProcessor<TryCatchBlockNodeWrapper>() { public class DefaultProcessor(val node: MethodNode) : CoveringTryCatchNodeProcessor<TryCatchBlockNodeWrapper>() {
{ init {
node.tryCatchBlocks.forEach { addNode(it) } node.tryCatchBlocks.forEach { addNode(it) }
} }
@@ -194,8 +194,9 @@ public open class DefaultSourceMapper(val sourceInfo: SourceInfo, override val p
var fileMappings: LinkedHashMap<String, RawFileMapping> = linkedMapOf() var fileMappings: LinkedHashMap<String, RawFileMapping> = linkedMapOf()
protected var origin: RawFileMapping by Delegates.notNull(); protected var origin: RawFileMapping by Delegates.notNull()
{
init {
visitSource(sourceInfo.source, sourceInfo.pathOrCleanFQN) visitSource(sourceInfo.source, sourceInfo.pathOrCleanFQN)
//map interval //map interval
(1..maxUsedValue).forEach {origin.mapLine(it, it - 1, true) } (1..maxUsedValue).forEach {origin.mapLine(it, it - 1, true) }
@@ -52,7 +52,7 @@ public class IncrementalPackageFragmentProvider(
val fqNameToPackageFragment = HashMap<FqName, PackageFragmentDescriptor>() val fqNameToPackageFragment = HashMap<FqName, PackageFragmentDescriptor>()
val fqNamesToLoad: Set<FqName> val fqNamesToLoad: Set<FqName>
;{ init {
fun createPackageFragment(fqName: FqName) { fun createPackageFragment(fqName: FqName) {
if (fqNameToPackageFragment.containsKey(fqName)) { if (fqNameToPackageFragment.containsKey(fqName)) {
return return
@@ -29,7 +29,7 @@ public class VariableDeclarationInstruction(
element: JetDeclaration, element: JetDeclaration,
lexicalScope: LexicalScope lexicalScope: LexicalScope
) : InstructionWithNext(element, lexicalScope) { ) : InstructionWithNext(element, lexicalScope) {
{ init {
assert(element is JetVariableDeclaration || element is JetParameter) { "Invalid element: ${render(element)}}" } assert(element is JetVariableDeclaration || element is JetParameter) { "Invalid element: ${render(element)}}" }
} }
@@ -41,9 +41,9 @@ public abstract class JetCodeFragment(
): JetFile((PsiManager.getInstance(_project) as PsiManagerEx).getFileManager().createFileViewProvider(LightVirtualFile(name, JetFileType.INSTANCE, text), true), false), JavaCodeFragment { ): JetFile((PsiManager.getInstance(_project) as PsiManagerEx).getFileManager().createFileViewProvider(LightVirtualFile(name, JetFileType.INSTANCE, text), true), false), JavaCodeFragment {
private var viewProvider = super<JetFile>.getViewProvider() as SingleRootFileViewProvider private var viewProvider = super<JetFile>.getViewProvider() as SingleRootFileViewProvider
private var myImports = LinkedHashSet<String>(); private var myImports = LinkedHashSet<String>()
{ init {
getViewProvider().forceCachedPsi(this) getViewProvider().forceCachedPsi(this)
init(TokenType.CODE_FRAGMENT, elementType) init(TokenType.CODE_FRAGMENT, elementType)
if (context != null) { if (context != null) {
@@ -490,7 +490,7 @@ public class JetPsiFactory(private val project: Project) {
return createExpression(sb.toString()) as JetWhenExpression return createExpression(sb.toString()) as JetWhenExpression
} }
{ init {
if (subjectText != null) { if (subjectText != null) {
sb.append("(").append(subjectText).append(") ") sb.append("(").append(subjectText).append(") ")
} }
@@ -35,7 +35,7 @@ public class KotlinFunctionStubImpl(
private val hasTypeParameterListBeforeFunctionName: Boolean, private val hasTypeParameterListBeforeFunctionName: Boolean,
private val isProbablyNothingType: Boolean private val isProbablyNothingType: Boolean
) : KotlinStubBaseImpl<JetNamedFunction>(parent, JetStubElementTypes.FUNCTION), KotlinFunctionStub { ) : KotlinStubBaseImpl<JetNamedFunction>(parent, JetStubElementTypes.FUNCTION), KotlinFunctionStub {
{ init {
if (isTopLevel && fqName == null) { if (isTopLevel && fqName == null) {
throw IllegalArgumentException("fqName shouldn't be null for top level functions") throw IllegalArgumentException("fqName shouldn't be null for top level functions")
} }
@@ -38,7 +38,7 @@ public class KotlinPropertyStubImpl(
private val fqName: FqName? private val fqName: FqName?
) : KotlinStubBaseImpl<JetProperty>(parent, JetStubElementTypes.PROPERTY), KotlinPropertyStub { ) : KotlinStubBaseImpl<JetProperty>(parent, JetStubElementTypes.PROPERTY), KotlinPropertyStub {
{ init {
if (isTopLevel && fqName == null) { if (isTopLevel && fqName == null) {
throw IllegalArgumentException("fqName shouldn't be null for top level properties") throw IllegalArgumentException("fqName shouldn't be null for top level properties")
} }
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
import kotlin.platform.platformStatic import kotlin.platform.platformStatic
public object ModifierMaskUtils { public object ModifierMaskUtils {
{ init {
assert(MODIFIER_KEYWORDS_ARRAY.size() <= 32, "Current implementation depends on the ability to represent modifier list as bit mask") assert(MODIFIER_KEYWORDS_ARRAY.size() <= 32, "Current implementation depends on the ability to represent modifier list as bit mask")
} }
@@ -31,7 +31,7 @@ public class MutablePackageFragmentProvider(public val module: ModuleDescriptor)
private val fqNameToPackage = HashMap<FqName, MutablePackageFragmentDescriptor>() private val fqNameToPackage = HashMap<FqName, MutablePackageFragmentDescriptor>()
private val subPackages = MultiMap.create<FqName, FqName>() private val subPackages = MultiMap.create<FqName, FqName>()
;{ init {
fqNameToPackage.put(FqName.ROOT, MutablePackageFragmentDescriptor(module, FqName.ROOT)) fqNameToPackage.put(FqName.ROOT, MutablePackageFragmentDescriptor(module, FqName.ROOT))
} }
@@ -33,7 +33,7 @@ public class FakeCallableDescriptorForObject(
public val classDescriptor: ClassDescriptor public val classDescriptor: ClassDescriptor
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor { ) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
{ init {
assert(classDescriptor.getClassObjectType() != null) { assert(classDescriptor.getClassObjectType() != null) {
"FakeCallableDescriptorForObject can be created only for objects, classes with companion object or enum entries: $classDescriptor" "FakeCallableDescriptorForObject can be created only for objects, classes with companion object or enum entries: $classDescriptor"
} }
@@ -90,7 +90,7 @@ public class LazyAnnotationDescriptor(
val annotationEntry: JetAnnotationEntry val annotationEntry: JetAnnotationEntry
) : AnnotationDescriptor, LazyEntity { ) : AnnotationDescriptor, LazyEntity {
{ init {
c.trace.record(BindingContext.ANNOTATION, annotationEntry, this) c.trace.record(BindingContext.ANNOTATION, annotationEntry, this)
} }
@@ -56,7 +56,7 @@ public class LazyScriptDescriptor(
ScriptDescriptor.NAME, ScriptDescriptor.NAME,
jetScript.toSourceElement() jetScript.toSourceElement()
) { ) {
{ init {
resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this) resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this)
} }
@@ -72,7 +72,7 @@ public class KotlinLightClassForPackage private(
} }
} }
{ init {
assert(!files.isEmpty()) { "No files for package " + packageFqName } assert(!files.isEmpty()) { "No files for package " + packageFqName }
} }
@@ -178,7 +178,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
private class SyntheticPackageViewForTest(private val module: ModuleDescriptor) : PackageViewDescriptor { private class SyntheticPackageViewForTest(private val module: ModuleDescriptor) : PackageViewDescriptor {
private val scope = WritableScopeImpl(JetScope.Empty, this, RedeclarationHandler.THROW_EXCEPTION, "runtime descriptor loader test") private val scope = WritableScopeImpl(JetScope.Empty, this, RedeclarationHandler.THROW_EXCEPTION, "runtime descriptor loader test")
;{ init {
scope.changeLockLevel(WritableScope.LockLevel.BOTH) scope.changeLockLevel(WritableScope.LockLevel.BOTH)
} }
@@ -34,7 +34,7 @@ private val INCOMPLETE_PATTERN = Pattern.compile("\\.\\.\\.( *)(.*)$")
private val INCOMPLETE_LINE_MESSAGE = "incomplete line" private val INCOMPLETE_LINE_MESSAGE = "incomplete line"
public abstract class AbstractReplInterpreterTest : UsefulTestCase() { public abstract class AbstractReplInterpreterTest : UsefulTestCase() {
{ init {
System.setProperty("java.awt.headless", "true") System.setProperty("java.awt.headless", "true")
} }
@@ -132,7 +132,7 @@ class MutableDiagnosticsTest : KotlinTestWithEnvironment() {
private inner class DummyDiagnostic : Diagnostic { private inner class DummyDiagnostic : Diagnostic {
val dummyElement = JetPsiFactory(getEnvironment().project).createType("Int") val dummyElement = JetPsiFactory(getEnvironment().project).createType("Int")
;{ init {
dummyElement.getContainingJetFile().doNotAnalyze = null dummyElement.getContainingJetFile().doNotAnalyze = null
} }
@@ -37,7 +37,7 @@ public class ConstraintSystemTestData(
private val functionFoo: FunctionDescriptor private val functionFoo: FunctionDescriptor
private val scopeToResolveTypeParameters: JetScope private val scopeToResolveTypeParameters: JetScope
{ init {
val functions = context.getSliceContents(BindingContext.FUNCTION) val functions = context.getSliceContents(BindingContext.FUNCTION)
functionFoo = findFunctionByName(functions.values(), "foo") functionFoo = findFunctionByName(functions.values(), "foo")
val function = DescriptorToSourceUtils.descriptorToDeclaration(functionFoo) as JetFunction val function = DescriptorToSourceUtils.descriptorToDeclaration(functionFoo) as JetFunction
@@ -37,9 +37,9 @@ public object LibraryUtils {
private val METAINF = "META-INF/" private val METAINF = "META-INF/"
private val MANIFEST_PATH = "${METAINF}MANIFEST.MF" private val MANIFEST_PATH = "${METAINF}MANIFEST.MF"
private val METAINF_RESOURCES = "${METAINF}resources/" private val METAINF_RESOURCES = "${METAINF}resources/"
private val KOTLIN_JS_MODULE_ATTRIBUTE_NAME = Attributes.Name(KOTLIN_JS_MODULE_NAME); private val KOTLIN_JS_MODULE_ATTRIBUTE_NAME = Attributes.Name(KOTLIN_JS_MODULE_NAME)
{ init {
var jsStdLib = "" var jsStdLib = ""
var jsLib = "" var jsLib = ""
@@ -46,9 +46,9 @@ class LazyJavaClassDescriptor(
) : ClassDescriptorBase(outerC.storageManager, containingDeclaration, fqName.shortName(), ) : ClassDescriptorBase(outerC.storageManager, containingDeclaration, fqName.shortName(),
outerC.sourceElementFactory.source(jClass)), JavaClassDescriptor { outerC.sourceElementFactory.source(jClass)), JavaClassDescriptor {
private val c: LazyJavaResolverContext = outerC.child(this, jClass); private val c: LazyJavaResolverContext = outerC.child(this, jClass)
{ init {
c.javaResolverCache.recordClass(jClass, this) c.javaResolverCache.recordClass(jClass, this)
} }
@@ -31,9 +31,9 @@ public class DeserializationComponentsForJava(
annotationAndConstantLoader: BinaryClassAnnotationAndConstantLoaderImpl, annotationAndConstantLoader: BinaryClassAnnotationAndConstantLoaderImpl,
packageFragmentProvider: LazyJavaPackageFragmentProvider packageFragmentProvider: LazyJavaPackageFragmentProvider
) { ) {
val components: DeserializationComponents; val components: DeserializationComponents
{ init {
val localClassResolver = LocalClassResolverImpl() val localClassResolver = LocalClassResolverImpl()
components = DeserializationComponents( components = DeserializationComponents(
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider, storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider,
@@ -27,9 +27,9 @@ public class KotlinClassHeader(
public val classKind: KotlinClass.Kind?, public val classKind: KotlinClass.Kind?,
public val syntheticClassKind: KotlinSyntheticClass.Kind? public val syntheticClassKind: KotlinSyntheticClass.Kind?
) { ) {
public val isCompatibleAbiVersion: Boolean get() = AbiVersionUtil.isAbiVersionCompatible(version); public val isCompatibleAbiVersion: Boolean get() = AbiVersionUtil.isAbiVersionCompatible(version)
{ init {
if (isCompatibleAbiVersion) { if (isCompatibleAbiVersion) {
assert((annotationData == null) == (kind != Kind.CLASS && kind != Kind.PACKAGE_FACADE)) { assert((annotationData == null) == (kind != Kind.CLASS && kind != Kind.PACKAGE_FACADE)) {
"Annotation data should be not null only for CLASS and PACKAGE_FACADE (kind=$kind)" "Annotation data should be not null only for CLASS and PACKAGE_FACADE (kind=$kind)"
@@ -32,7 +32,7 @@ public class ModuleDescriptorImpl(
override val defaultImports: List<ImportPath>, override val defaultImports: List<ImportPath>,
override val platformToKotlinClassMap: PlatformToKotlinClassMap override val platformToKotlinClassMap: PlatformToKotlinClassMap
) : DeclarationDescriptorImpl(Annotations.EMPTY, moduleName), ModuleDescriptor { ) : DeclarationDescriptorImpl(Annotations.EMPTY, moduleName), ModuleDescriptor {
{ init {
if (!moduleName.isSpecial()) { if (!moduleName.isSpecial()) {
throw IllegalArgumentException("Module name must be special: $moduleName") throw IllegalArgumentException("Module name must be special: $moduleName")
} }
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
public class CapturedTypeConstructor( public class CapturedTypeConstructor(
public val typeProjection: TypeProjection public val typeProjection: TypeProjection
): TypeConstructor { ): TypeConstructor {
{ init {
assert(typeProjection.getProjectionKind() != Variance.INVARIANT) { assert(typeProjection.getProjectionKind() != Variance.INVARIANT) {
"Only nontrivial projections can be captured, not: $typeProjection" "Only nontrivial projections can be captured, not: $typeProjection"
} }
@@ -152,7 +152,7 @@ public open class DelegatingFlexibleType protected (
} }
} }
{ init {
assert (!lowerBound.isFlexible()) { "Lower bound of a flexible type can not be flexible: $lowerBound" } assert (!lowerBound.isFlexible()) { "Lower bound of a flexible type can not be flexible: $lowerBound" }
assert (!upperBound.isFlexible()) { "Upper bound of a flexible type can not be flexible: $upperBound" } assert (!upperBound.isFlexible()) { "Upper bound of a flexible type can not be flexible: $upperBound" }
assert (lowerBound != upperBound) { "Lower and upper bounds are equal: $lowerBound == $upperBound" } assert (lowerBound != upperBound) { "Lower and upper bounds are equal: $lowerBound == $upperBound" }
@@ -50,7 +50,7 @@ class FuzzyType(
private val usedTypeParameters: HashSet<TypeParameterDescriptor>? private val usedTypeParameters: HashSet<TypeParameterDescriptor>?
public val freeParameters: Set<TypeParameterDescriptor> public val freeParameters: Set<TypeParameterDescriptor>
;{ init {
if (freeParameters.isNotEmpty()) { if (freeParameters.isNotEmpty()) {
usedTypeParameters = HashSet() usedTypeParameters = HashSet()
usedTypeParameters!!.addUsedTypeParameters(type) usedTypeParameters!!.addUsedTypeParameters(type)
@@ -46,7 +46,7 @@ class PartialBodyResolveFilter(
override val filter: ((JetElement) -> Boolean)? = { it is JetExpression && statementMarks.statementMark(it) != MarkLevel.SKIP } override val filter: ((JetElement) -> Boolean)? = { it is JetExpression && statementMarks.statementMark(it) != MarkLevel.SKIP }
;{ init {
assert(declaration.isAncestor(elementToResolve)) assert(declaration.isAncestor(elementToResolve))
assert(!JetPsiUtil.isLocal(declaration), assert(!JetPsiUtil.isLocal(declaration),
"Should never be invoked on local declaration otherwise we may miss some local declarations with type Nothing") "Should never be invoked on local declaration otherwise we may miss some local declarations with type Nothing")
@@ -383,7 +383,7 @@ class PartialBodyResolveFilter(
private val receiverName: SmartCastName?, private val receiverName: SmartCastName?,
private val selectorName: String? /* null means "this" (and receiverName should be null */ private val selectorName: String? /* null means "this" (and receiverName should be null */
) { ) {
{ init {
if (selectorName == null) { if (selectorName == null) {
assert(receiverName == null, "selectorName is allowed to be null only when receiverName is also null (which means 'this')") assert(receiverName == null, "selectorName is allowed to be null only when receiverName is also null (which means 'this')")
} }
@@ -87,8 +87,9 @@ public class LibraryDependenciesCache(private val project: Project) {
} }
private inner class LibraryUsageIndex { private inner class LibraryUsageIndex {
val modulesLibraryIsUsedIn: MultiMap<Library, Module> = MultiMap.createSet(); val modulesLibraryIsUsedIn: MultiMap<Library, Module> = MultiMap.createSet()
{
init {
ModuleManager.getInstance(project).getModules().forEach { ModuleManager.getInstance(project).getModules().forEach {
module -> module ->
ModuleRootManager.getInstance(module).getOrderEntries().forEach { ModuleRootManager.getInstance(module).getOrderEntries().forEach {
@@ -35,7 +35,7 @@ class LibraryModificationTracker(project: Project) : SimpleModificationTracker()
platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<LibraryModificationTracker>())!! platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<LibraryModificationTracker>())!!
} }
{ init {
val connection = project.getMessageBus().connect() val connection = project.getMessageBus().connect()
connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter( connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter(
object : VirtualFileAdapter() { object : VirtualFileAdapter() {
@@ -52,7 +52,7 @@ class ModuleTypeCacheManager private (project: Project) {
} }
private class VfsModificationTracker(project: Project): SimpleModificationTracker() { private class VfsModificationTracker(project: Project): SimpleModificationTracker() {
{ init {
val connection = project.getMessageBus().connect(); val connection = project.getMessageBus().connect();
connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter( connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter(
object : VirtualFileAdapter() { object : VirtualFileAdapter() {
@@ -90,7 +90,7 @@ public class DeserializerForDecompiler(val packageDirectory: VirtualFile, val di
} }
} }
{ init {
moduleDescriptor.initialize(packageFragmentProvider) moduleDescriptor.initialize(packageFragmentProvider)
moduleDescriptor.addDependencyOnModule(moduleDescriptor) moduleDescriptor.addDependencyOnModule(moduleDescriptor)
moduleDescriptor.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule()) moduleDescriptor.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule())
@@ -68,7 +68,7 @@ private class MissingDependencyErrorClassDescriptor(
private val scope = ScopeWithMissingDependencies(fullFqName, this) private val scope = ScopeWithMissingDependencies(fullFqName, this)
;{ init {
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE) val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
emptyConstructor.initialize(listOf(), listOf(), Visibilities.INTERNAL) emptyConstructor.initialize(listOf(), listOf(), Visibilities.INTERNAL)
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>")) emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
@@ -31,7 +31,7 @@ class KotlinSuppressableWarningProblemGroup(
private val diagnosticFactory: DiagnosticFactory<*> private val diagnosticFactory: DiagnosticFactory<*>
) : SuppressableProblemGroup { ) : SuppressableProblemGroup {
{ init {
assert (diagnosticFactory.getSeverity() == Severity.WARNING) assert (diagnosticFactory.getSeverity() == Severity.WARNING)
} }
@@ -40,7 +40,7 @@ public trait SearchRequestWithElement<T : PsiElement> : DeclarationSearchRequest
} }
abstract class DeclarationsSearch<T: PsiElement, R: DeclarationSearchRequest<T>>: QueryFactory<T, R>() { abstract class DeclarationsSearch<T: PsiElement, R: DeclarationSearchRequest<T>>: QueryFactory<T, R>() {
{ init {
registerExecutor( registerExecutor(
object : QueryExecutorBase<T, R>(true) { object : QueryExecutorBase<T, R>(true) {
override fun processQuery(queryParameters: R, consumer: Processor<T>) { override fun processQuery(queryParameters: R, consumer: Processor<T>) {
@@ -161,7 +161,7 @@ public class KotlinPsiSearchHelper(private val project: Project): PsiSearchHelpe
} }
public object UsagesSearch: QueryFactory<PsiReference, UsagesSearchRequest>() { public object UsagesSearch: QueryFactory<PsiReference, UsagesSearchRequest>() {
{ init {
val executorImpl = object : QueryExecutorBase<PsiReference, UsagesSearchRequest>() { val executorImpl = object : QueryExecutorBase<PsiReference, UsagesSearchRequest>() {
override fun processQuery(request: UsagesSearchRequest, consumer: Processor<PsiReference>) { override fun processQuery(request: UsagesSearchRequest, consumer: Processor<PsiReference>) {
val searchHelper = KotlinPsiSearchHelper(request.project) val searchHelper = KotlinPsiSearchHelper(request.project)
@@ -40,9 +40,9 @@ public class SubpackagesIndexService(private val project: Project) {
public inner class SubpackagesIndex(allPackageFqNames: Collection<String>) { public inner class SubpackagesIndex(allPackageFqNames: Collection<String>) {
// a map from any existing package (in kotlin) to a set of subpackages (not necessarily direct) containing files // a map from any existing package (in kotlin) to a set of subpackages (not necessarily direct) containing files
private val fqNameByPrefix = MultiMap.createSet<FqName, FqName>(); private val fqNameByPrefix = MultiMap.createSet<FqName, FqName>()
{ init {
for (fqNameAsString in allPackageFqNames) { for (fqNameAsString in allPackageFqNames) {
val fqName = FqName(fqNameAsString) val fqName = FqName(fqNameAsString)
var prefix = fqName var prefix = fqName
@@ -28,7 +28,7 @@ public object JetPsiPrecedences {
private val LOG = Logger.getInstance(javaClass<JetPsiPrecedences>()) private val LOG = Logger.getInstance(javaClass<JetPsiPrecedences>())
private val precedence: Map<IElementType, Int> private val precedence: Map<IElementType, Int>
{ init {
val builder = HashMap<IElementType, Int>() val builder = HashMap<IElementType, Int>()
for ((i, record) in JetExpressionParsing.Precedence.values().withIndices()) { for ((i, record) in JetExpressionParsing.Precedence.values().withIndices()) {
for (elementType in record.getOperations().getTypes()) { for (elementType in record.getOperations().getTypes()) {
@@ -72,7 +72,7 @@ abstract class CompletionSessionBase(protected val configuration: CompletionSess
protected val reference: JetSimpleNameReference? protected val reference: JetSimpleNameReference?
protected val expression: JetExpression? protected val expression: JetExpression?
;{ init {
val reference = position.getParent()?.getReferences()?.firstIsInstanceOrNull<JetSimpleNameReference>() val reference = position.getParent()?.getReferences()?.firstIsInstanceOrNull<JetSimpleNameReference>()
if (reference != null) { if (reference != null) {
if (reference.expression is JetLabelReferenceExpression) { if (reference.expression is JetLabelReferenceExpression) {
@@ -104,7 +104,7 @@ abstract class CompletionSessionBase(protected val configuration: CompletionSess
private val kotlinIdentifierStartPattern: ElementPattern<Char> private val kotlinIdentifierStartPattern: ElementPattern<Char>
private val kotlinIdentifierPartPattern: ElementPattern<Char> private val kotlinIdentifierPartPattern: ElementPattern<Char>
;{ init {
val includeDollar = position.prevLeaf()?.getNode()?.getElementType() != JetTokens.SHORT_TEMPLATE_ENTRY_START val includeDollar = position.prevLeaf()?.getNode()?.getElementType() != JetTokens.SHORT_TEMPLATE_ENTRY_START
if (includeDollar) { if (includeDollar) {
kotlinIdentifierStartPattern = StandardPatterns.character().javaIdentifierStart() kotlinIdentifierStartPattern = StandardPatterns.character().javaIdentifierStart()
@@ -174,7 +174,7 @@ private class JetDeclarationRemotenessWeigher(private val file: JetFile) : Looku
private val preciseImportPackages = HashSet<FqName>() private val preciseImportPackages = HashSet<FqName>()
private val allUnderImports = HashSet<FqName>() private val allUnderImports = HashSet<FqName>()
;{ init {
for (import in file.getImportDirectives()) { for (import in file.getImportDirectives()) {
val importPath = import.getImportPath() ?: continue val importPath = import.getImportPath() ?: continue
val fqName = importPath.fqnPart() val fqName = importPath.fqnPart()
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.types.TypeUtils
public object HeuristicSignatures { public object HeuristicSignatures {
private val signatures = HashMap<Pair<FqName, Name>, List<String>>() private val signatures = HashMap<Pair<FqName, Name>, List<String>>()
;{ init {
registerSignature("kotlin.Collection", "contains", "E") registerSignature("kotlin.Collection", "contains", "E")
registerSignature("kotlin.Collection", "containsAll", "kotlin.Collection<E>") registerSignature("kotlin.Collection", "containsAll", "kotlin.Collection<E>")
registerSignature("kotlin.MutableCollection", "remove", "E") registerSignature("kotlin.MutableCollection", "remove", "E")
@@ -87,7 +87,7 @@ object KeywordCompletion {
} }
private class ParentFilter(filter : ElementFilter) : PositionElementFilter() { private class ParentFilter(filter : ElementFilter) : PositionElementFilter() {
{ init {
setFilter(filter) setFilter(filter)
} }
@@ -52,7 +52,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
private val DEFAULT_DUMMY_IDENTIFIER = CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + "$" // add '$' to ignore context after the caret private val DEFAULT_DUMMY_IDENTIFIER = CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + "$" // add '$' to ignore context after the caret
;{ init {
val provider = object : CompletionProvider<CompletionParameters>() { val provider = object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) { override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
performCompletion(parameters, result) performCompletion(parameters, result)
@@ -31,7 +31,8 @@ class ToFromOriginalFileMapper(
private val shift: Int private val shift: Int
//TODO: lazy initialization? //TODO: lazy initialization?
;{
init {
val originalText = originalFile.getText() val originalText = originalFile.getText()
val syntheticText = syntheticFile.getText() val syntheticText = syntheticFile.getText()
assert(originalText.subSequence(0, completionOffset) == syntheticText.subSequence(0, completionOffset)) //TODO: drop it assert(originalText.subSequence(0, completionOffset) == syntheticText.subSequence(0, completionOffset)) //TODO: drop it
@@ -96,7 +96,7 @@ public enum class CaretPosition {
public data class GenerateLambdaInfo(val lambdaType: JetType, val explicitParameters: Boolean) public data class GenerateLambdaInfo(val lambdaType: JetType, val explicitParameters: Boolean)
public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val lambdaInfo: GenerateLambdaInfo?) : KotlinCallableInsertHandler() { public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val lambdaInfo: GenerateLambdaInfo?) : KotlinCallableInsertHandler() {
{ init {
if (caretPosition == CaretPosition.AFTER_BRACKETS && lambdaInfo != null) { if (caretPosition == CaretPosition.AFTER_BRACKETS && lambdaInfo != null) {
throw IllegalArgumentException("CaretPosition.AFTER_BRACKETS with lambdaInfo != null combination is not supported") throw IllegalArgumentException("CaretPosition.AFTER_BRACKETS with lambdaInfo != null combination is not supported")
} }
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() { public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() {
{ init {
addFixers( addFixers(
KotlinIfConditionFixer(), KotlinIfConditionFixer(),
KotlinMissingIfBranchFixer(), KotlinMissingIfBranchFixer(),
@@ -116,7 +116,7 @@ public class KotlinFindClassUsagesHandler(
// todo: Use JavaFindUsagesHelper.getElementNames() when it becomes public in IDEA // todo: Use JavaFindUsagesHelper.getElementNames() when it becomes public in IDEA
var stringsToSearch: Collection<String> var stringsToSearch: Collection<String>
object: JavaFindUsagesHandler(psiClass, JavaFindUsagesHandlerFactory.getInstance(element.getProject())) { object: JavaFindUsagesHandler(psiClass, JavaFindUsagesHandlerFactory.getInstance(element.getProject())) {
{ init {
stringsToSearch = getStringsToSearch(psiClass) stringsToSearch = getStringsToSearch(psiClass)
} }
} }
@@ -27,9 +27,9 @@ import org.jetbrains.kotlin.asJava.toLightMethods
import com.intellij.util.containers.ContainerUtil import com.intellij.util.containers.ContainerUtil
class KotlinOverrideTreeStructure(project: Project, val element: PsiElement) : HierarchyTreeStructure(project, null) { class KotlinOverrideTreeStructure(project: Project, val element: PsiElement) : HierarchyTreeStructure(project, null) {
val javaTreeStructures = element.toLightMethods().map { method -> MethodHierarchyTreeStructure(project, method) }; val javaTreeStructures = element.toLightMethods().map { method -> MethodHierarchyTreeStructure(project, method) }
{ init {
setBaseElement(javaTreeStructures.first().getBaseDescriptor()!!) setBaseElement(javaTreeStructures.first().getBaseDescriptor()!!)
} }
@@ -45,7 +45,7 @@ fun updateHighlightingResult(file: JetFile, hasErrors: Boolean) {
public class ErrorDuringFileAnalyzeNotificationProvider(val project: Project) : EditorNotifications.Provider<EditorNotificationPanel>() { public class ErrorDuringFileAnalyzeNotificationProvider(val project: Project) : EditorNotifications.Provider<EditorNotificationPanel>() {
private class HighlightingErrorNotificationPanel : EditorNotificationPanel() { private class HighlightingErrorNotificationPanel : EditorNotificationPanel() {
{ init {
setText("Kotlin internal error occurred in this file. Highlighting may be inadequate.") setText("Kotlin internal error occurred in this file. Highlighting may be inadequate.")
myLabel.setIcon(AllIcons.General.Error) myLabel.setIcon(AllIcons.General.Error)
createActionLabel("Open Event Log", ActivateToolWindowAction.getActionIdForToolWindow(EventLog.LOG_TOOL_WINDOW_ID)) createActionLabel("Open Event Log", ActivateToolWindowAction.getActionIdForToolWindow(EventLog.LOG_TOOL_WINDOW_ID))
@@ -55,7 +55,7 @@ public class KotlinImportOptimizer() : ImportOptimizer {
private val codeStyleSettings = JetCodeStyleSettings.getInstance(file.getProject()) private val codeStyleSettings = JetCodeStyleSettings.getInstance(file.getProject())
private val aliasImports: Map<Name, FqName> private val aliasImports: Map<Name, FqName>
;{ init {
val imports = file.getImportDirectives() val imports = file.getImportDirectives()
val aliasImports = HashMap<Name, FqName>() val aliasImports = HashMap<Name, FqName>()
for (import in imports) { for (import in imports) {
@@ -43,7 +43,7 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.patterns.StandardPatterns import com.intellij.patterns.StandardPatterns
class KDocCompletionContributor(): CompletionContributor() { class KDocCompletionContributor(): CompletionContributor() {
{ init {
extend(CompletionType.BASIC, psiElement().inside(javaClass<KDocName>()), extend(CompletionType.BASIC, psiElement().inside(javaClass<KDocName>()),
KDocNameCompletionProvider) KDocNameCompletionProvider)
@@ -90,7 +90,7 @@ class TypeCandidate(val theType: JetType, scope: JetScope? = null) {
} }
} }
{ init {
val typeParametersInType = theType.getTypeParameters() val typeParametersInType = theType.getTypeParameters()
if (scope == null) { if (scope == null) {
typeParameters = typeParametersInType.copyToArray() typeParameters = typeParametersInType.copyToArray()
@@ -133,9 +133,9 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
val currentFileContext: BindingContext val currentFileContext: BindingContext
val currentFileModule: ModuleDescriptor val currentFileModule: ModuleDescriptor
private val typeCandidates = HashMap<TypeInfo, List<TypeCandidate>>(); private val typeCandidates = HashMap<TypeInfo, List<TypeCandidate>>()
{ init {
val result = config.currentFile.analyzeFullyAndGetResult() val result = config.currentFile.analyzeFullyAndGetResult()
currentFileContext = result.bindingContext currentFileContext = result.bindingContext
currentFileModule = result.moduleDescriptor currentFileModule = result.moduleDescriptor
@@ -217,7 +217,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
val substitutions: List<JetTypeSubstitution> val substitutions: List<JetTypeSubstitution>
var released: Boolean = false var released: Boolean = false
{ init {
// gather relevant information // gather relevant information
val placement = placement val placement = placement
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
private class ParameterNameExpression( private class ParameterNameExpression(
private val names: Array<String>, private val names: Array<String>,
private val parameterTypeToNamesMap: Map<String, Array<String>>) : Expression() { private val parameterTypeToNamesMap: Map<String, Array<String>>) : Expression() {
{ init {
assert(names all { it.isNotEmpty() }) assert(names all { it.isNotEmpty() })
} }
@@ -46,7 +46,7 @@ public class JetChangeSignatureData(
private val parameters: List<JetParameterInfo> private val parameters: List<JetParameterInfo>
override val receiver: JetParameterInfo? override val receiver: JetParameterInfo?
;{ init {
$receiver = createReceiverInfoIfNeeded() $receiver = createReceiverInfoIfNeeded()
val valueParameters = when { val valueParameters = when {
@@ -21,7 +21,7 @@ import com.intellij.psi.*
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
public abstract class AbstractIntroduceAction : BasePlatformRefactoringAction() { public abstract class AbstractIntroduceAction : BasePlatformRefactoringAction() {
{ init {
setInjectedContext(true) setInjectedContext(true)
} }
@@ -179,7 +179,7 @@ abstract class OutputValueBoxer(val outputValues: List<OutputValue>) {
outputValues: List<OutputValue>, outputValues: List<OutputValue>,
val module: ModuleDescriptor val module: ModuleDescriptor
) : OutputValueBoxer(outputValues) { ) : OutputValueBoxer(outputValues) {
{ init {
assert(outputValues.size() <= 3, "At most 3 output values are supported") assert(outputValues.size() <= 3, "At most 3 output values are supported")
} }
@@ -45,7 +45,7 @@ public class KotlinInplacePropertyIntroducer(
): KotlinInplaceVariableIntroducer( ): KotlinInplaceVariableIntroducer(
property, editor, project, title, JetExpression.EMPTY_ARRAY, null, false, property, false, doNotChangeVar, exprType, false property, editor, project, title, JetExpression.EMPTY_ARRAY, null, false, property, false, doNotChangeVar, exprType, false
) { ) {
{ init {
assert(availableTargets.isNotEmpty(), "No targets available: ${JetPsiUtil.getElementTextWithContext(property)}") assert(availableTargets.isNotEmpty(), "No targets available: ${JetPsiUtil.getElementTextWithContext(property)}")
} }
@@ -37,7 +37,7 @@ public open class DialogWithEditor(
) : DialogWrapper(project, true) { ) : DialogWrapper(project, true) {
val editor: Editor = createEditor() val editor: Editor = createEditor()
;{ init {
init() init()
setTitle(title) setTitle(title)
} }
@@ -30,7 +30,7 @@ import com.intellij.codeInsight.template.TemplateManager
import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.command.WriteCommandAction
public class InplaceRenameTest : LightPlatformCodeInsightTestCase() { public class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
{ init {
System.setProperty("idea.platform.prefix", "Idea") System.setProperty("idea.platform.prefix", "Idea")
} }
@@ -101,7 +101,7 @@ class DeferredElement<TResult : Element>(
private var result: TResult? = null private var result: TResult? = null
{ init {
assignNoPrototype() assignNoPrototype()
} }
@@ -125,7 +125,7 @@ class PolyadicExpression(val expressions: List<Expression>, val token: String) :
} }
class LambdaExpression(val arguments: String?, val block: Block) : Expression() { class LambdaExpression(val arguments: String?, val block: Block) : Expression() {
{ init {
assignPrototypesFrom(block) assignPrototypesFrom(block)
} }
@@ -55,7 +55,7 @@ public open class JsFunctionScope(parent: JsScope, description: String) : JsScop
private inner class LabelScope(parent: LabelScope?, val ident: String) : JsScope(parent, "Label scope for $ident", null) { private inner class LabelScope(parent: LabelScope?, val ident: String) : JsScope(parent, "Label scope for $ident", null) {
val labelName: JsName val labelName: JsName
{ init {
val freshIdent = when { val freshIdent = when {
ident in RESERVED_WORDS -> getFreshIdent(ident) ident in RESERVED_WORDS -> getFreshIdent(ident)
parent != null -> parent.getFreshIdent(ident) parent != null -> parent.getFreshIdent(ident)
@@ -70,9 +70,9 @@ public class FunctionReader(private val context: TranslationContext) {
* Maps moduleName to kotlin object variable. * Maps moduleName to kotlin object variable.
* The default variable is Kotlin, but it can be renamed by minifier. * The default variable is Kotlin, but it can be renamed by minifier.
*/ */
private val moduleKotlinVariable = hashMapOf<String, String>(); private val moduleKotlinVariable = hashMapOf<String, String>()
{ init {
val config = context.getConfig() as LibrarySourcesConfig val config = context.getConfig() as LibrarySourcesConfig
val libs = config.getLibraries().map { File(it) } val libs = config.getLibraries().map { File(it) }
val files = LibraryUtils.readJsFiles(libs.map { it.getPath() }.toList()) val files = LibraryUtils.readJsFiles(libs.map { it.getPath() }.toList())
@@ -50,9 +50,9 @@ public class DelegationTranslator(
classDeclaration.getDelegationSpecifiers().filterIsInstance<JetDelegatorByExpressionSpecifier>(); classDeclaration.getDelegationSpecifiers().filterIsInstance<JetDelegatorByExpressionSpecifier>();
private class Field (val name: String, val generateField: Boolean) private class Field (val name: String, val generateField: Boolean)
private val fields = HashMap<JetDelegatorByExpressionSpecifier, Field>(); private val fields = HashMap<JetDelegatorByExpressionSpecifier, Field>()
{ init {
for (specifier in delegationBySpecifiers) { for (specifier in delegationBySpecifiers) {
val expression = specifier.getDelegateExpression() ?: val expression = specifier.getDelegateExpression() ?:
throw IllegalArgumentException("delegate expression should not be null: ${specifier.getText()}") throw IllegalArgumentException("delegate expression should not be null: ${specifier.getText()}")
@@ -70,7 +70,7 @@ public object NumberAndCharConversionFIF : CompositeFIF() {
} }
} }
{ init {
add(USE_AS_IS!!, ConversionUnaryIntrinsic(ID)) add(USE_AS_IS!!, ConversionUnaryIntrinsic(ID))
for((stringPattern, intrinsic) in convertOperations) { for((stringPattern, intrinsic) in convertOperations) {
add(pattern(stringPattern), intrinsic) add(pattern(stringPattern), intrinsic)
@@ -186,7 +186,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
val sourcesInfo: List<SourceInfo> val sourcesInfo: List<SourceInfo>
;{ init {
val normalizedSourceDirs: List<String> = val normalizedSourceDirs: List<String> =
sourceDirs.map { file -> file.getCanonicalPath() } sourceDirs.map { file -> file.getCanonicalPath() }
@@ -214,7 +214,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
fun sourceInfoByFile(file: JetFile) = sourceInfoByFile.get(file)!! fun sourceInfoByFile(file: JetFile) = sourceInfoByFile.get(file)!!
;{ init {
/** Loads the model from the given set of source files */ /** Loads the model from the given set of source files */
val allPackageFragments = HashSet<PackageFragmentDescriptor>() val allPackageFragments = HashSet<PackageFragmentDescriptor>()
for (source in sources) { for (source in sources) {