IDEA-150675 Lambda objects are rendered in an incomprehensive way

This commit is contained in:
Egor.Ushakov
2016-01-26 15:36:50 +03:00
parent 24a2e59994
commit 58de6c223e
3 changed files with 19 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -15,7 +15,7 @@
*/
package com.intellij.debugger.engine;
import com.sun.jdi.ReferenceType;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.sun.jdi.TypeComponent;
import com.sun.jdi.VirtualMachine;
@@ -30,8 +30,7 @@ public class DefaultSyntheticProvider implements SyntheticTypeComponentProvider
return false;
}
else {
ReferenceType type = typeComponent.declaringType();
if (type.name().contains("$$Lambda$")) {
if (DebuggerUtilsEx.isLambdaClassName(typeComponent.declaringType().name())) {
return true;
}
}
@@ -808,6 +808,15 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
return null;
}
public static boolean isLambdaClassName(String typeName) {
return getLambdaBaseClassName(typeName) != null;
}
@Nullable
public static String getLambdaBaseClassName(String typeName) {
return StringUtil.substringBefore(typeName, "$$Lambda$");
}
public static List<PsiLambdaExpression> collectLambdas(@NotNull SourcePosition position, final boolean onlyOnTheLine) {
ApplicationManager.getApplication().assertReadAccessAllowed();
PsiFile file = position.getFile();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -22,6 +22,7 @@ import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl;
import com.intellij.debugger.ui.impl.watch.MessageDescriptor;
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
@@ -80,6 +81,11 @@ public class ClassRenderer extends NodeRendererImpl{
if (SHOW_FQ_TYPE_NAMES) {
return typeName;
}
String baseLambdaClassName = DebuggerUtilsEx.getLambdaBaseClassName(typeName);
if (baseLambdaClassName != null) {
return renderTypeName(baseLambdaClassName) + "$lambda";
}
final int dotIndex = typeName.lastIndexOf('.');
if (dotIndex > 0) {
return typeName.substring(dotIndex + 1);