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

Java RefactoringFactory类代码示例

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

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



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

示例1: doTest

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
private void doTest() throws Exception {
  final String filename = getTestName(true) + ".xml";
  VirtualFile vfile = VirtualFileManager.getInstance().findFileByUrl("file://" + getTestDataPath() + filename);
  String text = FileDocumentManager.getInstance().getDocument(vfile).getText();
  final int off = text.indexOf("<ren>");
  text = text.replace("<ren>", "");
  configureFromFileText(filename, text);
  assertNotNull(myFile);
  PsiElement element = TargetElementUtil.getInstance().findTargetElement(
    getEditor(), 
    TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil.ELEMENT_NAME_ACCEPTED,
    off);
  assertNotNull(element);
  assertTrue(element instanceof PsiNamedElement);
  final RenameRefactoring rename =
    RefactoringFactory.getInstance(getProject()).createRename(element, ((PsiNamedElement)element).getName() + "-after");
  rename.setSearchInComments(false);
  rename.setSearchInNonJavaFiles(false);
  rename.run();
  checkResultByFile(filename + "-after");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AntRenameTest.java


示例2: doFix

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  if (m_targetName == null) {
    final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
    contextFromFocus.doWhenDone(new Consumer<DataContext>() {
      @Override
      public void consume(DataContext context) {
        final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
        if (renameHandler == null) {
          return;
        }
        renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
      }
    });
  }
  else {
    final RefactoringFactory factory = RefactoringFactory.getInstance(project);
    final RenameRefactoring renameRefactoring =
      factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
    renameRefactoring.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RenameFix.java


示例3: doTest

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
private void doTest() throws Exception {
  final String filename = getTestName(true) + ".xml";
  VirtualFile vfile = VirtualFileManager.getInstance().findFileByUrl("file://" + getTestDataPath() + filename);
  String text = FileDocumentManager.getInstance().getDocument(vfile).getText();
  final int off = text.indexOf("<ren>");
  text = text.replace("<ren>", "");
  configureFromFileText(filename, text);
  assertNotNull(myFile);
  PsiElement element = TargetElementUtilBase.getInstance().findTargetElement(
    getEditor(), 
    TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtilBase.ELEMENT_NAME_ACCEPTED,
    off);
  assertNotNull(element);
  assertTrue(element instanceof PsiNamedElement);
  final RenameRefactoring rename =
    RefactoringFactory.getInstance(getProject()).createRename(element, ((PsiNamedElement)element).getName() + "-after");
  rename.setSearchInComments(false);
  rename.setSearchInNonJavaFiles(false);
  rename.run();
  checkResultByFile(filename + "-after");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:AntRenameTest.java


示例4: doFix

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  if (m_targetName == null) {
    final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
    contextFromFocus.doWhenDone(new AsyncResult.Handler<DataContext>() {
      @Override
      public void run(DataContext context) {
        final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
        if (renameHandler == null) {
          return;
        }
        renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
      }
    });
  }
  else {
    final RefactoringFactory factory = RefactoringFactory.getInstance(project);
    final RenameRefactoring renameRefactoring =
      factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
    renameRefactoring.run();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:RenameFix.java


示例5: applyFix

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {

    final RenameRefactoring refactoring = RefactoringFactory.getInstance(project)
            .createRename(parameter, this.newParameterName, false, false);

    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
        @Override
        public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                @Override
                public void run() {
                    refactoring.run();
                }
            });
        }
    },
    "Rename parameter to match define",
    "Rename parameter to match define");
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:21,代码来源:MismatchedImportsQuickFix.java


