Dropped inheritance from HintAction when not needed, dropped JetHintAction

This commit is contained in:
Valentin Kipyatkov
2015-10-15 22:45:39 +03:00
parent 9c6e0293ed
commit 6dbfe11afc
4 changed files with 4 additions and 48 deletions
@@ -46,15 +46,13 @@ import org.jetbrains.kotlin.types.checker.JetTypeChecker
import org.jetbrains.kotlin.types.typeUtil.supertypes
import java.util.*
class AddFunctionToSupertypeFix(element: JetNamedFunction) : JetHintAction<JetNamedFunction>(element) {
class AddFunctionToSupertypeFix(element: JetNamedFunction) : KotlinQuickFixAction<JetNamedFunction>(element) {
private val functionsToAdd = generateFunctionsToAdd(element)
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean {
return super.isAvailable(project, editor, file) && !functionsToAdd.isEmpty()
}
override fun showHint(editor: Editor) = false
override fun getText(): String {
val single = functionsToAdd.singleOrNull()
return if (single != null)
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass
import com.intellij.codeInsight.hint.HintManager
import com.intellij.codeInsight.intention.HighPriorityAction
import com.intellij.codeInspection.HintAction
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.editor.Editor
@@ -51,7 +52,7 @@ import java.util.*
/**
* Check possibility and perform fix for unresolved references.
*/
public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction<JetSimpleNameExpression>(element), HighPriorityAction {
public class AutoImportFix(element: JetSimpleNameExpression) : KotlinQuickFixAction<JetSimpleNameExpression>(element), HighPriorityAction, HintAction {
private val modificationCountOnCreate = PsiModificationTracker.SERVICE.getInstance(element.getProject()).getModificationCount()
@Volatile private var anySuggestionFound: Boolean? = null
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.idea.quickfix
import com.google.common.collect.Lists
import com.intellij.codeInsight.hint.HintManager
import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.editor.Editor
@@ -53,7 +52,7 @@ import java.util.*
class ChangeMemberFunctionSignatureFix private constructor(
element: JetNamedFunction,
private val signatures: List<ChangeMemberFunctionSignatureFix.Signature>
) : JetHintAction<JetNamedFunction>(element) {
) : KotlinQuickFixAction<JetNamedFunction>(element) {
init {
assert(signatures.isNotEmpty())
@@ -230,8 +229,6 @@ class ChangeMemberFunctionSignatureFix private constructor(
}
override fun showHint(editor: Editor) = !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)
private class MyAction(
private val project: Project,
private val editor: Editor?,
@@ -1,40 +0,0 @@
/*
* 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.
*/
package org.jetbrains.kotlin.idea.quickfix;
import com.intellij.codeInspection.HintAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
/**
* A fix with the user information hint.
*/
public abstract class JetHintAction<T extends PsiElement> extends KotlinQuickFixAction<T> implements HintAction {
public JetHintAction(@NotNull T element) {
super(element);
}
protected boolean isCaretNearRef(Editor editor, T ref) {
TextRange range = getElement().getTextRange();
int offset = editor.getCaretModel().getOffset();
return offset == range.getEndOffset();
}
}