| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, the Dart project authors. |
| 3 * | 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * | 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * | 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. | 12 * the License. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 package com.google.dart.tools.debug.core.dartium; | 15 package com.google.dart.tools.debug.core.dartium; |
| 16 | 16 |
| 17 import com.google.dart.tools.debug.core.webkit.WebkitCallback; | 17 import com.google.dart.tools.debug.core.webkit.WebkitCallback; |
| 18 import com.google.dart.tools.debug.core.webkit.WebkitPropertyDescriptor; | 18 import com.google.dart.tools.debug.core.webkit.WebkitPropertyDescriptor; |
| 19 import com.google.dart.tools.debug.core.webkit.WebkitRemoteObject; | 19 import com.google.dart.tools.debug.core.webkit.WebkitRemoteObject; |
| 20 import com.google.dart.tools.debug.core.webkit.WebkitResult; | 20 import com.google.dart.tools.debug.core.webkit.WebkitResult; |
| 21 | 21 |
| 22 import org.eclipse.debug.core.DebugException; | 22 import org.eclipse.debug.core.DebugException; |
| 23 import org.eclipse.debug.core.model.IIndexedValue; | 23 import org.eclipse.debug.core.model.IIndexedValue; |
| 24 import org.eclipse.debug.core.model.IVariable; | 24 import org.eclipse.debug.core.model.IVariable; |
| 25 | 25 |
| 26 import java.io.IOException; | 26 import java.io.IOException; |
| 27 import java.util.ArrayList; |
| 28 import java.util.List; |
| 27 import java.util.concurrent.CountDownLatch; | 29 import java.util.concurrent.CountDownLatch; |
| 28 import java.util.concurrent.TimeUnit; | 30 import java.util.concurrent.TimeUnit; |
| 29 | 31 |
| 30 /** | 32 /** |
| 31 * This subclass of DartiumDebugValue is used specifically for array types. The
Eclipse debugging | 33 * This subclass of DartiumDebugValue is used specifically for array types. The
Eclipse debugging |
| 32 * framework will display arrays in groups of 100 elements if it can identify wh
ich IValues are | 34 * framework will display arrays in groups of 100 elements if it can identify wh
ich IValues are |
| 33 * arrays. | 35 * arrays. |
| 34 */ | 36 */ |
| 35 public class DartiumDebugIndexedValue extends DartiumDebugValue implements IInde
xedValue { | 37 public class DartiumDebugIndexedValue extends DartiumDebugValue implements IInde
xedValue { |
| 36 | 38 |
| 37 DartiumDebugIndexedValue(DartiumDebugTarget target, DartiumDebugVariable varia
ble, | 39 DartiumDebugIndexedValue(DartiumDebugTarget target, DartiumDebugVariable varia
ble, |
| 38 WebkitRemoteObject value) { | 40 WebkitRemoteObject value) { |
| 39 super(target, variable, value); | 41 super(target, variable, value); |
| 40 } | 42 } |
| 41 | 43 |
| 42 @Override | 44 @Override |
| 43 public int getInitialOffset() { | 45 public int getInitialOffset() { |
| 44 return 0; | 46 return 0; |
| 45 } | 47 } |
| 46 | 48 |
| 47 @Override | 49 @Override |
| 48 public int getSize() throws DebugException { | 50 public int getSize() throws DebugException { |
| 49 return value.getListLength(); | 51 return value.getListLength(getTarget().getConnection()); |
| 50 } | 52 } |
| 51 | 53 |
| 52 @Override | 54 @Override |
| 53 public IVariable getVariable(int offset) throws DebugException { | 55 public IVariable getVariable(int offset) throws DebugException { |
| 54 try { | 56 try { |
| 55 WebkitRemoteObject result = getIndexAt(value, offset); | 57 WebkitRemoteObject result = getIndexAt(value, offset); |
| 56 | 58 |
| 57 if (result == null) { | 59 if (result == null) { |
| 58 result = WebkitRemoteObject.createNull(); | 60 result = WebkitRemoteObject.createNull(); |
| 59 } | 61 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 IVariable[] results = new IVariable[length]; | 73 IVariable[] results = new IVariable[length]; |
| 72 | 74 |
| 73 for (int i = 0; i < length; i++) { | 75 for (int i = 0; i < length; i++) { |
| 74 results[i] = getVariable(offset + i); | 76 results[i] = getVariable(offset + i); |
| 75 } | 77 } |
| 76 | 78 |
| 77 return results; | 79 return results; |
| 78 } | 80 } |
| 79 | 81 |
| 80 @Override | 82 @Override |
| 83 public boolean hasVariables() throws DebugException { |
| 84 return true; |
| 85 } |
| 86 |
| 87 @Override |
| 81 public boolean isListValue() { | 88 public boolean isListValue() { |
| 82 return true; | 89 return true; |
| 83 } | 90 } |
| 84 | 91 |
| 92 @Override |
| 93 protected void populate() { |
| 94 try { |
| 95 int length = value.getListLength(getTarget().getConnection()); |
| 96 |
| 97 IVariable[] variables = getVariables(0, length); |
| 98 List<IVariable> variablesList = new ArrayList<IVariable>(); |
| 99 |
| 100 for (int i = 0; i < length; i++) { |
| 101 variablesList.add(variables[i]); |
| 102 } |
| 103 |
| 104 variableCollector = VariableCollector.fixed(getTarget(), variablesList); |
| 105 } catch (DebugException e) { |
| 106 variableCollector = VariableCollector.empty(); |
| 107 } |
| 108 } |
| 109 |
| 85 private WebkitRemoteObject getIndexAt(WebkitRemoteObject listObject, int offse
t) | 110 private WebkitRemoteObject getIndexAt(WebkitRemoteObject listObject, int offse
t) |
| 86 throws IOException { | 111 throws IOException { |
| 87 final WebkitRemoteObject[] results = new WebkitRemoteObject[1]; | 112 final WebkitRemoteObject[] results = new WebkitRemoteObject[1]; |
| 88 | 113 |
| 89 final CountDownLatch latch = new CountDownLatch(1); | 114 final CountDownLatch latch = new CountDownLatch(1); |
| 90 | 115 |
| 91 getConnection().getRuntime().callFunctionOn( | 116 getConnection().getRuntime().callFunctionOn( |
| 92 listObject.getObjectId(), | 117 listObject.getObjectId(), |
| 93 "()=>this[" + offset + "]", | 118 "() => this[" + offset + "]", |
| 94 null, | 119 null, |
| 95 false, | 120 false, |
| 96 new WebkitCallback<WebkitRemoteObject>() { | 121 new WebkitCallback<WebkitRemoteObject>() { |
| 97 @Override | 122 @Override |
| 98 public void handleResult(WebkitResult<WebkitRemoteObject> result) { | 123 public void handleResult(WebkitResult<WebkitRemoteObject> result) { |
| 99 results[0] = result.getResult(); | 124 results[0] = result.getResult(); |
| 100 latch.countDown(); | 125 latch.countDown(); |
| 101 } | 126 } |
| 102 }); | 127 }); |
| 103 | 128 |
| 104 try { | 129 try { |
| 105 latch.await(3, TimeUnit.SECONDS); | 130 latch.await(3, TimeUnit.SECONDS); |
| 106 } catch (InterruptedException e) { | 131 } catch (InterruptedException e) { |
| 107 return null; | 132 return null; |
| 108 } | 133 } |
| 109 | 134 |
| 110 return results[0]; | 135 return results[0]; |
| 111 } | 136 } |
| 112 | 137 |
| 113 } | 138 } |
| OLD | NEW |