Add operator modifier by inspection on idea module
This commit is contained in:
+3
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* 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.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.debugger.stepping
|
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
|
return this?.textRange?.contains(element.textRange) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -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.
|
* 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 {
|
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 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 =
|
override fun defaultDeclaration(size: Expression): VariableDeclaration =
|
||||||
KotlinVariableDeclaration(this, false, type.sizedDeclaration(size.toCode()))
|
KotlinVariableDeclaration(this, false, type.sizedDeclaration(size.toCode()))
|
||||||
|
|||||||
+3
-3
@@ -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.
|
* 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
|
import com.intellij.debugger.streams.trace.impl.handler.type.ListType
|
||||||
|
|
||||||
class KotlinListVariable(override val type: ListType, name: String) : VariableImpl(type, name), ListVariable {
|
class KotlinListVariable(override val type: ListType, name: String) : VariableImpl(type, name), ListVariable {
|
||||||
override fun get(index: Expression): Expression = call("get", index)
|
override operator fun get(index: Expression): Expression = call("get", index)
|
||||||
override fun set(index: Expression, newValue: Expression): Expression = call("set", index, newValue)
|
override operator fun set(index: Expression, newValue: Expression): Expression = call("set", index, newValue)
|
||||||
override fun add(element: Expression): Expression = call("add", element)
|
override fun add(element: Expression): Expression = call("add", element)
|
||||||
|
|
||||||
override fun contains(element: Expression): Expression = call("contains", element)
|
override fun contains(element: Expression): Expression = call("contains", element)
|
||||||
|
|||||||
+3
-3
@@ -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.
|
* 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
|
import com.intellij.debugger.streams.trace.impl.handler.type.MapType
|
||||||
|
|
||||||
class KotlinMapVariable(type: MapType, name: String) : MapVariableBase(type, name) {
|
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()}")
|
TextExpression("${toCode()}[${key.toCode()}] = ${newValue.toCode()}")
|
||||||
|
|
||||||
override fun contains(key: Expression): Expression = TextExpression("(${key.toCode()} in ${toCode()})")
|
override fun contains(key: Expression): Expression = TextExpression("(${key.toCode()} in ${toCode()})")
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* 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.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.conversion.copy
|
package org.jetbrains.kotlin.idea.conversion.copy
|
||||||
@@ -35,11 +24,11 @@ class ElementAndTextList() {
|
|||||||
|
|
||||||
operator fun plusAssign(other: PsiElement) = plusAssign(other as Any)
|
operator fun plusAssign(other: PsiElement) = plusAssign(other as Any)
|
||||||
|
|
||||||
private fun plusAssign(a: Any) {
|
private operator fun plusAssign(a: Any) {
|
||||||
elementsAndTexts.add(a)
|
elementsAndTexts.add(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun plusAssign(other: Collection<PsiElement>): Unit {
|
operator fun plusAssign(other: Collection<PsiElement>) {
|
||||||
elementsAndTexts.addAll(other)
|
elementsAndTexts.addAll(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* 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.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.intentions
|
package org.jetbrains.kotlin.idea.intentions
|
||||||
@@ -46,7 +35,7 @@ interface AddValVarToConstructorParameterAction {
|
|||||||
?.takeIf { it.allowedValOrVar() || !it.isExpectDeclaration() } != null
|
?.takeIf { it.allowedValOrVar() || !it.isExpectDeclaration() } != null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun invoke(element: KtParameter, editor: Editor?) {
|
operator fun invoke(element: KtParameter, editor: Editor?) {
|
||||||
val project = element.project
|
val project = element.project
|
||||||
|
|
||||||
element.addBefore(KtPsiFactory(project).createValKeyword(), element.nameIdentifier)
|
element.addBefore(KtPsiFactory(project).createValKeyword(), element.nameIdentifier)
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* 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.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.quickfix
|
package org.jetbrains.kotlin.idea.quickfix
|
||||||
@@ -38,7 +27,7 @@ abstract class KotlinQuickFixAction<out T : PsiElement>(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
|
override fun startInWriteAction() = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* 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.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.quickfix
|
package org.jetbrains.kotlin.idea.quickfix
|
||||||
@@ -55,7 +44,7 @@ class RemoveModifierFix(
|
|||||||
invoke()
|
invoke()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun invoke() {
|
operator fun invoke() {
|
||||||
element?.removeModifier(modifier)
|
element?.removeModifier(modifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class RemoveUselessCastFix(element: KtBinaryExpressionWithTypeRHS) : KotlinQuick
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : KotlinSingleIntentionActionFactory() {
|
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<KtBinaryExpressionWithTypeRHS>? {
|
override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<KtBinaryExpressionWithTypeRHS>? {
|
||||||
val expression = diagnostic.psiElement.getNonStrictParentOfType<KtBinaryExpressionWithTypeRHS>() ?: return null
|
val expression = diagnostic.psiElement.getNonStrictParentOfType<KtBinaryExpressionWithTypeRHS>() ?: return null
|
||||||
|
|||||||
+3
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* 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.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.quickfix.replaceWith
|
package org.jetbrains.kotlin.idea.quickfix.replaceWith
|
||||||
@@ -79,7 +68,7 @@ abstract class DeprecatedSymbolUsageFixBase(
|
|||||||
invoke(strategy, project, editor)
|
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 {
|
companion object {
|
||||||
fun fetchReplaceWithPattern(
|
fun fetchReplaceWithPattern(
|
||||||
|
|||||||
@@ -42,11 +42,13 @@ abstract class AbstractPullPushMembersHandler(
|
|||||||
CommonRefactoringUtil.showErrorHint(project, editor, message, refactoringName, helpId)
|
CommonRefactoringUtil.showErrorHint(project, editor, message, refactoringName, helpId)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun invoke(project: Project,
|
protected abstract operator fun invoke(
|
||||||
editor: Editor?,
|
project: Project,
|
||||||
classOrObject: KtClassOrObject?,
|
editor: Editor?,
|
||||||
member: KtNamedDeclaration?,
|
classOrObject: KtClassOrObject?,
|
||||||
dataContext: DataContext?)
|
member: KtNamedDeclaration?,
|
||||||
|
dataContext: DataContext?
|
||||||
|
)
|
||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext?) {
|
override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext?) {
|
||||||
val offset = editor.caretModel.offset
|
val offset = editor.caretModel.offset
|
||||||
|
|||||||
+3
-3
@@ -204,9 +204,9 @@ interface KotlinIntroduceParameterHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open class KotlinIntroduceParameterHandler(
|
open class KotlinIntroduceParameterHandler(
|
||||||
val helper: KotlinIntroduceParameterHelper = KotlinIntroduceParameterHelper.Default
|
val helper: KotlinIntroduceParameterHelper = KotlinIntroduceParameterHelper.Default
|
||||||
): RefactoringActionHandler {
|
) : RefactoringActionHandler {
|
||||||
open fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) {
|
open operator fun invoke(project: Project, editor: Editor, expression: KtExpression, targetParent: KtNamedDeclaration) {
|
||||||
val physicalExpression = expression.substringContextOrThis
|
val physicalExpression = expression.substringContextOrThis
|
||||||
if (physicalExpression is KtProperty && physicalExpression.isLocal && physicalExpression.nameIdentifier == null) {
|
if (physicalExpression is KtProperty && physicalExpression.isLocal && physicalExpression.nameIdentifier == null) {
|
||||||
showErrorHintByKey(project, editor, "cannot.refactor.no.expression", INTRODUCE_PARAMETER)
|
showErrorHintByKey(project, editor, "cannot.refactor.no.expression", INTRODUCE_PARAMETER)
|
||||||
|
|||||||
Reference in New Issue
Block a user