mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
[java] renaming modules
This commit is contained in:
@@ -26,6 +26,7 @@ import com.intellij.psi.impl.file.impl.JavaFileManager;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -53,6 +54,14 @@ public class PsiJavaModuleReference extends PsiReferenceBase.Poly<PsiJavaModuleR
|
||||
return ResolveCache.getInstance(getProject()).resolveWithCaching(this, Resolver.INSTANCE, false, incompleteCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement handleElementRename(@NotNull String newName) throws IncorrectOperationException {
|
||||
PsiJavaModuleReferenceElement element = getElement();
|
||||
PsiElementFactory factory = PsiElementFactory.SERVICE.getInstance(element.getProject());
|
||||
PsiJavaModuleReferenceElement newElement = factory.createModuleFromText("module " + newName + " {}").getNameElement();
|
||||
return element.replace(newElement);
|
||||
}
|
||||
|
||||
private Project getProject() {
|
||||
return getElement().getProject();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user