allow to cancel emulated breakpoints setup
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 11 Nov 2016 13:50:41 +0000 (16:50 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 11 Nov 2016 13:52:13 +0000 (16:52 +0300)
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
resources-en/src/messages/DebuggerBundle.properties

index 491529c1c3119272f0b947d15587cb84a29b4628..509e119d1086f3307db1c786460ff176a29016d3 100644 (file)
@@ -153,7 +153,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
     ApplicationManager.getApplication().invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, myProject)));
     ProgressIndicator indicator = indicatorRef.get();
     ProgressManager.getInstance().executeProcessUnderProgress(
-      () -> processSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(debugProcess, subType, false), indicator),
+      () -> processPreparedSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(debugProcess, subType, false), indicator),
       indicator);
     if (indicator.isCanceled()) {
       ApplicationManager.getApplication().invokeLater(
@@ -539,7 +539,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
     return StreamEx.empty();
   }
 
-  private static void processSubTypes(ReferenceType classType, Consumer<ReferenceType> consumer, ProgressIndicator progressIndicator) {
+  private static void processPreparedSubTypes(ReferenceType classType, Consumer<ReferenceType> consumer, ProgressIndicator progressIndicator) {
     long start = 0;
     if (LOG.isDebugEnabled()) {
       start = System.currentTimeMillis();
@@ -547,18 +547,26 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
     progressIndicator.start();
     progressIndicator.setText(DebuggerBundle.message("label.method.breakpoints.processing.classes"));
     try {
-      progressIndicator.setIndeterminate(true);
-
       MultiMap<ReferenceType, ReferenceType> inheritance = new MultiMap<>();
-      classType.virtualMachine().allClasses().stream()
-        .filter(ReferenceType::isPrepared)
-        .forEach(type -> supertypes(type).forEach(st -> inheritance.putValue(st, type)));
+      List<ReferenceType> allTypes = classType.virtualMachine().allClasses();
+      for (int i = 0; i < allTypes.size(); i++) {
+        if (progressIndicator.isCanceled()) {
+          return;
+        }
+        ReferenceType type = allTypes.get(i);
+        if (type.isPrepared()) {
+          supertypes(type).forEach(st -> inheritance.putValue(st, type));
+        }
+        progressIndicator.setText2(i + "/" + allTypes.size());
+        progressIndicator.setFraction((double)i / allTypes.size());
+      }
       List<ReferenceType> types = StreamEx.ofTree(classType, t -> StreamEx.of(inheritance.get(t))).skip(1).toList();
 
-      progressIndicator.setIndeterminate(false);
+      progressIndicator.setText(DebuggerBundle.message("label.method.breakpoints.setting.breakpoints"));
+
       for (int i = 0; i < types.size(); i++) {
         if (progressIndicator.isCanceled()) {
-          break;
+          return;
         }
         consumer.accept(types.get(i));
 
index 362844a0eef6b4571bf5e81b3f0e09dd807f9879..17a148924d48f377d4240928950bdd9ac8463ee7 100644 (file)
@@ -390,7 +390,8 @@ error.invalid.breakpoint.bad.line.number=Line number is invalid
 line.breakpoint.display.name=Line {0}
 line.breakpoint.display.name.with.class.or.method=Line {0,number,#} in {1}
 error.invalid.breakpoint.method.not.found=Method not found in class {0}
-label.method.breakpoints.processing.classes=Processing classes for method breakpoints
+label.method.breakpoints.processing.classes=Processing classes for emulated method breakpoints
+label.method.breakpoints.setting.breakpoints=Setting emulated method breakpoints
 label.method.breakpoint.properties.panel.method.entry=Method entr&y
 label.method.breakpoint.properties.panel.method.exit=Method e&xit
 label.method.breakpoint.properties.panel.emulated=Em&ulated