本文整理匯總了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");
}
}
示例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;
}
示例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;
}