From 2dd3e4d1fc5cbc2ace16f7caafcffa52142a3cf2 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Wed, 26 Jan 2011 12:11:14 +0300 Subject: [PATCH 1/2] IDEA-64609 Something with assertEquals and .class --- .../psi/impl/GroovyPsiElementFactoryImpl.java | 2 +- .../GrReferenceExpressionImpl.java | 50 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 36f529118600..6f8e9d3159d4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -304,7 +304,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { if (!(statement instanceof GrVariableDeclaration)) throw new IncorrectOperationException(""); GrVariableDeclaration decl = (GrVariableDeclaration) statement; final GrTypeElement element = decl.getTypeElementGroovy(); - if (element == null) throw new IncorrectOperationException(""); + if (element == null) throw new IncorrectOperationException(typeText); return element; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java index c6bc50ff0457..268e8fc0d27d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java @@ -450,13 +450,13 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements } } } - } else if (resolved == null) { + } + else if (resolved == null) { + GrExpression qualifier = getQualifierExpression(); if ("class".equals(getReferenceName())) { - result = createJavaLangClassType(JavaPsiFacade.getInstance(getProject()), (PsiClassType) JavaPsiFacade.getElementFactory(getProject()) - .createTypeFromText(getText(), this)); + result = createJavaLangClassType(JavaPsiFacade.getInstance(getProject()), getQualifierType()); } else { - GrExpression qualifier = getQualifierExpression(); if (qualifier != null) { PsiType qType = qualifier.getType(); if (qType instanceof PsiClassType) { @@ -488,7 +488,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements } @Nullable - private PsiType createJavaLangClassType(JavaPsiFacade facade, PsiClassType type) { + private PsiType createJavaLangClassType(JavaPsiFacade facade, @Nullable PsiType type) { PsiType result = null; PsiClass javaLangClass = facade.findClass(CommonClassNames.JAVA_LANG_CLASS, getResolveScope()); if (javaLangClass != null) { @@ -502,33 +502,33 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements return result; } + @Nullable + private PsiType getQualifierType() { + final GrExpression qualifier = getQualifierExpression(); + if (qualifier == null) { + final PsiNamedElement context = PsiTreeUtil.getParentOfType(this, GroovyFile.class, PsiClass.class); + PsiClass contextClass = null; + if (context instanceof PsiClass) { + contextClass = (PsiClass)context; + } + else if (context instanceof GroovyFile) contextClass = ((GroovyFile)context).getScriptClass(); + if (contextClass == null) return null; + return JavaPsiFacade.getElementFactory(getProject()).createType(contextClass); + } + else { + return qualifier.getType(); + } + } + @Nullable private PsiType getTypeForObjectGetClass(JavaPsiFacade facade, PsiMethod method) { PsiType type = PsiUtil.getSmartReturnType(method); if (type instanceof PsiClassType) { - PsiClass clazz = ((PsiClassType) type).resolve(); + PsiClass clazz = ((PsiClassType)type).resolve(); if (clazz != null && CommonClassNames.JAVA_LANG_CLASS.equals(clazz.getQualifiedName())) { PsiTypeParameter[] typeParameters = clazz.getTypeParameters(); if (typeParameters.length == 1) { - PsiClass qualifierClass = null; - GrExpression qualifier = getQualifierExpression(); - if (qualifier != null) { - PsiType qualifierType = qualifier.getType(); - if (qualifierType instanceof PsiClassType) { - qualifierClass = ((PsiClassType) qualifierType).resolve(); - } - } else { - PsiNamedElement context = PsiTreeUtil.getParentOfType(this, PsiClass.class, GroovyFile.class); - if (context instanceof PsiClass) qualifierClass = (PsiClass) context; - else if (context instanceof GroovyFile) qualifierClass = ((GroovyFile) context).getScriptClass(); - } - - PsiSubstitutor substitutor = PsiSubstitutor.EMPTY; - if (qualifierClass != null) { - PsiType t = facade.getElementFactory().createType(qualifierClass); - substitutor = substitutor.put(typeParameters[0], t); - } - return facade.getElementFactory().createType(clazz, substitutor); + return createJavaLangClassType(facade, getQualifierType()); } } } From d97d813c9dae2514f750c67085c0be6e0aeb36ef Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 26 Jan 2011 12:30:59 +0300 Subject: [PATCH 2/2] xdebugger: call processHandler.startNotify when session is started even if 'debug' tool window not opened (otherwise debug session cannot be stopped) --- .../src/com/intellij/xdebugger/impl/XDebugSessionImpl.java | 4 ---- .../src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 147c26d606b9..1d72e0b3f8a4 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -227,10 +227,6 @@ public class XDebugSessionImpl implements XDebugSession { public void showSessionTab() { RunContentDescriptor descriptor = getRunContentDescriptor(); ExecutionManager.getInstance(getProject()).getContentManager().showRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), descriptor); - ProcessHandler handler = descriptor.getProcessHandler(); - if (handler != null) { - handler.startNotify(); - } } private static > XBreakpointType getBreakpointTypeClass(final XBreakpointHandler handler) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index f07b6d15291c..cc132d1a7ecc 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -163,6 +163,8 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom if (!showToolWindowOnSuspendOnly) { session.showSessionTab(); } + ProcessHandler handler = session.getDebugProcess().getProcessHandler(); + handler.startNotify(); return session; }