/** | |
* Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
* All rights reserved. | |
* This component and the accompanying materials are made available | |
* under the terms of the License "Eclipse Public License v1.0" | |
* which accompanies this distribution, and is available | |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". | |
* | |
* Initial Contributors: | |
* Nokia Corporation - initial contribution. | |
* | |
* Contributors: | |
* | |
* Description: | |
* This enabler is necessary to get back into EDC in order to use its | |
* expression evaluator for any expression associated with a Log Action | |
* | |
*/ | |
package org.eclipse.cdt.debug.edc.internal.breakpointactions; | |
import org.eclipse.cdt.debug.core.breakpointactions.ILogActionEnabler; | |
import org.eclipse.cdt.debug.edc.internal.services.dsf.Expressions; | |
import org.eclipse.cdt.debug.edc.services.IEDCExpression; | |
import org.eclipse.cdt.dsf.datamodel.IDMContext; | |
import org.eclipse.cdt.dsf.debug.service.IFormattedValues; | |
public class EDCLogActionEnabler implements ILogActionEnabler { | |
Expressions exprService; | |
IDMContext dmContext; | |
/** | |
* @param service the expressions service used to evaluate the expression | |
* @param dmc the thread context in which to evaluate the expression | |
*/ | |
public EDCLogActionEnabler(Expressions service, IDMContext dmc) { | |
exprService = service; | |
dmContext = dmc; | |
} | |
/* (non-Javadoc) | |
* @see org.eclipse.cdt.debug.core.breakpointactions.ILogActionEnabler#evaluateExpression(java.lang.String) | |
*/ | |
public String evaluateExpression(String exprString) throws Exception { | |
IEDCExpression expression | |
= (IEDCExpression) exprService.createExpression(dmContext, exprString); | |
IFormattedValues.FormattedValueDMContext fvc | |
= exprService.getFormattedValueContext(expression, IFormattedValues.NATURAL_FORMAT); | |
return expression.getFormattedValue(fvc).getFormattedValue(); | |
} | |
} |