mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
jb v8 debug protocol: function scopes
This commit is contained in:
@@ -32,11 +32,8 @@ public interface ScriptManager {
|
||||
@Nullable
|
||||
Script forEachScript(@NotNull CommonProcessors.FindProcessor<Script> scriptProcessor);
|
||||
|
||||
@Nullable
|
||||
Script getScript(@NotNull FunctionValue function);
|
||||
|
||||
@NotNull
|
||||
AsyncResult<Script> getOrLoadScript(@NotNull FunctionValue function);
|
||||
AsyncResult<Script> getScript(@NotNull FunctionValue function);
|
||||
|
||||
@Nullable("if call frame script is native (at least in Google Chrome)")
|
||||
Script getScript(@NotNull CallFrame frame);
|
||||
|
||||
@@ -8,7 +8,6 @@ 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")
|
||||
@@ -57,10 +56,4 @@ 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));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.debugger.values;
|
||||
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.debugger.Scope;
|
||||
@@ -24,4 +25,11 @@ public interface FunctionValue extends ObjectValue {
|
||||
|
||||
@Nullable
|
||||
Scope[] getScopes();
|
||||
|
||||
/**
|
||||
* Method could be called (it is normal and expected) for unresolved function.
|
||||
* It must return quickly. Return {@link com.intellij.util.ThreeState#UNSURE} otherwise.
|
||||
*/
|
||||
@NotNull
|
||||
ThreeState hasScopes();
|
||||
}
|
||||
|
||||
@@ -247,15 +247,20 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
}
|
||||
}
|
||||
|
||||
remainingChildren = Variables.sortFilterAndAddValueList(variables, node, VariableView.this, maxPropertiesToShow, value.getType() != ValueType.FUNCTION);
|
||||
FunctionValue functionValue = value instanceof FunctionValue ? (FunctionValue)value : null;
|
||||
if (functionValue != null && functionValue.hasScopes() == ThreeState.NO) {
|
||||
functionValue = null;
|
||||
}
|
||||
|
||||
remainingChildren = Variables.sortFilterAndAddValueList(variables, node, VariableView.this, maxPropertiesToShow, functionValue == null);
|
||||
if (remainingChildren != null) {
|
||||
remainingChildrenOffset = maxPropertiesToShow;
|
||||
childrenModificationStamp = ((ObjectValue)value).getCacheStamp();
|
||||
}
|
||||
|
||||
if (value.getType() == ValueType.FUNCTION) {
|
||||
if (functionValue != null) {
|
||||
// we pass context as variable context instead of this variable value - we cannot watch function scopes variables, so, this variable name doesn't matter
|
||||
node.addChildren(XValueChildrenList.bottomGroup(new FunctionScopesValueGroup((FunctionValue)value, context)), true);
|
||||
node.addChildren(XValueChildrenList.bottomGroup(new FunctionScopesValueGroup(functionValue, context)), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -423,7 +428,7 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
((FunctionValue)value).resolve().doWhenDone(new Consumer<FunctionValue>() {
|
||||
@Override
|
||||
public void consume(final FunctionValue function) {
|
||||
getDebugProcess().getVm().getScriptManager().getOrLoadScript(function).doWhenDone(new Consumer<Script>() {
|
||||
getDebugProcess().getVm().getScriptManager().getScript(function).doWhenDone(new Consumer<Script>() {
|
||||
@Override
|
||||
public void consume(Script script) {
|
||||
navigatable.setSourcePosition(script == null ? null : getDebugProcess().getSourceInfo(null, script, function.getOpenParenLine(), function.getOpenParenColumn()));
|
||||
|
||||
+13
-6
@@ -1,23 +1,29 @@
|
||||
package org.jetbrains.protocolReader;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
abstract class ClassNameScheme {
|
||||
private final String suffix;
|
||||
private final String rootPackage;
|
||||
|
||||
private ClassNameScheme(String suffix, String rootPackage) {
|
||||
private ClassNameScheme(@NotNull String suffix, String rootPackage) {
|
||||
this.suffix = suffix;
|
||||
this.rootPackage = rootPackage;
|
||||
}
|
||||
|
||||
NamePath getFullName(String domainName, String baseName) {
|
||||
@NotNull
|
||||
NamePath getFullName(@NotNull String domainName, String baseName) {
|
||||
return new NamePath(getShortName(baseName), new NamePath(getPackageNameVirtual(domainName)));
|
||||
}
|
||||
|
||||
String getShortName(String baseName) {
|
||||
String getShortName(@NotNull String baseName) {
|
||||
if (baseName.endsWith("Descriptor")) {
|
||||
return baseName;
|
||||
}
|
||||
return new String(getShortNameChars(baseName));
|
||||
}
|
||||
|
||||
char[] getShortNameChars(String baseName) {
|
||||
private char[] getShortNameChars(@NotNull String baseName) {
|
||||
char[] name = new char[baseName.length() + suffix.length()];
|
||||
baseName.getChars(0, baseName.length(), name, 0);
|
||||
if (!suffix.isEmpty()) {
|
||||
@@ -39,7 +45,8 @@ abstract class ClassNameScheme {
|
||||
return getPackageName(rootPackage, domainName);
|
||||
}
|
||||
|
||||
public static String getPackageName(String rootPackage, String domain) {
|
||||
@NotNull
|
||||
public static String getPackageName(@NotNull String rootPackage, @NotNull String domain) {
|
||||
if (domain.isEmpty()) {
|
||||
return rootPackage;
|
||||
}
|
||||
@@ -47,7 +54,7 @@ abstract class ClassNameScheme {
|
||||
}
|
||||
|
||||
static class Input extends ClassNameScheme {
|
||||
Input(String suffix, String rootPackage) {
|
||||
Input(@NotNull String suffix, String rootPackage) {
|
||||
super(suffix, rootPackage);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user