diff --git a/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index 86aa8c5a314..81c841e34e9 100644 --- a/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.debugger.stepping @@ -177,7 +166,7 @@ class KotlinSteppingCommandProvider : JvmSteppingCommandProvider() { } } -private fun PsiElement?.contains(element: PsiElement): Boolean { +private operator fun PsiElement?.contains(element: PsiElement): Boolean { return this?.textRange?.contains(element.textRange) ?: false } diff --git a/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinArrayVariable.kt b/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinArrayVariable.kt index 9e675027c77..699cc2fa7d1 100644 --- a/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinArrayVariable.kt +++ b/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinArrayVariable.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -15,7 +15,7 @@ import com.intellij.debugger.streams.trace.impl.handler.type.ArrayType class KotlinArrayVariable(override val type: ArrayType, override val name: String) : VariableImpl(type, name), ArrayVariable { override fun get(index: Expression): Expression = TextExpression("$name[${index.toCode()}]!!") - override fun set(index: Expression, value: Expression): Expression = TextExpression("$name[${index.toCode()}] = ${value.toCode()}") + override operator fun set(index: Expression, value: Expression): Expression = TextExpression("$name[${index.toCode()}] = ${value.toCode()}") override fun defaultDeclaration(size: Expression): VariableDeclaration = KotlinVariableDeclaration(this, false, type.sizedDeclaration(size.toCode())) diff --git a/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinListVariable.kt b/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinListVariable.kt index 2970bc6cb4a..264229a2b3e 100644 --- a/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinListVariable.kt +++ b/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinListVariable.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -12,8 +12,8 @@ import com.intellij.debugger.streams.trace.dsl.impl.VariableImpl import com.intellij.debugger.streams.trace.impl.handler.type.ListType class KotlinListVariable(override val type: ListType, name: String) : VariableImpl(type, name), ListVariable { - override fun get(index: Expression): Expression = call("get", index) - override fun set(index: Expression, newValue: Expression): Expression = call("set", index, newValue) + override operator fun get(index: Expression): Expression = call("get", index) + override operator fun set(index: Expression, newValue: Expression): Expression = call("set", index, newValue) override fun add(element: Expression): Expression = call("add", element) override fun contains(element: Expression): Expression = call("contains", element) diff --git a/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinMapVariable.kt b/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinMapVariable.kt index 715b684a8fd..5be79a01732 100644 --- a/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinMapVariable.kt +++ b/idea/jvm-debugger/jvm-debugger-sequence/src/org/jetbrains/kotlin/idea/debugger/sequence/trace/dsl/KotlinMapVariable.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -13,9 +13,9 @@ import com.intellij.debugger.streams.trace.dsl.impl.common.MapVariableBase import com.intellij.debugger.streams.trace.impl.handler.type.MapType class KotlinMapVariable(type: MapType, name: String) : MapVariableBase(type, name) { - override fun get(key: Expression): Expression = this.call("getValue", key) + override operator fun get(key: Expression): Expression = this.call("getValue", key) - override fun set(key: Expression, newValue: Expression): Expression = + override operator fun set(key: Expression, newValue: Expression): Expression = TextExpression("${toCode()}[${key.toCode()}] = ${newValue.toCode()}") override fun contains(key: Expression): Expression = TextExpression("(${key.toCode()} in ${toCode()})") diff --git a/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ElementAndTextList.kt b/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ElementAndTextList.kt index 9f3bcfe24db..3c02003fbf2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ElementAndTextList.kt +++ b/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ElementAndTextList.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.conversion.copy @@ -35,11 +24,11 @@ class ElementAndTextList() { operator fun plusAssign(other: PsiElement) = plusAssign(other as Any) - private fun plusAssign(a: Any) { + private operator fun plusAssign(a: Any) { elementsAndTexts.add(a) } - operator fun plusAssign(other: Collection): Unit { + operator fun plusAssign(other: Collection) { elementsAndTexts.addAll(other) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddValVarToConstructorParameterAction.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddValVarToConstructorParameterAction.kt index ddb3596c510..d7e3b031721 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddValVarToConstructorParameterAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddValVarToConstructorParameterAction.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.intentions @@ -46,7 +35,7 @@ interface AddValVarToConstructorParameterAction { ?.takeIf { it.allowedValOrVar() || !it.isExpectDeclaration() } != null } - fun invoke(element: KtParameter, editor: Editor?) { + operator fun invoke(element: KtParameter, editor: Editor?) { val project = element.project element.addBefore(KtPsiFactory(project).createValKeyword(), element.nameIdentifier) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinQuickFixAction.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinQuickFixAction.kt index 20b88d006c6..659e212a0d6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinQuickFixAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinQuickFixAction.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.quickfix @@ -38,7 +27,7 @@ abstract class KotlinQuickFixAction(element: T) : QuickFixAc } } - protected abstract fun invoke(project: Project, editor: Editor?, file: KtFile) + protected abstract operator fun invoke(project: Project, editor: Editor?, file: KtFile) override fun startInWriteAction() = true } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index 68b9eacd84d..629f9946d5b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.quickfix @@ -55,7 +44,7 @@ class RemoveModifierFix( invoke() } - fun invoke() { + operator fun invoke() { element?.removeModifier(modifier) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUselessCastFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUselessCastFix.kt index 82188292a42..e9972a88002 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUselessCastFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUselessCastFix.kt @@ -25,7 +25,7 @@ class RemoveUselessCastFix(element: KtBinaryExpressionWithTypeRHS) : KotlinQuick } companion object : KotlinSingleIntentionActionFactory() { - fun invoke(element: KtBinaryExpressionWithTypeRHS) = dropEnclosingParenthesesIfPossible(element.replaced(element.left)) + operator fun invoke(element: KtBinaryExpressionWithTypeRHS) = dropEnclosingParenthesesIfPossible(element.replaced(element.left)) override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val expression = diagnostic.psiElement.getNonStrictParentOfType() ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt index e3e1390af4e..29fd348cd5d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.quickfix.replaceWith @@ -79,7 +68,7 @@ abstract class DeprecatedSymbolUsageFixBase( invoke(strategy, project, editor) } - protected abstract fun invoke(replacementStrategy: UsageReplacementStrategy, project: Project, editor: Editor?) + protected abstract operator fun invoke(replacementStrategy: UsageReplacementStrategy, project: Project, editor: Editor?) companion object { fun fetchReplaceWithPattern( diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt index 3eae651354b..3b3f715be48 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/AbstractPullPushMembersHandler.kt @@ -42,11 +42,13 @@ abstract class AbstractPullPushMembersHandler( CommonRefactoringUtil.showErrorHint(project, editor, message, refactoringName, helpId) } - protected abstract fun invoke(project: Project, - editor: Editor?, - classOrObject: KtClassOrObject?, - member: KtNamedDeclaration?, - dataContext: DataContext?) + protected abstract operator fun invoke( + project: Project, + editor: Editor?, + classOrObject: KtClassOrObject?, + member: KtNamedDeclaration?, + dataContext: DataContext? + ) override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext?) { val offset = editor.caretModel.offset diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index b4500c9c896..48d486532ac 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -204,9 +204,9 @@ interface KotlinIntroduceParameterHelper { } open class KotlinIntroduceParameterHandler( - val helper: KotlinIntroduceParameterHelper = KotlinIntroduceParameterHelper.Default -): RefactoringActionHandler { - open fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) { + val helper: KotlinIntroduceParameterHelper = KotlinIntroduceParameterHelper.Default +) : RefactoringActionHandler { + open operator fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) { val physicalExpression = expression.substringContextOrThis if (physicalExpression is KtProperty && physicalExpression.isLocal && physicalExpression.nameIdentifier == null) { showErrorHintByKey(project, editor, "cannot.refactor.no.expression", INTRODUCE_PARAMETER)