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

The following examples show how to use com.intellij.xdebugger.XExpression#getLanguage() . 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: XDebuggerHistoryManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean addRecentExpression(@Nonnull @NonNls String id, @Nullable XExpression expression) {
  if (expression == null || StringUtil.isEmptyOrSpaces(expression.getExpression())) {
    return false;
  }

  LinkedList<XExpression> list = myRecentExpressions.get(id);
  if (list == null) {
    list = new LinkedList<XExpression>();
    myRecentExpressions.put(id, list);
  }
  if (list.size() == MAX_RECENT_EXPRESSIONS) {
    list.removeLast();
  }

  XExpression trimmedExpression = new XExpressionImpl(expression.getExpression().trim(), expression.getLanguage(), expression.getCustomInfo());
  list.remove(trimmedExpression);
  list.addFirst(trimmedExpression);
  return true;
}
 
Example 2
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 3
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 4
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 5
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());
}