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


Java RefactoringElementListener.elementRenamed方法代码示例

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


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

示例1: doRenameXmlAttributeValue

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
private static void doRenameXmlAttributeValue(@NotNull XmlAttributeValue value,
                                              String newName,
                                              UsageInfo[] infos,
                                              @Nullable RefactoringElementListener listener)
  throws IncorrectOperationException {
  LOG.assertTrue(value.isValid());

  renameAll(value, infos, newName, value.getValue());

  PsiManager psiManager = value.getManager();
  LOG.assertTrue(psiManager != null);
  XmlFile file = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()).createFileFromText("dummy.xml", XMLLanguage.INSTANCE, "<a attr=\"" + newName + "\"/>");
  @SuppressWarnings("ConstantConditions")
  PsiElement element = value.replace(file.getRootTag().getAttributes()[0].getValueElement());
  if (listener != null) {
    listener.elementRenamed(element);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:RenameXmlAttributeProcessor.java

示例2: doRenameXmlAttributeValue

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
private static void doRenameXmlAttributeValue(@NotNull XmlAttributeValue value,
                                              String newName,
                                              UsageInfo[] infos,
                                              @Nullable RefactoringElementListener listener)
  throws IncorrectOperationException {
  LOG.assertTrue(value.isValid());

  renameAll(value, infos, newName, value.getValue());

  PsiManager psiManager = value.getManager();
  LOG.assertTrue(psiManager != null);
  XmlFile file = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()).createFileFromText("dummy.xml", "<a attr=\"" + newName + "\"/>");
  final PsiElement element = value.replace(file.getDocument().getRootTag().getAttributes()[0].getValueElement());
  if (listener != null) {
    listener.elementRenamed(element);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:RenameXmlAttributeProcessor.java

示例3: getPostRenameCallback

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
@Nullable
public Runnable getPostRenameCallback(final PsiElement element, final String newName, final RefactoringElementListener listener) {
  final Project project = element.getProject();
  final PsiPackage psiPackage = (PsiPackage)element;
  final String newQualifiedName = PsiUtilCore.getQualifiedNameAfterRename(psiPackage.getQualifiedName(), newName);
  return new Runnable() {
    public void run() {
      final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(newQualifiedName);
      if (aPackage == null) {
        return; //rename failed e.g. when the dir is used by another app
      }
      listener.elementRenamed(aPackage);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:RenamePsiPackageProcessor.java

示例4: doRenameXmlAttribute

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
private static void doRenameXmlAttribute(XmlAttribute attribute,
                                         String newName,
                                         @Nullable RefactoringElementListener listener) {
  try {
    final PsiElement element = attribute.setName(newName);
    if (listener != null) {
      listener.elementRenamed(element);
    }
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:RenameXmlAttributeProcessor.java

示例5: renameElement

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
@Override
public void renameElement(PsiElement element, String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener) throws IncorrectOperationException {
    final String attributeName = ComponentUtil.getAttributeName(newName);
    for (UsageInfo usage : usages) {
        RenameUtil.rename(usage, attributeName);
    }

    ((PsiNamedElement)element).setName(newName);
    if (listener != null) {
        listener.elementRenamed(element);
    }
}
 
开发者ID:kristianmandrup,项目名称:emberjs-plugin,代码行数:13,代码来源:EmberJSComponentRenameProcessor.java

示例6: getPostRenameCallback

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
@Nullable
public Runnable getPostRenameCallback(final PsiElement element, final String newName, final RefactoringElementListener listener) {
  final Project project = element.getProject();
  final PsiJavaPackage psiPackage = (PsiJavaPackage)element;
  final String newQualifiedName = PsiUtilCore.getQualifiedNameAfterRename(psiPackage.getQualifiedName(), newName);
  return new Runnable() {
    public void run() {
      final PsiJavaPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(newQualifiedName);
      if (aPackage == null) {
        return; //rename failed e.g. when the dir is used by another app
      }
      listener.elementRenamed(aPackage);
    }
  };
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:RenamePsiPackageProcessor.java

示例7: execute

import com.intellij.refactoring.listeners.RefactoringElementListener; //导入方法依赖的package包/类
public static void execute(final PsiElement element, final String newName, final UsageInfo[] usages,
                           @Nullable final RefactoringElementListener listener) throws IncorrectOperationException {
    try {
        final VirtualFile virtualFile;
        if (element instanceof PsiFile) {
            logger.info("Renaming file...");
            virtualFile = ((PsiFile) element).getVirtualFile();
        } else if (element instanceof PsiDirectory) {
            logger.info("Renaming directory...");
            virtualFile = ((PsiDirectory) element).getVirtualFile();
        } else {
            // should never reach here since we check if file/directory before making a rename
            logger.warn("RenameFile: failed to find proper object to rename: " + element.getClass());
            throw new IncorrectOperationException("Can't perform rename on objects other than files and directories");
        }

        final String currentPath = virtualFile.getPath();
        final String parentDirectory = virtualFile.getParent().getPath();
        final String newPath = Path.combine(parentDirectory, newName);
        final Project project = element.getProject();

        // a single file may have 0, 1, or 2 pending changes to it
        // 0 - file has not been touched in the local workspace
        // 1 - file has versioned OR unversioned changes
        // 2 - file has versioned AND unversioned changes (rare but can happen)
        final List<PendingChange> pendingChanges = new ArrayList<PendingChange>(2);
        pendingChanges.addAll(CommandUtils.getStatusForFiles(TFSVcs.getInstance(project).getServerContext(true),
                ImmutableList.of(currentPath)));

        // ** Rename logic **
        // If 1 change and it's an add that means it's a new unversioned file so rename thru the file system
        // Anything else can be renamed
        // Deleted files should not be at this point since IDE disables rename option for them
        if (pendingChanges.size() == 1 && pendingChanges.get(0).getChangeTypes().contains(ServerStatusType.ADD)) {
            logger.info("Renaming unversioned file thru file system");
            RenameUtil.doRenameGenericNamedElement(element, newName, usages, listener);
        } else {
            logger.info("Renaming file thru tf commandline");
            CommandUtils.renameFile(TFSVcs.getInstance(project).getServerContext(true), currentPath, newPath);

            // this alerts that a rename has taken place so any additional processing can take place
            final VFileEvent event = new VFilePropertyChangeEvent(element.getManager(), virtualFile, "name", currentPath, newName, false);
            PersistentFS.getInstance().processEvents(Collections.singletonList(event));
        }
    } catch (Throwable t) {
        logger.warn("renameElement experienced a failure while trying to rename a file", t);
        throw new IncorrectOperationException(t);
    }

    if (listener != null) {
        listener.elementRenamed(element);
    }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:54,代码来源:RenameFileDirectory.java


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