4 |
4 |
5 package org.chromium.debug.ui; |
5 package org.chromium.debug.ui; |
6 |
6 |
7 import org.chromium.debug.core.ChromiumDebugPlugin; |
7 import org.chromium.debug.core.ChromiumDebugPlugin; |
8 import org.chromium.debug.core.model.DebugElementImpl; |
8 import org.chromium.debug.core.model.DebugElementImpl; |
9 import org.chromium.debug.core.model.StackFrame; |
9 import org.chromium.debug.core.model.EvaluateContext; |
10 import org.chromium.debug.core.model.Variable; |
10 import org.chromium.debug.core.model.Variable; |
11 import org.chromium.sdk.CallFrame; |
11 import org.chromium.sdk.JsEvaluateContext; |
12 import org.chromium.sdk.JsVariable; |
12 import org.chromium.sdk.JsVariable; |
13 import org.eclipse.core.runtime.Status; |
13 import org.eclipse.core.runtime.Status; |
14 import org.eclipse.debug.core.DebugException; |
14 import org.eclipse.debug.core.DebugException; |
15 import org.eclipse.debug.core.model.IDebugElement; |
15 import org.eclipse.debug.core.model.IDebugElement; |
16 import org.eclipse.debug.core.model.IValue; |
16 import org.eclipse.debug.core.model.IValue; |
131 return false; |
131 return false; |
132 } |
132 } |
133 }); |
133 }); |
134 return; |
134 return; |
135 } |
135 } |
136 if (!(contextImpl instanceof StackFrame)) { |
136 |
|
137 final EvaluateContext evaluateContext = |
|
138 (EvaluateContext) contextImpl.getAdapter(EvaluateContext.class); |
|
139 if (evaluateContext == null) { |
137 listener.watchEvaluationFinished(new BadWatchExpressionResult( |
140 listener.watchEvaluationFinished(new BadWatchExpressionResult( |
138 new DebugException( |
141 new DebugException( |
139 new Status(Status.ERROR, ChromiumDebugUIPlugin.PLUGIN_ID, "Bad debug context")), //$NON-NLS-1$ |
142 new Status(Status.ERROR, ChromiumDebugUIPlugin.PLUGIN_ID, "Bad debug context")), //$NON-NLS-1$ |
140 expression)); |
143 expression)); |
141 return; |
144 return; |
142 } |
145 } |
143 StackFrame stackFrame = (StackFrame) contextImpl; |
|
144 final CallFrame frame = stackFrame.getCallFrame(); |
|
145 frame.evaluateAsync(expression, new CallFrame.EvaluateCallback() { |
|
146 public void success(JsVariable variable) { |
|
147 final Variable var = new Variable(contextImpl.getDebugTarget(), variable, false); |
|
148 listener.watchEvaluationFinished(new GoodWatchExpressionResult(var, expression)); |
|
149 } |
|
150 |
146 |
151 public void failure(String message) { |
147 evaluateContext.getJsEvaluateContext().evaluateAsync( |
152 listener.watchEvaluationFinished(new BadWatchExpressionResult(new DebugException( |
148 expression, |
153 createErrorStatus(message == null |
149 new JsEvaluateContext.EvaluateCallback() { |
154 ? Messages.JsWatchExpressionDelegate_ErrorEvaluatingExpression |
150 public void success(JsVariable variable) { |
155 : message, null)), expression)); |
151 final Variable var = new Variable(contextImpl.getDebugTarget(), variable, false); |
156 return; |
152 listener.watchEvaluationFinished(new GoodWatchExpressionResult(var, expression)); |
157 } |
153 } |
158 }, |
154 |
159 null); |
155 public void failure(String message) { |
|
156 listener.watchEvaluationFinished(new BadWatchExpressionResult(new DebugException( |
|
157 createErrorStatus(message == null |
|
158 ? Messages.JsWatchExpressionDelegate_ErrorEvaluatingExpression |
|
159 : message, null)), expression)); |
|
160 return; |
|
161 } |
|
162 }, |
|
163 null); |
160 } |
164 } |
161 |
165 |
162 private static Status createErrorStatus(String message, Exception e) { |
166 private static Status createErrorStatus(String message, Exception e) { |
163 return new Status(Status.ERROR, ChromiumDebugPlugin.PLUGIN_ID, message, e); |
167 return new Status(Status.ERROR, ChromiumDebugPlugin.PLUGIN_ID, message, e); |
164 } |
168 } |