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


Java RenameUtil.findUsages方法代码示例

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


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

示例1: processFunctionDeclaration

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
private static void processFunctionDeclaration(@NotNull PyChangeInfo changeInfo, @NotNull PyFunction function) {
  if (changeInfo.isParameterNamesChanged()) {
    final PyParameter[] oldParameters = function.getParameterList().getParameters();
    for (PyParameterInfo paramInfo: changeInfo.getNewParameters()) {
      if (paramInfo.getOldIndex() >= 0 && paramInfo.isRenamed()) {
        final String newName = StringUtil.trimLeading(paramInfo.getName(), '*').trim();
        final UsageInfo[] usages = RenameUtil.findUsages(oldParameters[paramInfo.getOldIndex()], newName, true, false, null);
        for (UsageInfo info : usages) {
          RenameUtil.rename(info, newName);
        }
      }
    }
  }
  if (changeInfo.isParameterSetOrOrderChanged()) {
    fixDoc(changeInfo, function);
    updateParameterList(changeInfo, function);
  }
  if (changeInfo.isNameChanged()) {
    RenameUtil.doRenameGenericNamedElement(function, changeInfo.getNewName(), UsageInfo.EMPTY_ARRAY, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyChangeSignatureUsageProcessor.java

示例2: testAllUsagesInCode

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
      .findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:RenameCollisionsTest.java

示例3: findUsagesForElement

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
private boolean findUsagesForElement(PsiNamedElement element,
                                     List<UsageInfo> result,
                                     final boolean searchInStringsAndComments,
                                     final boolean searchInNonJavaFiles,
                                     List<UnresolvableCollisionUsageInfo> unresolvedUsages,
                                     Map<PsiElement, String> allRenames) {
  final String newName = getNewName(element);
  if (newName != null) {

    final LinkedHashMap<PsiNamedElement, String> renames = new LinkedHashMap<PsiNamedElement, String>();
    renames.putAll(myRenames);
    if (allRenames != null) {
      for (PsiElement psiElement : allRenames.keySet()) {
        if (psiElement instanceof PsiNamedElement) {
          renames.put((PsiNamedElement)psiElement, allRenames.get(psiElement));
        }
      }
    }
    final UsageInfo[] usages = RenameUtil.findUsages(element, newName, searchInStringsAndComments, searchInNonJavaFiles, renames);
    for (final UsageInfo usage : usages) {
      if (usage instanceof UnresolvableCollisionUsageInfo) {
        if (unresolvedUsages != null) {
          unresolvedUsages.add((UnresolvableCollisionUsageInfo)usage);
        }
        return false;
      }
    }
    ContainerUtil.addAll(result, usages);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:AutomaticRenamer.java

示例4: processParameters

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
private static void processParameters(@NotNull final Project project,
                                      @NotNull final PyFunction generatedMethod,
                                      @NotNull final AbstractVariableData[] variableData,
                                      final boolean isMethod,
                                      final boolean isClassMethod,
                                      final boolean isStaticMethod) {
  final Map<String, String> map = createMap(variableData);
  // Rename parameters
  for (PyParameter parameter : generatedMethod.getParameterList().getParameters()) {
    final String name = parameter.getName();
    final String newName = map.get(name);
    if (name != null && newName != null && !name.equals(newName)) {
      final Map<PsiElement, String> allRenames = new java.util.HashMap<PsiElement, String>();
      allRenames.put(parameter, newName);
      final UsageInfo[] usages = RenameUtil.findUsages(parameter, newName, false, false, allRenames);
      try {
        RenameUtil.doRename(parameter, newName, usages, project, new RefactoringElementListenerComposite());
      }
      catch (IncorrectOperationException e) {
        RenameUtil.showErrorMessage(e, parameter, project);
        return;
      }
    }
  }
  // Change signature according to pass settings and
  final PyFunctionBuilder builder = new PyFunctionBuilder("foo", generatedMethod);
  if (isClassMethod) {
    builder.parameter("cls");
  }
  else if (isMethod && !isStaticMethod) {
    builder.parameter("self");
  }
  for (AbstractVariableData data : variableData) {
    if (data.isPassAsParameter()) {
      builder.parameter(data.getName());
    }
  }
  final PyParameterList pyParameterList = builder.buildFunction(project, LanguageLevel.forElement(generatedMethod)).getParameterList();
  generatedMethod.getParameterList().replace(pyParameterList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:PyExtractMethodUtil.java

示例5: testAllUsagesInCode

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtilBase
      .findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED);
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<PsiElement, String>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:RenameCollisionsTest.java

示例6: findUsagesForElement

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
@RequiredReadAction
private boolean findUsagesForElement(PsiNamedElement element,
                                     List<UsageInfo> result,
                                     final boolean searchInStringsAndComments,
                                     final boolean searchInNonJavaFiles,
                                     List<UnresolvableCollisionUsageInfo> unresolvedUsages,
                                     Map<PsiElement, String> allRenames) {
  final String newName = getNewName(element);
  if (newName != null) {

    final LinkedHashMap<PsiNamedElement, String> renames = new LinkedHashMap<PsiNamedElement, String>();
    renames.putAll(myRenames);
    if (allRenames != null) {
      for (PsiElement psiElement : allRenames.keySet()) {
        if (psiElement instanceof PsiNamedElement) {
          renames.put((PsiNamedElement)psiElement, allRenames.get(psiElement));
        }
      }
    }
    final UsageInfo[] usages = RenameUtil.findUsages(element, newName, searchInStringsAndComments, searchInNonJavaFiles, renames);
    for (final UsageInfo usage : usages) {
      if (usage instanceof UnresolvableCollisionUsageInfo) {
        if (unresolvedUsages != null) {
          unresolvedUsages.add((UnresolvableCollisionUsageInfo)usage);
        }
        return false;
      }
    }
    ContainerUtil.addAll(result, usages);
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:AutomaticRenamer.java

示例7: testAllUsagesInCode

import com.intellij.refactoring.rename.RenameUtil; //导入方法依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
      .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<PsiElement, String>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:RenameCollisionsTest.java


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