Move method: showErrorHint

This commit is contained in:
Natalia.Ukhorskaya
2013-02-20 17:17:03 +04:00
parent 6b6c349a47
commit 62266a64ee
2 changed files with 15 additions and 4 deletions
@@ -1,11 +1,15 @@
package org.jetbrains.jet.plugin.codeInsight; package org.jetbrains.jet.plugin.codeInsight;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiComment; import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore; import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetBlockExpression; import org.jetbrains.jet.lang.psi.JetBlockExpression;
@@ -152,6 +156,15 @@ public class CodeInsightUtils {
return null; return null;
} }
public static void showErrorHint(
@NotNull Project project, @NotNull Editor editor,
@NotNull String message, @NotNull String title,
@Nullable String helpId
) {
if (ApplicationManager.getApplication().isUnitTestMode()) throw new RuntimeException(message);
CommonRefactoringUtil.showErrorHint(project, editor, message, title, helpId);
}
private CodeInsightUtils() { private CodeInsightUtils() {
} }
} }
@@ -49,6 +49,7 @@ import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
import org.jetbrains.jet.plugin.codeInsight.ReferenceToClassesShortening; import org.jetbrains.jet.plugin.codeInsight.ReferenceToClassesShortening;
import org.jetbrains.jet.plugin.project.AnalyzeSingleFileUtil; import org.jetbrains.jet.plugin.project.AnalyzeSingleFileUtil;
import org.jetbrains.jet.plugin.refactoring.*; import org.jetbrains.jet.plugin.refactoring.*;
@@ -568,10 +569,7 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
} }
private static void showErrorHint(Project project, Editor editor, String message) { private static void showErrorHint(Project project, Editor editor, String message) {
if (ApplicationManager.getApplication().isUnitTestMode()) throw new RuntimeException(message); CodeInsightUtils.showErrorHint(project, editor, message, INTRODUCE_VARIABLE, HelpID.INTRODUCE_VARIABLE);
CommonRefactoringUtil.showErrorHint(project, editor, message,
INTRODUCE_VARIABLE,
HelpID.INTRODUCE_VARIABLE);
} }
@Override @Override