diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index 022c163d20ce..2c6d1a56912a 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -280,6 +280,7 @@
+
@@ -1615,10 +1616,6 @@
-
-
expressions = GrIntroduceHandlerBase.collectExpressions(psiFile, editor, offset, true);
- if (expressions.isEmpty()) return;
- if (expressions.size() == 1) {
- passInner(expressions.get(0));
- }
- else {
- IntroduceTargetChooser.showChooser(editor, expressions, new Pass() {
- @Override
- public void pass(GrExpression grExpression) {
- passInner(grExpression);
- }
- }, new Function() {
- @Override
- public String fun(GrExpression grExpression) {
- return grExpression.getText();
- }
- });
- }
- }
-
- /**
- * Shows an information balloon in a reasonable place at the top right of the window.
- *
- * @param project our project
- * @param message the text, HTML markup allowed
- * @param messageType message type, changes the icon and the background.
- */
- // TODO: move to a better place
- public static void showBalloon(Project project, String message, MessageType messageType) {
- // ripped from com.intellij.openapi.vcs.changes.ui.ChangesViewBalloonProblemNotifier
- final JFrame frame = WindowManager.getInstance().getFrame(project.isDefault() ? null : project);
- if (frame == null) return;
- final JComponent component = frame.getRootPane();
- if (component == null) return;
- final Rectangle rect = component.getVisibleRect();
- final Point p = new Point(rect.x + rect.width - 10, rect.y + 10);
- final RelativePoint point = new RelativePoint(component, p);
-
- JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null)
- .setShowCallout(false).setCloseButtonEnabled(true)
- .createBalloon().show(point, Balloon.Position.atLeft);
- }
-
- public static void passInner(GrExpression expression) {
- PsiType type = expression.getType();
- String text = type == null ? "type is null" : type.getCanonicalText();
-
- showBalloon(expression.getProject(), StringUtil.escapeXml(text), MessageType.INFO);
- }
-
- @Override
- public void update(AnActionEvent e) {
- Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
- if (editor != null) {
- PsiFile psiFile = HandlerUtils.getPsiFile(editor, e.getDataContext());
- if (psiFile instanceof GroovyFile) {
- e.getPresentation().setEnabled(true);
- return;
- }
- }
- e.getPresentation().setEnabled(false);
- }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyExpressionTypeProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyExpressionTypeProvider.java
new file mode 100644
index 000000000000..0ea0544b0bb2
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyExpressionTypeProvider.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-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.plugins.groovy.codeInsight.hint;
+
+import com.intellij.lang.ExpressionTypeProvider;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
+
+import java.util.List;
+
+public class GroovyExpressionTypeProvider extends ExpressionTypeProvider {
+
+ @NotNull
+ @Override
+ public String getInformationHint(@NotNull GrExpression element) {
+ final PsiType type = element.getType();
+ return type == null ? "" : StringUtil.escapeXml(type.getCanonicalText());
+ }
+
+ @NotNull
+ @Override
+ public String getErrorHint() {
+ return "No expression found";
+ }
+
+ @NotNull
+ @Override
+ public List getExpressionsAt(@NotNull PsiElement elementAt) {
+ return GrIntroduceHandlerBase.collectExpressions(elementAt, true);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
index 3446c7f5bbe1..16f632a80c92 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
@@ -202,6 +202,11 @@ public abstract class GrIntroduceHandlerBase collectExpressions(final PsiFile file, final Editor editor, final int offset, boolean acceptVoidCalls) {
int correctedOffset = correctOffset(editor, offset);
final PsiElement elementAtCaret = file.findElementAt(correctedOffset);
+ return collectExpressions(elementAtCaret, acceptVoidCalls);
+ }
+
+ @NotNull
+ public static List collectExpressions(PsiElement elementAtCaret, boolean acceptVoidCalls) {
final List expressions = new ArrayList();
for (GrExpression expression = PsiTreeUtil.getParentOfType(elementAtCaret, GrExpression.class);