diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java index aabdc0fcb175..a9982cd41b14 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 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. @@ -24,6 +24,7 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.requests.ClassPrepareRequestor; import com.intellij.execution.filters.LineNumbersMapping; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ThreeState; import com.intellij.xdebugger.frame.XStackFrame; @@ -59,62 +60,55 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR private Cache mySourcePositionCache = new Cache(); + private interface Processor { + T process(PositionManager positionManager) throws NoDataException; + } + + private T iterate(Processor processor, T defaultValue) { + for (PositionManager positionManager : myPositionManagers) { + try { + return processor.process(positionManager); + } + catch (NoDataException ignored) {} + catch (VMDisconnectedException e) {throw e;} + catch (InternalException ignored) {} + catch (ProcessCanceledException ignored) {} + catch (Exception e) {LOG.error(e);} + catch (AssertionError e) {LOG.error(e);} + } + return defaultValue; + } + @Override - public SourcePosition getSourcePosition(Location location) { + public SourcePosition getSourcePosition(final Location location) { if (location == null) return null; SourcePosition res = mySourcePositionCache.get(location); if (res != null) return res; - for (PositionManager positionManager : myPositionManagers) { - try { - res = positionManager.getSourcePosition(location); + return iterate(new Processor() { + @Override + public SourcePosition process(PositionManager positionManager) throws NoDataException { + SourcePosition res = positionManager.getSourcePosition(location); mySourcePositionCache.put(location, res); return res; } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (InternalException ignored) { - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - return null; + }, null); } @Override @NotNull - public List getAllClasses(@NotNull SourcePosition classPosition) { - for (PositionManager positionManager : myPositionManagers) { - try { + public List getAllClasses(@NotNull final SourcePosition classPosition) { + return iterate(new Processor>() { + @Override + public List process(PositionManager positionManager) throws NoDataException { return positionManager.getAllClasses(classPosition); } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (InternalException ignored) { - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - return Collections.emptyList(); + }, Collections.emptyList()); } @Override @NotNull - public List locationsOfLine(@NotNull ReferenceType type, @NotNull SourcePosition position) { + public List locationsOfLine(@NotNull final ReferenceType type, @NotNull SourcePosition position) { VirtualFile file = position.getFile().getVirtualFile(); if (file != null) { LineNumbersMapping mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY); @@ -126,54 +120,31 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR } } - for (PositionManager positionManager : myPositionManagers) { - try { - return positionManager.locationsOfLine(type, position); + final SourcePosition finalPosition = position; + return iterate(new Processor>() { + @Override + public List process(PositionManager positionManager) throws NoDataException { + return positionManager.locationsOfLine(type, finalPosition); } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (InternalException ignored) { - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - return Collections.emptyList(); + }, Collections.emptyList()); } @Override - public ClassPrepareRequest createPrepareRequest(@NotNull ClassPrepareRequestor requestor, @NotNull SourcePosition position) { - for (PositionManager positionManager : myPositionManagers) { - try { + public ClassPrepareRequest createPrepareRequest(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) { + return iterate(new Processor() { + @Override + public ClassPrepareRequest process(PositionManager positionManager) throws NoDataException { return positionManager.createPrepareRequest(requestor, position); } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - - return null; + }, null); } @NotNull @Override - public List createPrepareRequests(@NotNull ClassPrepareRequestor requestor, @NotNull SourcePosition position) { - for (PositionManager positionManager : myPositionManagers) { - try { + public List createPrepareRequests(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) { + return iterate(new Processor>() { + @Override + public List process(PositionManager positionManager) throws NoDataException { if (positionManager instanceof MultiRequestPositionManager) { return ((MultiRequestPositionManager)positionManager).createPrepareRequests(requestor, position); } @@ -185,20 +156,7 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR return Collections.singletonList(prepareRequest); } } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - - return Collections.emptyList(); + }, Collections.emptyList()); } @Nullable diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java index 2d83c119a9bf..8c98f4f5a5e4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 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. @@ -17,6 +17,7 @@ package com.intellij.debugger.impl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.sun.jdi.VMDisconnectedException; @@ -157,6 +158,7 @@ public abstract class InvokeThread { catch (EventQueueClosedException ignored) { break; } + catch (ProcessCanceledException ignored) {} catch (RuntimeException e) { if(e.getCause() instanceof InterruptedException) { break;