コード例 #1
0
 @Override
 public void tokenize(@NotNull T element, TokenConsumer consumer) {
   if (element instanceof PsiLanguageInjectionHost
       && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost) element)) {
     return;
   }
   consumer.consumeToken(element, mySplitter);
 }
  @NotNull
  @Override
  public PsiReference[] getReferencesByElement(
      @NotNull PsiElement element, @NotNull ProcessingContext context) {

    if (XmlSchemaTagsProcessor.PROCESSING_FLAG.get() != null || context.get(SUPPRESS) != null) {
      return PsiReference.EMPTY_ARRAY;
    }
    @SuppressWarnings("unchecked")
    PsiElement host = getHost((T) element);
    if (host instanceof PsiLanguageInjectionHost
        && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost) host)) {
      return PsiReference.EMPTY_ARRAY;
    }
    String unquotedValue = ElementManipulators.getValueText(element);
    if (XmlHighlightVisitor.skipValidation(element)
        || !XmlUtil.isSimpleValue(unquotedValue, element)) {
      return PsiReference.EMPTY_ARRAY;
    }
    @SuppressWarnings("unchecked")
    final Object descriptor = getDescriptor((T) element);
    if (descriptor instanceof XmlEnumerationDescriptor) {
      XmlEnumerationDescriptor enumerationDescriptor = (XmlEnumerationDescriptor) descriptor;

      if (enumerationDescriptor.isFixed()
          || enumerationDescriptor.isEnumerated((XmlElement) element)) {
        //noinspection unchecked
        return enumerationDescriptor.getValueReferences((XmlElement) element, unquotedValue);
      } else if (unquotedValue.equals(
          enumerationDescriptor.getDefaultValue())) { // todo case insensitive
        return ContainerUtil.map2Array(
            enumerationDescriptor.getValueReferences((XmlElement) element, unquotedValue),
            PsiReference.class,
            reference -> PsiDelegateReference.createSoft(reference, true));
      }
    }
    return PsiReference.EMPTY_ARRAY;
  }