IDEA-25204: Can't find usages of filter or servlet
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Fri, 5 Mar 2010 14:42:26 +0000 (17:42 +0300)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Fri, 5 Mar 2010 14:42:26 +0000 (17:42 +0300)
xml/dom-impl/src/com/intellij/util/xml/impl/GenericDomValueReference.java
xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java
xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java

index 44f1e4c78542cf383b05551fedbfe59189de5d17..4877c1bbdef53cb9bd6dd5f886f1710b39dda41e 100644 (file)
@@ -19,10 +19,12 @@ import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider;
 import com.intellij.codeInsight.lookup.LookupElement;
 import com.intellij.codeInsight.lookup.LookupValueFactory;
 import com.intellij.openapi.util.TextRange;
+import com.intellij.pom.PomTarget;
 import com.intellij.pom.references.PomService;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiReferenceBase;
+import com.intellij.psi.impl.PomTargetPsiElementImpl;
 import com.intellij.psi.xml.XmlAttributeValue;
 import com.intellij.psi.xml.XmlElement;
 import com.intellij.psi.xml.XmlTag;
@@ -106,7 +108,16 @@ public class GenericDomValueReference<T> extends PsiReferenceBase<XmlElement> im
   public boolean isReferenceTo(final PsiElement element) {
     final Converter<T> converter = getConverter();
     if (converter instanceof ResolvingConverter) {
-      return ((ResolvingConverter<T>)converter).isReferenceTo(element, getStringValue(), myGenericValue.getValue(), getConvertContext());
+      T value = myGenericValue.getValue();
+      if (value instanceof DomElement && element instanceof PomTargetPsiElementImpl) {
+        PomTarget target = ((PomTargetPsiElementImpl)element).getTarget();
+        if (target instanceof DomTarget) {
+          if (value.equals(((DomTarget)target).getDomElement())) {
+            return true;
+          }
+        }
+      }
+      return ((ResolvingConverter<T>)converter).isReferenceTo(element, getStringValue(), value, getConvertContext());
     }
     return super.isReferenceTo(element);
   }
index 524ce448691c8caf27b5022c1cc444d10f8f45ae..28328d62ced482ade315e96878d7363b7e68c8d1 100644 (file)
@@ -102,6 +102,11 @@ public class DomResolveConverter<T extends DomElement> extends ResolvingConverte
     return target == null ? super.getPsiElement(resolvedValue) : PomService.convertToPsi(target);
   }
 
+  @Override
+  public boolean isReferenceTo(@NotNull PsiElement element, String stringValue, @Nullable T resolveResult, ConvertContext context) {
+    return resolveResult != null && element.getManager().areElementsEquivalent(element, resolveResult.getXmlElement());
+  }
+
   private static DomElement getResolvingScope(final ConvertContext context) {
     final DomElement invocationElement = context.getInvocationElement();
     return invocationElement.getManager().getResolvingScope((GenericDomValue)invocationElement);
index 79b0ae17fb36f4a39f9a346db5aa32a660e10d21..f80a09254844858fb648b2d89d9edba9e96a8bf5 100644 (file)
@@ -159,7 +159,7 @@ public abstract class ResolvingConverter<T> extends Converter<T> {
    */
   public boolean isReferenceTo(@NotNull PsiElement element, final String stringValue, @Nullable T resolveResult,
                                final ConvertContext context) {
-    return element.getManager().areElementsEquivalent(element, resolveResult == null ? null : getPsiElement(resolveResult));
+    return resolveResult != null && element.getManager().areElementsEquivalent(element, getPsiElement(resolveResult));
   }
 
   /**