IDEA-74704 Groovy 1.9: Introduce Refactorings applied to multi-catch parameter should not suggest union type

This commit is contained in:
Maxim Medvedev
2011-10-04 22:06:48 +04:00
parent 01d8597863
commit aa0cd78f2d
3 changed files with 9 additions and 1 deletions
@@ -181,6 +181,7 @@ public abstract class GroovyRefactoringUtil {
// todo add type hierarchy
public static Map<String, PsiType> getCompatibleTypeNames(@NotNull PsiType type) {
if (type instanceof PsiDisjunctionType) type = ((PsiDisjunctionType)type).getLeastUpperBound();
Map<String, PsiType> map = new LinkedHashMap<String, PsiType>();
final PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(type);
if (unboxed != null) type = unboxed;
@@ -231,13 +231,18 @@ public class GrIntroduceConstantDialog extends DialogWrapper
private void initializeTypeCombo() {
final PsiType expressionType;
PsiType expressionType;
if (myContext.expression != null) {
expressionType = myContext.expression.getType();
}
else {
expressionType = myContext.var.getDeclaredType();
}
if (expressionType instanceof PsiDisjunctionType) {
expressionType = ((PsiDisjunctionType)expressionType).getLeastUpperBound();
}
if (expressionType != null) {
myTypes = GroovyRefactoringUtil.getCompatibleTypeNames(expressionType);
for (String typeName : myTypes.keySet()) {
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.groovy.refactoring.ui;
import com.intellij.psi.PsiDisjunctionType;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
@@ -34,6 +35,7 @@ public class GrTypeComboBox extends JComboBox {
public GrTypeComboBox(PsiType type, boolean selectType) {
super();
if (type instanceof PsiDisjunctionType) type = ((PsiDisjunctionType)type).getLeastUpperBound();
myType = type;
initialize();
if (selectType && getItemCount() > 1) {