Java Code Examples for com.intellij.xdebugger.XExpression#getExpression()

The following examples show how to use com.intellij.xdebugger.XExpression#getExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XDebuggerEvaluateActionHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void showDialog(@Nonnull XDebugSession session,
                               VirtualFile file,
                               XDebuggerEditorsProvider editorsProvider,
                               XStackFrame stackFrame,
                               XDebuggerEvaluator evaluator,
                               @Nonnull XExpression expression) {
  if (expression.getLanguage() == null) {
    Language language = null;
    if (stackFrame != null) {
      XSourcePosition position = stackFrame.getSourcePosition();
      if (position != null) {
        language = LanguageUtil.getFileLanguage(position.getFile());
      }
    }
    if (language == null && file != null) {
      language = LanguageUtil.getFileTypeLanguage(file.getFileType());
    }
    expression = new XExpressionImpl(expression.getExpression(), language, expression.getCustomInfo(), expression.getMode());
  }
  new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show();
}
 
Example 2
Source File: DartVmServiceListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private String evaluateExpression(final @NotNull String isolateId,
                                  final @Nullable Frame vmTopFrame,
                                  final @Nullable XExpression xExpression) {
  final String evalText = xExpression == null ? null : xExpression.getExpression();
  if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null;

  final Ref<String> evalResult = new Ref<>();
  final Semaphore semaphore = new Semaphore();
  semaphore.down();

  myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() {
    @Override
    public void evaluated(@NotNull final XValue result) {
      if (result instanceof DartVmServiceValue) {
        evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef()));
      }
      semaphore.up();
    }

    @Override
    public void errorOccurred(@NotNull final String errorMessage) {
      evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage);
      semaphore.up();
    }
  });

  semaphore.waitFor(1000);
  return evalResult.get();
}
 
Example 3
Source File: DartVmServiceListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private String evaluateExpression(final @NotNull String isolateId,
                                  final @Nullable Frame vmTopFrame,
                                  final @Nullable XExpression xExpression) {
  final String evalText = xExpression == null ? null : xExpression.getExpression();
  if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null;

  final Ref<String> evalResult = new Ref<>();
  final Semaphore semaphore = new Semaphore();
  semaphore.down();

  myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() {
    @Override
    public void evaluated(@NotNull final XValue result) {
      if (result instanceof DartVmServiceValue) {
        evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef()));
      }
      semaphore.up();
    }

    @Override
    public void errorOccurred(@NotNull final String errorMessage) {
      evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage);
      semaphore.up();
    }
  });

  semaphore.waitFor(1000);
  return evalResult.get();
}
 
Example 4
Source File: WatchNodeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public WatchNodeImpl(@Nonnull XDebuggerTree tree,
                     @Nonnull WatchesRootNode parent,
                     @Nonnull XExpression expression,
                     @Nullable XStackFrame stackFrame) {
  super(tree, parent, expression.getExpression(), new XWatchValue(expression, tree, stackFrame));
  myExpression = expression;
}
 
Example 5
Source File: XDebuggerEditorBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setExpression(@Nullable XExpression text) {
  if (text == null) {
    text = getMode() == EvaluationMode.EXPRESSION ? XExpressionImpl.EMPTY_EXPRESSION : XExpressionImpl.EMPTY_CODE_FRAGMENT;
  }
  Language language = text.getLanguage();
  if (language == null) {
    if (myContext != null) {
      language = myContext.getLanguage();
    }
    if (language == null && mySourcePosition != null) {
      language = LanguageUtil.getFileLanguage(mySourcePosition.getFile());
    }
    if (language == null) {
      language = LanguageUtil.getFileTypeLanguage(getEditorsProvider().getFileType());
    }
    text = new XExpressionImpl(text.getExpression(), language, text.getCustomInfo(), text.getMode());
  }

  Collection<Language> languages = getSupportedLanguages();
  boolean many = languages.size() > 1;

  if (language != null) {
    myChooseFactory.setVisible(many);
  }
  myChooseFactory.setVisible(myChooseFactory.isVisible() || many);
  //myChooseFactory.setEnabled(many && languages.contains(language));

  if (language != null && language.getAssociatedFileType() != null) {
    Image fileTypeIcon = ImageEffects.layered(language.getAssociatedFileType().getIcon(), AllIcons.General.Dropdown);
    myChooseFactory.setIcon(TargetAWT.to(fileTypeIcon));
    myChooseFactory.setDisabledIcon(TargetAWT.to(ImageEffects.grayed(fileTypeIcon)));
  }

  doSetText(text);
}
 
Example 6
Source File: WeaveBreakpointHandler.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Nullable
private String getExpression(@NotNull XLineBreakpoint<XBreakpointProperties> lineBreakpoint)
{
    final XExpression conditionExpression = lineBreakpoint.getConditionExpression();
    return conditionExpression != null ? conditionExpression.getExpression() : null;
}
 
Example 7
Source File: WatchNodeImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public XWatchValue(XExpression expression, XDebuggerTree tree, XStackFrame stackFrame) {
  super(expression.getExpression());
  myExpression = expression;
  myTree = tree;
  myStackFrame = stackFrame;
}
 
Example 8
Source File: XBreakpointBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getLogExpression() {
  XExpression expression = getLogExpressionObject();
  return expression != null ? expression.getExpression() : null;
}
 
Example 9
Source File: XBreakpointBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getCondition() {
  XExpression expression = getConditionExpression();
  return expression != null ? expression.getExpression() : null;
}
 
Example 10
Source File: XExpressionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static XExpressionImpl changeMode(XExpression expression, EvaluationMode mode) {
  return new XExpressionImpl(expression.getExpression(), expression.getLanguage(), expression.getCustomInfo(), mode);
}
 
Example 11
Source File: XExpressionState.java    From consulo with Apache License 2.0 4 votes vote down vote up
public XExpressionState(boolean disabled, XExpression expression) {
  this(disabled, expression.getExpression(), expression.getLanguage() != null ? expression.getLanguage().getID() : null, expression.getCustomInfo());
}