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

Java RefactoringActionHandlerFactory类代码示例

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

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



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

示例1: moveClass

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
private void moveClass(Project project, Editor editor, PsiFile file, PsiClass aClass) {
  RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  DataManager dataManager = DataManager.getInstance();
  DataContext dataContext = dataManager.getDataContext();
  final String fqName = aClass.getQualifiedName();
  LOG.assertTrue(fqName != null);
  PsiDirectory directory = PackageUtil
    .findOrCreateDirectoryForPackage(myCurrentModule, StringUtil.getPackageName(fqName), mySourceRoot, true);
  DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT.getName(), directory, dataContext);

  moveHandler.invoke(project, new PsiElement[]{aClass}, context);
  PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
  PsiClass newClass = JavaPsiFacade.getInstance(project).findClass(fqName, GlobalSearchScope.moduleScope(myCurrentModule));
  if (reference != null && newClass != null) {
    final QuestionAction action = new AddImportAction(project, reference, editor, newClass);
    action.execute();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MoveClassToModuleFix.java


示例2: doFix

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
@Override
public void doFix(@NotNull final Project project,
                  ProblemDescriptor descriptor) {
  final PsiElement nameElement = descriptor.getPsiElement();
  final PsiClass aClass = (PsiClass)nameElement.getParent();
  final Application application = ApplicationManager.getApplication();
  application.invokeLater(new Runnable() {

    @Override
    public void run() {
      final RefactoringActionHandlerFactory factory =
        RefactoringActionHandlerFactory.getInstance();
      final RefactoringActionHandler moveHandler =
        factory.createMoveHandler();
      final DataManager dataManager = DataManager.getInstance();
      final DataContext dataContext = dataManager.getDataContext();
      moveHandler.invoke(project, new PsiElement[]{aClass},
                         dataContext);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MoveClassFix.java


示例3: doFix

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
@Override
protected void doFix(@NotNull final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement location = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)location.getParent();
  final RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  final AsyncResult<DataContext> result = DataManager.getInstance().getDataContextFromFocus();
  result.doWhenDone(new Consumer<DataContext>() {
    @Override
    public void consume(final DataContext originalContext) {
      final DataContext dataContext = new DataContext() {
        @Override
        public Object getData(@NonNls String name) {
          if (LangDataKeys.TARGET_PSI_ELEMENT.is(name)) {
            return usageClass.getElement();
          }
          return originalContext.getData(name);
        }
      };
      moveHandler.invoke(project, new PsiElement[]{method}, dataContext);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StaticMethodOnlyUsedInOneClassInspection.java


示例4: doFix

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
@Override
protected void doFix(@NotNull final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement location = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)location.getParent();
  final RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  final AsyncResult<DataContext> result = DataManager.getInstance().getDataContextFromFocus();
  result.doWhenDone(new AsyncResult.Handler<DataContext>() {
    @Override
    public void run(final DataContext originalContext) {
      final DataContext dataContext = new DataContext() {
        @Override
        public Object getData(@NonNls String name) {
          if (LangDataKeys.TARGET_PSI_ELEMENT.is(name)) {
            return usageClass.getElement();
          }
          return originalContext.getData(name);
        }
      };
      moveHandler.invoke(project, new PsiElement[]{method}, dataContext);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:StaticMethodOnlyUsedInOneClassInspection.java


示例5: moveClass

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
private void moveClass(Project project, Editor editor, PsiFile file, PsiClass aClass) {
  RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  DataManager dataManager = DataManager.getInstance();
  DataContext dataContext = dataManager.getDataContext();
  final String fqName = aClass.getQualifiedName();
  LOG.assertTrue(fqName != null);
  PsiDirectory directory = PackageUtil
    .findOrCreateDirectoryForPackage(myCurrentModule, StringUtil.getPackageName(fqName), mySourceRoot, true);
  DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT, directory, dataContext);

  moveHandler.invoke(project, new PsiElement[]{aClass}, context);
  PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
  PsiClass newClass = JavaPsiFacade.getInstance(project).findClass(fqName, GlobalSearchScope.moduleScope(myCurrentModule));
  if (reference != null && newClass != null) {
    final QuestionAction action = new AddImportAction(project, reference, editor, newClass);
    action.execute();
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:MoveClassToModuleFix.java


示例6: doFix

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
public void doFix(@NotNull final Project project,
                  ProblemDescriptor descriptor) {
  final PsiElement nameElement = descriptor.getPsiElement();
  final PsiClass aClass = (PsiClass)nameElement.getParent();
  final Application application = ApplicationManager.getApplication();
  application.invokeLater(new Runnable() {

    public void run() {
      final RefactoringActionHandlerFactory factory =
        RefactoringActionHandlerFactory.getInstance();
      final RefactoringActionHandler moveHandler =
        factory.createMoveHandler();
      final DataManager dataManager = DataManager.getInstance();
      final DataContext dataContext = dataManager.getDataContext();
      moveHandler.invoke(project, new PsiElement[]{aClass},
                         dataContext);
    }
  });
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:MoveClassFix.java


示例7: invoke

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  Form[] forms = Form.DATA_KEY.getData(dataContext);
  if (forms == null || forms.length != 1) return;
  PsiClass boundClass = forms [0].getClassToBind();
  RefactoringActionHandlerFactory.getInstance().createRenameHandler().invoke(project, new PsiElement[] { boundClass },
                                                                             dataContext);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:FormRenameHandler.java


示例8: invoke

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
  Runnable runnable = new Runnable() {
    public void run() {
      RefactoringActionHandlerFactory.getInstance().createRenameHandler().invoke(project, new PsiElement[]{myElement},
                                                                                 DataManager.getInstance().getDataContext());
    }
  };
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    runnable.run();
  }
  else {
    ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:RenameVariableFix.java


示例9: invoke

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext)
{
	Form[] forms = dataContext.getData(Form.DATA_KEY);
	if(forms == null || forms.length != 1)
	{
		return;
	}
	PsiClass boundClass = forms[0].getClassToBind();
	RefactoringActionHandlerFactory.getInstance().createRenameHandler().invoke(project, new PsiElement[]{boundClass}, dataContext);
}
 
开发者ID:consulo,项目名称:consulo-ui-designer,代码行数:12,代码来源:FormRenameHandler.java


示例10: getActionHandler

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
private RefactoringActionHandler getActionHandler() {
  return RefactoringActionHandlerFactory.getInstance().createMoveHandler();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ProjectViewDropTarget.java


示例11: getHandler

import com.intellij.refactoring.RefactoringActionHandlerFactory; //导入依赖的package包/类
@NotNull
@Override
public RefactoringActionHandler getHandler()
{
	return RefactoringActionHandlerFactory.getInstance().createMoveHandler();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:StaticMethodOnlyUsedInOneClassInspection.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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