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

Java RenameUtil类代码示例

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

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



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

示例1: checkMovePackage

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
private static boolean checkMovePackage(Project project, PsiPackage aPackage) {
  final PsiDirectory[] directories = aPackage.getDirectories();
  final VirtualFile[] virtualFiles = aPackage.occursInPackagePrefixes();
  if (directories.length > 1 || virtualFiles.length > 0) {
    final StringBuffer message = new StringBuffer();
    RenameUtil.buildPackagePrefixChangedMessage(virtualFiles, message, aPackage.getQualifiedName());
    if (directories.length > 1) {
      DirectoryAsPackageRenameHandlerBase.buildMultipleDirectoriesInPackageMessage(message, aPackage.getQualifiedName(), directories);
      message.append("\n\n");
      String report = RefactoringBundle
        .message("all.these.directories.will.be.moved.and.all.references.to.0.will.be.changed", aPackage.getQualifiedName());
      message.append(report);
    }
    message.append("\n");
    message.append(RefactoringBundle.message("do.you.wish.to.continue"));
    int ret =
      Messages.showYesNoDialog(project, message.toString(), RefactoringBundle.message("warning.title"), Messages.getWarningIcon());
    if (ret != Messages.YES) {
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MoveClassesOrPackagesImpl.java


示例2: 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


示例3: processRef

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Nullable
@Override
protected PsiElement processRef(PsiReference ref, String newName) {
  PsiElement element = ref.getElement();
  if (RenameUtil.isValidName(element.getProject(), element, newName) || element instanceof GrReferenceElement) {
    return super.processRef(ref, newName);
  }

  PsiElement nameElement;
  if (element instanceof PsiReferenceExpression) {
    nameElement = ((PsiReferenceExpression)element).getReferenceNameElement();
  }
  else {
    return null;
  }
  TextRange range = nameElement.getTextRange();
  Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(nameElement.getContainingFile());
  document.replaceString(range.getStartOffset(), range.getEndOffset(), newName);

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RenameAliasImportedMethodProcessor.java


示例4: findConflicts

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
public MultiMap<PsiElement, String> findConflicts(Ref<UsageInfo[]> refUsages) {
  MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
  addMethodConflicts(conflictDescriptions);
  UsageInfo[] usagesIn = refUsages.get();
  RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions);
  Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(usagesIn));
  RenameUtil.removeConflictUsages(usagesSet);
  if (myChangeInfo.isVisibilityChanged()) {
    try {
      addInaccessibilityDescriptions(usagesSet, conflictDescriptions);
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }

  return conflictDescriptions;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GrChangeSignatureConflictSearcher.java


示例5: setUp

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    PowerMockito.mockStatic(CommandUtils.class, TFSVcs.class, PersistentFS.class, RenameUtil.class);

    when(mockPsiFile.getVirtualFile()).thenReturn(mockVirtualFile);
    when(mockPsiFile.getProject()).thenReturn(mockProject);
    when(mockPsiDirectory.getVirtualFile()).thenReturn(mockVirtualFile);
    when(mockPsiDirectory.getProject()).thenReturn(mockProject);
    when(mockVirtualParent.getPath()).thenReturn(PARENT_PATH);
    when(mockVirtualFile.getParent()).thenReturn(mockVirtualParent);

    when(mockTFSVcs.getServerContext(anyBoolean())).thenReturn(mockServerContext);
    when(TFSVcs.getInstance(mockProject)).thenReturn(mockTFSVcs);
    when(PersistentFS.getInstance()).thenReturn(mockPersistentFS);
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:17,代码来源:RenameFileDirectoryTest.java


示例6: testExecute_RenameFileNoChanges

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Test
public void testExecute_RenameFileNoChanges() {
    when(mockVirtualFile.getPath()).thenReturn(CURRENT_FILE_PATH);
    when(CommandUtils.getStatusForFiles(mockServerContext, ImmutableList.of(CURRENT_FILE_PATH)))
            .thenReturn(Collections.EMPTY_LIST);

    RenameFileDirectory.execute(mockPsiFile, NEW_FILE_NAME, usageInfos, mockListener);

    verifyStatic(times(1));
    CommandUtils.renameFile(eq(mockServerContext), eq(CURRENT_FILE_PATH), eq(NEW_FILE_PATH));
    PersistentFS.getInstance().processEvents(any(List.class));
    verify(mockListener).elementRenamed(mockPsiFile);

    verifyStatic(never());
    RenameUtil.doRenameGenericNamedElement(any(PsiElement.class), any(String.class), any(UsageInfo[].class), any(RefactoringElementListener.class));
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:17,代码来源:RenameFileDirectoryTest.java


示例7: testExecute_RenameDirectoryNoChanges

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Test
public void testExecute_RenameDirectoryNoChanges() {
    String dirName = Path.combine("/path/to/the", "directory");
    when(mockVirtualFile.getPath()).thenReturn(dirName);
    when(CommandUtils.getStatusForFiles(mockServerContext, ImmutableList.of(dirName)))
            .thenReturn(Collections.EMPTY_LIST);

    RenameFileDirectory.execute(mockPsiFile, NEW_DIRECTORY_NAME, usageInfos, mockListener);

    verifyStatic(times(1));
    CommandUtils.renameFile(eq(mockServerContext), eq(dirName), eq(Path.combine("/path/to/the", "newDirectory")));
    PersistentFS.getInstance().processEvents(any(List.class));
    verify(mockListener).elementRenamed(mockPsiFile);

    verifyStatic(never());
    RenameUtil.doRenameGenericNamedElement(any(PsiElement.class), any(String.class), any(UsageInfo[].class), any(RefactoringElementListener.class));
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:18,代码来源:RenameFileDirectoryTest.java


示例8: testExecute_RenameFileEditChanges

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Test
public void testExecute_RenameFileEditChanges() {
    when(mockPendingChange.getChangeTypes()).thenReturn(ImmutableList.of(ServerStatusType.EDIT));
    when(mockVirtualFile.getPath()).thenReturn(CURRENT_FILE_PATH);
    when(CommandUtils.getStatusForFiles(mockServerContext, ImmutableList.of(CURRENT_FILE_PATH)))
            .thenReturn(ImmutableList.of(mockPendingChange));

    RenameFileDirectory.execute(mockPsiFile, NEW_FILE_NAME, usageInfos, mockListener);

    verifyStatic(times(1));
    CommandUtils.renameFile(eq(mockServerContext), eq(CURRENT_FILE_PATH), eq(NEW_FILE_PATH));
    PersistentFS.getInstance().processEvents(any(List.class));
    verify(mockListener).elementRenamed(mockPsiFile);

    verifyStatic(never());
    RenameUtil.doRenameGenericNamedElement(any(PsiElement.class), any(String.class), any(UsageInfo[].class), any(RefactoringElementListener.class));
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:18,代码来源:RenameFileDirectoryTest.java


示例9: testExecute_RenameFileEditRenameChanges

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Test
public void testExecute_RenameFileEditRenameChanges() {
    when(mockPendingChange.getChangeTypes()).thenReturn(ImmutableList.of(ServerStatusType.EDIT, ServerStatusType.RENAME));
    when(mockVirtualFile.getPath()).thenReturn(CURRENT_FILE_PATH);
    when(CommandUtils.getStatusForFiles(mockServerContext, ImmutableList.of(CURRENT_FILE_PATH)))
            .thenReturn(ImmutableList.of(mockPendingChange));

    RenameFileDirectory.execute(mockPsiFile, NEW_FILE_NAME, usageInfos, mockListener);

    verifyStatic(times(1));
    CommandUtils.renameFile(eq(mockServerContext), eq(CURRENT_FILE_PATH), eq(NEW_FILE_PATH));
    PersistentFS.getInstance().processEvents(any(List.class));
    verify(mockListener).elementRenamed(mockPsiFile);

    verifyStatic(never());
    RenameUtil.doRenameGenericNamedElement(any(PsiElement.class), any(String.class), any(UsageInfo[].class), any(RefactoringElementListener.class));
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:18,代码来源:RenameFileDirectoryTest.java


示例10: testExecute_RenameFileUnversionedChange

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
@Test
public void testExecute_RenameFileUnversionedChange() {
    when(mockPendingChange.getChangeTypes()).thenReturn(ImmutableList.of(ServerStatusType.ADD));
    when(mockVirtualFile.getPath()).thenReturn(CURRENT_FILE_PATH);
    when(CommandUtils.getStatusForFiles(mockServerContext, ImmutableList.of(CURRENT_FILE_PATH)))
            .thenReturn(ImmutableList.of(mockPendingChange));

    RenameFileDirectory.execute(mockPsiFile, NEW_FILE_NAME, usageInfos, mockListener);

    verifyStatic(times(1));
    RenameUtil.doRenameGenericNamedElement(mockPsiFile, NEW_FILE_NAME, usageInfos, mockListener);
    verify(mockListener).elementRenamed(mockPsiFile);

    verifyStatic(never());
    CommandUtils.renameFile(any(ServerContext.class), any(String.class), any(String.class));
    PersistentFS.getInstance().processEvents(any(List.class));
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:18,代码来源:RenameFileDirectoryTest.java


示例11: checkMovePackage

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
private static boolean checkMovePackage(Project project, PsiPackage aPackage) {
  final PsiDirectory[] directories = aPackage.getDirectories();
  final VirtualFile[] virtualFiles = aPackage.occursInPackagePrefixes();
  if (directories.length > 1 || virtualFiles.length > 0) {
    final StringBuffer message = new StringBuffer();
    RenameUtil.buildPackagePrefixChangedMessage(virtualFiles, message, aPackage.getQualifiedName());
    if (directories.length > 1) {
      DirectoryAsPackageRenameHandlerBase.buildMultipleDirectoriesInPackageMessage(message, aPackage.getQualifiedName(), directories);
      message.append("\n\n");
      String report = RefactoringBundle
        .message("all.these.directories.will.be.moved.and.all.references.to.0.will.be.changed", aPackage.getQualifiedName());
      message.append(report);
    }
    message.append("\n");
    message.append(RefactoringBundle.message("do.you.wish.to.continue"));
    int ret =
      Messages.showYesNoDialog(project, message.toString(), RefactoringBundle.message("warning.title"), Messages.getWarningIcon());
    if (ret != 0) {
      return false;
    }
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:MoveClassesOrPackagesImpl.java


示例12: checkMovePackage

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
private static boolean checkMovePackage(Project project, PsiJavaPackage aPackage) {
  final PsiDirectory[] directories = aPackage.getDirectories();
  final VirtualFile[] virtualFiles = aPackage.occursInPackagePrefixes();
  if (directories.length > 1 || virtualFiles.length > 0) {
    final StringBuffer message = new StringBuffer();
    RenameUtil.buildPackagePrefixChangedMessage(virtualFiles, message, aPackage.getQualifiedName());
    if (directories.length > 1) {
      DirectoryAsPackageRenameHandlerBase.buildMultipleDirectoriesInPackageMessage(message, aPackage.getQualifiedName(), directories);
      message.append("\n\n");
      String report = RefactoringBundle
        .message("all.these.directories.will.be.moved.and.all.references.to.0.will.be.changed", aPackage.getQualifiedName());
      message.append(report);
    }
    message.append("\n");
    message.append(RefactoringBundle.message("do.you.wish.to.continue"));
    int ret =
      Messages.showYesNoDialog(project, message.toString(), RefactoringBundle.message("warning.title"), Messages.getWarningIcon());
    if (ret != 0) {
      return false;
    }
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:MoveClassesOrPackagesImpl.java


示例13: renameManifoldTypeRefs

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
private void renameManifoldTypeRefs( PsiElement element, RefactoringElementListener elementListener )
{
  ApplicationManager.getApplication().invokeLater( () ->
    WriteCommandAction.runWriteCommandAction( element.getProject(), () ->
    {
      Module ijModule = ModuleUtilCore.findModuleForPsiElement( element );
      if( ijModule == null )
      {
        return;
      }

      ManModule module = ManProject.getModule( ijModule );
      PsiClass psiClass = findPsiClass( (PsiFileSystemItem)element, module );
      if( psiClass == null )
      {
        return;
      }

      RenameUtil.doRename( psiClass, psiClass.getName(), _usages.toArray( new UsageInfo[_usages.size()] ), element.getProject(), elementListener );

      // for plain text files, also rename a class name declaration if such a thing exists e.g., javascript class declaration
      if( _classDeclElement != null )
      {
        _classDeclElement.setName( psiClass.getName() == null ? "" : psiClass.getName() );
      }
    } ) );
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:28,代码来源:RenameTypeManifoldFileProcessor.java


示例14: handleManifoldRename

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
private void handleManifoldRename( PsiElement element, RefactoringElementListener elementListener )
{
  if( !(element instanceof PsiNamedElement) || _javaUsages.isEmpty() )
  {
    return;
  }

  String name = ((PsiNamedElement)element).getName();
  String newBaseName = JsonUtil.makeIdentifier( name );

  //## find a way to add this as part of the overall rename Undo?

  ApplicationManager.getApplication().saveAll();

  ApplicationManager.getApplication().invokeLater( () ->
                                                     WriteCommandAction.runWriteCommandAction( element.getProject(), () ->
                                                     {
                                                       for( Map.Entry<Pair<FeaturePath, PsiElement>, List<UsageInfo>> entry : _javaUsages.entrySet() )
                                                       {
                                                         Pair<FeaturePath, PsiElement> key = entry.getKey();
                                                         List<UsageInfo> value = entry.getValue();
                                                         String newFeatureName = newBaseName;
                                                         FeaturePath path = key.getFirst();
                                                         if( path != null )
                                                         {
                                                           newFeatureName = findFeatureName( path );
                                                           if( newFeatureName == null )
                                                           {
                                                             newFeatureName = newBaseName;
                                                           }
                                                         }
                                                         if( newFeatureName != null )
                                                         {
                                                           RenameUtil.doRename( key.getSecond(), newFeatureName, value.toArray( new UsageInfo[value.size()] ), element.getProject(), elementListener );
                                                         }
                                                       }
                                                     } ) );
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:39,代码来源:RenameResourceElementProcessor.java


示例15: performPsiSpoilingRefactoring

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
protected void performPsiSpoilingRefactoring() {
  RenameUtil.renameNonCodeUsages(myProject, myNonCodeUsages);
  if (myMoveCallback != null) {
    if (myMoveCallback instanceof MoveClassesOrPackagesCallback) {
      ((MoveClassesOrPackagesCallback) myMoveCallback).classesOrPackagesMoved(myMoveDestination);
    }
    myMoveCallback.refactoringCompleted();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MoveClassesOrPackagesProcessor.java


示例16: performPsiSpoilingRefactoring

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
protected void performPsiSpoilingRefactoring() {
  if (myNonCodeUsages != null) {
    RenameUtil.renameNonCodeUsages(myProject, myNonCodeUsages);
  }
  if (myMoveCallback != null) {
    if (myMoveCallback instanceof MoveClassesOrPackagesCallback) {
      ((MoveClassesOrPackagesCallback) myMoveCallback).classesMovedToInner(myTargetClass);
    }
    myMoveCallback.refactoringCompleted();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MoveClassToInnerProcessor.java


示例17: preprocessUsages

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
  for (ChangeSignatureUsageProcessor processor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) {
    if (!processor.setupDefaultValues(myChangeInfo, refUsages, myProject)) return false;
  }
  MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
  for (ChangeSignatureUsageProcessor usageProcessor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) {
    final MultiMap<PsiElement, String> conflicts = usageProcessor.findConflicts(myChangeInfo, refUsages);
    for (PsiElement key : conflicts.keySet()) {
      Collection<String> collection = conflictDescriptions.get(key);
      if (collection.size() == 0) collection = new HashSet<String>();
      collection.addAll(conflicts.get(key));
      conflictDescriptions.put(key, collection);
    }
  }

  final UsageInfo[] usagesIn = refUsages.get();
  RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions);
  Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(usagesIn));
  RenameUtil.removeConflictUsages(usagesSet);
  if (!conflictDescriptions.isEmpty()) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      throw new ConflictsInTestsException(conflictDescriptions.values());
    }
    if (myPrepareSuccessfulSwingThreadCallback != null) {
      ConflictsDialog dialog = prepareConflictsDialog(conflictDescriptions, usagesIn);
      if (!dialog.showAndGet()) {
        if (dialog.isShowConflicts()) prepareSuccessful();
        return false;
      }
    }
  }

  if (myChangeInfo.isReturnTypeChanged()) {
    askToRemoveCovariantOverriders(usagesSet);
  }

  refUsages.set(usagesSet.toArray(new UsageInfo[usagesSet.size()]));
  prepareSuccessful();
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:ChangeSignatureProcessor.java


示例18: findConflicts

import com.intellij.refactoring.rename.RenameUtil; //导入依赖的package包/类
public MultiMap<PsiElement, String> findConflicts(Ref<UsageInfo[]> refUsages) {
  MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
  addMethodConflicts(conflictDescriptions);
  Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(refUsages.get()));
  RenameUtil.removeConflictUsages(usagesSet);
  if (myChangeInfo.isVisibilityChanged()) {
    try {
      addInaccessibilityDescriptions(usagesSet, conflictDescriptions);
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
  
  checkContract(conflictDescriptions, myChangeInfo.getMethod());

  for (UsageInfo usageInfo : usagesSet) {
    final PsiElement element = usageInfo.getElement();
    if (usageInfo instanceof OverriderUsageInfo) {
      final PsiMethod method = ((OverriderUsageInfo)usageInfo).getOverridingMethod();
      final PsiMethod baseMethod = ((OverriderUsageInfo)usageInfo).getBaseMethod();
      final int delta = baseMethod.getParameterList().getParametersCount() - method.getParameterList().getParametersCount();
      if (delta > 0) {
        final boolean[] toRemove = myChangeInfo.toRemoveParm();
        if (toRemove[toRemove.length - 1]) { //todo check if implicit parameter is not the last one
          conflictDescriptions.putValue(baseMethod, "Implicit last parameter should not be deleted");
        }
      }

      checkContract(conflictDescriptions, method);
    } else if (element instanceof PsiMethodReferenceExpression) {
      conflictDescriptions.putValue(element, "Changed method is used in method reference");
    }
  }

  return conflictDescriptions;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaChangeSignatureUsageProcessor.java


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Basemap类代码示例发布时间:2022-05-23
下一篇:
Java BarGraph类代码示例发布时间: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