xdebugger api: added ability to format text selected in editor for 'Evaluate' dialog

This commit is contained in:
nik
2011-03-30 15:21:56 +04:00
parent c200e3a6c7
commit 55454371b7
2 changed files with 20 additions and 8 deletions
@@ -112,6 +112,14 @@ public abstract class XDebuggerEvaluator {
return sideEffectsAllowed ? null : getExpressionRangeAtOffset(project, document, offset);
}
/**
* Override this method to format selected text before it is shown in 'Evaluate' dialog
*/
@NotNull
public String formatTextForEvaluation(@NotNull String text) {
return text;
}
/**
* @return delay before showing value tooltip (in ms)
*/
@@ -46,24 +46,28 @@ public class XDebuggerEvaluateActionHandler extends XDebuggerSuspendedActionHand
@Nullable Project project = PlatformDataKeys.PROJECT.getData(dataContext);
@Nullable Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
String expression = editor != null ? editor.getSelectionModel().getSelectedText() : null;
String selectedText = editor != null ? editor.getSelectionModel().getSelectedText() : null;
if (selectedText != null) {
selectedText = evaluator.formatTextForEvaluation(selectedText);
}
String text = selectedText;
if (expression == null && editor != null) {
if (text == null && editor != null) {
Document document = editor.getDocument();
TextRange range = evaluator.getExpressionRangeAtOffset(project, document, editor.getCaretModel().getOffset(), true);
expression = range == null ? null : document.getText(range);
text = range == null ? null : document.getText(range);
}
if (expression == null) {
if (text == null) {
XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext);
if (value != null) {
expression = value.getEvaluationExpression();
text = value.getEvaluationExpression();
}
}
if (expression == null) {
expression = "";
if (text == null) {
text = "";
}
final XDebuggerEvaluationDialog dialog = new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression,
final XDebuggerEvaluationDialog dialog = new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, text,
stackFrame.getSourcePosition());
dialog.show();
}