本文整理汇总了Java中com.intellij.refactoring.listeners.RefactoringElementListener类的典型用法代码示例。如果您正苦于以下问题:Java RefactoringElementListener类的具体用法?Java RefactoringElementListener怎么用?Java RefactoringElementListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RefactoringElementListener类属于com.intellij.refactoring.listeners包,在下文中一共展示了RefactoringElementListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getListener
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Nullable
@Override
public RefactoringElementListener getListener(final PsiElement psiElement) {
if (!(psiElement instanceof PsiClass)) return null;
final String oldName = ((PsiClass)psiElement).getQualifiedName();
if (oldName == null) return null;
final EntryPointsManagerBase entryPointsManager = EntryPointsManagerBase.getInstance(psiElement.getProject());
return new UndoRefactoringElementAdapter() {
@Override
protected void refactored(@NotNull PsiElement element, @Nullable String oldQualifiedName) {
if (element instanceof PsiClass) {
final String newQualifiedName = ((PsiClass)element).getQualifiedName();
if (newQualifiedName != null) {
final int idx = entryPointsManager.ADDITIONAL_ANNOTATIONS.indexOf(oldQualifiedName != null ? newQualifiedName : oldName);
if (idx > -1) {
entryPointsManager.ADDITIONAL_ANNOTATIONS.remove(idx);
entryPointsManager.ADDITIONAL_ANNOTATIONS.add(idx, oldQualifiedName != null ? oldQualifiedName : newQualifiedName);
}
}
}
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AdditionalAnnotationsRefactoringElementListener.java
示例2: move
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
public boolean move(PsiFile file,
PsiDirectory moveDestination,
Map<PsiElement, PsiElement> oldToNewElementsMapping,
List<PsiFile> movedFiles,
RefactoringElementListener listener) {
if (!(file instanceof PsiClassOwner)) {
return false;
}
final PsiClass[] classes = ((PsiClassOwner)file).getClasses();
if (classes.length == 0) {
return false;
}
if (FileTypeUtils.isInServerPageFile(file)) {
return false;
}
for (PsiClass psiClass : classes) {
final PsiClass newClass = MoveClassesOrPackagesUtil.doMoveClass(psiClass, moveDestination);
oldToNewElementsMapping.put(psiClass, newClass);
listener.elementMoved(newClass);
}
return true;
}
示例3: getListener
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
public RefactoringElementListener getListener(PsiElement element) {
if (!(element instanceof PsiQualifiedNamedElement) && !(element instanceof PsiDirectory)) return null;
final PsiFile containingFile = element.getContainingFile();
RefactoringElementListenerComposite composite = null;
String oldName = getQualifiedName(element, false);
if (oldName != null) {
composite = getComposite(element, containingFile, null, oldName);
}
if (element instanceof PsiQualifiedNamedElement) {
oldName = getQualifiedName(element, true);
if (oldName != null) {
composite = getComposite(element, containingFile, composite, oldName);
}
}
return composite;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RefactoringScopeElementListenerProvider.java
示例4: doRename
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
public static void doRename(final PsiElement element, String newName, UsageInfo[] usages, final Project project,
@Nullable final RefactoringElementListener listener) throws IncorrectOperationException{
final RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element);
final String fqn = element instanceof PsiFile ? ((PsiFile)element).getVirtualFile().getPath() : CopyReferenceAction.elementToFqn(element);
if (fqn != null) {
UndoableAction action = new BasicUndoableAction() {
@Override
public void undo() throws UnexpectedUndoException {
if (listener instanceof UndoRefactoringElementListener) {
((UndoRefactoringElementListener)listener).undoElementMovedOrRenamed(element, fqn);
}
}
@Override
public void redo() throws UnexpectedUndoException {
}
};
UndoManager.getInstance(project).undoableActionPerformed(action);
}
processor.renameElement(element, newName, usages, listener);
}
示例5: move
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
public boolean move(PsiFile psiFile,
PsiDirectory moveDestination,
Map<PsiElement, PsiElement> oldToNewElementsMapping,
List<PsiFile> movedFiles,
RefactoringElementListener listener) {
if (moveDestination.equals(psiFile.getContainingDirectory())) {
return false;
}
MoveFileHandler.forElement(psiFile).prepareMovedFile(psiFile, moveDestination, oldToNewElementsMapping);
PsiFile moving = moveDestination.findFile(psiFile.getName());
if (moving == null) {
MoveFilesOrDirectoriesUtil.doMoveFile(psiFile, moveDestination);
}
moving = moveDestination.findFile(psiFile.getName());
movedFiles.add(moving);
listener.elementMoved(psiFile);
return true;
}
示例6: addAffectedElement
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
private void addAffectedElement(PsiElement oldElement) {
if(myOldElementToListenerListMap.get(oldElement) != null) return;
ArrayList<RefactoringElementListener> listenerList = new ArrayList<RefactoringElementListener>();
for (RefactoringElementListenerProvider provider : myListenerProviders) {
try {
final RefactoringElementListener listener = provider.getListener(oldElement);
if (listener != null) {
listenerList.add(listener);
}
}
catch (Throwable e) {
LOG.error(e);
}
}
myOldElementToListenerListMap.put(oldElement, listenerList);
}
示例7: elementMoved
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
public void elementMoved(@NotNull final PsiElement newElement) {
myRunnables.add(new Runnable() {
@Override
public void run() {
for (RefactoringElementListener refactoringElementListener : myListenerList) {
try {
refactoringElementListener.elementMoved(newElement);
}
catch (Throwable e) {
LOG.error(e);
}
}
}
});
}
示例8: elementRenamed
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
public void elementRenamed(@NotNull final PsiElement newElement) {
myRunnables.add(new Runnable() {
@Override
public void run() {
for (RefactoringElementListener refactoringElementListener : myListenerList) {
try {
refactoringElementListener.elementRenamed(newElement);
}
catch (Throwable e) {
LOG.error(e);
}
}
}
});
}
示例9: 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);
}
}
示例10: renameElement
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
public void renameElement(PsiElement element, final String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener)
throws IncorrectOperationException {
if (element instanceof PsiField) {
new RenameJavaVariableProcessor().renameElement(element, newName, usages, listener);
}
else {
if (element instanceof PsiNamedElement) {
super.renameElement(element, newName, usages, listener);
if (element instanceof PsiFile) {
VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
if (virtualFile != null && !LocalHistory.getInstance().isUnderControl(virtualFile)) {
DocumentReference ref = DocumentReferenceManager.getInstance().create(virtualFile);
UndoManager.getInstance(element.getProject()).nonundoableActionPerformed(ref, false);
}
}
}
else if (element instanceof XmlAttributeValue) {
new RenameXmlAttributeProcessor().renameElement(element, newName, usages, listener);
}
}
}
示例11: getRefactoringElementListener
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的package包/类
@Override
@Nullable
public RefactoringElementListener getRefactoringElementListener(PsiElement element) {
return RefactoringListeners.getClassOrPackageListener(element, new RefactoringListeners.Accessor<PsiClass>() {
@Override
public void setName(String qualifiedName) {
ACTIVITY_CLASS = qualifiedName;
}
@Nullable
@Override
public PsiClass getPsiElement() {
return getConfigurationModule().findClass(ACTIVITY_CLASS);
}
@Override
public void setPsiElement(PsiClass psiClass) {
ACTIVITY_CLASS = JavaExecutionUtil.getRuntimeQualifiedName(psiClass);
}
});
}
示例12: testExecute_RenameFileNoChanges
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的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));
}
示例13: testExecute_RenameDirectoryNoChanges
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的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));
}
示例14: testExecute_RenameFileEditChanges
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的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));
}
示例15: testExecute_RenameFileEditRenameChanges
import com.intellij.refactoring.listeners.RefactoringElementListener; //导入依赖的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));
}