mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-7986 initial web workers debugging support
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -103,6 +104,40 @@ public abstract class Promise<T> {
|
||||
return totalPromise;
|
||||
}
|
||||
|
||||
public static <T> Promise<T> any(@NotNull final Collection<Promise<T>> promises, @NotNull final String totalError) {
|
||||
if (promises.isEmpty()) {
|
||||
//noinspection unchecked
|
||||
return (Promise<T>)DONE;
|
||||
}
|
||||
else if (promises.size() == 1) {
|
||||
return ContainerUtil.getFirstItem(promises);
|
||||
}
|
||||
|
||||
final AsyncPromise<T> totalPromise = new AsyncPromise<T>();
|
||||
Consumer<T> done = new Consumer<T>() {
|
||||
@Override
|
||||
public void consume(T result) {
|
||||
totalPromise.setResult(result);
|
||||
}
|
||||
};
|
||||
Consumer<Throwable> rejected = new Consumer<Throwable>() {
|
||||
private volatile int toConsume = promises.size();
|
||||
|
||||
@Override
|
||||
public void consume(Throwable throwable) {
|
||||
if (--toConsume <= 0) {
|
||||
totalPromise.setError(totalError);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (Promise<? extends T> promise : promises) {
|
||||
promise.done(done);
|
||||
promise.rejected(rejected);
|
||||
}
|
||||
return totalPromise;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Promise<Void> wrapAsVoid(@NotNull ActionCallback asyncResult) {
|
||||
final AsyncPromise<Void> promise = new AsyncPromise<Void>();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.debugger
|
||||
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.util.Url
|
||||
import org.jetbrains.concurrency.Promise
|
||||
import java.util.*
|
||||
|
||||
@@ -31,7 +32,14 @@ interface BreakpointManager {
|
||||
val regExpBreakpointSupported: Boolean
|
||||
get() = false
|
||||
|
||||
fun setBreakpoint(target: BreakpointTarget, line: Int, column: Int = Breakpoint.EMPTY_VALUE, condition: String? = null, ignoreCount: Int = Breakpoint.EMPTY_VALUE, enabled: Boolean = true, promiseRef: Ref<Promise<out Breakpoint>>? = null): Breakpoint
|
||||
fun setBreakpoint(target: BreakpointTarget,
|
||||
line: Int,
|
||||
column: Int = Breakpoint.EMPTY_VALUE,
|
||||
url: Url? = null,
|
||||
condition: String? = null,
|
||||
ignoreCount: Int = Breakpoint.EMPTY_VALUE,
|
||||
enabled: Boolean = true,
|
||||
promiseRef: Ref<Promise<out Breakpoint>>? = null): Breakpoint
|
||||
|
||||
fun remove(breakpoint: Breakpoint): Promise<*>
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.Ref
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.util.EventDispatcher
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.Url
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import gnu.trove.TObjectHashingStrategy
|
||||
import org.jetbrains.concurrency.Promise
|
||||
@@ -47,9 +48,9 @@ abstract class BreakpointManagerBase<T : BreakpointBase<*>> : BreakpointManager
|
||||
|
||||
protected abstract fun createBreakpoint(target: BreakpointTarget, line: Int, column: Int, condition: String?, ignoreCount: Int, enabled: Boolean): T
|
||||
|
||||
protected abstract fun doSetBreakpoint(target: BreakpointTarget, breakpoint: T): Promise<out Breakpoint>
|
||||
protected abstract fun doSetBreakpoint(target: BreakpointTarget, url: Url?, breakpoint: T): Promise<out Breakpoint>
|
||||
|
||||
override final fun setBreakpoint(target: BreakpointTarget, line: Int, column: Int, condition: String?, ignoreCount: Int, enabled: Boolean, promiseRef: Ref<Promise<out Breakpoint>>?): Breakpoint {
|
||||
override fun setBreakpoint(target: BreakpointTarget, line: Int, column: Int, url: Url?, condition: String?, ignoreCount: Int, enabled: Boolean, promiseRef: Ref<Promise<out Breakpoint>>?): Breakpoint {
|
||||
val breakpoint = createBreakpoint(target, line, column, condition, ignoreCount, enabled)
|
||||
val existingBreakpoint = breakpointDuplicationByTarget.putIfAbsent(breakpoint, breakpoint)
|
||||
if (existingBreakpoint != null) {
|
||||
@@ -59,7 +60,7 @@ abstract class BreakpointManagerBase<T : BreakpointBase<*>> : BreakpointManager
|
||||
|
||||
breakpoints.add(breakpoint)
|
||||
if (enabled) {
|
||||
val promise = doSetBreakpoint(target, breakpoint)
|
||||
val promise = doSetBreakpoint(target, url, breakpoint)
|
||||
.rejected { dispatcher.multicaster.errorOccurred(breakpoint, it.message ?: it.toString()) }
|
||||
promiseRef?.set(promise)
|
||||
}
|
||||
@@ -114,7 +115,7 @@ class DummyBreakpointManager : BreakpointManager {
|
||||
override val breakpoints: Iterable<Breakpoint>
|
||||
get() = emptyList()
|
||||
|
||||
override fun setBreakpoint(target: BreakpointTarget, line: Int, column: Int, condition: String?, ignoreCount: Int, enabled: Boolean, promiseRef: Ref<Promise<out Breakpoint>>?): Breakpoint {
|
||||
override fun setBreakpoint(target: BreakpointTarget, line: Int, column: Int, url: Url?, condition: String?, ignoreCount: Int, enabled: Boolean, promiseRef: Ref<Promise<out Breakpoint>>?): Breakpoint {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
promiseRef?.set(resolvedPromise(it))
|
||||
return it
|
||||
}
|
||||
return breakpointManager.setBreakpoint(target, location.line, location.column, breakpoint?.conditionExpression?.expression, promiseRef = promiseRef)
|
||||
return breakpointManager.setBreakpoint(target, location.line, location.column, location.url, breakpoint?.conditionExpression?.expression, promiseRef = promiseRef)
|
||||
}
|
||||
|
||||
protected abstract fun createTarget(breakpoint: XLineBreakpoint<*>?, breakpointManager: BreakpointManager, location: Location, isTemporary: Boolean): BreakpointTarget
|
||||
|
||||
Reference in New Issue
Block a user