This commit is contained in:
Alexey Kudravtsev
2011-04-08 16:00:38 +04:00
parent 7d3193fcc5
commit 5a602e1051
7 changed files with 19 additions and 13 deletions
@@ -77,7 +77,7 @@ public class ImplicitVariableElementInfoFactory implements SmartPointerElementIn
}
@Override
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
if (other instanceof ImplicitVariableInfo) {
return myVar == ((ImplicitVariableInfo)other).myVar;
}
@@ -69,7 +69,7 @@ class FileElementInfo implements SmartPointerElementInfo {
}
@Override
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
if (other instanceof FileElementInfo) {
return myVirtualFile == ((FileElementInfo)other).myVirtualFile;
}
@@ -65,7 +65,7 @@ class HardElementInfo implements SmartPointerElementInfo {
}
@Override
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
return Comparing.equal(myElement, other.restoreElement());
}
@@ -77,4 +77,13 @@ class InjectedSelfElementInfo extends SelfElementInfo {
return result.get();
}
@Override
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
if (getClass() != other.getClass()) return false;
if (!super.pointsToTheSameElementAs(other)) return false;
SmartPointerElementInfo myElementInfo = ((SmartPsiElementPointerImpl)myPsiFileRangeInHostElement).getElementInfo();
SmartPointerElementInfo oElementInfo = ((SmartPsiElementPointerImpl)((InjectedSelfElementInfo)other).myPsiFileRangeInHostElement).getElementInfo();
return myElementInfo.pointsToTheSameElementAs(oElementInfo);
}
}
@@ -254,7 +254,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
}
@Override
public boolean pointsToTheSameElementAs(SmartPointerElementInfo other) {
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
if (other instanceof SelfElementInfo) {
return myVirtualFile == ((SelfElementInfo)other).myVirtualFile
&& myType == ((SelfElementInfo)other).myType
@@ -38,7 +38,7 @@ interface SmartPointerElementInfo {
void dispose();
int elementHashCode(); // must be immutable
boolean pointsToTheSameElementAs(SmartPointerElementInfo other);
boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other);
VirtualFile getVirtualFile();
@@ -85,7 +85,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
if (element != null && !element.isValid()) {
element = null;
}
if (element == null && myElementInfo != null) {
if (element == null) {
element = (E)myElementInfo.restoreElement();
if (element != null && (!element.getClass().equals(myElementClass) || !element.isValid())) {
element = null;
@@ -168,17 +168,13 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
}
public void documentAndPsiInSync() {
if (myElementInfo != null) {
myElementInfo.documentAndPsiInSync();
}
myElementInfo.documentAndPsiInSync();
}
@Override
public void dispose() {
if (myElementInfo != null) {
myElementInfo.dispose();
myElement = null;
}
myElementInfo.dispose();
myElement = null;
}
@Override
@@ -190,6 +186,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
myElementInfo.fastenBelt(offset);
}
@NotNull
SmartPointerElementInfo getElementInfo() {
return myElementInfo;
}