diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 875eac0e47aa..b24502ceab12 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -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, Pair, InputFilter>> myIndices = new THashMap, Pair, InputFilter>>(); private final List> myIndicesWithoutFileTypeInfo = new ArrayList>(); @@ -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> value: myFileType2IndicesWithFileTypeInfoMap.values()) { + for (List> 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(); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginUpdateInfoDialog.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginUpdateInfoDialog.java index 43d64d5feb35..7de6147a8f99 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginUpdateInfoDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginUpdateInfoDialog.java @@ -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(); diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java index 590cd2aa796c..db556615f0f2 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java @@ -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 defaultMemberFilterPromise = Promise.resolve(this); + public static final DebuggerViewSupport INSTANCE = new BasicDebuggerViewSupport(); @Nullable @@ -88,13 +90,8 @@ public class BasicDebuggerViewSupport implements DebuggerViewSupport, MemberFilt @NotNull @Override - public Promise createMemberFilter(@NotNull VariableContext context) { - return Promise.resolve(this); - } - - @Override - public boolean isMemberVisible(@NotNull Variable variable, boolean filterFunctions) { - return true; + public Promise 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) { diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java index abdd8d2aed26..9359c71a9ba2 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java @@ -54,10 +54,7 @@ public interface DebuggerViewSupport { Promise computeAdditionalObjectProperties(@NotNull ObjectValue value, @NotNull Variable variable, @NotNull VariableContext context, @NotNull XCompositeNode node); @NotNull - Promise createMemberFilter(@NotNull VariableContext context); - - @NotNull - String normalizeMemberName(@NotNull Variable variable); + Promise getMemberFilter(@NotNull VariableContext context); @Nullable Value transformErrorOnGetUsedReferenceValue(@Nullable Value value, @Nullable String error); diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilter.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilter.java index b9b60178e5ff..7d39fb8ca451 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilter.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilter.java @@ -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(); } \ No newline at end of file diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilterBase.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilterBase.java new file mode 100644 index 000000000000..8700e763acb4 --- /dev/null +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilterBase.java @@ -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 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; + } +} diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilterWithNameMappings.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilterWithNameMappings.java new file mode 100644 index 000000000000..5d97eeaebfa8 --- /dev/null +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/MemberFilterWithNameMappings.java @@ -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 rawNameToSource; + + public MemberFilterWithNameMappings(@NotNull Map 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 entry : rawNameToSource.entrySet()) { + if (entry.getValue().equals(name)) { + return entry.getKey(); + } + } + return null; + } +} diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.java index 2a932147cc5c..33c9a3f1f9cd 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/ScopeVariablesGroup.java @@ -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 promise = Variables.processScopeVariables(scope, node, context, callFrame == null); if (callFrame != null) { - promise.done(new ConsumerRunnable() { + promise.done(new ValueNodeConsumer(node) { @Override - public void run() { - if (node.isObsolete()) { - return; - } - + public void consume(Void ignored) { callFrame.getReceiverVariable().done(new Consumer() { @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() { diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContext.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContext.java index b10393fd1344..3db49cdf68ab 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContext.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContext.java @@ -23,7 +23,7 @@ public interface VariableContext { DebuggerViewSupport getViewSupport(); @NotNull - Promise createMemberFilter(); + Promise getMemberFilter(); @Nullable Scope getScope(); diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextBase.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextBase.java index 08c3986eae41..ef5792b2dadc 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextBase.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextBase.java @@ -19,8 +19,8 @@ public abstract class VariableContextBase implements VariableContext { @NotNull @Override - public Promise createMemberFilter() { - return getViewSupport().createMemberFilter(this); + public Promise getMemberFilter() { + return getViewSupport().getMemberFilter(this); } @Nullable diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextWrapper.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextWrapper.java index b67fc7ad4af1..8adda59f2310 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextWrapper.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableContextWrapper.java @@ -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> memberFilterPromise = new AtomicNotNullLazyValue>() { + @NotNull + @Override + protected Promise 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 createMemberFilter() { - return parentContext.getViewSupport().createMemberFilter(this); + public Promise getMemberFilter() { + return memberFilterPromise.getValue(); } @NotNull diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java index c955e1c78598..210c514e97a2 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java @@ -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 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 createMemberFilter() { - return context.getViewSupport().createMemberFilter(this); + public Promise 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 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> properties = value.getProperties(); - return createMemberFilter() + return getMemberFilter() .then(new ValueNodeAsyncFunction(node) { @NotNull @Override - public Promise fun(final MemberFilter memberFilter) { + public Promise fun(MemberFilter memberFilter) { + VariableView.this.memberFilter = memberFilter; return properties.then(new ValueNodeAsyncFunction, Void>(node) { @NotNull @Override public Promise fun(List 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 properties, @NotNull XCompositeNode node, @NotNull MemberFilter memberFilter) { + private void computeArrayRanges(@NotNull List properties, @NotNull XCompositeNode node) { final List 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); diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/Variables.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/Variables.java index c95d725db4f9..fee69956c3eb 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/Variables.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/Variables.java @@ -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(node) { @NotNull @Override @@ -56,13 +56,15 @@ public final class Variables { } } - Collections.sort(properties, memberFilter.hasNameMappings() ? new Comparator() { + Comparator comparator = memberFilter.hasNameMappings() ? new Comparator() { @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 sortFilterAndAddValueList(@NotNull List variables, - @NotNull XCompositeNode node, - @NotNull VariableContext context, - @NotNull MemberFilter memberFilter, - int maxChildrenToAdd, - boolean defaultIsLast) { + public static List processNamedObjectProperties(@NotNull List variables, + @NotNull XCompositeNode node, + @NotNull VariableContext context, + @NotNull MemberFilter memberFilter, + int maxChildrenToAdd, + boolean defaultIsLast) { List 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 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 variables, int from, int to, @NotNull VariableContext variableContext) { - return createVariablesList(variables, from, to, variableContext, null); - } - @NotNull public static XValueChildrenList createVariablesList(@NotNull List 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); } diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariablesGroup.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariablesGroup.java index 32f9b15288ec..3617c09f7be7 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariablesGroup.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariablesGroup.java @@ -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); } } \ No newline at end of file diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/connection/VmConnection.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/connection/VmConnection.java index 9f9debf07bee..59efe409cc7f 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/connection/VmConnection.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/connection/VmConnection.java @@ -38,10 +38,15 @@ public abstract class VmConnection 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 opened() { return opened; diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/frame/CallFrameView.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/frame/CallFrameView.java index b35f957814f3..e140c1f5f18f 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/frame/CallFrameView.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/frame/CallFrameView.java @@ -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 createMemberFilter() { - return debugProcess.createMemberFilter(this); + public Promise getMemberFilter() { + return viewSupport.getMemberFilter(this); + } + + @NotNull + public Promise getMemberFilter(@NotNull Scope scope) { + return ScopeVariablesGroup.createVariableContext(scope, this, callFrame).getMemberFilter(); } @Nullable