author | Eugene Ostroukhov <eugeneo@symbian.org> |
Thu, 18 Mar 2010 11:56:59 -0700 | |
changeset 276 | f2f4a1259de8 |
parent 52 | f577ea64429e |
permissions | -rw-r--r-- |
2 | 1 |
// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 |
// Use of this source code is governed by a BSD-style license that can be |
|
3 |
// found in the LICENSE file. |
|
4 |
||
5 |
package org.chromium.debug.core.model; |
|
6 |
||
276
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
7 |
import java.util.Collections; |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
8 |
import java.util.Set; |
2 | 9 |
|
10 |
import org.chromium.sdk.JsArray; |
|
11 |
import org.eclipse.debug.core.DebugException; |
|
12 |
import org.eclipse.debug.core.model.IIndexedValue; |
|
13 |
import org.eclipse.debug.core.model.IVariable; |
|
14 |
||
15 |
/** |
|
16 |
* An IIndexedValue implementation for an array element range using a JsArray |
|
17 |
* instance. |
|
18 |
*/ |
|
19 |
public class ArrayValue extends Value implements IIndexedValue { |
|
20 |
||
21 |
private final IVariable[] elements; |
|
22 |
||
52
f577ea64429e
Migrated to unmodified Chromium Development Tools version
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
2
diff
changeset
|
23 |
public ArrayValue(DebugTargetImpl debugTarget, JsArray array) { |
2 | 24 |
super(debugTarget, array); |
25 |
this.elements = createElements(); |
|
26 |
} |
|
27 |
||
28 |
private IVariable[] createElements() { |
|
276
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
29 |
JsArray jsArray = (JsArray) getJsValue(); |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
30 |
return StackFrame.wrapVariables(getDebugTarget(), jsArray.getProperties(), |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
31 |
ARRAY_HIDDEN_PROPERTY_NAMES, |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
32 |
// Do not show internal properties for arrays (this may be an option). |
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
33 |
null); |
2 | 34 |
} |
35 |
||
36 |
public int getInitialOffset() { |
|
37 |
return 0; |
|
38 |
} |
|
39 |
||
40 |
public int getSize() throws DebugException { |
|
41 |
return elements.length; |
|
42 |
} |
|
43 |
||
44 |
public IVariable getVariable(int offset) throws DebugException { |
|
45 |
return elements[offset]; |
|
46 |
} |
|
47 |
||
48 |
public IVariable[] getVariables(int offset, int length) throws DebugException { |
|
49 |
IVariable[] result = new IVariable[length]; |
|
50 |
System.arraycopy(elements, offset, result, 0, length); |
|
51 |
return result; |
|
52 |
} |
|
53 |
||
54 |
@Override |
|
55 |
public IVariable[] getVariables() throws DebugException { |
|
56 |
return elements; |
|
57 |
} |
|
58 |
||
59 |
@Override |
|
60 |
public boolean hasVariables() throws DebugException { |
|
61 |
return elements.length > 0; |
|
62 |
} |
|
63 |
||
276
f2f4a1259de8
Bug 2065 - Pull updated Chrome Developer Tools into the workspace
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
52
diff
changeset
|
64 |
private static final Set<String> ARRAY_HIDDEN_PROPERTY_NAMES = Collections.singleton("length"); |
2 | 65 |
} |