mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
xdebugger api: added ability to format text selected in editor for 'Evaluate' dialog
This commit is contained in:
@@ -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)
|
||||
*/
|
||||
|
||||
+12
-8
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user