本文整理汇总了Java中com.intellij.xdebugger.evaluation.XDebuggerEvaluator.getExpressionRangeAtOffset方法的典型用法代码示例。如果您正苦于以下问题:Java XDebuggerEvaluator.getExpressionRangeAtOffset方法的具体用法?Java XDebuggerEvaluator.getExpressionRangeAtOffset怎么用?Java XDebuggerEvaluator.getExpressionRangeAtOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.xdebugger.evaluation.XDebuggerEvaluator
的用法示例。
在下文中一共展示了XDebuggerEvaluator.getExpressionRangeAtOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTextToEvaluate
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; //导入方法依赖的package包/类
@Nullable
private static String getTextToEvaluate(DataContext dataContext, XDebugSession session) {
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
if (editor == null) {
return null;
}
String text = editor.getSelectionModel().getSelectedText();
if (text == null && session.isSuspended()) {
final XStackFrame stackFrame = session.getCurrentStackFrame();
if (stackFrame != null) {
final XDebuggerEvaluator evaluator = stackFrame.getEvaluator();
if (evaluator != null) {
final int offset = editor.getCaretModel().getOffset();
final Document document = editor.getDocument();
final TextRange textRange = evaluator.getExpressionRangeAtOffset(session.getProject(), document, offset, false);
if (textRange != null) {
text = document.getText(textRange);
}
}
}
}
return StringUtil.isEmptyOrSpaces(text) ? null : text;
}
示例2: getExpressionRange
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; //导入方法依赖的package包/类
@Nullable
private static TextRange getExpressionRange(final XDebuggerEvaluator evaluator, final Project project, final ValueHintType type, final Editor editor,
final int offset) {
SelectionModel selectionModel = editor.getSelectionModel();
int selectionStart = selectionModel.getSelectionStart();
int selectionEnd = selectionModel.getSelectionEnd();
if ((type == ValueHintType.MOUSE_CLICK_HINT || type == ValueHintType.MOUSE_ALT_OVER_HINT) && selectionModel.hasSelection()
&& selectionStart <= offset && offset <= selectionEnd) {
return new TextRange(selectionStart, selectionEnd);
}
return evaluator.getExpressionRangeAtOffset(project, editor.getDocument(), offset, false);
}
示例3: perform
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; //导入方法依赖的package包/类
protected void perform(@NotNull final XDebugSession session, final DataContext dataContext) {
XDebuggerEditorsProvider editorsProvider = session.getDebugProcess().getEditorsProvider();
XStackFrame stackFrame = session.getCurrentStackFrame();
if (stackFrame == null) return;
final XDebuggerEvaluator evaluator = stackFrame.getEvaluator();
if (evaluator == null) return;
@Nullable Project project = PlatformDataKeys.PROJECT.getData(dataContext);
@Nullable Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
String selectedText = editor != null ? editor.getSelectionModel().getSelectedText() : null;
if (selectedText != null) {
selectedText = evaluator.formatTextForEvaluation(selectedText);
}
String text = selectedText;
if (text == null && editor != null) {
Document document = editor.getDocument();
TextRange range = evaluator.getExpressionRangeAtOffset(project, document, editor.getCaretModel().getOffset(), true);
text = range == null ? null : document.getText(range);
}
if (text == null) {
XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext);
if (value != null) {
text = value.getEvaluationExpression();
}
}
if (text == null) {
text = "";
}
final XDebuggerEvaluationDialog dialog = new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, text,
stackFrame.getSourcePosition());
dialog.show();
}