当前位置: 首页>>代码示例>>Java>>正文


Java XmlAttributeValue.getReferences方法代码示例

本文整理汇总了Java中com.intellij.psi.xml.XmlAttributeValue.getReferences方法的典型用法代码示例。如果您正苦于以下问题:Java XmlAttributeValue.getReferences方法的具体用法?Java XmlAttributeValue.getReferences怎么用?Java XmlAttributeValue.getReferences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.xml.XmlAttributeValue的用法示例。


在下文中一共展示了XmlAttributeValue.getReferences方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveByLocation

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
private static PsiFile resolveByLocation(PsiFile baseFile, String location) {
  if (baseFile instanceof XmlFile) {
    XmlTag tag = ((XmlFile)baseFile).getRootTag();
    if (tag != null) {
      XmlAttribute attribute = tag.getAttribute("schemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI);
      if (attribute != null) {
        XmlAttributeValue element = attribute.getValueElement();
        if (element != null) {
          PsiReference[] references = element.getReferences();
          for (PsiReference reference : references) {
            if (location.equals(reference.getCanonicalText())) {
              PsiElement resolve = reference.resolve();
              return resolve instanceof PsiFile ? (PsiFile)resolve : null;
            }
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XmlResourceResolver.java

示例2: findProperties

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
private static String[] findProperties(@NotNull XmlTag tag) {
  final XmlAttribute typeAttribute = tag.getAttribute(ITEM_TYPE);
  if (typeAttribute != null) {
    final XmlAttributeValue valueElement = typeAttribute.getValueElement();
    final PsiReference[] references = valueElement != null ? valueElement.getReferences() : PsiReference.EMPTY_ARRAY;
    List<String> result = new ArrayList<String>();
    for (PsiReference reference : references) {
      final PsiElement target = reference != null ? reference.resolve() : null;
      if (target instanceof PsiFile) {
        result.addAll(extractProperties((PsiFile)target, StringUtil.stripQuotesAroundValue(reference.getCanonicalText())));
      }
    }
    return ArrayUtil.toStringArray(result);
  }
  return ArrayUtil.EMPTY_STRING_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MicrodataAttributeDescriptorsProvider.java

示例3: getAndroidResourceReference

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@Nullable
public static AndroidResourceReferenceBase getAndroidResourceReference(@Nullable GenericAttributeValue<ResourceValue> attribute,
                                                                       boolean localOnly) {
  if (attribute == null) {
    return null;
  }

  final ResourceValue resValue = attribute.getValue();
  if (resValue == null || (localOnly && resValue.getPackage() != null)) {
    return null;
  }

  final XmlAttributeValue value = attribute.getXmlAttributeValue();
  if (value == null) {
    return null;
  }

  for (PsiReference reference : value.getReferences()) {
    if (reference instanceof AndroidResourceReferenceBase) {
      return (AndroidResourceReferenceBase)reference;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidDomUtil.java

示例4: checkUnusedLocations

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
private static void checkUnusedLocations(XmlAttribute attribute, ProblemsHolder holder, @NotNull XmlRefCountHolder refCountHolder) {
  if (XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(attribute.getNamespace())) {
    if (XmlUtil.NO_NAMESPACE_SCHEMA_LOCATION_ATT.equals(attribute.getLocalName())) {
      if (refCountHolder.isInUse("")) return;
      holder.registerProblem(attribute, XmlBundle.message("xml.inspections.unused.schema.location"), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
                             new RemoveNamespaceLocationFix(""));
    }
    else if (XmlUtil.SCHEMA_LOCATION_ATT.equals(attribute.getLocalName())) {
      XmlAttributeValue value = attribute.getValueElement();
      if (value == null) return;
      PsiReference[] references = value.getReferences();
      for (int i = 0, referencesLength = references.length; i < referencesLength; i++) {
        PsiReference reference = references[i];
        if (reference instanceof URLReference) {
          String ns = getNamespaceFromReference(reference);
          if (ArrayUtil.indexOf(attribute.getParent().knownNamespaces(), ns) == -1 && !refCountHolder.isUsedNamespace(ns)) {
            if (!XmlHighlightVisitor.hasBadResolve(reference, false)) {
              holder.registerProblemForReference(reference, ProblemHighlightType.LIKE_UNUSED_SYMBOL, XmlBundle.message("xml.inspections.unused.schema.location"),
                                                 new RemoveNamespaceLocationFix(ns));
            }
            for (int j = i + 1; j < referencesLength; j++) {
              PsiReference nextRef = references[j];
              if (nextRef instanceof URLReference) break;
              if (!XmlHighlightVisitor.hasBadResolve(nextRef, false)) {
                holder.registerProblemForReference(nextRef, ProblemHighlightType.LIKE_UNUSED_SYMBOL, XmlBundle.message("xml.inspections.unused.schema.location"),
                                                   new RemoveNamespaceLocationFix(ns));
              }
            }
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:XmlUnusedNamespaceInspection.java

示例5: getLocationReferences

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
private static PsiReference[] getLocationReferences(String namespace, XmlAttributeValue value) {
  PsiReference[] references = value.getReferences();
  for (int i = 0, referencesLength = references.length; i < referencesLength; i+=2) {
    PsiReference reference = references[i];
    if (namespace.equals(getNamespaceFromReference(reference))) {
      if (i + 1 < referencesLength) {
        return new PsiReference[] { references[i + 1], reference };
      }
      else {
        return new PsiReference[] { reference };
      }
    }
  }
  return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:XmlUnusedNamespaceInspection.java

示例6: resolveReference

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@Nullable
static PsiElement resolveReference(XmlAttribute ref) {
  if (ref != null) {
    XmlAttributeValue value = ref.getValueElement();
    if (value != null) {
      PsiReference[] references = value.getReferences();
      if (references.length > 0)
        return references[0].resolve();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:XmlSchemaTagsProcessor.java

示例7: resolveFile

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@Nullable
public static PsiFile resolveFile(XmlAttribute location, PsiFile baseFile) {
    if (location == null) return null;
    final XmlAttributeValue valueElement = location.getValueElement();
    if (valueElement == null) return null;

    // prefer direct relative path
    final String value = valueElement.getValue();
    final PsiFile file = resolveFile(value, baseFile);
    if (file != baseFile && file instanceof XmlFile) {
        return file;
    }

    final PsiReference[] references = valueElement.getReferences();
    for (PsiReference reference : references) {
        final PsiElement target = reference.resolve();
        if (target == null && reference instanceof PsiPolyVariantReference) {
            final ResolveResult[] results = ((PsiPolyVariantReference)reference).multiResolve(false);
            for (ResolveResult result : results) {
                if (result.isValidResult()) {
                    // TODO: how to weigh/prioritize the results? 
                    final PsiElement element = result.getElement();
                    if (element != baseFile && element instanceof XmlFile) {
                        return (PsiFile)target;
                    }
                }
            }
        } else if (target != baseFile && target instanceof XmlFile) {
            return (PsiFile)target;
        }
    }
    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:ResolveUtil.java

示例8: visitXmlAttributeValue

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@Override
public void visitXmlAttributeValue(XmlAttributeValue value) {
  for (PsiReference reference : value.getReferences()) {
    if (!(reference instanceof OnClickConverter.MyReference)) {
      continue;
    }
    final OnClickConverter.MyReference ref = (OnClickConverter.MyReference)reference;
    final String methodName = ref.getValue();

    if (methodName.isEmpty()) {
      continue;
    }
    final ResolveResult[] results = ref.multiResolve(false);
    final Set<PsiClass> resolvedClasses = new HashSet<PsiClass>();
    final Set<PsiClass> resolvedClassesWithMistake = new HashSet<PsiClass>();

    for (ResolveResult result : results) {
      if (result instanceof OnClickConverter.MyResolveResult) {
        final PsiElement element = result.getElement();

        if (element != null) {
          final PsiClass aClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);

          if (aClass != null) {
            resolvedClasses.add(aClass);

            if (!((OnClickConverter.MyResolveResult)result).hasCorrectSignature()) {
              resolvedClassesWithMistake.add(aClass);
            }
          }
        }
      }
    }
    PsiClass activity = null;
    for (PsiClass relatedActivity : myRelatedActivities) {
      if (!containsOrExtends(resolvedClasses, relatedActivity)) {
        activity = relatedActivity;
        break;
      }
      else if (activity == null && containsOrExtends(resolvedClassesWithMistake, relatedActivity)) {
        activity = relatedActivity;
      }
    }

    if (activity != null) {
      reportMissingOnClickProblem(ref, activity, methodName, resolvedClassesWithMistake.contains(activity));
    }
    else if (results.length == 0) {
      myResult.add(myInspectionManager.createProblemDescriptor(
        value, reference.getRangeInElement(), ProblemsHolder.unresolvedReferenceMessage(reference),
        ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly));
    }
    else if (resolvedClassesWithMistake.size() > 0) {
      reportMissingOnClickProblem(ref, resolvedClassesWithMistake.iterator().next(), methodName, true);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:58,代码来源:AndroidMissingOnClickHandlerInspection.java

示例9: getReferences

import com.intellij.psi.xml.XmlAttributeValue; //导入方法依赖的package包/类
@Override
@NotNull
public PsiReference[] getReferences() {
    final XmlAttributeValue nameElement = getNameElement();
    return nameElement != null ? nameElement.getReferences() : myElement.getReferences();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:XsltElementImpl.java


注:本文中的com.intellij.psi.xml.XmlAttributeValue.getReferences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。