示例6: doFix

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor)
{
	final PsiElement nameIdentifier = descriptor.getPsiElement();
	final PsiElement elementToRename = nameIdentifier.getParent();
	if(m_targetName == null)
	{
		final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
		contextFromFocus.doWhenDone(context -> {
			final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
			if(renameHandler == null)
			{
				return;
			}
			renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
		});
	}
	else
	{
		final RefactoringFactory factory = RefactoringFactory.getInstance(project);
		final RenameRefactoring renameRefactoring = factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
		renameRefactoring.run();
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:RenameFix.java


示例7: renameTargets

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
public static void renameTargets(AliasingPsiTarget target, @NotNull String newDelegateName) {
  final PsiNamedElement namedElement = (PsiNamedElement)target.getNavigationElement();
  if (!newDelegateName.equals(namedElement.getName())) {
    final RenameRefactoring refactoring =
      RefactoringFactory.getInstance(namedElement.getProject()).createRename(namedElement, newDelegateName);
    refactoring.run();

  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AliasingPsiTargetUtil.java


示例8: doFix

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
@Override
public void doFix(Project project, ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  final RefactoringFactory factory =
    RefactoringFactory.getInstance(project);
  final RenameRefactoring renameRefactoring =
    factory.createRename(elementToRename, m_targetName);
  renameRefactoring.setSearchInComments(false);
  renameRefactoring.setSearchInNonJavaFiles(false);
  renameRefactoring.run();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:RenameParameterFix.java


示例9: renameTargets

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
protected void renameTargets(@NotNull String newDelegateName) {
  final PsiNamedElement namedElement = (PsiNamedElement)getNavigationElement();
  if (!newDelegateName.equals(namedElement.getName())) {
    final RenameRefactoring refactoring =
      RefactoringFactory.getInstance(namedElement.getProject()).createRename(namedElement, newDelegateName);
    refactoring.run();

  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:AliasingPsiTarget.java


示例10: replaceWordRefactoring

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
private void replaceWordRefactoring(String selectedValue)
{
    final Project project = editor.getProject();

    int offset = editor.getCaretModel().getOffset();
    PsiElement elementAt = psiFile.findElementAt(offset);

    RefactoringFactory refactoringFactory = RefactoringFactoryImpl.getInstance(project);
    RenameRefactoring rename = refactoringFactory.createRename(findNamedElement(elementAt), selectedValue);

    UsageInfo[] usages = rename.findUsages();
    rename.doRefactoring(usages);
}
 
开发者ID:pascaldevink,项目名称:intellij-thesaurus,代码行数:14,代码来源:ThesaurusListPopupStep.java


示例11: updateModuleReference

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
/**
 * Updates an existing AMD module reference (define literal + the parameter)
 *
 * @param targetFile the file containing the reference
 * @param match a MatchResult that represents the new module reference
 * @param statement the define or require statement that is being updated
 * @param replacementExpression an expression that will replace the define literal expression
 * @param updateReferences if true, will update references to the parameter if it is renamed
 */
public void updateModuleReference(final PsiFile targetFile, final MatchResult match, final DefineStatement statement, final PsiElement replacementExpression, final boolean updateReferences)
{
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
            PsiElement defineLiteral = statement.getArguments().getExpressions()[match.getIndex()];
            defineLiteral.replace(replacementExpression);

            if(!updateReferences)
            {
                return;
            }

            // sometimes the lengths of the imports don't match up due to plugins etc.
            if(!(match.getIndex() >= statement.getFunction().getParameters().length))
            {
                // for performance reasons we should only rename a parameter if the name has actually changed
                String parameterText = statement.getFunction().getParameters()[match.getIndex()].getText();
                String newParameterName = NameResolver.defineToParameter(match.getPath(), moduleNamingExceptionMap);

                if(parameterText.equals(newParameterName))
                {
                    return;
                }

                RenameRefactoring refactoring = RefactoringFactory.getInstance(targetFile.getProject())
                        .createRename(statement.getFunction().getParameters()[match.getIndex()], newParameterName, false, false);

                refactoring.doRefactoring(refactoring.findUsages());
            }
        }
    });
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:43,代码来源:ImportUpdater.java


示例12: renameTargets

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
protected void renameTargets(@Nonnull String newDelegateName) {
  final PsiNamedElement namedElement = (PsiNamedElement)getNavigationElement();
  if (!newDelegateName.equals(namedElement.getName())) {
    final RenameRefactoring refactoring =
      RefactoringFactory.getInstance(namedElement.getProject()).createRename(namedElement, newDelegateName);
    refactoring.run();

  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:AliasingPsiTarget.java


示例13: doFix

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
public void doFix(Project project, ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  final RefactoringFactory factory =
    RefactoringFactory.getInstance(project);
  final RenameRefactoring renameRefactoring =
    factory.createRename(elementToRename, m_targetName);
  renameRefactoring.setSearchInComments(false);
  renameRefactoring.setSearchInNonJavaFiles(false);
  renameRefactoring.run();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:RenameParameterFix.java


示例14: invoke

import com.intellij.refactoring.RefactoringFactory; //导入依赖的package包/类
/**
 * Called when user invokes intention.
 */
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    RefactoringFactory.getInstance(project).createRename(myPsiNode, myTargetName).doRefactoring(UsageInfo.EMPTY_ARRAY);
}
 
开发者ID:carymrobbins,项目名称:intellij-haskforce,代码行数:8,代码来源:HaskellModuleNameFix.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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