com.intellij.xdebugger.evaluation.EvaluationMode Java Examples

The following examples show how to use com.intellij.xdebugger.evaluation.EvaluationMode. 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: CppDebugProcess.java    From CppTools with Apache License 2.0 6 votes vote down vote up
@Override
public XDebuggerEditorsProvider getEditorsProvider() {
  return new XDebuggerEditorsProvider() {
    @NotNull
    @Override
    public FileType getFileType() {
      return CppSupportLoader.CPP_FILETYPE;
    }

    @NotNull
    @Override
    public Document createDocument(@NotNull Project project, @NotNull String s, @Nullable XSourcePosition xSourcePosition, @NotNull EvaluationMode evaluationMode) {
      VirtualFile virtualFile = new LightVirtualFile("dummy.cpp", s);
      ICppCodeFragment file = new CppCodeFragment(new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, true));
      return PsiDocumentManager.getInstance(project).getDocument(file);
    }
  };
}
 
Example #2
Source File: SkylarkDebuggerEditorsProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public Document createDocument(
    Project project,
    String expression,
    @Nullable XSourcePosition sourcePosition,
    EvaluationMode mode) {
  PsiElement context = null;
  if (sourcePosition != null) {
    context = getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
  }
  PsiFile codeFragment =
      createExpressionCodeFragment(project, expression, sourcePosition, context);
  Document document = PsiDocumentManager.getInstance(project).getDocument(codeFragment);
  assert document != null;
  return document;
}
 
Example #3
Source File: XDebuggerEvaluationDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void switchToMode(EvaluationMode mode, XExpression text) {
  if (myMode == mode) return;

  myMode = mode;

  if (mode == EvaluationMode.EXPRESSION) {
    text = new XExpressionImpl(StringUtil.convertLineSeparators(text.getExpression(), " "), text.getLanguage(), text.getCustomInfo());
  }

  myInputComponent = createInputComponent(mode, text);
  myMainPanel.removeAll();
  myInputComponent.addComponent(myMainPanel, myResultPanel);

  setTitle(myInputComponent.getTitle());
  mySwitchModeAction.putValue(Action.NAME, getSwitchButtonText(mode));
  getInputEditor().requestFocusInEditor();
}
 
Example #4
Source File: XDebuggerEvaluationDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private EvaluationInputComponent createInputComponent(EvaluationMode mode, XExpression text) {
  final Project project = mySession.getProject();
  text = XExpressionImpl.changeMode(text, mode);
  if (mode == EvaluationMode.EXPRESSION) {
    return new ExpressionInputComponent(project, myEditorsProvider, mySourcePosition, text, myDisposable);
  }
  else {
    return new CodeFragmentInputComponent(project, myEditorsProvider, mySourcePosition, text,
                                          getDimensionServiceKey() + ".splitter", myDisposable);
  }
}
 
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: XDebuggerEditorBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected XDebuggerEditorBase(final Project project,
                              @Nonnull XDebuggerEditorsProvider debuggerEditorsProvider,
                              @Nonnull EvaluationMode mode,
                              @Nullable @NonNls String historyId,
                              final @Nullable XSourcePosition sourcePosition) {
  myProject = project;
  myDebuggerEditorsProvider = debuggerEditorsProvider;
  myMode = mode;
  myHistoryId = historyId;
  mySourcePosition = sourcePosition;

  myChooseFactory.setToolTipText(XDebuggerBundle.message("xdebugger.evaluate.language.hint"));
  myChooseFactory.setBorder(JBUI.Borders.empty(0, 3, 0, 3));
  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent e, int clickCount) {
      if (myChooseFactory.isEnabled()) {
        ListPopup oldPopup = SoftReference.dereference(myPopup);
        if (oldPopup != null && !oldPopup.isDisposed()) {
          oldPopup.cancel();
          myPopup = null;
          return true;
        }
        ListPopup popup = createLanguagePopup();
        popup.showUnderneathOf(myChooseFactory);
        myPopup = new WeakReference<>(popup);
        return true;
      }
      return false;
    }
  }.installOn(myChooseFactory);
}
 
Example #7
Source File: XDebuggerExpressionComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
public XDebuggerExpressionComboBox(@Nonnull Project project, @Nonnull XDebuggerEditorsProvider debuggerEditorsProvider, @Nullable @NonNls String historyId,
                                   @Nullable XSourcePosition sourcePosition, boolean showEditor) {
  super(project, debuggerEditorsProvider, EvaluationMode.EXPRESSION, historyId, sourcePosition);
  myComboBox = new ComboBox<>(100);
  myComboBox.setEditable(true);
  myExpression = XExpressionImpl.EMPTY_EXPRESSION;
  Dimension minimumSize = new Dimension(myComboBox.getMinimumSize());
  minimumSize.width = 100;
  myComboBox.setMinimumSize(minimumSize);
  initEditor();
  fillComboBox();
  myComponent = showEditor ? addMultilineButton(myComboBox) : myComboBox;
}
 
