diff --git a/java/debugger/impl/src/com/intellij/debugger/codeinsight/JavaWithRuntimeCastSurrounder.java b/java/debugger/impl/src/com/intellij/debugger/codeinsight/JavaWithRuntimeCastSurrounder.java index 08cced8c51c4..0bb24ce60dee 100644 --- a/java/debugger/impl/src/com/intellij/debugger/codeinsight/JavaWithRuntimeCastSurrounder.java +++ b/java/debugger/impl/src/com/intellij/debugger/codeinsight/JavaWithRuntimeCastSurrounder.java @@ -71,7 +71,7 @@ public class JavaWithRuntimeCastSurrounder extends JavaExpressionSurrounder { return null; } - private class SurroundWithCastWorker extends RuntimeTypeEvaluator { + private static class SurroundWithCastWorker extends RuntimeTypeEvaluator { private final Editor myEditor; public SurroundWithCastWorker(Editor editor, PsiExpression expression, DebuggerContextImpl context, final ProgressIndicator indicator) { @@ -80,7 +80,7 @@ public class JavaWithRuntimeCastSurrounder extends JavaExpressionSurrounder { } @Override - protected void typeCalculationFinished(@Nullable final PsiClass type) { + protected void typeCalculationFinished(@Nullable final PsiType type) { if (type == null) { return; } @@ -94,9 +94,9 @@ public class JavaWithRuntimeCastSurrounder extends JavaExpressionSurrounder { try { PsiElementFactory factory = JavaPsiFacade.getInstance(myElement.getProject()).getElementFactory(); PsiParenthesizedExpression parenth = - (PsiParenthesizedExpression)factory.createExpressionFromText("((" + type.getQualifiedName() + ")expr)", null); - PsiTypeCastExpression cast = (PsiTypeCastExpression)parenth.getExpression(); - cast.getOperand().replace(myElement); + (PsiParenthesizedExpression)factory.createExpressionFromText("((" + type.getCanonicalText() + ")expr)", null); + //noinspection ConstantConditions + ((PsiTypeCastExpression)parenth.getExpression()).getOperand().replace(myElement); parenth = (PsiParenthesizedExpression)JavaCodeStyleManager.getInstance(project).shortenClassReferences(parenth); PsiExpression expr = (PsiExpression)myElement.replace(parenth); TextRange range = expr.getTextRange(); diff --git a/java/debugger/impl/src/com/intellij/debugger/codeinsight/RuntimeTypeEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/codeinsight/RuntimeTypeEvaluator.java index ecb7556bf2c7..a3bf6ca1db11 100644 --- a/java/debugger/impl/src/com/intellij/debugger/codeinsight/RuntimeTypeEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/codeinsight/RuntimeTypeEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -19,6 +19,7 @@ import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.DebuggerInvocationUtil; import com.intellij.debugger.EvaluatingComputable; import com.intellij.debugger.engine.ContextUtil; +import com.intellij.debugger.engine.DebuggerUtils; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; @@ -33,7 +34,6 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; import com.sun.jdi.ClassType; import com.sun.jdi.InterfaceType; import com.sun.jdi.Type; @@ -43,13 +43,13 @@ import org.jetbrains.annotations.Nullable; /** * @author peter */ -public abstract class RuntimeTypeEvaluator extends EditorEvaluationCommand { +public abstract class RuntimeTypeEvaluator extends EditorEvaluationCommand { public RuntimeTypeEvaluator(@Nullable Editor editor, PsiElement expression, DebuggerContextImpl context, final ProgressIndicator indicator) { super(editor, expression, context, indicator); } public void threadAction() { - PsiClass type = null; + PsiType type = null; try { type = evaluate(); } @@ -62,10 +62,10 @@ public abstract class RuntimeTypeEvaluator extends EditorEvaluationCommand() { @@ -82,36 +82,37 @@ public abstract class RuntimeTypeEvaluator extends EditorEvaluationCommand nameRef = new AtomicReference(); + final AtomicReference nameRef = new AtomicReference(); final RuntimeTypeEvaluator worker = new RuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().getProgressIndicator()) { @Override - protected void typeCalculationFinished(@Nullable PsiClass type) { + protected void typeCalculationFinished(@Nullable PsiType type) { nameRef.set(type); semaphore.up(); } @@ -106,10 +106,7 @@ public class DefaultCodeFragmentFactory extends CodeFragmentFactory { ProgressManager.checkCanceled(); if (semaphore.waitFor(20)) break; } - final PsiClass psiClass = nameRef.get(); - if (psiClass != null) { - return JavaPsiFacade.getElementFactory(project).createType(psiClass); - } + return nameRef.get(); } return null; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java index fea7faf504f9..73874ef9c0be 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java @@ -219,16 +219,17 @@ public class DebuggerTreeNodeExpression { Project project = expression.getProject(); - PsiClass type = RuntimeTypeEvaluator.getCastableRuntimeType(project, value); + PsiType type = RuntimeTypeEvaluator.getCastableRuntimeType(project, value); if (type == null) { return expression; } PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); - String typeName = type.getQualifiedName(); + String typeName = type.getCanonicalText(); try { PsiParenthesizedExpression parenthExpression = (PsiParenthesizedExpression)elementFactory.createExpressionFromText( "((" + typeName + ")expression)", null); + //noinspection ConstantConditions ((PsiTypeCastExpression)parenthExpression.getExpression()).getOperand().replace(expression); Set imports = expression.getUserData(ADDITIONAL_IMPORTS_KEY); if (imports == null) {