当前位置: 首页>>代码示例>>Java>>正文


Java XDebuggerEvaluator.getExpressionRangeAtOffset方法代码示例

本文整理汇总了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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:XAddToWatchesFromEditorActionHandler.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:XQuickEvaluateHandler.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:XDebuggerEvaluateActionHandler.java


注:本文中的com.intellij.xdebugger.evaluation.XDebuggerEvaluator.getExpressionRangeAtOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。