public XmlNSDescriptor getNSDescriptor(final String namespace, boolean strict) {
    final XmlTag parentTag = getParentTag();

    if (parentTag == null && namespace.equals(XmlUtil.XHTML_URI)) {
      final XmlNSDescriptor descriptor = getDtdDescriptor(XmlUtil.getContainingFile(this));
      if (descriptor != null) {
        return descriptor;
      }
    }

    Map<String, CachedValue<XmlNSDescriptor>> map = initNSDescriptorsMap();
    final CachedValue<XmlNSDescriptor> descriptor = map.get(namespace);
    if (descriptor != null) {
      final XmlNSDescriptor value = descriptor.getValue();
      if (value != null) {
        return value;
      }
    }

    if (parentTag == null) {
      final XmlDocument parentOfType = PsiTreeUtil.getParentOfType(this, XmlDocument.class);
      if (parentOfType == null) {
        return null;
      }
      return parentOfType.getDefaultNSDescriptor(namespace, strict);
    }

    return parentTag.getNSDescriptor(namespace, strict);
  }
Beispiel #2
0
 @Override
 @Nullable
 public PsiModifierList getAnnotationList() {
   if (myAnnotationList == null) {
     myAnnotationList =
         CachedValuesManager.getManager(myManager.getProject())
             .createCachedValue(new PackageAnnotationValueProvider());
   }
   return myAnnotationList.getValue();
 }
Beispiel #3
0
 /**
  * Returns the value for the given key only if it is not expired, or null if no value exists or is
  * expired.
  *
  * <p>This method will return null if either there is no value associated with this key or if the
  * associated value is expired.
  *
  * @param key the key to look up
  */
 @NeededForTesting
 public V get(K key) {
   CachedValue<V> cachedValue = getCachedValue(key);
   return cachedValue == null || cachedValue.isExpired() ? null : cachedValue.getValue();
 }
Beispiel #4
0
 /**
  * Returns the value for the given key, or null if no value exists.
  *
  * <p>When using this method, it is not possible to determine whether the value is expired or not.
  * Use {@link #getCachedValue(Object)} to achieve that instead. However, if using {@link
  * #getCachedValue(Object)} to determine if an item is expired, one should use the item within the
  * {@link CachedValue} and not call {@link #getPossiblyExpired(Object)} to get the value
  * afterwards, since that is not guaranteed to return the same value or that the newly returned
  * value is in the same state.
  *
  * @param key the key to look up
  */
 public V getPossiblyExpired(K key) {
   CachedValue<V> cachedValue = getCachedValue(key);
   return cachedValue == null ? null : cachedValue.getValue();
 }