mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
smart pointers for PsiDirectory shouldn't subclass pointers for PsiFile
This commit is contained in:
@@ -15,20 +15,72 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.smartPointers;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: cdr
|
||||
*/
|
||||
class DirElementInfo extends FileElementInfo {
|
||||
class DirElementInfo extends SmartPointerElementInfo {
|
||||
private final VirtualFile myVirtualFile;
|
||||
private final Project myProject;
|
||||
|
||||
|
||||
public DirElementInfo(@NotNull PsiDirectory directory) {
|
||||
super(directory.getProject(), directory.getVirtualFile());
|
||||
myProject = directory.getProject();
|
||||
myVirtualFile = directory.getVirtualFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement restoreElement() {
|
||||
return SelfElementInfo.restoreDirectoryFromVirtual(myVirtualFile, myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile restoreFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int elementHashCode() {
|
||||
return myVirtualFile.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
if (other instanceof DirElementInfo) {
|
||||
return Comparing.equal(myVirtualFile, ((DirElementInfo)other).myVirtualFile);
|
||||
}
|
||||
return Comparing.equal(restoreElement(), other.restoreElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile getVirtualFile() {
|
||||
return myVirtualFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Segment getRange() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Segment getPsiRange() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,9 +41,6 @@ class FileElementInfo extends SmartPointerElementInfo {
|
||||
public FileElementInfo(@NotNull PsiFile file) {
|
||||
this(file.getProject(), file.getVirtualFile(), file.getLanguage());
|
||||
}
|
||||
protected FileElementInfo(@NotNull Project project, VirtualFile virtualFile) {
|
||||
this(project, virtualFile, null);
|
||||
}
|
||||
|
||||
protected FileElementInfo(@NotNull Project project, VirtualFile virtualFile, Language lang) {
|
||||
myVirtualFile = virtualFile;
|
||||
|
||||
Reference in New Issue
Block a user