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


Java EditorActionHandler类代码示例

本文整理汇总了Java中com.intellij.openapi.editor.actionSystem.EditorActionHandler的典型用法代码示例。如果您正苦于以下问题:Java EditorActionHandler类的具体用法?Java EditorActionHandler怎么用?Java EditorActionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EditorActionHandler类属于com.intellij.openapi.editor.actionSystem包,在下文中一共展示了EditorActionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public Result preprocessEnter(
    @NotNull PsiFile psiFile,
    @NotNull Editor editor,
    @NotNull Ref<Integer> caretOffset,
    @NotNull Ref<Integer> caretOffsetChange,
    @NotNull DataContext dataContext,
    @Nullable EditorActionHandler originalHandler) {
  if (psiFile instanceof SoyFile && isBetweenSiblingTags(psiFile, caretOffset.get())) {
    if (originalHandler != null) {
      originalHandler.execute(editor, dataContext);
    }
    return Result.Default;
  }
  return Result.Continue;
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:17,代码来源:EnterHandler.java

示例2: executeWriteAction

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public void executeWriteAction(@NotNull Editor editor, Caret caret, DataContext dataContext) {
  final Document document = editor.getDocument();
  final int caretOffset = editor.getCaretModel().getOffset();
  if (caretOffset < 1) {
    return;
  }

  final SelectionModel selectionModel = editor.getSelectionModel();
  final CharSequence text = document.getCharsSequence();
  final char c = text.charAt(caretOffset - 1);
  if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) {
    int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1;
    document.deleteString(startOffset, caretOffset);
  }
  else {
    final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
    handler.execute(editor, caret, dataContext);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:HungryBackspaceAction.java

示例3: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public Result preprocessEnter(@NotNull final PsiFile file,
                              @NotNull final Editor editor,
                              @NotNull final Ref<Integer> caretOffsetRef,
                              @NotNull final Ref<Integer> caretAdvance,
                              @NotNull final DataContext dataContext,
                              final EditorActionHandler originalHandler) {

  int caretOffset = caretOffsetRef.get();
  if (!isApplicable(file, caretOffset)) {
    return Result.Continue;
  }

  int maxRBraceCount = getMaxRBraceCount(file, editor, caretOffset);
  if (maxRBraceCount > 0) {
    insertRBraces(file, editor,
                  caretOffset,
                  getRBraceOffset(file, editor, caretOffset),
                  adjustRBraceCountForPosition(editor, caretOffset, maxRBraceCount));
    return Result.DefaultForceIndent;
  }
  return Result.Continue;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EnterAfterUnmatchedBraceHandler.java

示例4: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public Result preprocessEnter(@NotNull PsiFile file,
                              @NotNull Editor editor,
                              @NotNull Ref<Integer> caretOffset,
                              @NotNull Ref<Integer> caretAdvance,
                              @NotNull DataContext dataContext,
                              EditorActionHandler originalHandler) {
  int offset = caretOffset.get();
  if (editor instanceof EditorWindow) {
    file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
    editor = InjectedLanguageUtil.getTopLevelEditor(editor);
    offset = editor.getCaretModel().getOffset();
  }
  if (!(file instanceof PyFile)) {
    return Result.Continue;
  }

  // honor dedent (PY-3009)
  if (BackspaceHandler.isWhitespaceBeforeCaret(editor)) {
    return Result.DefaultSkipIndent;
  }
  return Result.Continue;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PyEnterAtIndentHandler.java

示例5: handleEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
protected static boolean handleEnter(Editor editor,
                                     DataContext dataContext,
                                     @NotNull Project project,
                                     EditorActionHandler originalHandler) {
  if (HandlerUtils.isReadOnly(editor)) {
    return false;
  }
  int caretOffset = editor.getCaretModel().getOffset();
  if (caretOffset < 1) return false;

  if (handleBetweenSquareBraces(editor, caretOffset, dataContext, project, originalHandler)) {
    return true;
  }
  if (handleInString(editor, caretOffset, dataContext, originalHandler)) {
    return true;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyEnterHandler.java

示例6: handleBetweenSquareBraces

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
private static boolean handleBetweenSquareBraces(Editor editor,
                                                 int caret,
                                                 DataContext context,
                                                 Project project,
                                                 EditorActionHandler originalHandler) {
  String text = editor.getDocument().getText();
  if (text == null || text.isEmpty()) return false;
  final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter();
  if (caret < 1 || caret > text.length() - 1) {
    return false;
  }
  HighlighterIterator iterator = highlighter.createIterator(caret - 1);
  if (GroovyTokenTypes.mLBRACK == iterator.getTokenType()) {
    if (text.length() > caret) {
      iterator = highlighter.createIterator(caret);
      if (GroovyTokenTypes.mRBRACK == iterator.getTokenType()) {
        originalHandler.execute(editor, context);
        originalHandler.execute(editor, context);
        editor.getCaretModel().moveCaretRelatively(0, -1, false, false, true);
        insertSpacesByGroovyContinuationIndent(editor, project);
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GroovyEnterHandler.java

示例7: runPasteAction

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
private void runPasteAction(final String toPaste) {
    final Producer<Transferable> producer = new Producer<Transferable>() {
        @Nullable
        @Override
        public Transferable produce() {
            return new StringSelection(toPaste);
        }
    };
    EditorActionManager actionManager = EditorActionManager.getInstance();
    EditorActionHandler pasteActionHandler = actionManager.getActionHandler(ACTION_EDITOR_PASTE);
    final PasteHandler pasteHandler = new PasteHandler(pasteActionHandler);
    new WriteCommandAction.Simple(getProject(), new PsiFile[0]) {
        protected void run() throws Throwable {
            Component component = myFixture.getEditor().getComponent();
            DataContext dataContext = DataManager.getInstance().getDataContext(component);
            pasteHandler.execute(myFixture.getEditor(), dataContext, producer);
        }
    }.execute();
}
 
开发者ID:platan,项目名称:idea-gradle-dependencies-formatter,代码行数:20,代码来源:MavenToGradleDependenciesCopyPasteProcessorTest.java

示例8: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, @Nullable EditorActionHandler originalHandler) {
  // if we have something right now, use it, but don't wait for anything
  final Eddy.Output output = EddyFileListener.getOutputFor(editor);
  if (output == null)
    return Result.Continue;

  // only do this if a hint is showing
  if (!EddyFileListener.isHintShowing()) {
    return Result.Continue;
  }

  // check if we should be auto-applying
  if (!output.shouldAutoApply())
    return Result.Continue;

  Project project = editor.getProject();
  if (project == null)
    return Result.Continue;

  int co = editor.getCaretModel().getCurrentCaret().getOffset();
  // autoExecute will commit the document
  caretOffset.set(caretOffset.get() - co + output.autoApply());
  return Result.DefaultSkipIndent;
}
 
开发者ID:eddysystems,项目名称:eddy,代码行数:26,代码来源:EddyEnterHandlerDelegate.java

示例9: selectWordAtCaret

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public void selectWordAtCaret(boolean honorCamelWordsSettings) {
  validateContext(true);
  removeSelection();
  final EditorSettings settings = myEditor.getSettings();
  boolean camelTemp = settings.isCamelWords();

  final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings;
  if (needOverrideSetting) {
    settings.setCamelWords(false);
  }

  try {
    EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(
      IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
    handler.execute(myEditor, myEditor.getDataContext());
  }
  finally {
    if (needOverrideSetting) {
      settings.resetCamelWords();
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:SelectionModelImpl.java

示例10: truncatePrefix

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
static void truncatePrefix(final DataContext dataContext, LookupImpl lookup, final EditorActionHandler handler, final int hideOffset) {
  final Editor editor = lookup.getEditor();
  if (!lookup.performGuardedChange(new Runnable() {
    @Override
    public void run() {
      handler.execute(editor, dataContext);
    }
  })) {
    return;
  }

  final CompletionProgressIndicator process = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
  if (lookup.truncatePrefix(process == null || !process.isAutopopupCompletion())) {
    return;
  }

  if (process != null) {
    if (hideOffset < editor.getCaretModel().getOffset()) {
      process.scheduleRestart();
      return;
    }
    process.prefixUpdated();
  }

  lookup.hide();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:BackspaceHandler.java

示例11: handleBetweenSquareBraces

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
private static boolean handleBetweenSquareBraces(Editor editor,
                                                 int caret,
                                                 DataContext context,
                                                 Project project,
                                                 EditorActionHandler originalHandler) {
  String text = editor.getDocument().getText();
  if (text == null || text.length() == 0) return false;
  final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter();
  if (caret < 1 || caret > text.length() - 1) {
    return false;
  }
  HighlighterIterator iterator = highlighter.createIterator(caret - 1);
  if (mLBRACK == iterator.getTokenType()) {
    if (text.length() > caret) {
      iterator = highlighter.createIterator(caret);
      if (mRBRACK == iterator.getTokenType()) {
        originalHandler.execute(editor, context);
        originalHandler.execute(editor, context);
        editor.getCaretModel().moveCaretRelatively(0, -1, false, false, true);
        insertSpacesByGroovyContinuationIndent(editor, project);
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:GroovyEnterHandler.java

示例12: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
@RequiredDispatchThread
public Result preprocessEnter(@NotNull final PsiFile file,
		@NotNull final Editor editor,
		@NotNull final Ref<Integer> caretOffsetRef,
		@NotNull final Ref<Integer> caretAdvance,
		@NotNull final DataContext dataContext,
		final EditorActionHandler originalHandler)
{
	final int caretOffset = caretOffsetRef.get();
	final Document document = editor.getDocument();
	final PsiElement psiAtOffset = file.findElementAt(caretOffset);
	final PsiElement probablyDocComment = psiAtOffset instanceof PsiWhiteSpace && psiAtOffset.getText().startsWith("\n") ? psiAtOffset.getPrevSibling() : psiAtOffset == null && caretOffset > 0
			&& caretOffset == document.getTextLength() ? file.findElementAt(caretOffset - 1) : psiAtOffset;

	if(probablyDocComment != null && PsiTreeUtil.getParentOfType(probablyDocComment, CSharpDocRoot.class, false) != null)
	{
		document.insertString(caretOffset, DOC_LINE_START + " ");
		caretAdvance.set(4);
		return Result.Default;
	}

	return Result.Continue;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:25,代码来源:CSharpEnterInDocLineCommentHandler.java

示例13: executeWriteAction

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public void executeWriteAction(@Nonnull Editor editor, Caret caret, DataContext dataContext) {
  final Document document = editor.getDocument();
  final int caretOffset = editor.getCaretModel().getOffset();
  if (caretOffset < 1) {
    return;
  }

  final SelectionModel selectionModel = editor.getSelectionModel();
  final CharSequence text = document.getCharsSequence();
  final char c = text.charAt(caretOffset - 1);
  if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) {
    int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1;
    document.deleteString(startOffset, caretOffset);
  }
  else {
    final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
    handler.execute(editor, caret, dataContext);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:HungryBackspaceAction.java

示例14: selectWordAtCaret

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public void selectWordAtCaret(final boolean honorCamelWordsSettings) {
  validateContext(true);
  myEditor.getCaretModel().doWithCaretMerging(() -> {
    removeSelection();
    final EditorSettings settings = myEditor.getSettings();
    boolean camelTemp = settings.isCamelWords();

    final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings;
    if (needOverrideSetting) {
      settings.setCamelWords(false);
    }

    try {
      EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
      handler.execute(myEditor, this, myEditor.getDataContext());
    }
    finally {
      if (needOverrideSetting) {
        settings.resetCamelWords();
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:CaretImpl.java

示例15: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public Result preprocessEnter(@Nonnull final PsiFile file,
                              @Nonnull final Editor editor,
                              @Nonnull final Ref<Integer> caretOffsetRef,
                              @Nonnull final Ref<Integer> caretAdvance,
                              @Nonnull final DataContext dataContext,
                              final EditorActionHandler originalHandler) {

  int caretOffset = caretOffsetRef.get();
  if (!isApplicable(file, caretOffset)) {
    return Result.Continue;
  }

  int maxRBraceCount = getMaxRBraceCount(file, editor, caretOffset);
  if (maxRBraceCount > 0) {
    insertRBraces(file, editor,
                  caretOffset,
                  getRBraceOffset(file, editor, caretOffset),
                  generateStringToInsert(editor, caretOffset, maxRBraceCount));
    return Result.DefaultForceIndent;
  }
  return Result.Continue;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:EnterAfterUnmatchedBraceHandler.java


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