Debugger: Fix compatibility with AS 3.3
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.debugger.breakpoints
|
||||||
|
|
||||||
|
import com.intellij.debugger.engine.DebugProcessImpl
|
||||||
|
import com.intellij.openapi.progress.util.ProgressWindow
|
||||||
|
import com.intellij.xdebugger.breakpoints.XBreakpoint
|
||||||
|
import com.intellij.xdebugger.breakpoints.XBreakpointListener
|
||||||
|
|
||||||
|
object BreakpointListenerConnector {
|
||||||
|
@JvmStatic
|
||||||
|
fun subscribe(debugProcess: DebugProcessImpl, indicator: ProgressWindow, listener: XBreakpointListener<XBreakpoint<*>>) {
|
||||||
|
debugProcess.project.messageBus.connect(indicator).subscribe(XBreakpointListener.TOPIC, listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.debugger.breakpoints
|
||||||
|
|
||||||
|
import com.intellij.debugger.engine.DebugProcessImpl
|
||||||
|
import com.intellij.openapi.progress.util.ProgressWindow
|
||||||
|
import com.intellij.xdebugger.XDebuggerManager
|
||||||
|
import com.intellij.xdebugger.breakpoints.XBreakpoint
|
||||||
|
import com.intellij.xdebugger.breakpoints.XBreakpointListener
|
||||||
|
|
||||||
|
object BreakpointListenerConnector {
|
||||||
|
fun subscribe(debugProcess: DebugProcessImpl, indicator: ProgressWindow, listener: XBreakpointListener<XBreakpoint<*>>) {
|
||||||
|
XDebuggerManager.getInstance(debugProcess.project).breakpointManager.addBreakpointListener(listener, indicator)
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-3
@@ -67,6 +67,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
// This class is copied from com.intellij.debugger.ui.breakpoints.MethodBreakpoint.
|
// This class is copied from com.intellij.debugger.ui.breakpoints.MethodBreakpoint.
|
||||||
// Changed parts are marked with '// MODIFICATION: ' comments.
|
// Changed parts are marked with '// MODIFICATION: ' comments.
|
||||||
@@ -165,7 +166,7 @@ public class KotlinFunctionBreakpoint extends BreakpointWithHighlighter<JavaMeth
|
|||||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||||
RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
|
RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
|
||||||
ClassPrepareRequest request = requestsManager.createClassPrepareRequest((debuggerProcess, referenceType) -> {
|
ClassPrepareRequest request = requestsManager.createClassPrepareRequest((debuggerProcess, referenceType) -> {
|
||||||
if (DebuggerUtilsImpl.instanceOf(referenceType, baseType)) {
|
if (instanceOf(referenceType, baseType)) {
|
||||||
createRequestForPreparedClassEmulated(breakpoint, debugProcess, referenceType, false);
|
createRequestForPreparedClassEmulated(breakpoint, debugProcess, referenceType, false);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
@@ -204,7 +205,7 @@ public class KotlinFunctionBreakpoint extends BreakpointWithHighlighter<JavaMeth
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
debugProcess.getProject().getMessageBus().connect(indicator).subscribe(XBreakpointListener.TOPIC, listener);
|
BreakpointListenerConnector.subscribe(debugProcess, indicator, listener);
|
||||||
ProgressManager.getInstance().executeProcessUnderProgress(
|
ProgressManager.getInstance().executeProcessUnderProgress(
|
||||||
() -> processPreparedSubTypes(baseType,
|
() -> processPreparedSubTypes(baseType,
|
||||||
(subType, classesByName) ->
|
(subType, classesByName) ->
|
||||||
@@ -688,7 +689,7 @@ public class KotlinFunctionBreakpoint extends BreakpointWithHighlighter<JavaMeth
|
|||||||
ReferenceType type = allTypes.get(i);
|
ReferenceType type = allTypes.get(i);
|
||||||
if (type.isPrepared()) {
|
if (type.isPrepared()) {
|
||||||
try {
|
try {
|
||||||
DebuggerUtilsImpl.supertypes(type).forEach(st -> inheritance.putValue(st, type));
|
supertypes(type).forEach(st -> inheritance.putValue(st, type));
|
||||||
}
|
}
|
||||||
catch (ObjectCollectedException ignored) {
|
catch (ObjectCollectedException ignored) {
|
||||||
}
|
}
|
||||||
@@ -720,4 +721,25 @@ public class KotlinFunctionBreakpoint extends BreakpointWithHighlighter<JavaMeth
|
|||||||
progressIndicator.stop();
|
progressIndicator.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MODIFICATION: Add utilities absent in older platform versions
|
||||||
|
private static boolean instanceOf(@Nullable ReferenceType type, @NotNull ReferenceType superType) {
|
||||||
|
if (type == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (superType.equals(type)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return supertypes(type).anyMatch(t -> instanceOf(t, superType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<? extends ReferenceType> supertypes(ReferenceType type) {
|
||||||
|
if (type instanceof InterfaceType) {
|
||||||
|
return ((InterfaceType)type).superinterfaces().stream();
|
||||||
|
} else if (type instanceof ClassType) {
|
||||||
|
return StreamEx.<ReferenceType>ofNullable(((ClassType)type).superclass()).prepend(((ClassType)type).interfaces());
|
||||||
|
}
|
||||||
|
return StreamEx.empty();
|
||||||
|
}
|
||||||
|
// MODIFICATION: End
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user