本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}