mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.AppTopics;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.util.DelegatingProgressIndicator;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
@@ -78,7 +79,6 @@ import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import gnu.trove.*;
|
||||
import jsr166e.extra.SequenceLock;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -99,8 +99,9 @@ import java.util.concurrent.locks.Lock;
|
||||
*/
|
||||
public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.FileBasedIndexImpl");
|
||||
@NonNls
|
||||
private static final String CORRUPTION_MARKER_NAME = "corruption.marker";
|
||||
private static final NotificationGroup NOTIFICATIONS = new NotificationGroup("Indexing", NotificationDisplayType.BALLOON, false);
|
||||
|
||||
private final Map<ID<?, ?>, Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>> myIndices =
|
||||
new THashMap<ID<?, ?>, Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>>();
|
||||
private final List<ID<?, ?>> myIndicesWithoutFileTypeInfo = new ArrayList<ID<?, ?>>();
|
||||
@@ -265,9 +266,20 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
|
||||
private void initExtensions() {
|
||||
try {
|
||||
final FileBasedIndexExtension[] extensions = Extensions.getExtensions(FileBasedIndexExtension.EXTENSION_POINT_NAME);
|
||||
FileBasedIndexExtension[] extensions = Extensions.getExtensions(FileBasedIndexExtension.EXTENSION_POINT_NAME);
|
||||
|
||||
boolean versionChanged = false;
|
||||
for (FileBasedIndexExtension<?, ?> extension : extensions) {
|
||||
ourRebuildStatus.put(extension.getName(), new AtomicInteger(OK));
|
||||
try {
|
||||
ourRebuildStatus.put(extension.getName(), new AtomicInteger(OK));
|
||||
versionChanged |= registerIndexer(extension);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
PluginManager.handleComponentError(t, extension.getClass().getName(), null);
|
||||
}
|
||||
}
|
||||
|
||||
File indexRoot = PathManager.getIndexRoot();
|
||||
@@ -277,12 +289,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
FileUtil.deleteWithRenaming(indexRoot);
|
||||
indexRoot.mkdirs();
|
||||
}
|
||||
boolean versionChanged = false;
|
||||
for (FileBasedIndexExtension<?, ?> extension : extensions) {
|
||||
versionChanged |= registerIndexer(extension);
|
||||
}
|
||||
|
||||
for(List<ID<?, ?>> value: myFileType2IndicesWithFileTypeInfoMap.values()) {
|
||||
for (List<ID<?, ?>> value : myFileType2IndicesWithFileTypeInfoMap.values()) {
|
||||
value.addAll(myIndicesWithoutFileTypeInfo);
|
||||
}
|
||||
FileUtil.delete(corruptionMarker);
|
||||
@@ -297,8 +305,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
if (rebuildNotification != null
|
||||
&& !ApplicationManager.getApplication().isHeadlessEnvironment()
|
||||
&& Registry.is("ide.showIndexRebuildMessage")) {
|
||||
new NotificationGroup("Indexing", NotificationDisplayType.BALLOON, false)
|
||||
.createNotification("Index Rebuild", rebuildNotification, NotificationType.INFORMATION, null).notify(null);
|
||||
NOTIFICATIONS.createNotification("Index Rebuild", rebuildNotification, NotificationType.INFORMATION, null).notify(null);
|
||||
}
|
||||
|
||||
dropUnregisteredIndices();
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.plugins.PluginManagerMain;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.progress.PerformInBackgroundOption;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -76,7 +77,7 @@ class PluginUpdateInfoDialog extends AbstractUpdateDialog {
|
||||
protected void doOKAction() {
|
||||
super.doOKAction();
|
||||
|
||||
ProgressManager.getInstance().run(new Task.Modal(null, IdeBundle.message("progress.downloading.plugins"), true) {
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(null, IdeBundle.message("progress.downloading.plugins"), true, PerformInBackgroundOption.DEAF) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
UpdateChecker.saveDisabledToUpdatePlugins();
|
||||
|
||||
+5
-25
@@ -17,7 +17,9 @@ import javax.swing.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BasicDebuggerViewSupport implements DebuggerViewSupport, MemberFilter {
|
||||
public class BasicDebuggerViewSupport extends MemberFilterBase implements DebuggerViewSupport {
|
||||
protected final Promise<MemberFilter> defaultMemberFilterPromise = Promise.<MemberFilter>resolve(this);
|
||||
|
||||
public static final DebuggerViewSupport INSTANCE = new BasicDebuggerViewSupport();
|
||||
|
||||
@Nullable
|
||||
@@ -88,13 +90,8 @@ public class BasicDebuggerViewSupport implements DebuggerViewSupport, MemberFilt
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<MemberFilter> createMemberFilter(@NotNull VariableContext context) {
|
||||
return Promise.<MemberFilter>resolve(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMemberVisible(@NotNull Variable variable, boolean filterFunctions) {
|
||||
return true;
|
||||
public Promise<MemberFilter> getMemberFilter(@NotNull VariableContext context) {
|
||||
return defaultMemberFilterPromise;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -103,23 +100,6 @@ public class BasicDebuggerViewSupport implements DebuggerViewSupport, MemberFilt
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName(@NotNull Variable variable) {
|
||||
return variable.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNameMappings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String normalizeMemberName(@NotNull Variable variable) {
|
||||
return variable.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Value transformErrorOnGetUsedReferenceValue(@Nullable Value value, @Nullable String error) {
|
||||
|
||||
+1
-4
@@ -54,10 +54,7 @@ public interface DebuggerViewSupport {
|
||||
Promise<Void> computeAdditionalObjectProperties(@NotNull ObjectValue value, @NotNull Variable variable, @NotNull VariableContext context, @NotNull XCompositeNode node);
|
||||
|
||||
@NotNull
|
||||
Promise<MemberFilter> createMemberFilter(@NotNull VariableContext context);
|
||||
|
||||
@NotNull
|
||||
String normalizeMemberName(@NotNull Variable variable);
|
||||
Promise<MemberFilter> getMemberFilter(@NotNull VariableContext context);
|
||||
|
||||
@Nullable
|
||||
Value transformErrorOnGetUsedReferenceValue(@Nullable Value value, @Nullable String error);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.debugger;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -13,5 +14,8 @@ public interface MemberFilter {
|
||||
@NotNull
|
||||
String getName(@NotNull Variable variable);
|
||||
|
||||
@Nullable
|
||||
String sourceNameToRaw(@NotNull String name);
|
||||
|
||||
boolean hasNameMappings();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.jetbrains.debugger;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class MemberFilterBase implements MemberFilter {
|
||||
@Override
|
||||
public boolean isMemberVisible(@NotNull Variable variable, boolean filterFunctions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Variable> getAdditionalVariables() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNameMappings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName(@NotNull Variable variable) {
|
||||
return variable.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String sourceNameToRaw(@NotNull String name) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package org.jetbrains.debugger;
|
||||
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MemberFilterWithNameMappings extends MemberFilterBase {
|
||||
protected final Map<String, String> rawNameToSource;
|
||||
|
||||
public MemberFilterWithNameMappings(@NotNull Map<String, String> rawNameToSource) {
|
||||
this.rawNameToSource = rawNameToSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean hasNameMappings() {
|
||||
return !rawNameToSource.isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName(@NotNull Variable variable) {
|
||||
String name = variable.getName();
|
||||
return ObjectUtils.chooseNotNull(sourceNameToRaw(name), name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String sourceNameToRaw(@NotNull String name) {
|
||||
if (!hasNameMappings()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : rawNameToSource.entrySet()) {
|
||||
if (entry.getValue().equals(name)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -8,7 +8,6 @@ import com.intellij.xdebugger.frame.XValueGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.concurrency.ConsumerRunnable;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,20 +18,24 @@ public class ScopeVariablesGroup extends XValueGroup {
|
||||
|
||||
private final CallFrame callFrame;
|
||||
|
||||
public ScopeVariablesGroup(@NotNull final Scope scope, @NotNull final VariableContext context, @Nullable CallFrame callFrame) {
|
||||
public ScopeVariablesGroup(@NotNull Scope scope, @NotNull VariableContext parentContext, @Nullable CallFrame callFrame) {
|
||||
super(createScopeNodeName(scope));
|
||||
|
||||
this.scope = scope;
|
||||
context = createVariableContext(scope, parentContext, callFrame);
|
||||
this.callFrame = scope.getType() == Scope.Type.LOCAL ? callFrame : null;
|
||||
}
|
||||
|
||||
// public only for tests
|
||||
@NotNull
|
||||
public static VariableContext createVariableContext(@NotNull Scope scope, @NotNull VariableContext parentContext, @Nullable CallFrame callFrame) {
|
||||
if (callFrame == null || scope.getType() == Scope.Type.LIBRARY) {
|
||||
// functions scopes - we can watch variables only from global scope
|
||||
this.context = new ParentlessVariableContext(context, scope, scope.getType() == Scope.Type.GLOBAL);
|
||||
return new ParentlessVariableContext(parentContext, scope, scope.getType() == Scope.Type.GLOBAL);
|
||||
}
|
||||
else {
|
||||
this.context = new VariableContextWrapper(context, scope);
|
||||
return new VariableContextWrapper(parentContext, scope);
|
||||
}
|
||||
|
||||
this.callFrame = scope.getType() == Scope.Type.LOCAL ? callFrame : null;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@@ -90,18 +93,14 @@ public class ScopeVariablesGroup extends XValueGroup {
|
||||
public void computeChildren(final @NotNull XCompositeNode node) {
|
||||
Promise<Void> promise = Variables.processScopeVariables(scope, node, context, callFrame == null);
|
||||
if (callFrame != null) {
|
||||
promise.done(new ConsumerRunnable() {
|
||||
promise.done(new ValueNodeConsumer<Void>(node) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (node.isObsolete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void consume(Void ignored) {
|
||||
callFrame.getReceiverVariable().done(new Consumer<Variable>() {
|
||||
@Override
|
||||
public void consume(Variable variable) {
|
||||
if (!node.isObsolete()) {
|
||||
node.addChildren(variable == null ? XValueChildrenList.EMPTY : XValueChildrenList.singleton(CallFrameBase.RECEIVER_NAME, new VariableView(variable, context)), true);
|
||||
node.addChildren(variable == null ? XValueChildrenList.EMPTY : XValueChildrenList.singleton(new VariableView(variable, context)), true);
|
||||
}
|
||||
}
|
||||
}).rejected(new Consumer<Throwable>() {
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public interface VariableContext {
|
||||
DebuggerViewSupport getViewSupport();
|
||||
|
||||
@NotNull
|
||||
Promise<MemberFilter> createMemberFilter();
|
||||
Promise<MemberFilter> getMemberFilter();
|
||||
|
||||
@Nullable
|
||||
Scope getScope();
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@ public abstract class VariableContextBase implements VariableContext {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<MemberFilter> createMemberFilter() {
|
||||
return getViewSupport().createMemberFilter(this);
|
||||
public Promise<MemberFilter> getMemberFilter() {
|
||||
return getViewSupport().getMemberFilter(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+13
-2
@@ -1,5 +1,7 @@
|
||||
package org.jetbrains.debugger;
|
||||
|
||||
import com.intellij.openapi.util.AtomicNotNullLazyValue;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
@@ -8,6 +10,15 @@ class VariableContextWrapper implements VariableContext {
|
||||
private final VariableContext parentContext;
|
||||
private final Scope scope;
|
||||
|
||||
// it's worth to cache it (JavaScriptDebuggerViewSupport, for example, performs expensive computation)
|
||||
private final NotNullLazyValue<Promise<MemberFilter>> memberFilterPromise = new AtomicNotNullLazyValue<Promise<MemberFilter>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Promise<MemberFilter> compute() {
|
||||
return parentContext.getViewSupport().getMemberFilter(VariableContextWrapper.this);
|
||||
}
|
||||
};
|
||||
|
||||
public VariableContextWrapper(@NotNull VariableContext parentContext, @Nullable Scope scope) {
|
||||
this.parentContext = parentContext;
|
||||
this.scope = scope;
|
||||
@@ -21,8 +32,8 @@ class VariableContextWrapper implements VariableContext {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<MemberFilter> createMemberFilter() {
|
||||
return parentContext.getViewSupport().createMemberFilter(this);
|
||||
public Promise<MemberFilter> getMemberFilter() {
|
||||
return memberFilterPromise.getValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -50,14 +50,15 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
private final VariableContext context;
|
||||
|
||||
private final Variable variable;
|
||||
|
||||
private volatile Value value;
|
||||
// lazy computed
|
||||
private MemberFilter memberFilter;
|
||||
|
||||
private volatile List<Variable> remainingChildren;
|
||||
private volatile int remainingChildrenOffset;
|
||||
|
||||
public VariableView(@NotNull Variable variable, @NotNull VariableContext context) {
|
||||
this(context.getViewSupport().normalizeMemberName(variable), variable, context);
|
||||
this(variable.getName(), variable, context);
|
||||
}
|
||||
|
||||
public VariableView(@NotNull String name, @NotNull Variable variable, @NotNull VariableContext context) {
|
||||
@@ -148,8 +149,8 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<MemberFilter> createMemberFilter() {
|
||||
return context.getViewSupport().createMemberFilter(this);
|
||||
public Promise<MemberFilter> getMemberFilter() {
|
||||
return context.getViewSupport().getMemberFilter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,7 +297,7 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
if (list != null) {
|
||||
int to = Math.min(remainingChildrenOffset + XCompositeNode.MAX_CHILDREN_TO_SHOW, list.size());
|
||||
boolean isLast = to == list.size();
|
||||
node.addChildren(Variables.createVariablesList(list, remainingChildrenOffset, to, this), isLast);
|
||||
node.addChildren(Variables.createVariablesList(list, remainingChildrenOffset, to, this, memberFilter), isLast);
|
||||
if (!isLast) {
|
||||
node.tooManyChildren(list.size() - to);
|
||||
remainingChildrenOffset += XCompositeNode.MAX_CHILDREN_TO_SHOW;
|
||||
@@ -386,17 +387,18 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
private Promise<Void> computeNamedProperties(@NotNull final ObjectValue value, @NotNull final XCompositeNode node, final boolean isLastChildren) {
|
||||
// start properties loading to achieve, possibly, parallel execution (properties loading & member filter computation)
|
||||
final Promise<List<Variable>> properties = value.getProperties();
|
||||
return createMemberFilter()
|
||||
return getMemberFilter()
|
||||
.then(new ValueNodeAsyncFunction<MemberFilter, Void>(node) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<Void> fun(final MemberFilter memberFilter) {
|
||||
public Promise<Void> fun(MemberFilter memberFilter) {
|
||||
VariableView.this.memberFilter = memberFilter;
|
||||
return properties.then(new ValueNodeAsyncFunction<List<Variable>, Void>(node) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<Void> fun(List<Variable> variables) {
|
||||
if (value.getType() == ValueType.ARRAY && !(value instanceof ArrayValue)) {
|
||||
computeArrayRanges(variables, node, memberFilter);
|
||||
computeArrayRanges(variables, node);
|
||||
return Promise.DONE;
|
||||
}
|
||||
|
||||
@@ -405,8 +407,8 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
functionValue = null;
|
||||
}
|
||||
|
||||
remainingChildren =
|
||||
Variables.sortFilterAndAddValueList(variables, node, VariableView.this, memberFilter, XCompositeNode.MAX_CHILDREN_TO_SHOW, isLastChildren && functionValue == null);
|
||||
remainingChildren = Variables.processNamedObjectProperties(variables, node, VariableView.this, VariableView.this.memberFilter, XCompositeNode.MAX_CHILDREN_TO_SHOW,
|
||||
isLastChildren && functionValue == null);
|
||||
if (remainingChildren != null) {
|
||||
remainingChildrenOffset = XCompositeNode.MAX_CHILDREN_TO_SHOW;
|
||||
}
|
||||
@@ -422,7 +424,7 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
});
|
||||
}
|
||||
|
||||
private void computeArrayRanges(@NotNull List<Variable> properties, @NotNull XCompositeNode node, @NotNull MemberFilter memberFilter) {
|
||||
private void computeArrayRanges(@NotNull List<Variable> properties, @NotNull XCompositeNode node) {
|
||||
final List<Variable> variables = Variables.filterAndSort(properties, memberFilter, false);
|
||||
int count = variables.size();
|
||||
int bucketSize = XCompositeNode.MAX_CHILDREN_TO_SHOW;
|
||||
@@ -459,7 +461,8 @@ public final class VariableView extends XNamedValue implements VariableContext {
|
||||
}
|
||||
|
||||
for (int i = notGroupedVariablesOffset; i < variables.size(); i++) {
|
||||
groupList.add(new VariableView(variables.get(i), this));
|
||||
Variable variable = variables.get(i);
|
||||
groupList.add(new VariableView(memberFilter.getName(variable), variable, this));
|
||||
}
|
||||
|
||||
node.addChildren(groupList, true);
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Variables {
|
||||
@NotNull final XCompositeNode node,
|
||||
@NotNull final VariableContext context,
|
||||
final boolean isLast) {
|
||||
return context.createMemberFilter()
|
||||
return context.getMemberFilter()
|
||||
.then(new ValueNodeAsyncFunction<MemberFilter, Void>(node) {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -56,13 +56,15 @@ public final class Variables {
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(properties, memberFilter.hasNameMappings() ? new Comparator<Variable>() {
|
||||
Comparator<Variable> comparator = memberFilter.hasNameMappings() ? new Comparator<Variable>() {
|
||||
@Override
|
||||
public int compare(@NotNull Variable o1, @NotNull Variable o2) {
|
||||
return naturalCompare(memberFilter.getName(o1), memberFilter.getName(o2));
|
||||
}
|
||||
} : NATURAL_NAME_COMPARATOR);
|
||||
sort(functions);
|
||||
} : NATURAL_NAME_COMPARATOR;
|
||||
|
||||
Collections.sort(properties, comparator);
|
||||
Collections.sort(functions, comparator);
|
||||
|
||||
addAditionalVariables(variables, additionalVariables, properties, memberFilter);
|
||||
|
||||
@@ -85,12 +87,12 @@ public final class Variables {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<Variable> sortFilterAndAddValueList(@NotNull List<Variable> variables,
|
||||
@NotNull XCompositeNode node,
|
||||
@NotNull VariableContext context,
|
||||
@NotNull MemberFilter memberFilter,
|
||||
int maxChildrenToAdd,
|
||||
boolean defaultIsLast) {
|
||||
public static List<Variable> processNamedObjectProperties(@NotNull List<Variable> variables,
|
||||
@NotNull XCompositeNode node,
|
||||
@NotNull VariableContext context,
|
||||
@NotNull MemberFilter memberFilter,
|
||||
int maxChildrenToAdd,
|
||||
boolean defaultIsLast) {
|
||||
List<Variable> list = filterAndSort(variables, memberFilter, true);
|
||||
if (list.isEmpty()) {
|
||||
if (defaultIsLast) {
|
||||
@@ -101,7 +103,7 @@ public final class Variables {
|
||||
|
||||
int to = Math.min(maxChildrenToAdd, list.size());
|
||||
boolean isLast = to == list.size();
|
||||
node.addChildren(createVariablesList(list, 0, to, context), defaultIsLast && isLast);
|
||||
node.addChildren(createVariablesList(list, 0, to, context, memberFilter), defaultIsLast && isLast);
|
||||
if (isLast) {
|
||||
return null;
|
||||
}
|
||||
@@ -124,7 +126,7 @@ public final class Variables {
|
||||
result.add(variable);
|
||||
}
|
||||
}
|
||||
sort(result);
|
||||
Collections.sort(result, NATURAL_NAME_COMPARATOR);
|
||||
|
||||
addAditionalVariables(variables, additionalVariables, result, memberFilter);
|
||||
return result;
|
||||
@@ -144,10 +146,6 @@ public final class Variables {
|
||||
}
|
||||
}
|
||||
|
||||
private static void sort(@NotNull List<Variable> result) {
|
||||
Collections.sort(result, NATURAL_NAME_COMPARATOR);
|
||||
}
|
||||
|
||||
// prefixed '_' must be last, fixed case sensitive natural compare
|
||||
private static int naturalCompare(@Nullable String string1, @Nullable String string2) {
|
||||
//noinspection StringEquality
|
||||
@@ -242,38 +240,34 @@ public final class Variables {
|
||||
return createVariablesList(variables, 0, variables.size(), variableContext, memberFilter);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static XValueChildrenList createVariablesList(@NotNull List<Variable> variables, int from, int to, @NotNull VariableContext variableContext) {
|
||||
return createVariablesList(variables, from, to, variableContext, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static XValueChildrenList createVariablesList(@NotNull List<Variable> variables, int from, int to, @NotNull VariableContext variableContext, @Nullable MemberFilter memberFilter) {
|
||||
XValueChildrenList list = new XValueChildrenList(to - from);
|
||||
VariableContext getterOrSetterContext = null;
|
||||
for (int i = from; i < to; i++) {
|
||||
Variable variable = variables.get(i);
|
||||
list.add(memberFilter == null ? new VariableView(variable, variableContext) : new VariableView(memberFilter.getName(variable), variable, variableContext));
|
||||
String normalizedName = memberFilter == null ? variable.getName() : memberFilter.getName(variable);
|
||||
list.add(new VariableView(normalizedName, variable, variableContext));
|
||||
if (variable instanceof ObjectProperty) {
|
||||
ObjectProperty property = (ObjectProperty)variable;
|
||||
if (property.getGetter() != null) {
|
||||
if (getterOrSetterContext == null) {
|
||||
getterOrSetterContext = new NonWatchableVariableContext(variableContext);
|
||||
}
|
||||
list.add(new VariableView(new VariableImpl("get " + property.getName(), property.getGetter()), getterOrSetterContext));
|
||||
list.add(new VariableView(new VariableImpl("get " + normalizedName, property.getGetter()), getterOrSetterContext));
|
||||
}
|
||||
if (property.getSetter() != null) {
|
||||
if (getterOrSetterContext == null) {
|
||||
getterOrSetterContext = new NonWatchableVariableContext(variableContext);
|
||||
}
|
||||
list.add(new VariableView(new VariableImpl("set " + property.getName(), property.getSetter()), getterOrSetterContext));
|
||||
list.add(new VariableView(new VariableImpl("set " + normalizedName, property.getSetter()), getterOrSetterContext));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static class NonWatchableVariableContext extends VariableContextWrapper {
|
||||
private static final class NonWatchableVariableContext extends VariableContextWrapper {
|
||||
public NonWatchableVariableContext(VariableContext variableContext) {
|
||||
super(variableContext, null);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,6 @@ public class VariablesGroup extends XValueGroup {
|
||||
@Override
|
||||
public void computeChildren(@NotNull XCompositeNode node) {
|
||||
node.setAlreadySorted(true);
|
||||
node.addChildren(Variables.createVariablesList(variables, start, end, context), true);
|
||||
node.addChildren(Variables.createVariablesList(variables, start, end, context, null), true);
|
||||
}
|
||||
}
|
||||
+5
@@ -38,10 +38,15 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
return state.get();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void addDebugListener(@NotNull DebugEventListener listener, @NotNull Disposable parentDisposable) {
|
||||
dispatcher.addListener(listener, parentDisposable);
|
||||
}
|
||||
|
||||
public void addDebugListener(@NotNull DebugEventListener listener) {
|
||||
dispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AsyncPromise<Void> opened() {
|
||||
return opened;
|
||||
|
||||
+15
-10
@@ -12,29 +12,29 @@ import org.jetbrains.debugger.*;
|
||||
import java.util.List;
|
||||
|
||||
public final class CallFrameView extends StackFrameImplBase implements VariableContext {
|
||||
private final DebuggerViewSupport debugProcess;
|
||||
private final DebuggerViewSupport viewSupport;
|
||||
private final CallFrame callFrame;
|
||||
|
||||
private final Script script;
|
||||
|
||||
private final boolean inLibraryContent;
|
||||
|
||||
public CallFrameView(@NotNull CallFrame callFrame, @NotNull DebuggerViewSupport debugProcess, @Nullable Script script) {
|
||||
this(callFrame, debugProcess.getSourceInfo(script, callFrame), debugProcess, script);
|
||||
public CallFrameView(@NotNull CallFrame callFrame, @NotNull DebuggerViewSupport viewSupport, @Nullable Script script) {
|
||||
this(callFrame, viewSupport.getSourceInfo(script, callFrame), viewSupport, script);
|
||||
}
|
||||
|
||||
public CallFrameView(@NotNull CallFrame callFrame,
|
||||
@Nullable SourceInfo sourceInfo,
|
||||
@NotNull DebuggerViewSupport debugProcess,
|
||||
@NotNull DebuggerViewSupport viewSupport,
|
||||
@Nullable Script script) {
|
||||
super(sourceInfo);
|
||||
|
||||
this.debugProcess = debugProcess;
|
||||
this.viewSupport = viewSupport;
|
||||
this.callFrame = callFrame;
|
||||
this.script = script;
|
||||
|
||||
// isInLibraryContent call could be costly, so we compute it only once (our customizePresentation called on each repaint)
|
||||
inLibraryContent = sourceInfo != null && debugProcess.isInLibraryContent(sourceInfo, script);
|
||||
inLibraryContent = sourceInfo != null && viewSupport.isInLibraryContent(sourceInfo, script);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -50,7 +50,7 @@ public final class CallFrameView extends StackFrameImplBase implements VariableC
|
||||
|
||||
@Override
|
||||
protected XDebuggerEvaluator createEvaluator() {
|
||||
return debugProcess.createFrameEvaluator(this);
|
||||
return viewSupport.createFrameEvaluator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,13 +109,18 @@ public final class CallFrameView extends StackFrameImplBase implements VariableC
|
||||
@NotNull
|
||||
@Override
|
||||
public DebuggerViewSupport getViewSupport() {
|
||||
return debugProcess;
|
||||
return viewSupport;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Promise<MemberFilter> createMemberFilter() {
|
||||
return debugProcess.createMemberFilter(this);
|
||||
public Promise<MemberFilter> getMemberFilter() {
|
||||
return viewSupport.getMemberFilter(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Promise<MemberFilter> getMemberFilter(@NotNull Scope scope) {
|
||||
return ScopeVariablesGroup.createVariableContext(scope, this, callFrame).getMemberFilter();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user