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


Java CommandProcessor.getCurrentCommand方法代码示例

本文整理汇总了Java中com.intellij.openapi.command.CommandProcessor.getCurrentCommand方法的典型用法代码示例。如果您正苦于以下问题:Java CommandProcessor.getCurrentCommand方法的具体用法?Java CommandProcessor.getCurrentCommand怎么用?Java CommandProcessor.getCurrentCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.command.CommandProcessor的用法示例。


在下文中一共展示了CommandProcessor.getCurrentCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertInsideCommand

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private void assertInsideCommand() {
  if (!myAssertThreading) return;
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  if (!commandProcessor.isUndoTransparentActionInProgress() &&
      commandProcessor.getCurrentCommand() == null) {
    throw new IncorrectOperationException("Must not change document outside command or undo-transparent action. See com.intellij.openapi.command.WriteCommandAction or com.intellij.openapi.command.CommandProcessor");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:DocumentImpl.java

示例2: performRefactoring

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
protected boolean performRefactoring() {
  boolean bind = false;
  if (myInsertedName != null) {

    final CommandProcessor commandProcessor = CommandProcessor.getInstance();
    if (commandProcessor.getCurrentCommand() != null && getVariable() != null) {
      commandProcessor.setCurrentCommandName(getCommandName());
    }

    bind = true;
    if (!isIdentifier(myInsertedName, myLanguage)) {
      performOnInvalidIdentifier(myInsertedName, myNameSuggestions);
    }
    else {
      if (mySnapshot != null) {
        if (isIdentifier(myInsertedName, myLanguage)) {
          ApplicationManager.getApplication().runWriteAction(new Runnable() {
            @Override
            public void run() {
              mySnapshot.apply(myInsertedName);
            }
          });
        }
      }
    }
    performRefactoringRename(myInsertedName, myMarkAction);
  }
  return bind;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:VariableInplaceRenamer.java

示例3: emulateEnter

import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
/**
 * Emulates pressing <code>Enter</code> at current caret position.
 *
 * @param editor       target editor
 * @param project      target project
 * @param shifts       two-elements array which is expected to be filled with the following info:
 *                       1. The first element holds added lines number;
 *                       2. The second element holds added symbols number;
 */
private static void emulateEnter(@NotNull final Editor editor, @NotNull Project project, int[] shifts) {
  final DataContext dataContext = prepareContext(editor.getComponent(), project);
  int caretOffset = editor.getCaretModel().getOffset();
  Document document = editor.getDocument();
  SelectionModel selectionModel = editor.getSelectionModel();
  int startSelectionOffset = 0;
  int endSelectionOffset = 0;
  boolean restoreSelection = selectionModel.hasSelection();
  if (restoreSelection) {
    startSelectionOffset = selectionModel.getSelectionStart();
    endSelectionOffset = selectionModel.getSelectionEnd();
    selectionModel.removeSelection();
  }
  int textLengthBeforeWrap = document.getTextLength();
  int lineCountBeforeWrap = document.getLineCount();

  DataManager.getInstance().saveInDataContext(dataContext, WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY, true);
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  try {
    Runnable command = new Runnable() {
      @Override
      public void run() {
        EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, dataContext);
      }
    };
    if (commandProcessor.getCurrentCommand() == null) {
      commandProcessor.executeCommand(editor.getProject(), command, WRAP_LINE_COMMAND_NAME, null);
    }
    else {
      command.run();
    }
  }
  finally {
    DataManager.getInstance().saveInDataContext(dataContext, WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY, null);
  }
  int symbolsDiff = document.getTextLength() - textLengthBeforeWrap;
  if (restoreSelection) {
    int newSelectionStart = startSelectionOffset;
    int newSelectionEnd = endSelectionOffset;
    if (startSelectionOffset >= caretOffset) {
      newSelectionStart += symbolsDiff;
    }
    if (endSelectionOffset >= caretOffset) {
      newSelectionEnd += symbolsDiff;
    }
    selectionModel.setSelection(newSelectionStart, newSelectionEnd);
  }
  shifts[0] = document.getLineCount() - lineCountBeforeWrap;
  shifts[1] = symbolsDiff;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:CodeFormatterFacade.java


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