Example #8
Source File: XDebuggerExpressionEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public XDebuggerExpressionEditor(Project project,
                                 @Nonnull XDebuggerEditorsProvider debuggerEditorsProvider,
                                 @Nullable @NonNls String historyId,
                                 @Nullable XSourcePosition sourcePosition,
                                 @Nonnull XExpression text,
                                 final boolean multiline,
                                 boolean editorFont,
                                 boolean showEditor) {
  super(project, debuggerEditorsProvider, multiline ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION, historyId, sourcePosition);
  myExpression = XExpressionImpl.changeMode(text, getMode());
  myEditorTextField =
          new EditorTextField(createDocument(myExpression), project, debuggerEditorsProvider.getFileType(), false, !multiline) {
            @Override
            protected EditorEx createEditor() {
              final EditorEx editor = super.createEditor();
              editor.setVerticalScrollbarVisible(multiline);
              editor.getColorsScheme().setEditorFontName(getFont().getFontName());
              editor.getColorsScheme().setEditorFontSize(getFont().getSize());
              return editor;
            }

            @Override
            public Object getData(@Nonnull Key dataId) {
              if (LangDataKeys.CONTEXT_LANGUAGES == dataId) {
                return new Language[]{myExpression.getLanguage()};
              } else if (CommonDataKeys.PSI_FILE == dataId) {
                return PsiDocumentManager.getInstance(getProject()).getPsiFile(getDocument());
              }
              return super.getData(dataId);
            }
          };
  if (editorFont) {
    myEditorTextField.setFontInheritedFromLAF(false);
    myEditorTextField.setFont(EditorUtil.getEditorFont());
  }
  myComponent = decorate(myEditorTextField, multiline, showEditor);
}
 
Example #9
Source File: XDebuggerEvaluationDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
  XExpression text = getInputEditor().getExpression();
  EvaluationMode newMode = (myMode == EvaluationMode.EXPRESSION) ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION;
  // remember only on user selection
  XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().setEvaluationDialogMode(newMode);
  switchToMode(newMode, text);
}
 
Example #10
Source File: MuleDebuggerEditorsProvider.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition xSourcePosition, @NotNull EvaluationMode evaluationMode)
{

    final PsiFile psiFile = PsiFileFactory.getInstance(project)
                                          .createFileFromText("muleExpr." + getFileType().getDefaultExtension(), getFileType(), text, LocalTimeCounter.currentTime(), true);
    return PsiDocumentManager.getInstance(project).getDocument(psiFile);
}
 
Example #11
Source File: XDebuggerEvaluationDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JButton createJButtonForAction(Action action) {
  final JButton button = super.createJButtonForAction(action);
  if (action == mySwitchModeAction) {
    int width1 = new JButton(getSwitchButtonText(EvaluationMode.EXPRESSION)).getPreferredSize().width;
    int width2 = new JButton(getSwitchButtonText(EvaluationMode.CODE_FRAGMENT)).getPreferredSize().width;
    final Dimension size = new Dimension(Math.max(width1, width2), button.getPreferredSize().height);
    button.setMinimumSize(size);
    button.setPreferredSize(size);
  }
  return button;
}
 
Example #12
Source File: WeaveDebuggerEditorsProvider.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition xSourcePosition, @NotNull EvaluationMode evaluationMode) {

    final PsiFile psiFile = PsiFileFactory.getInstance(project)
            .createFileFromText("muleExpr." + getFileType().getDefaultExtension(), getFileType(), text, LocalTimeCounter.currentTime(), true);
    return PsiDocumentManager.getInstance(project).getDocument(psiFile);
}
 
Example #13
Source File: MuleDebuggerEditorProperties.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode evaluationMode) {
    final PsiFile psiFile = PsiFileFactory.getInstance(project)
            .createFileFromText("MelExpr." + getFileType().getDefaultExtension(), getFileType(), text, LocalTimeCounter.currentTime(), true);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
    assert document != null;
    return document;
}
 
Example #14
Source File: XDebuggerEvaluationDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addToWatches() {
  if (myMode == EvaluationMode.EXPRESSION) {
    XExpression expression = getInputEditor().getExpression();
    if (!XDebuggerUtilImpl.isEmptyExpression(expression)) {
      XDebugSessionTab tab = ((XDebugSessionImpl)mySession).getSessionTab();
      if (tab != null) {
        tab.getWatchesView().addWatchExpression(expression, -1, true);
        getInputEditor().requestFocusInEditor();
      }
    }
  }
}
 
Example #15
Source File: BlazeAndroidNativeDebuggerLanguageSupport.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public Document createDocument(
    final Project project,
    final String text,
    @Nullable XSourcePosition sourcePosition,
    final EvaluationMode mode) {
  final PsiElement context = OCDebuggerTypesHelper.getContextElement(sourcePosition, project);
  if (context != null && context.getLanguage() == OCLanguage.getInstance()) {
    return new WriteAction<Document>() {
      @Override
      protected void run(Result<Document> result) {
        PsiFile fragment =
            mode == EvaluationMode.EXPRESSION
                ? OCElementFactory.expressionCodeFragment(text, project, context, true, false)
                : OCElementFactory.expressionOrStatementsCodeFragment(
                    text, project, context, true, false);
        //noinspection ConstantConditions
        result.setResult(PsiDocumentManager.getInstance(project).getDocument(fragment));
      }
    }.execute().getResultObject();
  } else {
    final LightVirtualFile plainTextFile =
        new LightVirtualFile("oc-debug-editor-when-no-source-position-available.txt", text);
    //noinspection ConstantConditions
    return FileDocumentManager.getInstance().getDocument(plainTextFile);
  }
}
 
Example #16
Source File: HaxeDebuggerEditorsProvider.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@NotNull
public Document createDocument(@NotNull final Project project,
                               @NotNull final String text, @Nullable final XSourcePosition position, @NotNull EvaluationMode mode) {
  return HaxeDebuggerSupportUtils.createDocument(
    text,
    project,
    position != null ? position.getFile() : null, position != null ? position.getOffset() : -1
  );
}
 
Example #17
Source File: XQueryEditorsProvider.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text,
                               @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode mode) {
    final PsiFile psiFile = PsiFileFactory.getInstance(project)
            .createFileFromText("XQueryExpr." + fileType.getDefaultExtension(), fileType, text,
                    LocalTimeCounter.currentTime(), true);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
    assert document != null;
    return document;
}
 
Example #18
Source File: XValue.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Asynchronously calculates expression which evaluates to the current value
 */
@Nonnull
public AsyncResult<XExpression> calculateEvaluationExpression() {
  String expression = getEvaluationExpression();
  XExpression res =
          expression != null ? XDebuggerUtil.getInstance().createExpression(expression, null, null, EvaluationMode.EXPRESSION) : null;
  return AsyncResult.done(res);
}
 
Example #19
Source File: XDebuggerUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public abstract XExpression createExpression(@Nonnull String text, Language language, String custom, EvaluationMode mode);
 
Example #20
Source File: XDebuggerEditorBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public EvaluationMode getMode() {
  return myMode;
}
 
Example #21
Source File: XDebuggerEvaluationDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String getSwitchButtonText(EvaluationMode mode) {
  return mode != EvaluationMode.EXPRESSION
         ? XDebuggerBundle.message("button.text.expression.mode")
         : XDebuggerBundle.message("button.text.code.fragment.mode");
}
 
Example #22
Source File: XExpressionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public XExpressionImpl(@Nonnull String expression, Language language, String customInfo) {
  this(expression, language, customInfo, EvaluationMode.EXPRESSION);
}
 
Example #23
Source File: XExpressionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public XExpressionImpl(@Nonnull String expression, Language language, String customInfo, EvaluationMode mode) {
  myExpression = expression;
  myLanguage = language;
  myCustomInfo = customInfo;
  myMode = mode;
}
 
Example #24
Source File: XExpressionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public EvaluationMode getMode() {
  return myMode;
}
 
Example #25
Source File: XExpressionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static XExpressionImpl fromText(@Nullable String text) {
  return text != null ? new XExpressionImpl(text, null, null, EvaluationMode.EXPRESSION) : null;
}
 
Example #26
Source File: XExpressionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static XExpressionImpl fromText(@Nullable String text, EvaluationMode mode) {
  return text != null ? new XExpressionImpl(text, null, null, mode) : null;
}
 
Example #27
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 #28
Source File: XDebuggerGeneralSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Tag("evaluation-dialog-mode")
public EvaluationMode getEvaluationDialogMode() {
  return myEvaluationDialogMode;
}
 
Example #29
Source File: XDebuggerGeneralSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setEvaluationDialogMode(EvaluationMode evaluationDialogMode) {
  myEvaluationDialogMode = evaluationDialogMode;
}
 
Example #30
Source File: XDebuggerUtilImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public XExpression createExpression(@Nonnull String text, Language language, String custom, EvaluationMode mode) {
  return new XExpressionImpl(text, language, custom, mode);
}