mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
jump to source: ability to jump to native V8 script (actual only for V8 debugger protocol)
This commit is contained in:
@@ -182,7 +182,7 @@ public class AsyncResult<T> extends ActionCallback {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <R> AsyncResult<R> done(@NotNull R result) {
|
||||
public static <R> AsyncResult<R> done(@Nullable R result) {
|
||||
return new AsyncResult<R>().setDone(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,10 @@ public interface ScriptManager {
|
||||
Script forEachScript(@NotNull CommonProcessors.FindProcessor<Script> scriptProcessor);
|
||||
|
||||
@Nullable
|
||||
Script getScript(FunctionValue function);
|
||||
Script getScript(@NotNull FunctionValue function);
|
||||
|
||||
@NotNull
|
||||
AsyncResult<Script> getOrLoadScript(@NotNull FunctionValue function);
|
||||
|
||||
@Nullable("if call frame script is native (at least in Google Chrome)")
|
||||
Script getScript(CallFrame frame);
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.util.Processor;
|
||||
import com.intellij.util.Url;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.debugger.values.FunctionValue;
|
||||
|
||||
public abstract class ScriptManagerBase<SCRIPT extends ScriptBase> implements ScriptManager {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -56,4 +57,10 @@ public abstract class ScriptManagerBase<SCRIPT extends ScriptBase> implements Sc
|
||||
public static boolean isSpecial(@NotNull Url url) {
|
||||
return !url.isInLocalFileSystem() && (url.getScheme() == null || url.getScheme().equals(ScriptManager.VM_SCHEME) || url.getAuthority() == null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AsyncResult<Script> getOrLoadScript(@NotNull FunctionValue function) {
|
||||
return AsyncResult.done(getScript(function));
|
||||
}
|
||||
}
|
||||
@@ -418,10 +418,13 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
if (fun != null) {
|
||||
fun.doWhenDone(new Consumer<FunctionValue>() {
|
||||
@Override
|
||||
public void consume(FunctionValue function) {
|
||||
DebuggerViewSupport debugProcess = getDebugProcess();
|
||||
Script script = debugProcess.getVm().getScriptManager().getScript(function);
|
||||
navigatable.setSourcePosition(script == null ? null : debugProcess.getSourceInfo(null, script, function.getOpenParenLine(), function.getOpenParenColumn()));
|
||||
public void consume(final FunctionValue function) {
|
||||
getDebugProcess().getVm().getScriptManager().getOrLoadScript(function).doWhenDone(new Consumer<Script>() {
|
||||
@Override
|
||||
public void consume(Script script) {
|
||||
navigatable.setSourcePosition(script == null ? null : getDebugProcess().getSourceInfo(null, script, function.getOpenParenLine(), function.getOpenParenColumn()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+30
-2
@@ -2,6 +2,9 @@ package org.jetbrains.jsonProtocol;
|
||||
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import gnu.trove.TIntProcedure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
@@ -91,7 +94,7 @@ public abstract class OutMessage {
|
||||
}
|
||||
}
|
||||
|
||||
protected final void writeIntArray(String name, int[] value) {
|
||||
protected final void writeIntArray(@NotNull String name, @NotNull int[] value) {
|
||||
try {
|
||||
beginArguments();
|
||||
writer.name(name);
|
||||
@@ -106,7 +109,32 @@ public abstract class OutMessage {
|
||||
}
|
||||
}
|
||||
|
||||
protected final void writeIntList(String name, TIntArrayList value) {
|
||||
protected final void writeIntSet(@NotNull String name, @NotNull TIntHashSet value) {
|
||||
try {
|
||||
beginArguments();
|
||||
writer.name(name);
|
||||
writer.beginArray();
|
||||
value.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(int value) {
|
||||
try {
|
||||
writer.value(value);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
writer.endArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final void writeIntList(@NotNull String name, @NotNull TIntArrayList value) {
|
||||
try {
|
||||
beginArguments();
|
||||
writer.name(name);
|
||||
|
||||
Reference in New Issue
Block a user