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


Java BaseRefactoringAction.getElementAtCaret方法代码示例

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


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

示例1: invoke

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  PsiElement element = getElement(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    final String newName = DEFAULT_NAME.getData(dataContext);
    if (newName != null) {
      rename(element, project, element, editor, newName);
      return;
    }
  }

  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final PsiElement nameSuggestionContext = InjectedLanguageUtil.findElementAtNoCommit(file, editor.getCaretModel().getOffset());
  invoke(element, project, nameSuggestionContext, editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PsiElementRenameHandler.java

示例2: invoke

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:InlineRefactoringActionHandler.java

示例3: invoke

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:InlineRefactoringActionHandler.java

示例4: update

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
/** Only show if selection is a literal */
@Override
public void update(AnActionEvent e) {
	Presentation presentation = e.getPresentation();
	VirtualFile grammarFile = MyActionUtils.getGrammarFileFromEvent(e);
	if ( grammarFile==null ) {
		presentation.setEnabled(false);
		return;
	}
	PsiFile file = e.getData(LangDataKeys.PSI_FILE);
	Editor editor = e.getData(PlatformDataKeys.EDITOR);
	PsiElement selectedElement = BaseRefactoringAction.getElementAtCaret(editor, file);
	if ( selectedElement==null ) { // we clicked somewhere outside text
		presentation.setEnabled(false);
		return;
	}
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:18,代码来源:GenerateLexerRulesForLiteralsAction.java

示例5: invoke

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
@Override
public void invoke(@Nonnull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  PsiElement element = getElement(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    final String newName = dataContext.getData(DEFAULT_NAME);
    if (newName != null) {
      rename(element, project, element, editor, newName);
      return;
    }
  }

  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final PsiElement nameSuggestionContext = InjectedLanguageUtil.findElementAtNoCommit(file, editor.getCaretModel().getOffset());
  invoke(element, project, nameSuggestionContext, editor);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:PsiElementRenameHandler.java

示例6: invoke

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
@Override
public void invoke(@Nonnull final Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

  PsiElement element = dataContext.getData(LangDataKeys.PSI_ELEMENT);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }
  if (element != null) {
    for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) {
      if (handler.canInlineElementInEditor(element, editor)) {
        handler.inlineElement(project, editor, element);
        return;
      }
    }

    if (invokeInliner(editor, element)) return;

    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:InlineRefactoringActionHandler.java

示例7: invoke

import com.intellij.refactoring.actions.BaseRefactoringAction; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  PsiElement element = getElement(dataContext);
  if (element == null) {
    element = BaseRefactoringAction.getElementAtCaret(editor, file);
  }

  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final PsiElement nameSuggestionContext = InjectedLanguageUtil.findElementAtNoCommit(file, editor.getCaretModel().getOffset());
  invoke(element, project, nameSuggestionContext, editor);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:PsiElementRenameHandler.java


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