• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EditorActionHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: preprocessEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffset, @NotNull final Ref<Integer> caretAdvance,
                              @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) {
  /**
   * if we are between open and close tags, we ensure the caret ends up in the "logical" place on Enter.
   * i.e. "{#foo}<caret>{/foo}" becomes the following on Enter:
   *
   * {#foo}
   * <caret>
   * {/foo}
   *
   * (Note: <caret> may be indented depending on formatter settings.)
   */
  if (file instanceof DustFile
      && isBetweenHbTags(editor, file, caretOffset.get())) {
    originalHandler.execute(editor, dataContext);
    return Result.Default;
  }
  return Result.Continue;
}
 
开发者ID:yifanz,项目名称:Intellij-Dust,代码行数:20,代码来源:DustEnterHandler.java


示例17: doEnter

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) {
  PsiElement parent = psiElement.getParent();
  if (!(parent instanceof PsiCodeBlock)) {
    return false;
  }

  final ASTNode node = psiElement.getNode();
  if (node != null && CONTROL_FLOW_ELEMENT_TYPES.contains(node.getElementType())) {
    return false;
  } 
  
  boolean leaveCodeBlock = isControlFlowBreak(psiElement);
  if (!leaveCodeBlock) {
    return false;
  }
  
  final int offset = parent.getTextRange().getEndOffset();
  
  // Check if there is empty line after the code block. Just move caret there in the case of the positive answer.
  final CharSequence text = editor.getDocument().getCharsSequence();
  if (offset < text.length() - 1) {
    final int i = CharArrayUtil.shiftForward(text, offset + 1, " \t");
    if (i < text.length() && text.charAt(i) == '\n') {
      editor.getCaretModel().moveToOffset(offset + 1);
      EditorActionManager actionManager = EditorActionManager.getInstance();
      EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END);
      final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
      if (dataContext != null) {
        actionHandler.execute(editor, dataContext);
        return true;
      }
    }
  }
  
  editor.getCaretModel().moveToOffset(offset);
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:LeaveCodeBlockEnterProcessor.java


示例18: expandCodeBlock

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
static boolean expandCodeBlock(Editor editor, PsiElement psiElement) {
  PsiCodeBlock block = getControlStatementBlock(editor.getCaretModel().getOffset(), psiElement);
  if (processExistingBlankLine(editor, block, psiElement)) {
    return true;
  }
  if (block == null) {
    return false;
  }

  EditorActionHandler enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE);
  PsiElement firstElement = block.getFirstBodyElement();
  if (firstElement == null) {
    firstElement = block.getRBrace();
    // Plain enter processor inserts enter after the end of line, hence, we don't want to use it here because the line ends with
    // the empty braces block. So, we get the following in case of default handler usage:
    //     Before:
    //         if (condition[caret]) {}
    //     After:
    //         if (condition) {}
    //             [caret]
    enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_ENTER);
  }
  editor.getCaretModel().moveToOffset(firstElement != null ?
                                      firstElement.getTextRange().getStartOffset() :
                                      block.getTextRange().getEndOffset());
  enterHandler.execute(editor, ((EditorEx)editor).getDataContext());
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PlainEnterProcessor.java


示例19: selectWordAtCaret

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public void selectWordAtCaret(final boolean honorCamelWordsSettings) {
  removeSelection();

  EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(
    IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
  handler.execute(myEditor, DataManager.getInstance().getDataContext(myEditor.getComponent()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:TextComponentSelectionModel.java


示例20: selectWordAtCaret

import com.intellij.openapi.editor.actionSystem.EditorActionHandler; //导入依赖的package包/类
@Override
public void selectWordAtCaret(final boolean honorCamelWordsSettings) {
  validateContext(true);
  myEditor.getCaretModel().doWithCaretMerging(new Runnable() {
    @Override
    public void run() {
      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, CaretImpl.this, myEditor.getDataContext());
      }
      finally {
        if (needOverrideSetting) {
          settings.resetCamelWords();
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:CaretImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Action类代码示例发布时间:2022-05-21
下一篇:
Java TypeResolver类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap