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


Java RenameUtil类代码示例

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


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


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