equal
deleted
inserted
replaced
2 // Use of this source code is governed by a BSD-style license that can be |
2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. |
3 // found in the LICENSE file. |
4 |
4 |
5 package org.chromium.debug.core.model; |
5 package org.chromium.debug.core.model; |
6 |
6 |
7 import java.util.ArrayList; |
7 import java.util.Collections; |
8 import java.util.List; |
8 import java.util.Set; |
9 import java.util.SortedMap; |
|
10 |
9 |
11 import org.chromium.sdk.JsArray; |
10 import org.chromium.sdk.JsArray; |
12 import org.chromium.sdk.JsVariable; |
|
13 import org.eclipse.debug.core.DebugException; |
11 import org.eclipse.debug.core.DebugException; |
14 import org.eclipse.debug.core.model.IIndexedValue; |
12 import org.eclipse.debug.core.model.IIndexedValue; |
15 import org.eclipse.debug.core.model.IVariable; |
13 import org.eclipse.debug.core.model.IVariable; |
16 |
14 |
17 /** |
15 /** |
26 super(debugTarget, array); |
24 super(debugTarget, array); |
27 this.elements = createElements(); |
25 this.elements = createElements(); |
28 } |
26 } |
29 |
27 |
30 private IVariable[] createElements() { |
28 private IVariable[] createElements() { |
31 SortedMap<Integer, ? extends JsVariable> elements = ((JsArray) getJsValue()).toSparseArray(); |
29 JsArray jsArray = (JsArray) getJsValue(); |
32 List<IVariable> variables = new ArrayList<IVariable>(elements.size()); |
30 return StackFrame.wrapVariables(getDebugTarget(), jsArray.getProperties(), |
33 for (JsVariable jsVar : elements.values()) { |
31 ARRAY_HIDDEN_PROPERTY_NAMES, |
34 variables.add(new Variable(getDebugTarget(), jsVar, false)); |
32 // Do not show internal properties for arrays (this may be an option). |
35 } |
33 null); |
36 return variables.toArray(new IVariable[variables.size()]); |
|
37 } |
34 } |
38 |
35 |
39 public int getInitialOffset() { |
36 public int getInitialOffset() { |
40 return 0; |
37 return 0; |
41 } |
38 } |
62 @Override |
59 @Override |
63 public boolean hasVariables() throws DebugException { |
60 public boolean hasVariables() throws DebugException { |
64 return elements.length > 0; |
61 return elements.length > 0; |
65 } |
62 } |
66 |
63 |
|
64 private static final Set<String> ARRAY_HIDDEN_PROPERTY_NAMES = Collections.singleton("length"); |
67 } |
65 } |