From 5a602e10516fa9bd7201f4a058d526370f458d5d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 8 Apr 2011 15:53:44 +0400 Subject: [PATCH] test fix --- .../ImplicitVariableElementInfoFactory.java | 2 +- .../psi/impl/smartPointers/FileElementInfo.java | 2 +- .../psi/impl/smartPointers/HardElementInfo.java | 2 +- .../impl/smartPointers/InjectedSelfElementInfo.java | 9 +++++++++ .../psi/impl/smartPointers/SelfElementInfo.java | 2 +- .../impl/smartPointers/SmartPointerElementInfo.java | 2 +- .../smartPointers/SmartPsiElementPointerImpl.java | 13 +++++-------- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java b/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java index 37ee533d4a27..53888a5a2b69 100644 --- a/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java +++ b/java/java-impl/src/com/intellij/psi/impl/smartPointers/ImplicitVariableElementInfoFactory.java @@ -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; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java index 24fc5e010d83..54412d636905 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java @@ -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; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java index 0573a30cc0bb..50c5ff8b32cd 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java @@ -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()); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java index 5e9299408f1e..2535d73ebfa0 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/InjectedSelfElementInfo.java @@ -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); + } } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java index 6ebadcfe8f1d..f347c6b0cd15 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java index 8ef474f6dd1e..ef8b6afda90f 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java @@ -38,7 +38,7 @@ interface SmartPointerElementInfo { void dispose(); int elementHashCode(); // must be immutable - boolean pointsToTheSameElementAs(SmartPointerElementInfo other); + boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other); VirtualFile getVirtualFile(); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java index 4224bd4c6521..7401a1664a07 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java @@ -85,7 +85,7 @@ class SmartPsiElementPointerImpl 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 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 implements SmartPointerEx myElementInfo.fastenBelt(offset); } + @NotNull SmartPointerElementInfo getElementInfo() { return myElementInfo; }