IDEA-141082 Smart step into several lambdas - tests
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 8 Jun 2015 17:29:55 +0000 (20:29 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 8 Jun 2015 17:31:08 +0000 (20:31 +0300)
java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java

index 40fc9e5f203bf6c9e145577009883ee5071cfd2a..43b131c92c25a4f4603c7acd110e3b41a1dffb0b 100644 (file)
@@ -269,11 +269,6 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
             }
             while(true);
             final List<PsiLambdaExpression> lambdas = new ArrayList<PsiLambdaExpression>(3);
-            // add initial lambda if we're inside already
-            NavigatablePsiElement method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiLambdaExpression.class);
-            if (method instanceof PsiLambdaExpression) {
-              lambdas.add((PsiLambdaExpression)method);
-            }
             final PsiElementVisitor lambdaCollector = new JavaRecursiveElementVisitor() {
               @Override
               public void visitLambdaExpression(PsiLambdaExpression expression) {
@@ -282,6 +277,11 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
               }
             };
             element.accept(lambdaCollector);
+            // add initial lambda if we're inside already
+            NavigatablePsiElement method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiLambdaExpression.class);
+            if (method instanceof PsiLambdaExpression) {
+              lambdas.add((PsiLambdaExpression)method);
+            }
             for (PsiElement sibling = getNextElement(element); sibling != null; sibling = getNextElement(sibling)) {
               if (!lineRange.intersects(sibling.getTextRange())) {
                 break;
index 52ca25f663babb9aee70d7f7e16d4723bbcb05ab..615ed5c6519301b3429b9991ea53969ea3942dcb 100644 (file)
@@ -187,6 +187,33 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
     });
   }
 
+  protected void printContextWithText(final StackFrameContext context) {
+    ApplicationManager.getApplication().runReadAction(new Runnable() {
+      @Override
+      public void run() {
+        if (context.getFrameProxy() != null) {
+          SourcePosition sourcePosition = PositionUtil.getSourcePosition(context);
+          int offset = sourcePosition.getOffset();
+          Document document = PsiDocumentManager.getInstance(myProject).getDocument(sourcePosition.getFile());
+          CharSequence text = document.getImmutableCharSequence();
+          String positionText = "";
+          if (offset > -1) {
+            positionText = StringUtil.escapeLineBreak(" [" + text.subSequence(Math.max(0, offset - 20), offset) + "<*>"
+            + text.subSequence(offset, Math.min(offset + 20, text.length())) + "]");
+          }
+
+          println(sourcePosition.getFile().getVirtualFile().getName()
+                  + ":" + sourcePosition.getLine()
+                  + positionText,
+                  ProcessOutputTypes.SYSTEM);
+        }
+        else {
+          println("Context thread is null", ProcessOutputTypes.SYSTEM);
+        }
+      }
+    });
+  }
+
   protected void invokeRatherLater(SuspendContextImpl context, final Runnable runnable) {
     invokeRatherLater(new SuspendContextCommandImpl(context) {
       @Override